1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-24 17:10:29 +00:00

Take links into account when accumulating dependencies

This commit is contained in:
Jeremy Ruston 2012-01-07 10:30:50 +00:00
parent c716cdce20
commit b92183a3a7
4 changed files with 40 additions and 9 deletions

View File

@ -199,6 +199,21 @@ WikiStore.prototype.listTiddlers = function(type,template,emptyMessage) {
return "<span>Listing!</span>";
};
WikiStore.prototype.tiddlerInfo = function(title) {
var tiddler = this.getTiddler(title),
parseTree = this.parseTiddler(title);
if(tiddler && parseTree) {
var d = parseTree.dependencies;
if(d === null) {
return "Dependencies: *";
} else {
return "Dependencies: " + d.join(", ");
}
} else {
return "";
}
};
/*
argOptions: {defaultName:"type"},
@ -379,6 +394,15 @@ WikiStore.prototype.installMacros = function() {
"text/html": this.jsParser.parse("return store.renderTiddler('text/html',params.target);"),
"text/plain": this.jsParser.parse("return store.renderTiddler('text/plain',params.target);")
}
},
info: {
params: {
},
code: {
"text/html": this.jsParser.parse("return store.tiddlerInfo(tiddler.fields.title);"),
"text/plain": this.jsParser.parse("return store.tiddlerInfo(tiddler.fields.title);")
}
}
};
};

View File

@ -50,6 +50,14 @@ WikiTextParser.prototype.parse = function(text) {
return new WikiTextParseTree(this.children,this.dependencies,this.store);
};
WikiTextParser.prototype.addDependency = function(dependency) {
if(dependency === null) {
this.dependencies = null;
} else if(this.dependencies && this.dependencies.indexOf(dependency) === -1) {
this.dependencies.push(dependency);
}
};
WikiTextParser.prototype.outputText = function(place,startPos,endPos) {
if(startPos < endPos) {
place.push({type: "text", value: this.source.substring(startPos,endPos)});

View File

@ -115,15 +115,9 @@ var parseMacroCall = function(w,name,paramString) {
var args = new ArgParser(paramString,{defaultName: "anon"}),
insertParam = function(param,name,arg) {
if(param.dependantAll) {
w.dependencies = null;
w.addDependency(null);
} else if(param.type === "tiddler") {
if(arg.evaluated) {
w.dependencies = null;
} else {
if(w.dependencies) {
w.dependencies.push(arg.string);
}
}
w.addDependency(arg.evaluated ? null : arg.string);
}
params[name] = {type: arg.evaluated ? "eval" : "string", value: arg.string};
};
@ -470,9 +464,11 @@ var rules = [
// Pretty bracketted link
var link = lookaheadMatch[3];
setAttr(e,"href",link);
w.addDependency(link);
} else {
// Simple bracketted link
setAttr(e,"href",text);
w.addDependency(text);
}
w.output.push(e);
e.children.push({type: "text", value: text});
@ -502,6 +498,7 @@ var rules = [
if(w.autoLinkWikiWords) {
var link = {type: "a", children: []};
setAttr(link,"href",w.matchText);
w.addDependency(w.matchText);
w.output.push(link);
w.outputText(link.children,w.matchStart,w.nextMatch);
} else {
@ -517,6 +514,7 @@ var rules = [
{
var e = {type: "a", children: []};
setAttr(e,"href",w.matchText);
w.addDependency(w.matchText);
w.output.push(e);
w.outputText(e.children,w.matchStart,w.nextMatch);
}

View File

@ -7,3 +7,4 @@ modifier: JeremyRuston
<<view modifier link>> <<view modified date>>}}}
{{body{
<<view text wikified>>}}}
<<info>>