mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-25 09:30:28 +00:00
Improvements to list macro
Allow shorthand list types, and cope with no template being specified
This commit is contained in:
parent
bd5995b2e4
commit
f0974740db
@ -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() {
|
||||
// Get the list of tiddlers object
|
||||
this.getTiddlerList();
|
||||
@ -43,7 +53,16 @@ exports.executeMacro = 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")) {
|
||||
template = this.params.editTemplateText;
|
||||
}
|
||||
// Check for no template specified
|
||||
if(!template && !templateText) {
|
||||
templateText = "<<view title link>>";
|
||||
}
|
||||
// Create the tiddler macro
|
||||
return $tw.Tree.Macro("tiddler",{
|
||||
srcParams: {
|
||||
|
Loading…
Reference in New Issue
Block a user