1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-01-11 18:00:26 +00:00

Proper support for DefaultTiddlers

Now a shadow tiddler called `$:/DefaultTiddlers`
This commit is contained in:
Jeremy Ruston 2012-07-07 17:14:02 +01:00
parent f74bb7d9f5
commit 36372f2aed
2 changed files with 26 additions and 0 deletions

View File

@ -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);

View File

@ -0,0 +1,6 @@
title: $:/DefaultTiddlers
HelloThere
Introduction
Improvements
Docs