From 510006d67df9521a3b7aa2f9adaccd30f8f2f595 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Fri, 13 Jan 2012 16:50:11 +0000 Subject: [PATCH] Added story macro And the PageTemplate for it to go into --- js/App.js | 6 ++- js/macros/story.js | 43 ++++++++++++++++++++++ tiddlywiki5/tiddlers/Motovun Jack.jpg.meta | 2 +- tiddlywiki5/tiddlers/PageTemplate.tid | 3 ++ tiddlywiki5/tiddlers/StoryTiddlers.tid | 5 +++ tiddlywiki5/tiddlers/split.recipe | 3 ++ tiddlywiki5/tiddlywiki5.recipe | 3 +- 7 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 js/macros/story.js create mode 100644 tiddlywiki5/tiddlers/PageTemplate.tid create mode 100644 tiddlywiki5/tiddlers/StoryTiddlers.tid diff --git a/js/App.js b/js/App.js index d6b6bfc2c..ce7789b30 100644 --- a/js/App.js +++ b/js/App.js @@ -91,6 +91,7 @@ var App = function() { this.store.installMacro(require("./macros/echo.js").macro); this.store.installMacro(require("./macros/info.js").macro); this.store.installMacro(require("./macros/list.js").macro); + this.store.installMacro(require("./macros/story.js").macro); this.store.installMacro(require("./macros/tiddler.js").macro); this.store.installMacro(require("./macros/version.js").macro); this.store.installMacro(require("./macros/view.js").macro); @@ -104,8 +105,9 @@ var App = function() { navigators.registerNavigator("StoryNavigator",new StoryNavigator(navigators)); // Use the story navigator for all links navigators.install("a","StoryNavigator"); - // Navigate to HelloThere - navigators.navigateTo("HelloThere","StoryNavigator"); + // Open the PageTemplate + var div = $("
").html(this.store.renderTiddler("text/html","PageTemplate")); + div.appendTo("body"); } }; diff --git a/js/macros/story.js b/js/macros/story.js new file mode 100644 index 000000000..ee7a1cff2 --- /dev/null +++ b/js/macros/story.js @@ -0,0 +1,43 @@ +/*\ +title: js/macros/story.js + +\*/ +(function(){ + +/*jslint node: true */ +"use strict"; + +var utils = require("../Utils.js"); + +exports.macro = { + name: "story", + types: ["text/html","text/plain"], + params: { + story: {byName: "default", type: "text", optional: false}, + template: {byName: true, type: "text", optional: true} + }, + code: function(type,tiddler,store,params) { + var templateType = "text/x-tiddlywiki", + templateText = "<>", + template = params.template ? store.getTiddler(params.template) : null, + tiddlers = store.getTiddlerText(params.story).split("\n"), + t, + output = []; + if(template) { + templateType = template.fields.type; + templateText = template.fields.text; + } + for(t=0; t"); + output.push(store.renderText(templateType,templateText,"text/html",title)); + output.push(""); + } + } + return output.join("\n"); + } +}; + +})(); + diff --git a/tiddlywiki5/tiddlers/Motovun Jack.jpg.meta b/tiddlywiki5/tiddlers/Motovun Jack.jpg.meta index b281504ce..e24f2d6dd 100644 --- a/tiddlywiki5/tiddlers/Motovun Jack.jpg.meta +++ b/tiddlywiki5/tiddlers/Motovun Jack.jpg.meta @@ -1,3 +1,3 @@ title: Motovun Jack.jpg -type: image/jpg +type: image/jpeg source: http://www.flickr.com/photos/jermy/6292279493/in/photostream diff --git a/tiddlywiki5/tiddlers/PageTemplate.tid b/tiddlywiki5/tiddlers/PageTemplate.tid new file mode 100644 index 000000000..fb0ed6d9e --- /dev/null +++ b/tiddlywiki5/tiddlers/PageTemplate.tid @@ -0,0 +1,3 @@ +title: PageTemplate + +<> diff --git a/tiddlywiki5/tiddlers/StoryTiddlers.tid b/tiddlywiki5/tiddlers/StoryTiddlers.tid new file mode 100644 index 000000000..90db46d1d --- /dev/null +++ b/tiddlywiki5/tiddlers/StoryTiddlers.tid @@ -0,0 +1,5 @@ +title: StoryTiddlers + +HelloThere +ThisIsAlpha +NewWikiTextFeatures diff --git a/tiddlywiki5/tiddlers/split.recipe b/tiddlywiki5/tiddlers/split.recipe index 8df533fba..ae225e487 100644 --- a/tiddlywiki5/tiddlers/split.recipe +++ b/tiddlywiki5/tiddlers/split.recipe @@ -13,3 +13,6 @@ tiddler: SiteTitle.tid tiddler: SiteSubtitle.tid tiddler: SimpleTemplate.tid + +tiddler: PageTemplate.tid +tiddler: StoryTiddlers.tid diff --git a/tiddlywiki5/tiddlywiki5.recipe b/tiddlywiki5/tiddlywiki5.recipe index 303dba49a..b042f2d1f 100644 --- a/tiddlywiki5/tiddlywiki5.recipe +++ b/tiddlywiki5/tiddlywiki5.recipe @@ -6,7 +6,7 @@ recipe: tiddlers/split.recipe recipe: ../parsers/split.recipe tiddler: ../docs/High Level Architecture.svg tiddler: http://wikitext.tiddlyspace.com/fractalveg.jpg - type: image/jpg + type: image/jpeg jslib: ../test/tiddlywiki.2.6.5/source/tiddlywiki/jquery/jquery.js @@ -31,6 +31,7 @@ jsmodule: ../js/App.js jsmodule: ../js/macros/echo.js jsmodule: ../js/macros/info.js jsmodule: ../js/macros/list.js +jsmodule: ../js/macros/story.js jsmodule: ../js/macros/tiddler.js jsmodule: ../js/macros/version.js jsmodule: ../js/macros/view.js