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

Improvements to list macro

Allow shorthand list types, and cope with no template being specified
This commit is contained in:
Jeremy Ruston 2012-10-16 19:06:52 +01:00
parent bd5995b2e4
commit f0974740db

View File

@ -26,6 +26,16 @@ exports.info = {
} }
}; };
/*
These types are shorthands for particular filters
*/
var typeMappings = {
all: "[!is[shadow]]",
missing: "[is[missing]]",
orphans: "[is[orphan]]",
shadowed: "[is[shadow]]"
};
exports.executeMacro = function() { exports.executeMacro = function() {
// Get the list of tiddlers object // Get the list of tiddlers object
this.getTiddlerList(); this.getTiddlerList();
@ -43,7 +53,16 @@ exports.executeMacro = function() {
}; };
exports.getTiddlerList = function() { exports.getTiddlerList = function() {
this.list = this.wiki.filterTiddlers(this.params.filter,this.tiddlerTitle); var filter;
if(this.hasParameter("type")) {
filter = typeMappings[this.params.type];
} else if(this.hasParameter("filter")) {
filter = this.params.filter;
}
if(!filter) {
filter = "[!is[shadow]]";
}
this.list = this.wiki.filterTiddlers(filter,this.tiddlerTitle);
}; };
/* /*
@ -83,6 +102,10 @@ exports.createListElementMacro = function(title) {
if(draft && this.hasParameter("editTemplateText")) { if(draft && this.hasParameter("editTemplateText")) {
template = this.params.editTemplateText; template = this.params.editTemplateText;
} }
// Check for no template specified
if(!template && !templateText) {
templateText = "<<view title link>>";
}
// Create the tiddler macro // Create the tiddler macro
return $tw.Tree.Macro("tiddler",{ return $tw.Tree.Macro("tiddler",{
srcParams: { srcParams: {