Source: site.view [edit]
Function name: rssStories
Arguments:
Description: Emits stories as RSS feed
Page type: html
Render function:  
Module: jw

Page source:

<webl>
var stories = WubCall("jw.stories", []);

var info = [. 
   "title" = "Stories for Jamie",
   "url" = "http://www.jamieweil.net/site/stories",
   "description" = "These are stories left for Jamie Weil on her contact page.",
   "about" = "http://www.jamieweil.net",
   .];

var convertDateTime = fun(dateTime)
   var df = Wub_GetDateFormatClass();
   var dfmed = df.getDateTimeInstance(df.SHORT, df.MEDIUM);
   var dfshort = df.getDateTimeInstance(df.SHORT, df.SHORT);
   var dt = (dfmed.parse(dateTime) ? dfshort.parse(dateTime) ? "");
   var sdf1 = Wub_SimpleDateFormat("yyyy-MM-dd");
   var sdf2 = Wub_SimpleDateFormat("HH:mm:ss");
   return sdf1.format(dt) + "T" + sdf2.format(dt) + "Z";
end;


/*
   title=``,
   postedby=``,
   when=`12/23/05 05:20:00 AM`,
   content=``
   .],
*/

var items="";
var itemsdetail="";
every story in stories do
   var etitle = "Story by " + story.name;
   var ewho = story.name;
   var edesc = story.story;
   var ewhen = convertDateTime(story.date);  // 2005-11-07T16:32:44Z
   var link = "http://www.jamieweil.net/site/stories:" + story.id;
   items = items + `     <rdf:li rdf:resource="` + link + `" />` + "\n";

   itemsdetail= itemsdetail + `
  <item rdf:about="` + link + `">
  <title><![CDATA[` + etitle + `]]></title> 
  <description><![CDATA[` + edesc + `]]>
  </description> 
  <link>` + link + `</link> 
  <dc:publisher>WubHub</dc:publisher> 
  <dc:creator>` + ewho + `</dc:creator> 
  <dc:rights /> 
  <dc:date>` + ewhen + `</dc:date> 
  </item>
`;

end;

var res = `<?xml version="1.0" ?> 
 <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:syn="http://purl.org/rss/1.0/modules/syndication/" xmlns="http://purl.org/rss/1.0/">
 <channel about="` + info.about + `">
  <title><![CDATA[` + info.title + `]]></title> 
  <link>` + info.url + `</link> 
  <description><![CDATA[` + info.description + `]]>
  </description> 
  <items>
  <rdf:Seq>
` + items + `
  </rdf:Seq>
  </items>
  </channel>
` + itemsdetail +
`  </rdf:RDF>`;

res;
</webl>