2011-12-13 12:30:09 +00:00
|
|
|
/*\
|
|
|
|
title: js/Main.js
|
|
|
|
|
|
|
|
This is the main() function in the browser
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
2011-12-14 14:11:11 +00:00
|
|
|
/*jslint node: true, browser: true */
|
2011-12-13 12:30:09 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var WikiStore = require("./WikiStore.js").WikiStore,
|
|
|
|
Tiddler = require("./Tiddler.js").Tiddler,
|
|
|
|
tiddlerInput = require("./TiddlerInput.js"),
|
|
|
|
tiddlerOutput = require("./TiddlerOutput.js"),
|
|
|
|
WikiTextProcessor = require("./WikiTextProcessor.js").WikiTextProcessor,
|
2011-12-28 22:07:17 +00:00
|
|
|
Sandbox = require("./Sandbox.js").Sandbox,
|
2011-12-13 16:20:56 +00:00
|
|
|
Navigators = require("./Navigators.js").Navigators,
|
|
|
|
StoryNavigator = require("./StoryNavigator.js").StoryNavigator;
|
2011-12-13 12:30:09 +00:00
|
|
|
|
2011-12-28 17:16:56 +00:00
|
|
|
var store = new WikiStore(),
|
2011-12-13 12:30:09 +00:00
|
|
|
t;
|
|
|
|
|
|
|
|
// Register the wikitext processor
|
2011-12-28 17:16:56 +00:00
|
|
|
store.registerTextProcessor("text/x-tiddlywiki",new WikiTextProcessor({
|
|
|
|
store: store
|
2011-12-13 12:30:09 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
// Register the standard tiddler serializers and deserializers
|
2011-12-28 17:16:56 +00:00
|
|
|
tiddlerInput.register(store);
|
|
|
|
tiddlerOutput.register(store);
|
2011-12-13 12:30:09 +00:00
|
|
|
|
|
|
|
// Add the shadow tiddlers that are built into TiddlyWiki
|
|
|
|
var shadowShadowStore = new WikiStore({
|
|
|
|
shadowStore: null
|
|
|
|
}),
|
|
|
|
shadowShadows = [
|
|
|
|
{title: "StyleSheet", text: ""},
|
|
|
|
{title: "MarkupPreHead", text: ""},
|
|
|
|
{title: "MarkupPostHead", text: ""},
|
|
|
|
{title: "MarkupPreBody", text: ""},
|
|
|
|
{title: "MarkupPostBody", text: ""},
|
|
|
|
{title: "WindowTitle", text: "<<tiddler SiteTitle>> - <<tiddler SiteSubtitle>>"},
|
|
|
|
{title: "DefaultTiddlers", text: "[[GettingStarted]]"},
|
|
|
|
{title: "MainMenu", text: "[[GettingStarted]]"},
|
|
|
|
{title: "SiteTitle", text: "My TiddlyWiki"},
|
|
|
|
{title: "SiteSubtitle", text: "a reusable non-linear personal web notebook"},
|
2011-12-28 17:16:56 +00:00
|
|
|
{title: "SiteUrl", text: ""}
|
2011-12-13 12:30:09 +00:00
|
|
|
];
|
|
|
|
store.shadows.shadows = shadowShadowStore;
|
|
|
|
for(t=0; t<shadowShadows.length; t++) {
|
|
|
|
shadowShadowStore.addTiddler(new Tiddler(shadowShadows[t]));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load the tiddlers built into the TiddlyWiki document
|
|
|
|
var storeArea = document.getElementById("storeArea"),
|
2011-12-28 17:16:56 +00:00
|
|
|
tiddlers = store.deserializeTiddlers("(DOM)",storeArea);
|
2011-12-13 12:30:09 +00:00
|
|
|
for(t=0; t<tiddlers.length; t++) {
|
|
|
|
store.addTiddler(new Tiddler(tiddlers[t]));
|
|
|
|
}
|
|
|
|
|
2011-12-28 22:07:17 +00:00
|
|
|
// Set up the sandbox for evaluated macro parameters
|
|
|
|
store.sandbox = new Sandbox(store.getTiddlerText("javascript.pegjs"));
|
|
|
|
|
2011-12-13 16:20:56 +00:00
|
|
|
// Install the standard navigators
|
|
|
|
var navigators = new Navigators({
|
|
|
|
document: document,
|
|
|
|
store: store
|
|
|
|
});
|
2011-12-13 12:30:09 +00:00
|
|
|
|
2011-12-13 16:20:56 +00:00
|
|
|
navigators.registerNavigator("StoryNavigator",new StoryNavigator(navigators));
|
|
|
|
// Use the story navigator for all links
|
|
|
|
navigators.install("a","StoryNavigator");
|
|
|
|
|
2012-01-03 11:08:00 +00:00
|
|
|
store.installMacros();
|
|
|
|
|
|
|
|
//console.log(JSON.stringify(store.sandbox.parse("store.classesForLink(\"HelloThere\");")));
|
|
|
|
|
2011-12-13 16:20:56 +00:00
|
|
|
// Navigate to HelloThere
|
|
|
|
navigators.navigateTo("HelloThere","StoryNavigator");
|
|
|
|
|
2012-01-03 11:08:00 +00:00
|
|
|
|
2011-12-13 16:20:56 +00:00
|
|
|
})();
|