1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-27 03:57:21 +00:00

Added story macro

And the PageTemplate for it to go into
This commit is contained in:
Jeremy Ruston 2012-01-13 16:50:11 +00:00
parent f5c56c066e
commit 510006d67d
7 changed files with 61 additions and 4 deletions

View File

@ -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 = $("<div/>").html(this.store.renderTiddler("text/html","PageTemplate"));
div.appendTo("body");
}
};

43
js/macros/story.js Normal file
View File

@ -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 = "<<view text wikified>>",
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<tiddlers.length; t++) {
var title = tiddlers[t].trim();
if(title !== "") {
output.push("<article>");
output.push(store.renderText(templateType,templateText,"text/html",title));
output.push("</article>");
}
}
return output.join("\n");
}
};
})();

View File

@ -1,3 +1,3 @@
title: Motovun Jack.jpg
type: image/jpg
type: image/jpeg
source: http://www.flickr.com/photos/jermy/6292279493/in/photostream

View File

@ -0,0 +1,3 @@
title: PageTemplate
<<story story:StoryTiddlers template:SimpleTemplate>>

View File

@ -0,0 +1,5 @@
title: StoryTiddlers
HelloThere
ThisIsAlpha
NewWikiTextFeatures

View File

@ -13,3 +13,6 @@ tiddler: SiteTitle.tid
tiddler: SiteSubtitle.tid
tiddler: SimpleTemplate.tid
tiddler: PageTemplate.tid
tiddler: StoryTiddlers.tid

View File

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