/rss_action
rss feed

Sourcecode in Site/actions.js:
1:   function rss_action() {
2:      res.contentType = "text/xml";
3:      res.dependsOn(this.lastupdate);
4:      res.digest();
5:   
6:      var now = new Date();
7:      var systitle = root.getTitle();
8:      var sdf = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
9:      sdf.setTimeZone(new java.util.SimpleTimeZone(0, "UTC"));
10:  
11:     var collection, subtitle;
12:     switch (true) {
13:        case (req.data.show == "all") :
14:           collection = this.allcontent;
15:           subtitle = "with comments";
16:           break;
17:        // FIXME: i don't think a day makes much sense as rss output [tobi]
18:        case (req.data.day != null) :
19:           collection = this.get(req.data.day);
20:           subtitle = req.data.day;
21:           break;
22:        case (req.data.topic != null) :
23:           collection = this.topics.get(req.data.topic);
24:           subtitle = req.data.topic;
25:           break;
26:        default :
27:           collection = this.allstories;
28:     }
29:     var size = (collection != null) ? collection.size() : 0;
30:  
31:     var max = req.data.max ? parseInt(req.data.max) : 7;
32:     max = Math.min(max, size);
33:     max = Math.min(max, 10);
34:  
35:     var item = {};
36:     if (max > 0 && this.online) {
37:        var items = new java.lang.StringBuffer();
38:        var resources = new java.lang.StringBuffer();
39:        collection.prefetchChildren(0, max);
40:        for (var i=0; i<max; i++) {
41:           var story = collection.get(i);
42:           var item = {
43:              url: story.href(),
44:              title: story.getRenderedContentPart("title").clip(50),
45:              text: story.getRenderedContentPart("text").clip(500),
46:              publisher: systitle,
47:              creator: story.creator.name,
48:              date: sdf.format(story.createtime),
49:              subject: story.topic ? story.topic : "",
50:              year: story.createtime.getFullYear()
51:           };
52:           if (story.creator.publishemail)
53:              item.email = story.creator.email.entitize();
54:           if (!item.title) {
55:              // shit happens: if a content part contains a markup
56:              // element only, String.clip() will return nothing...
57:              if (!item.text)
58:                 item.title = "...";
59:              else
60:                 item.title = story.getRenderedContentPart("text").clip(25);
61:           }
62:           items.append(story.renderSkinAsString("rssItem", item));
63:           resources.append(story.renderSkinAsString("rssResource", item));
64:        }
65:  
66:        var site = {
67:           subtitle: subtitle,
68:           url: this.href(),
69:           title: systitle,
70:           creator: this.creator.name,
71:           year: now.getFullYear(),
72:           lastupdate: max > 0 ? sdf.format(this.lastUpdate): sdf.format(this.createtime),
73:           items: items.toString(),
74:           resources: resources.toString()
75:        };
76:        if (this.email)
77:           site.email = this.email.entitize();
78:        else if (this.creator.publishemail)
79:           site.email = this.creator.email.entitize();
80:        this.renderSkin("rss", site);
81:     }
82:     return;
83:  }