1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-12-09 18:28:07 +00:00

Add hooks mechanism and th-opening-default-tiddlers-list hook

see: https://github.com/Jermolene/TiddlyWiki5/issues/1064
This commit is contained in:
James Welford Anderson
2014-11-23 01:11:56 +09:00
parent d6c5e51501
commit 90caf5bf42
2 changed files with 34 additions and 0 deletions

View File

@@ -58,6 +58,8 @@ exports.startup = function() {
window.location.hash = "";
var storyFilter = $tw.wiki.getTiddlerText(DEFAULT_TIDDLERS_TITLE),
storyList = $tw.wiki.filterTiddlers(storyFilter);
//invoke any hooks that might change the default story list
storyList = $tw.hooks.invokeHook("th-opening-default-tiddlers-list",storyList);
$tw.wiki.addTiddler({title: DEFAULT_STORY_TITLE, text: "", list: storyList},$tw.wiki.getModificationFields());
if(storyList[0]) {
$tw.wiki.addToHistory(storyList[0]);
@@ -116,6 +118,8 @@ function openStartupTiddlers(options) {
}
// Process the story filter to get the story list
var storyList = $tw.wiki.filterTiddlers(storyFilter);
//invoke any hooks that might change the default story list
storyList = $tw.hooks.invokeHook("th-opening-default-tiddlers-list",storyList);
// If the target tiddler isn't included then splice it in at the top
if(target && storyList.indexOf(target) === -1) {
storyList.unshift(target);