mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-11 18:00:26 +00:00
Take links into account when accumulating dependencies
This commit is contained in:
parent
c716cdce20
commit
b92183a3a7
@ -199,6 +199,21 @@ WikiStore.prototype.listTiddlers = function(type,template,emptyMessage) {
|
|||||||
return "<span>Listing!</span>";
|
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"},
|
argOptions: {defaultName:"type"},
|
||||||
@ -379,6 +394,15 @@ WikiStore.prototype.installMacros = function() {
|
|||||||
"text/html": this.jsParser.parse("return store.renderTiddler('text/html',params.target);"),
|
"text/html": this.jsParser.parse("return store.renderTiddler('text/html',params.target);"),
|
||||||
"text/plain": this.jsParser.parse("return store.renderTiddler('text/plain',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);")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -50,6 +50,14 @@ WikiTextParser.prototype.parse = function(text) {
|
|||||||
return new WikiTextParseTree(this.children,this.dependencies,this.store);
|
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) {
|
WikiTextParser.prototype.outputText = function(place,startPos,endPos) {
|
||||||
if(startPos < endPos) {
|
if(startPos < endPos) {
|
||||||
place.push({type: "text", value: this.source.substring(startPos,endPos)});
|
place.push({type: "text", value: this.source.substring(startPos,endPos)});
|
||||||
|
@ -115,15 +115,9 @@ var parseMacroCall = function(w,name,paramString) {
|
|||||||
var args = new ArgParser(paramString,{defaultName: "anon"}),
|
var args = new ArgParser(paramString,{defaultName: "anon"}),
|
||||||
insertParam = function(param,name,arg) {
|
insertParam = function(param,name,arg) {
|
||||||
if(param.dependantAll) {
|
if(param.dependantAll) {
|
||||||
w.dependencies = null;
|
w.addDependency(null);
|
||||||
} else if(param.type === "tiddler") {
|
} else if(param.type === "tiddler") {
|
||||||
if(arg.evaluated) {
|
w.addDependency(arg.evaluated ? null : arg.string);
|
||||||
w.dependencies = null;
|
|
||||||
} else {
|
|
||||||
if(w.dependencies) {
|
|
||||||
w.dependencies.push(arg.string);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
params[name] = {type: arg.evaluated ? "eval" : "string", value: arg.string};
|
params[name] = {type: arg.evaluated ? "eval" : "string", value: arg.string};
|
||||||
};
|
};
|
||||||
@ -470,9 +464,11 @@ var rules = [
|
|||||||
// Pretty bracketted link
|
// Pretty bracketted link
|
||||||
var link = lookaheadMatch[3];
|
var link = lookaheadMatch[3];
|
||||||
setAttr(e,"href",link);
|
setAttr(e,"href",link);
|
||||||
|
w.addDependency(link);
|
||||||
} else {
|
} else {
|
||||||
// Simple bracketted link
|
// Simple bracketted link
|
||||||
setAttr(e,"href",text);
|
setAttr(e,"href",text);
|
||||||
|
w.addDependency(text);
|
||||||
}
|
}
|
||||||
w.output.push(e);
|
w.output.push(e);
|
||||||
e.children.push({type: "text", value: text});
|
e.children.push({type: "text", value: text});
|
||||||
@ -502,6 +498,7 @@ var rules = [
|
|||||||
if(w.autoLinkWikiWords) {
|
if(w.autoLinkWikiWords) {
|
||||||
var link = {type: "a", children: []};
|
var link = {type: "a", children: []};
|
||||||
setAttr(link,"href",w.matchText);
|
setAttr(link,"href",w.matchText);
|
||||||
|
w.addDependency(w.matchText);
|
||||||
w.output.push(link);
|
w.output.push(link);
|
||||||
w.outputText(link.children,w.matchStart,w.nextMatch);
|
w.outputText(link.children,w.matchStart,w.nextMatch);
|
||||||
} else {
|
} else {
|
||||||
@ -517,6 +514,7 @@ var rules = [
|
|||||||
{
|
{
|
||||||
var e = {type: "a", children: []};
|
var e = {type: "a", children: []};
|
||||||
setAttr(e,"href",w.matchText);
|
setAttr(e,"href",w.matchText);
|
||||||
|
w.addDependency(w.matchText);
|
||||||
w.output.push(e);
|
w.output.push(e);
|
||||||
w.outputText(e.children,w.matchStart,w.nextMatch);
|
w.outputText(e.children,w.matchStart,w.nextMatch);
|
||||||
}
|
}
|
||||||
|
@ -6,4 +6,5 @@ modifier: JeremyRuston
|
|||||||
{{small{
|
{{small{
|
||||||
<<view modifier link>> <<view modified date>>}}}
|
<<view modifier link>> <<view modified date>>}}}
|
||||||
{{body{
|
{{body{
|
||||||
<<view text wikified>>}}}
|
<<view text wikified>>}}}
|
||||||
|
<<info>>
|
Loading…
Reference in New Issue
Block a user