1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-11-24 03:04:51 +00:00

Add support for filtering shadow tiddlers

This commit is contained in:
Jeremy Ruston
2013-04-03 14:29:12 +01:00
parent 0d247cb752
commit dc00e584fb
6 changed files with 46 additions and 19 deletions

View File

@@ -164,6 +164,18 @@ exports.tiddlerExists = function(title) {
return !!this.tiddlers[title];
};
exports.isSystemTiddler = function(title) {
return title.indexOf("$:/") === 0;
};
exports.isTemporaryTiddler = function(title) {
return title.indexOf("$:/temp/") === 0;
};
exports.isShadowTiddler = function(title) {
return $tw.utils.hop(this.shadowTiddlers,title);
};
exports.addTiddler = function(tiddler) {
// Check if we're passed a fields hashmap instead of a tiddler
if(!(tiddler instanceof $tw.Tiddler)) {
@@ -184,7 +196,7 @@ exports.getTiddlers = function(sortField,excludeTag) {
sortField = sortField || "title";
var tiddlers = [], t, titles = [];
for(t in this.tiddlers) {
if($tw.utils.hop(this.tiddlers,t) && !this.tiddlers[t].isSystem() && (!excludeTag || !this.tiddlers[t].hasTag(excludeTag))) {
if($tw.utils.hop(this.tiddlers,t) && !this.isSystemTiddler(t) && (!excludeTag || !this.tiddlers[t].hasTag(excludeTag))) {
tiddlers.push(this.tiddlers[t]);
}
}
@@ -344,7 +356,7 @@ exports.getOrphanTitles = function() {
exports.getSystemTitles = function() {
var titles = [];
for(var title in this.tiddlers) {
if(this.tiddlers[title].isSystem()) {
if(this.isSystemTiddler(title)) {
titles.push(title);
}
}
@@ -352,6 +364,15 @@ exports.getSystemTitles = function() {
return titles;
};
exports.getShadowTitles = function() {
var titles = [];
for(var title in this.shadowTiddlers) {
titles.push(title);
}
titles.sort();
return titles;
};
/*
Retrieves a list of the tiddler titles that are tagged with a given tag
*/