Added story macro

And the PageTemplate for it to go into
print-window-tiddler
Jeremy Ruston 2012-01-13 16:50:11 +00:00
rodzic f5c56c066e
commit 510006d67d
7 zmienionych plików z 61 dodań i 4 usunięć

Wyświetl plik

@ -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 100644
Wyświetl plik

@ -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");
}
};
})();

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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