1 package mircoders.producer;
6 import freemarker.template.*;
12 import mircoders.module.*;
13 import mircoders.storage.*;
14 import mircoders.entity.*;
17 public class ProducerStartPage extends Producer {
19 private static String startPageTemplate = MirConfig.getProp("Producer.StartPage.Template");
20 private static String featuresRSSTemplate = MirConfig.getProp("Producer.FeaturesRSS.Template");
21 private static int itemsPerPage = Integer.parseInt(MirConfig.getProp("Producer.StartPage.Items"));
22 private static int newsPerPage = Integer.parseInt(MirConfig.getProp("Producer.StartPage.Newswire"));
24 public static void main(String argv[]){
26 // Why are we reloading the configuration here?
27 // is there something I'm missing?
28 // mh. <heckmann@hbe.ca>
29 // Configuration.initConfig(argv[0]);
30 new ProducerStartPage().handle(new PrintWriter(System.out), null);
31 } catch(Exception e) {
32 System.err.println(e.toString());
36 public void handle(PrintWriter htmlout, EntityUsers user, boolean force,boolean sync)
37 throws StorageObjectException, ModuleException
39 long startTime = System.currentTimeMillis();
40 printHTML(htmlout, "Producer.StartPage: started");
41 SimpleHash startPageModel = new SimpleHash();
44 ModuleBreaking breakingModule = new ModuleBreaking(DatabaseBreaking.getInstance());
45 startPageModel.put("breakingnews", breakingModule.getBreakingNews());
46 startPageModel.put("topics", topicsModule.getTopicsList());
47 startPageModel.put("newswire", contentModule.getNewsWire(0,newsPerPage));
48 startPageModel.put("startspecial", contentModule.getStartArticle());
49 startPageModel.put("features", contentModule.getFeatures(0,itemsPerPage));
50 startPageModel.put("dc_now", new SimpleScalar(StringUtil.date2w3DateTime(new GregorianCalendar())));
53 /* @todo switch to compressed */
54 produce(startPageTemplate, "/index.shtml", startPageModel, htmlout);
56 /* should be mandatory in light of new www.indy newswire.
57 * but remember Mir is not indy specific. -mh.
58 * Also should it really always be produced in UTF8 chars -mh?
60 produce(featuresRSSTemplate, "/features.1-0.rdf", startPageModel, htmlout, "UTF8");
63 logHTMLFinish(htmlout, "Startpage", 1, startTime, System.currentTimeMillis());
66 logHTML(htmlout, "Producer.Startpage: rsyncing...");
68 printHTML(htmlout, "Producer.Startpage: rsync done");