//--
//-- RSS Saving
//--
function saveRss(localPath)
{
var rssPath = localPath.substr(0,localPath.lastIndexOf(".")) + ".xml";
if(saveFile(rssPath,convertUnicodeToFileFormat(generateRss())))
displayMessage(config.messages.rssSaved,"file://" + rssPath);
else
alert(config.messages.rssFailed);
}
tiddlerToRssItem = function(tiddler,uri)
{
var s = "
" + tiddler.title.htmlEncode() + "\n";
s += "" + wikifyStatic(tiddler.text,null,tiddler).htmlEncode() + "\n";
var i;
for(i=0; i" + tiddler.tags[i] + "\n";
s += "" + uri + "#" + encodeURIComponent(String.encodeTiddlyLink(tiddler.title)) + "\n";
s +="" + tiddler.modified.toGMTString() + "\n";
return s;
};
function generateRss()
{
var s = [];
var d = new Date();
var u = store.getTiddlerText("SiteUrl");
// Assemble the header
s.push("<" + "?xml version=\"1.0\"?" + ">");
s.push("");
s.push("");
s.push("" + wikifyPlainText(store.getTiddlerText("SiteTitle",""),null,tiddler).htmlEncode() + "");
if(u)
s.push("" + u.htmlEncode() + "");
s.push("" + wikifyPlainText(store.getTiddlerText("SiteSubtitle",""),null,tiddler).htmlEncode() + "");
s.push("" + config.locale + "");
s.push("Copyright " + d.getFullYear() + " " + config.options.txtUserName.htmlEncode() + "");
s.push("" + d.toGMTString() + "");
s.push("" + d.toGMTString() + "");
s.push("http://blogs.law.harvard.edu/tech/rss");
s.push("TiddlyWiki " + formatVersion() + "");
// The body
var tiddlers = store.getTiddlers("modified","excludeLists");
var i,n = config.numRssItems > tiddlers.length ? 0 : tiddlers.length-config.numRssItems;
for(i=tiddlers.length-1; i>=n; i--) {
s.push("- \n" + tiddlerToRssItem(tiddlers[i],u) + "\n
");
}
// And footer
s.push("");
s.push("");
// Save it all
return s.join("\n");
}