mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-11 09:50:27 +00:00
Proper support for DefaultTiddlers
Now a shadow tiddler called `$:/DefaultTiddlers`
This commit is contained in:
parent
f74bb7d9f5
commit
36372f2aed
@ -61,6 +61,26 @@ exports.startup = function() {
|
||||
wiki: $tw.wiki,
|
||||
rootElement: document.body
|
||||
});
|
||||
// Install the scroller
|
||||
$tw.scroller = new $tw.utils.Scroller();
|
||||
// Get the default tiddlers
|
||||
var defaultTiddlersTitle = "$:/DefaultTiddlers",
|
||||
defaultTiddlersTiddler = $tw.wiki.getTiddler(defaultTiddlersTitle),
|
||||
defaultTiddlers = [];
|
||||
if(defaultTiddlersTiddler) {
|
||||
defaultTiddlers = $tw.wiki.filterTiddlers(defaultTiddlersTiddler.fields.text);
|
||||
}
|
||||
// Initialise the story and history
|
||||
var storyTitle = "$:/StoryTiddlers",
|
||||
historyTitle = "$:/History",
|
||||
story = {tiddlers: []},
|
||||
history = {stack: []};
|
||||
for(var t=0; t<defaultTiddlers.length; t++) {
|
||||
story.tiddlers[t] = {title: defaultTiddlers[t]};
|
||||
history.stack[defaultTiddlers.length - t - 1] = {title: defaultTiddlers[t], fromTitle: defaultTiddlers[t+1]};
|
||||
}
|
||||
$tw.wiki.addTiddler(new $tw.Tiddler({title: storyTitle,text: JSON.stringify(story)}));
|
||||
$tw.wiki.addTiddler(new $tw.Tiddler({title: historyTitle,text: JSON.stringify(history)}));
|
||||
// Display the PageTemplate
|
||||
var template = "$:/templates/PageTemplate";
|
||||
$tw.renderer = $tw.wiki.parseTiddler(template);
|
||||
|
6
tw5.com/wiki/DefaultTiddlers.tid
Normal file
6
tw5.com/wiki/DefaultTiddlers.tid
Normal file
@ -0,0 +1,6 @@
|
||||
title: $:/DefaultTiddlers
|
||||
|
||||
HelloThere
|
||||
Introduction
|
||||
Improvements
|
||||
Docs
|
Loading…
Reference in New Issue
Block a user