1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-08-08 23:03:50 +00:00

Don't load tiddlers that don't have a title

We were getting problems (eg, adding a `readme.md` to a plugin without
an accompanying `readme.md.meta` would end up creating a tiddler called
“undefined”)
This commit is contained in:
Jermolene 2014-01-12 21:48:18 +00:00
parent 19080f9958
commit b04141fefd
2 changed files with 19 additions and 11 deletions

View File

@ -779,7 +779,9 @@ $tw.Wiki.prototype.addTiddler = function(tiddler) {
if(!(tiddler instanceof $tw.Tiddler)) { if(!(tiddler instanceof $tw.Tiddler)) {
tiddler = new $tw.Tiddler(tiddler); tiddler = new $tw.Tiddler(tiddler);
} }
this.tiddlers[tiddler.fields.title] = tiddler; if(tiddler.fields.title) {
this.tiddlers[tiddler.fields.title] = tiddler;
}
}; };
$tw.Wiki.prototype.addTiddlers = function(tiddlers) { $tw.Wiki.prototype.addTiddlers = function(tiddlers) {
@ -859,10 +861,12 @@ $tw.Wiki.prototype.unpackPluginTiddlers = function() {
// Extract the constituent tiddlers // Extract the constituent tiddlers
$tw.utils.each(pluginInfo.tiddlers,function(constituentTiddler,constituentTitle) { $tw.utils.each(pluginInfo.tiddlers,function(constituentTiddler,constituentTitle) {
// Save the tiddler object // Save the tiddler object
self.shadowTiddlers[constituentTitle] = { if(constituentTitle) {
source: tiddler.fields.title, self.shadowTiddlers[constituentTitle] = {
tiddler: new $tw.Tiddler(constituentTiddler,{title: constituentTitle}) source: tiddler.fields.title,
}; tiddler: new $tw.Tiddler(constituentTiddler,{title: constituentTitle})
};
}
}); });
}); });
}; };
@ -911,7 +915,7 @@ $tw.Wiki.prototype.getTiddler = function(title) {
var t = this.tiddlers[title]; var t = this.tiddlers[title];
if(t instanceof $tw.Tiddler) { if(t instanceof $tw.Tiddler) {
return t; return t;
} else if($tw.utils.hop(this.shadowTiddlers,title)) { } else if(title !== undefined && $tw.utils.hop(this.shadowTiddlers,title)) {
return this.shadowTiddlers[title].tiddler; return this.shadowTiddlers[title].tiddler;
} else { } else {
return undefined; return undefined;
@ -1226,7 +1230,9 @@ $tw.loadPluginFolder = function(filepath,excludeRegExp) {
// Save the plugin tiddlers into the plugin info // Save the plugin tiddlers into the plugin info
pluginInfo.tiddlers = pluginInfo.tiddlers || {}; pluginInfo.tiddlers = pluginInfo.tiddlers || {};
for(t=0; t<pluginTiddlers.length; t++) { for(t=0; t<pluginTiddlers.length; t++) {
pluginInfo.tiddlers[pluginTiddlers[t].title] = pluginTiddlers[t]; if(pluginTiddlers[t].title) {
pluginInfo.tiddlers[pluginTiddlers[t].title] = pluginTiddlers[t];
}
} }
} }
} }

View File

@ -204,10 +204,12 @@ exports.addTiddler = function(tiddler) {
// Get the title // Get the title
var title = tiddler.fields.title; var title = tiddler.fields.title;
// Save the tiddler // Save the tiddler
this.tiddlers[title] = tiddler; if(title) {
this.clearCache(title); this.tiddlers[title] = tiddler;
this.clearGlobalCache(); this.clearCache(title);
this.enqueueTiddlerEvent(title); this.clearGlobalCache();
this.enqueueTiddlerEvent(title);
}
}; };
/* /*