1 package net.sourceforge.blogentis.modules.screens;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import net.sourceforge.blogentis.feed.Feed;
26 import net.sourceforge.blogentis.feed.FeedFactory;
27 import net.sourceforge.blogentis.rss.RSSVersion;
28 import net.sourceforge.blogentis.rss.RSSVersionFactory;
29 import net.sourceforge.blogentis.turbine.BaseBlogScreen;
30 import net.sourceforge.blogentis.turbine.BlogParameterParser;
31 import net.sourceforge.blogentis.utils.LinkFactoryService;
32
33 import org.apache.turbine.util.RunData;
34 import org.apache.turbine.util.TurbineException;
35 import org.apache.velocity.context.Context;
36
37 /***
38 * the screen that produces RSS per-post, per-section and per-blog.
39 *
40 * @author abas
41 */
42 public class RSS
43 extends BaseBlogScreen {
44 protected void doBuildTemplate(RunData data, Context context)
45 throws Exception {
46 BlogParameterParser bpp = (BlogParameterParser)data.getParameters();
47 String version = data.getParameters().getString("ver", "rdf");
48 RSSVersion rssv = RSSVersionFactory.getVersionFor(version);
49
50 if (rssv == null) {
51 data.setRedirectURI(LinkFactoryService.getLink().thisPage(data)
52 .setPage(null).toString());
53 data.setStatusCode(302);
54 throw new TurbineException("No such RSS version");
55 }
56
57 Feed f = FeedFactory.getFeed(data);
58 f.setContextProperties(context);
59 f.setVersion(rssv.getVersion());
60
61 context.put("items", f.getItemsTranslated());
62 context.put("channel", f);
63
64 super.doBuildTemplate(data, context);
65
66 setTemplate(data, bpp.getBlog(), rssv.getTemplate());
67
68 data.setContentType("text/xml");
69 data.getResponse().setContentType("text/xml");
70 }
71
72 public String getLayoutTemplate(RunData data) {
73 return "RSS.vm";
74 }
75
76 public String getLayout(RunData data) {
77 return "RSS";
78 }
79 }