1 43 package net.jforum.util.rss; 44 45 import java.io.StringWriter ; 46 47 import net.jforum.JForumExecutionContext; 48 import net.jforum.util.preferences.ConfigKeys; 49 import net.jforum.util.preferences.SystemGlobals; 50 import freemarker.template.SimpleHash; 51 import freemarker.template.Template; 52 53 57 public class GenericRSS implements RSSAware 58 { 59 private RSS rss; 60 61 protected void setRSS(RSS rss) 62 { 63 this.rss = rss; 64 } 65 66 public String createRSS() throws Exception 67 { 68 Template t = JForumExecutionContext.templateConfig().getTemplate(SystemGlobals.getValue(ConfigKeys.TEMPLATE_DIR) 69 + "/rss_template.htm"); 70 StringWriter sw = new StringWriter (); 71 72 SimpleHash templateContext = JForumExecutionContext.getTemplateContext(); 73 74 templateContext.put("encoding", SystemGlobals.getValue(ConfigKeys.ENCODING)); 75 templateContext.put("rss", this.rss); 76 t.process(templateContext, sw); 77 78 return sw.toString(); 79 } 80 } | Popular Tags |