mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-28 18:04:44 +00:00
Add support for filtering shadow tiddlers
This commit is contained in:
parent
0d247cb752
commit
dc00e584fb
@ -106,7 +106,13 @@ exports.operators = {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "system":
|
case "system":
|
||||||
return "for(title in source) {if(" + op + "this.getTiddler(title).isSystem()) {$tw.utils.pushTop(subResults,title);}}";
|
return "for(title in source) {if(" + op + "this.isSystemTiddler(title)) {$tw.utils.pushTop(subResults,title);}}";
|
||||||
|
case "shadow":
|
||||||
|
if(operator.prefix === "!") {
|
||||||
|
return "for(title in source) {if(!this.isShadowTiddler(title)) {$tw.utils.pushTop(subResults,title);}}";
|
||||||
|
} else {
|
||||||
|
return "for(title in this.shadowTiddlers) {$tw.utils.pushTop(subResults,title);}";
|
||||||
|
}
|
||||||
case "missing":
|
case "missing":
|
||||||
if(operator.prefix === "!") {
|
if(operator.prefix === "!") {
|
||||||
return "for(title in source) {$tw.utils.pushTop(subResults,title);}";
|
return "for(title in source) {$tw.utils.pushTop(subResults,title);}";
|
||||||
@ -134,7 +140,9 @@ exports.operators = {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "system":
|
case "system":
|
||||||
return "for(r=subResults.length-1; r>=0; r--) {if(" + op + "this.getTiddler(subResults[r]).isSystem()) {subResults.splice(r,1);}}";
|
return "for(r=subResults.length-1; r>=0; r--) {if(" + op + "this.isSystemTiddler(subResults[r])) {subResults.splice(r,1);}}";
|
||||||
|
case "shadow":
|
||||||
|
return "for(r=subResults.length-1; r>=0; r--) {if(" + op + "this.isShadowTiddler(subResults[r])) {subResults.splice(r,1);}}";
|
||||||
case "missing":
|
case "missing":
|
||||||
return "t = this.getMissingTitles(); for(r=subResults.length-1; r>=0; r--) {if(" + op + "!$tw.utils.hop(t,subResults[r])) {subResults.splice(r,1);}}";
|
return "t = this.getMissingTitles(); for(r=subResults.length-1; r>=0; r--) {if(" + op + "!$tw.utils.hop(t,subResults[r])) {subResults.splice(r,1);}}";
|
||||||
case "orphan":
|
case "orphan":
|
||||||
|
@ -16,17 +16,6 @@ exports.hasTag = function(tag) {
|
|||||||
return this.fields.tags && this.fields.tags.indexOf(tag) !== -1;
|
return this.fields.tags && this.fields.tags.indexOf(tag) !== -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.isSystem = function() {
|
|
||||||
if(!$tw.utils.hop(this,"systemFlag")) {
|
|
||||||
this.systemFlag = this.fields.title.indexOf("$:/") === 0;
|
|
||||||
}
|
|
||||||
return this.systemFlag;
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.isTemporary = function() {
|
|
||||||
return this.fields.title.indexOf("$:/temp/") === 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.getFieldString = function(field) {
|
exports.getFieldString = function(field) {
|
||||||
var value = this.fields[field];
|
var value = this.fields[field];
|
||||||
// Check for a missing field
|
// Check for a missing field
|
||||||
|
@ -37,6 +37,7 @@ LinkWidget.prototype.generate = function() {
|
|||||||
this.isExternal = isLinkExternal(this.to);
|
this.isExternal = isLinkExternal(this.to);
|
||||||
if(!this.isExternal) {
|
if(!this.isExternal) {
|
||||||
this.isMissing = !this.renderer.renderTree.wiki.tiddlerExists(this.to);
|
this.isMissing = !this.renderer.renderTree.wiki.tiddlerExists(this.to);
|
||||||
|
this.isShadow = this.renderer.renderTree.wiki.isShadowTiddler(this.to);
|
||||||
}
|
}
|
||||||
// Compose the link
|
// Compose the link
|
||||||
var classes = ["tw-tiddlylink"]
|
var classes = ["tw-tiddlylink"]
|
||||||
@ -44,12 +45,17 @@ LinkWidget.prototype.generate = function() {
|
|||||||
$tw.utils.pushTop(classes,"tw-tiddlylink-external");
|
$tw.utils.pushTop(classes,"tw-tiddlylink-external");
|
||||||
} else {
|
} else {
|
||||||
$tw.utils.pushTop(classes,"tw-tiddlylink-internal");
|
$tw.utils.pushTop(classes,"tw-tiddlylink-internal");
|
||||||
if(this.isMissing) {
|
if(this.isShadow) {
|
||||||
|
$tw.utils.pushTop(classes,"tw-tiddlylink-shadow");
|
||||||
|
}
|
||||||
|
if(this.isMissing && !this.isShadow) {
|
||||||
$tw.utils.pushTop(classes,"tw-tiddlylink-missing");
|
$tw.utils.pushTop(classes,"tw-tiddlylink-missing");
|
||||||
} else {
|
} else {
|
||||||
|
if(!this.isMissing) {
|
||||||
$tw.utils.pushTop(classes,"tw-tiddlylink-resolves");
|
$tw.utils.pushTop(classes,"tw-tiddlylink-resolves");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
var events = [{name: "click", handlerObject: this, handlerMethod: "handleClickEvent"}];
|
var events = [{name: "click", handlerObject: this, handlerMethod: "handleClickEvent"}];
|
||||||
if(this.hover) {
|
if(this.hover) {
|
||||||
events.push({name: "mouseover", handlerObject: this, handlerMethod: "handleMouseOverOrOutEvent"});
|
events.push({name: "mouseover", handlerObject: this, handlerMethod: "handleMouseOverOrOutEvent"});
|
||||||
|
@ -98,7 +98,7 @@ TranscludeWidget.prototype.generate = function() {
|
|||||||
if(this.renderer.hasAttribute("class")) {
|
if(this.renderer.hasAttribute("class")) {
|
||||||
$tw.utils.pushTop(classes,this.renderer.getAttribute("class").split(" "));
|
$tw.utils.pushTop(classes,this.renderer.getAttribute("class").split(" "));
|
||||||
}
|
}
|
||||||
if(!this.renderer.renderTree.wiki.tiddlerExists(this.targetTitle)) {
|
if(!this.renderer.renderTree.wiki.tiddlerExists(this.targetTitle) && !this.renderer.renderTree.wiki.isShadowTiddler(this.targetTitle)) {
|
||||||
$tw.utils.pushTop(classes,"tw-tiddler-missing");
|
$tw.utils.pushTop(classes,"tw-tiddler-missing");
|
||||||
}
|
}
|
||||||
// Create the renderers for the wrapper and the children
|
// Create the renderers for the wrapper and the children
|
||||||
|
@ -164,6 +164,18 @@ exports.tiddlerExists = function(title) {
|
|||||||
return !!this.tiddlers[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) {
|
exports.addTiddler = function(tiddler) {
|
||||||
// Check if we're passed a fields hashmap instead of a tiddler
|
// Check if we're passed a fields hashmap instead of a tiddler
|
||||||
if(!(tiddler instanceof $tw.Tiddler)) {
|
if(!(tiddler instanceof $tw.Tiddler)) {
|
||||||
@ -184,7 +196,7 @@ exports.getTiddlers = function(sortField,excludeTag) {
|
|||||||
sortField = sortField || "title";
|
sortField = sortField || "title";
|
||||||
var tiddlers = [], t, titles = [];
|
var tiddlers = [], t, titles = [];
|
||||||
for(t in this.tiddlers) {
|
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]);
|
tiddlers.push(this.tiddlers[t]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +356,7 @@ exports.getOrphanTitles = function() {
|
|||||||
exports.getSystemTitles = function() {
|
exports.getSystemTitles = function() {
|
||||||
var titles = [];
|
var titles = [];
|
||||||
for(var title in this.tiddlers) {
|
for(var title in this.tiddlers) {
|
||||||
if(this.tiddlers[title].isSystem()) {
|
if(this.isSystemTiddler(title)) {
|
||||||
titles.push(title);
|
titles.push(title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -352,6 +364,15 @@ exports.getSystemTitles = function() {
|
|||||||
return titles;
|
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
|
Retrieves a list of the tiddler titles that are tagged with a given tag
|
||||||
*/
|
*/
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
title: $:/templates/MoreSideBar
|
title: $:/templates/MoreSideBar
|
||||||
|
|
||||||
<div class="tw-tab-set">
|
<div class="tw-tab-set">
|
||||||
<div class="tw-tab-buttons"><$button type="set" set="$:/state/moreSideBarTabSet" setTo="tagsTab" qualifyTiddlerTitles="yes" selectedClass="tw-tab-selected">Tags</$button><$button type="set" set="$:/state/moreSideBarTabSet" setTo="missingTab" qualifyTiddlerTitles="yes" selectedClass="tw-tab-selected">Missing</$button><$button type="set" set="$:/state/moreSideBarTabSet" setTo="orphanTab" qualifyTiddlerTitles="yes" selectedClass="tw-tab-selected">Orphans</$button><$button type="set" set="$:/state/moreSideBarTabSet" setTo="systemTab" qualifyTiddlerTitles="yes" selectedClass="tw-tab-selected">System</$button></div>
|
<div class="tw-tab-buttons"><$button type="set" set="$:/state/moreSideBarTabSet" setTo="tagsTab" qualifyTiddlerTitles="yes" selectedClass="tw-tab-selected">Tags</$button><$button type="set" set="$:/state/moreSideBarTabSet" setTo="missingTab" qualifyTiddlerTitles="yes" selectedClass="tw-tab-selected">Missing</$button><$button type="set" set="$:/state/moreSideBarTabSet" setTo="orphanTab" qualifyTiddlerTitles="yes" selectedClass="tw-tab-selected">Orphans</$button><$button type="set" set="$:/state/moreSideBarTabSet" setTo="systemTab" qualifyTiddlerTitles="yes" selectedClass="tw-tab-selected">System</$button><$button type="set" set="$:/state/moreSideBarTabSet" setTo="shadowsTab" qualifyTiddlerTitles="yes" selectedClass="tw-tab-selected">Shadows</$button></div>
|
||||||
<div class="tw-tab-contents">
|
<div class="tw-tab-contents">
|
||||||
<$reveal type="match" state="$:/state/moreSideBarTabSet" text="tagsTab" qualifyTiddlerTitles="yes">
|
<$reveal type="match" state="$:/state/moreSideBarTabSet" text="tagsTab" qualifyTiddlerTitles="yes">
|
||||||
<$list filter="[tags[]sort[title]]" itemClass="tw-menu-list-item" template="$:/templates/TagTemplate"/>
|
<$list filter="[tags[]sort[title]]" itemClass="tw-menu-list-item" template="$:/templates/TagTemplate"/>
|
||||||
@ -15,5 +15,8 @@ title: $:/templates/MoreSideBar
|
|||||||
<$reveal type="match" state="$:/state/moreSideBarTabSet" text="systemTab" qualifyTiddlerTitles="yes">
|
<$reveal type="match" state="$:/state/moreSideBarTabSet" text="systemTab" qualifyTiddlerTitles="yes">
|
||||||
<$list filter="[is[system]sort[title]]" itemClass="tw-menu-list-item"/>
|
<$list filter="[is[system]sort[title]]" itemClass="tw-menu-list-item"/>
|
||||||
</$reveal>
|
</$reveal>
|
||||||
|
<$reveal type="match" state="$:/state/moreSideBarTabSet" text="shadowsTab" qualifyTiddlerTitles="yes">
|
||||||
|
<$list filter="[is[shadow]sort[title]]" itemClass="tw-menu-list-item"/>
|
||||||
|
</$reveal>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user