From d748d04d92ee816afb4873f7314c327c611f7cf8 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Sat, 10 Dec 2011 11:46:37 +0000 Subject: [PATCH] Added support for generating the tag from wikifying WindowTitle --- js/Recipe.js | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/js/Recipe.js b/js/Recipe.js index fb3b0ccd62..883ce57c62 100755 --- a/js/Recipe.js +++ b/js/Recipe.js @@ -220,7 +220,10 @@ Recipe.prototype.outputTiddlersForMarker = function(out,marker) { var tiddlers = this.markers[marker], outputType = Recipe.tiddlerOutputMapper[marker] || "raw", outputter = Recipe.tiddlerOutputter[outputType]; - if(outputter && tiddlers) { + if(!tiddlers) { + tiddlers = []; + } + if(outputter) { outputter.call(this,out,tiddlers); } }; @@ -231,7 +234,8 @@ Recipe.tiddlerOutputMapper = { js: "javascript", jsdeprecated: "javascript", jquery: "javascript", - shadow: "shadow" + shadow: "shadow", + title: "title" }; Recipe.tiddlerOutputter = { @@ -273,6 +277,9 @@ Recipe.tiddlerOutputter = { tid = this.store.shadows.getTiddler(title); out.push(tiddlerOutput.outputTiddlerDiv(tid)); } + }, + title: function(out,tiddlers) { + out.push(this.renderTiddler("WindowTitle","text/plain")); } }; @@ -283,17 +290,13 @@ Recipe.prototype.cookRss = function() numRssItems = 20, s = [], d = new Date(), - renderTiddler = function(title,type) { - var r = new WikiTextRenderer(me.store.getTiddler(title).getParseTree(),me.store,title); - return r.render(type); - }, - u = renderTiddler("SiteUrl","text/plain"), + u = this.renderTiddler("SiteUrl","text/plain"), encodeTiddlyLink = function(title) { return title.indexOf(" ") == -1 ? title : "[[" + title + "]]"; }, tiddlerToRssItem = function(tiddler,uri) { var s = "<title" + ">" + utils.htmlEncode(tiddler.fields.title) + "</title" + ">\n"; - s += "<description>" + utils.htmlEncode(renderTiddler(tiddler.fields.title,"text/plain")) + "</description>\n"; + s += "<description>" + utils.htmlEncode(me.renderTiddler(tiddler.fields.title,"text/plain")) + "</description>\n"; var i; if(tiddler.fields.tags) { for(i=0; i<tiddler.fields.tags.length; i++) { @@ -332,10 +335,10 @@ Recipe.prototype.cookRss = function() s.push("<" + "?xml version=\"1.0\"?" + ">"); s.push("<rss version=\"2.0\">"); s.push("<channel>"); - s.push("<title" + ">" + utils.htmlEncode(renderTiddler("SiteTitle","text/plain")) + "</title" + ">"); + s.push("<title" + ">" + utils.htmlEncode(this.renderTiddler("SiteTitle","text/plain")) + "</title" + ">"); if(u) s.push("<link>" + utils.htmlEncode(u) + "</link>"); - s.push("<description>" + utils.htmlEncode(renderTiddler("SiteSubtitle","text/plain")) + "</description>"); + s.push("<description>" + utils.htmlEncode(this.renderTiddler("SiteSubtitle","text/plain")) + "</description>"); //s.push("<language>" + config.locale + "</language>"); s.push("<pubDate>" + d.toUTCString() + "</pubDate>"); s.push("<lastBuildDate>" + d.toUTCString() + "</lastBuildDate>"); @@ -354,5 +357,10 @@ Recipe.prototype.cookRss = function() return s.join("\n"); }; +Recipe.prototype.renderTiddler = function(title,type) { + var r = new WikiTextRenderer(this.store.getTiddler(title).getParseTree(),this.store,title); + return r.render(type); +}; + exports.Recipe = Recipe;