Saturday, March 19, 2011 at 1:05 AM.
scripting2Suite.server.buildLiveBlogFeed
on buildLiveBlogFeed (username, adrstory, flupload=true) {
<<Changes
<<3/18/11; 5:36:45 PM by DW
<<Look for subs with links, use that for the link attribute if present.
<<http://changes.scripting2.com/#p5698
<<7/10/10; 7:32:40 AM by DW
<<The channel-level link is the url of the story, not the url of the blog.
<<7/10/10; 5:25:03 AM by DW
<<RSS feeds now take their title, link and description from the blog prefs if they haven't been set independently (right now there's no UI to set them).
<<6/27/10; 7:01:07 PM by DW
<<Build the live-blog feed from the indicated story.
local (adrdata = scripting2Suite.initUser (username), now = clock.now (), xmltext = "");
bundle { //generate xmltext
local (indentlevel = 0);
on add (s) {
xmltext = xmltext + (string.filledstring ("\t", indentlevel) + s + "\r\n");};
on encode (s) {
if system.environment.isMac { //02/22/2001 JES: convert to Latin text
return (xml.entityEncode (latinToMac.macToLatin (s), true))}
else {
return (xml.entityEncode (s, true))}};
bundle { //add header elements
local (headerdata, programversion = scripting2Suite.getProgramName ());
scripting2Suite.server.getRssHeaderData (username, @headerdata); //7/10/10 by DW
add ("<?xml version=\"1.0\"?>");
add ("<!-- RSS generated by " + programversion + " on " + date.netstandardstring (now) + " -->");
add ("<rss version=\"2.0\" xmlns:scripting2=\"http://scripting2.com/namespace.html\">"); indentlevel++;
add ("<channel>"); indentlevel++;
add ("<title>" + encode (headerdata.title) + "</title>");
add ("<link>" + encode (adrstory^.url) + "</link>");
add ("<description>" + encode (headerdata.description) + "</description>");
add ("<language>en-us</language>");
add ("<copyright>" + "Copyright " + date.year () + " " + encode (headerdata.copyrightHolder) + "</copyright>");
add ("<pubDate>" + date.netstandardstring (now) + "</pubDate>");
add ("<lastBuildDate>" + date.netstandardstring (now) + "</lastBuildDate>");
add ("<docs>" + scripting2Suite.data.urls.rssDocs + "</docs>");
add ("<generator>" + programversion + "</generator>");
add ("<managingEditor>" + encode (headerdata.managingEditor) + "</managingEditor>");
add ("<webMaster>" + encode (headerdata.webmaster) + "</webMaster>");
bundle { //add <cloud>, 7/18/09 by DW
add ("<cloud domain=\"rpc.rsscloud.org\" port=\"5337\" path=\"/rsscloud/pleaseNotify\" registerProcedure=\"\" protocol=\"http-post\" />")}};
bundle { //add items
local (adrsummit = scripting2Suite.server.getStorySummit (adrstory), adritem);
for adritem in adrsummit {
if nameof (adritem^) endswith "outline" {
local (adratts = @adritem^.["/atts"], flhavelink = false);
add ("<item>"); indentlevel++;
add ("<title>" + adratts^.text + "</title>");
bundle { //see if it has a subhead that's a link node, 3/18/11 by DW
local (adrsub);
for adrsub in adritem {
if nameof (adrsub^) endswith "outline" {
local (adratts = @adrsub^.["/atts"]);
if defined (adratts^.type) {
if adratts^.type == "link" {
add ("<link>" + adratts^.url + "</link>");
add ("<description>" + adratts^.text + "</description>");
flhavelink = true;
break}}}}};
if not flhavelink {
if defined (adratts^.type) {
if adratts^.type == "link" {
add ("<link>" + adratts^.url + "</link>")}}};
if defined (adratts^.created) {
add ("<pubDate>" + adratts^.created + "</pubDate>");
add ("<guid isPermaLink=\"false\">" + number (date (adratts^.created)) + "</guid>")};
add ("</item>"); indentlevel--}}};
add ("</channel>"); indentlevel--;
add ("</rss>"); indentlevel--;
bundle { //string substitutions
xmltext = scripting2Suite.server.glossarySubstitution (@adrdata^.prefs.glossary, xmltext);
xmltext = scripting2Suite.server.glossarySubstitution (@scripting2Suite.data.systemGlossary, xmltext)}};
bundle { //save the file
if flupload {
adrdata^.stats.urlLiveBlogFeed = scripting2Suite.writeStaticFile (username, scripting2Suite.data.paths.liveBlogFeed, xmltext)}}};
bundle { //test code
local (adrstory = @scripting2Data.server.users.davewiner.calendar.["2010"].["06"].["27"].["00295"]);
buildLiveBlogFeed ("davewiner", adrstory)}
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.