kopia lustrzana https://github.com/miklobit/TiddlyWiki5
Fixed problem with tiddler context within macros
rodzic
341c7143ed
commit
318381a21b
|
@ -282,13 +282,13 @@ Recipe.prototype.cookRss = function()
|
||||||
numRssItems = 20,
|
numRssItems = 20,
|
||||||
s = [],
|
s = [],
|
||||||
d = new Date(),
|
d = new Date(),
|
||||||
u = this.store.getTiddler("SiteUrl").getParseTree().render("text/plain"),
|
u = this.store.getTiddler("SiteUrl").getParseTree().render("text/plain",me.store,"SiteUrl"),
|
||||||
encodeTiddlyLink = function(title) {
|
encodeTiddlyLink = function(title) {
|
||||||
return title.indexOf(" ") == -1 ? title : "[[" + title + "]]";
|
return title.indexOf(" ") == -1 ? title : "[[" + title + "]]";
|
||||||
},
|
},
|
||||||
tiddlerToRssItem = function(tiddler,uri) {
|
tiddlerToRssItem = function(tiddler,uri) {
|
||||||
var s = "<title" + ">" + utils.htmlEncode(tiddler.fields.title) + "</title" + ">\n";
|
var s = "<title" + ">" + utils.htmlEncode(tiddler.fields.title) + "</title" + ">\n";
|
||||||
s += "<description>" + utils.htmlEncode(tiddler.getParseTree().render("text/html")) + "</description>\n";
|
s += "<description>" + utils.htmlEncode(tiddler.getParseTree().render("text/html",me.store,tiddler.fields.title)) + "</description>\n";
|
||||||
var i;
|
var i;
|
||||||
if(tiddler.fields.tags) {
|
if(tiddler.fields.tags) {
|
||||||
for(i=0; i<tiddler.fields.tags.length; i++) {
|
for(i=0; i<tiddler.fields.tags.length; i++) {
|
||||||
|
@ -327,10 +327,10 @@ Recipe.prototype.cookRss = function()
|
||||||
s.push("<" + "?xml version=\"1.0\"?" + ">");
|
s.push("<" + "?xml version=\"1.0\"?" + ">");
|
||||||
s.push("<rss version=\"2.0\">");
|
s.push("<rss version=\"2.0\">");
|
||||||
s.push("<channel>");
|
s.push("<channel>");
|
||||||
s.push("<title" + ">" + utils.htmlEncode(this.store.getTiddler("SiteTitle").getParseTree().render("text/plain")) + "</title" + ">");
|
s.push("<title" + ">" + utils.htmlEncode(this.store.getTiddler("SiteTitle").getParseTree().render("text/plain",me.store,"SiteTitle")) + "</title" + ">");
|
||||||
if(u)
|
if(u)
|
||||||
s.push("<link>" + utils.htmlEncode(u) + "</link>");
|
s.push("<link>" + utils.htmlEncode(u) + "</link>");
|
||||||
s.push("<description>" + utils.htmlEncode(this.store.getTiddler("SiteSubtitle").getParseTree().render("text/plain")) + "</description>");
|
s.push("<description>" + utils.htmlEncode(this.store.getTiddler("SiteSubtitle").getParseTree().render("text/plain",me.store,"SiteSubtitle")) + "</description>");
|
||||||
//s.push("<language>" + config.locale + "</language>");
|
//s.push("<language>" + config.locale + "</language>");
|
||||||
s.push("<pubDate>" + d.toUTCString() + "</pubDate>");
|
s.push("<pubDate>" + d.toUTCString() + "</pubDate>");
|
||||||
s.push("<lastBuildDate>" + d.toUTCString() + "</lastBuildDate>");
|
s.push("<lastBuildDate>" + d.toUTCString() + "</lastBuildDate>");
|
||||||
|
|
|
@ -13,22 +13,25 @@ var ArgParser = require("./ArgParser.js").ArgParser,
|
||||||
|
|
||||||
var wikiTextMacros = exports;
|
var wikiTextMacros = exports;
|
||||||
|
|
||||||
wikiTextMacros.executeMacros = function(tree,store,tiddler) {
|
wikiTextMacros.versionTiddlyWiki = "2.6.5";
|
||||||
|
|
||||||
|
wikiTextMacros.executeMacros = function(tree,store,title) {
|
||||||
for(var t=0; t<tree.length; t++) {
|
for(var t=0; t<tree.length; t++) {
|
||||||
if(tree[t].type === "macro") {
|
if(tree[t].type === "macro") {
|
||||||
wikiTextMacros.executeMacro(tree[t],store,tiddler);
|
wikiTextMacros.executeMacro(tree[t],store,title);
|
||||||
}
|
}
|
||||||
if(tree[t].children) {
|
if(tree[t].children) {
|
||||||
wikiTextMacros.executeMacros(tree[t].children,store,tiddler);
|
wikiTextMacros.executeMacros(tree[t].children,store,title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
wikiTextMacros.executeMacro = function(macroNode,store,tiddler) {
|
wikiTextMacros.executeMacro = function(macroNode,store,title) {
|
||||||
var macroInfo = wikiTextMacros.macros[macroNode.name];
|
var macroInfo = wikiTextMacros.macros[macroNode.name];
|
||||||
|
console.error("Executing macro %s with params %s in tiddler %s",macroNode.name,0,title);
|
||||||
macroNode.output = [];
|
macroNode.output = [];
|
||||||
if(macroInfo) {
|
if(macroInfo) {
|
||||||
macroInfo.handler(macroNode,store,tiddler);
|
macroInfo.handler(macroNode,store,title);
|
||||||
} else {
|
} else {
|
||||||
macroNode.output.push({type: "text", value: "Unknown macro " + macroNode.name});
|
macroNode.output.push({type: "text", value: "Unknown macro " + macroNode.name});
|
||||||
}
|
}
|
||||||
|
@ -36,39 +39,39 @@ wikiTextMacros.executeMacro = function(macroNode,store,tiddler) {
|
||||||
|
|
||||||
wikiTextMacros.macros = {
|
wikiTextMacros.macros = {
|
||||||
allTags: {
|
allTags: {
|
||||||
handler: function(macroNode,store,tiddler) {
|
handler: function(macroNode,store,title) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
br: {
|
br: {
|
||||||
handler: function(macroNode,store,tiddler) {
|
handler: function(macroNode,store,title) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
list: {
|
list: {
|
||||||
handler: function(macroNode,store,tiddler) {
|
handler: function(macroNode,store,title) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
slider: {
|
slider: {
|
||||||
handler: function(macroNode,store,tiddler) {
|
handler: function(macroNode,store,title) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
tabs: {
|
tabs: {
|
||||||
handler: function(macroNode,store,tiddler) {
|
handler: function(macroNode,store,title) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
tag: {
|
tag: {
|
||||||
handler: function(macroNode,store,tiddler) {
|
handler: function(macroNode,store,title) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
tagging: {
|
tagging: {
|
||||||
handler: function(macroNode,store,tiddler) {
|
handler: function(macroNode,store,title) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
tags: {
|
tags: {
|
||||||
handler: function(macroNode,store,tiddler) {
|
handler: function(macroNode,store,title) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
tiddler: {
|
tiddler: {
|
||||||
handler: function(macroNode,store,tiddler) {
|
handler: function(macroNode,store,title) {
|
||||||
var args = new ArgParser(macroNode.params,{defaultName:"name"}),
|
var args = new ArgParser(macroNode.params,{defaultName:"name"}),
|
||||||
targetTitle = args.getValueByName("name",null),
|
targetTitle = args.getValueByName("name",null),
|
||||||
withTokens = args.getValuesByName("with",[]),
|
withTokens = args.getValuesByName("with",[]),
|
||||||
|
@ -82,15 +85,15 @@ wikiTextMacros.macros = {
|
||||||
macroNode.output.push(parseTree.tree[t]);
|
macroNode.output.push(parseTree.tree[t]);
|
||||||
}
|
}
|
||||||
// Execute any macros in the copy
|
// Execute any macros in the copy
|
||||||
wikiTextMacros.executeMacros(macroNode.output,store,tiddler);
|
wikiTextMacros.executeMacros(macroNode.output,store,title);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
timeline: {
|
timeline: {
|
||||||
handler: function(macroNode,store,tiddler) {
|
handler: function(macroNode,store,title) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
today: {
|
today: {
|
||||||
handler: function(macroNode,store,tiddler) {
|
handler: function(macroNode,store,title) {
|
||||||
var now = new Date(),
|
var now = new Date(),
|
||||||
args = new ArgParser(macroNode.params,{noNames:true}),
|
args = new ArgParser(macroNode.params,{noNames:true}),
|
||||||
value = args.byPos[0] ? utils.formatDateString(now,args.byPos[0].v) : now.toLocaleString();
|
value = args.byPos[0] ? utils.formatDateString(now,args.byPos[0].v) : now.toLocaleString();
|
||||||
|
@ -98,12 +101,12 @@ wikiTextMacros.macros = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
version: {
|
version: {
|
||||||
handler: function(macroNode,store,tiddler) {
|
handler: function(macroNode,store,title) {
|
||||||
macroNode.output.push({type: "text", value: "0.0.0"});
|
macroNode.output.push({type: "text", value: wikiTextMacros.versionTiddlyWiki});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
view: {
|
view: {
|
||||||
handler: function(macroNode,store,tiddler) {
|
handler: function(macroNode,store,title) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -101,7 +101,7 @@ WikiTextParser.prototype.renderAsHtml = function(store,title) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
wikiTextMacros.executeMacros(this.tree,store);
|
wikiTextMacros.executeMacros(this.tree,store,title);
|
||||||
renderSubTree(this.tree);
|
renderSubTree(this.tree);
|
||||||
return output.join("");
|
return output.join("");
|
||||||
};
|
};
|
||||||
|
@ -131,7 +131,7 @@ WikiTextParser.prototype.renderAsText = function(store,title) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
wikiTextMacros.executeMacros(this.tree,store);
|
wikiTextMacros.executeMacros(this.tree,store,title);
|
||||||
renderSubTree(this.tree);
|
renderSubTree(this.tree);
|
||||||
return output.join("");
|
return output.join("");
|
||||||
};
|
};
|
||||||
|
|
|
@ -148,7 +148,7 @@ WikiTextRules.rules = [
|
||||||
// Move the caption to the first row if it isn't already
|
// Move the caption to the first row if it isn't already
|
||||||
if(table.children.length !== 1) {
|
if(table.children.length !== 1) {
|
||||||
table.children.pop(); // Take rowContainer out of the children array
|
table.children.pop(); // Take rowContainer out of the children array
|
||||||
table.splice(0,0,rowContainer); // Insert it at the bottom
|
table.children.splice(0,0,rowContainer); // Insert it at the bottom
|
||||||
}
|
}
|
||||||
rowContainer.attributes.align = rowCount === 0 ? "top" : "bottom";
|
rowContainer.attributes.align = rowCount === 0 ? "top" : "bottom";
|
||||||
w.subWikifyTerm(rowContainer.children,this.rowTermRegExp);
|
w.subWikifyTerm(rowContainer.children,this.rowTermRegExp);
|
||||||
|
|
Ładowanie…
Reference in New Issue