diff --git a/js/macros/story.js b/js/macros/story.js index 77f93d19e..c893d1086 100644 --- a/js/macros/story.js +++ b/js/macros/story.js @@ -21,7 +21,7 @@ exports.macro = { }, events: { "tw-navigate": function(event) { - var template = this.hasParameter("defaultViewTemplate") ? this.params.defaultViewTemplate : "SimpleTemplate", + var template = this.hasParameter("defaultViewTemplate") ? this.params.defaultViewTemplate : "ViewTemplate", storyTiddler = this.store.getTiddler(this.params.story), story = {tiddlers: []}; if(storyTiddler && storyTiddler.hasOwnProperty("text")) { @@ -48,7 +48,16 @@ exports.macro = { storyRecord.title = "Draft of " + event.tiddlerTitle + " at " + (new Date()); storyRecord.template = template; var tiddler = this.store.getTiddler(event.tiddlerTitle); - this.store.addTiddler(new Tiddler({text: "Type the text for the tiddler '" + event.tiddlerTitle + "'"},tiddler,{title: storyRecord.title, "draft.title": event.tiddlerTitle})); + this.store.addTiddler(new Tiddler( + { + text: "Type the text for the tiddler '" + event.tiddlerTitle + "'" + }, + tiddler, + { + title: storyRecord.title, + "draft.title": event.tiddlerTitle, + "draft.of": event.tiddlerTitle + })); } } this.store.addTiddler(new Tiddler(storyTiddler,{text: JSON.stringify(story)})); @@ -56,7 +65,7 @@ exports.macro = { return false; }, "tw-SaveTiddler": function(event) { - var template = this.hasParameter("defaultViewTemplate") ? this.params.defaultEditTemplate : "SimpleTemplate", + var template = this.hasParameter("defaultViewTemplate") ? this.params.defaultEditTemplate : "ViewTemplate", storyTiddler = this.store.getTiddler(this.params.story), story = {tiddlers: []}, storyTiddlerModified = false; @@ -72,6 +81,10 @@ exports.macro = { this.store.addTiddler(new Tiddler(tiddler,{title: tiddler["draft.title"],"draft.title": undefined})); // Remove the draft tiddler this.store.deleteTiddler(storyRecord.title); + // Remove the original tiddler if we're renaming it + if(tiddler["draft.of"] !== tiddler["draft.title"]) { + this.store.deleteTiddler(tiddler["draft.of"]); + } // Make the story record point to the newly saved tiddler storyRecord.title = tiddler["draft.title"]; storyRecord.template = template; @@ -103,13 +116,14 @@ exports.macro = { return content; }, refreshInDom: function(changes) { + var t; /*jslint browser: true */ if(this.dependencies.hasChanged(changes,this.tiddlerTitle)) { // Get the tiddlers we're supposed to be displaying var self = this, story = JSON.parse(this.store.getTiddlerText(this.params.story)), template = this.params.template, - t,n,domNode, + n,domNode, findTiddler = function (childIndex,tiddlerTitle,templateTitle) { while(childIndex < self.content.length) { var params = self.content[childIndex].params; diff --git a/tiddlywiki5/shadows/StoryTiddlers.tid b/tiddlywiki5/shadows/StoryTiddlers.tid index 09e17e160..8e9825055 100644 --- a/tiddlywiki5/shadows/StoryTiddlers.tid +++ b/tiddlywiki5/shadows/StoryTiddlers.tid @@ -3,8 +3,8 @@ type: application/json { "tiddlers": [ - {"title": "HelloThere", "template": "SimpleTemplate"}, - {"title": "Introduction", "template": "SimpleTemplate"}, - {"title": "NewWikiTextFeatures", "template": "SimpleTemplate"} + {"title": "HelloThere", "template": "ViewTemplate"}, + {"title": "Introduction", "template": "ViewTemplate"}, + {"title": "NewWikiTextFeatures", "template": "ViewTemplate"} ] } \ No newline at end of file diff --git a/tiddlywiki5/shadows/templates/SimpleTemplate.tid b/tiddlywiki5/shadows/templates/ViewTemplate.tid similarity index 90% rename from tiddlywiki5/shadows/templates/SimpleTemplate.tid rename to tiddlywiki5/shadows/templates/ViewTemplate.tid index 9689cde7f..e5be9e5f9 100644 --- a/tiddlywiki5/shadows/templates/SimpleTemplate.tid +++ b/tiddlywiki5/shadows/templates/ViewTemplate.tid @@ -1,4 +1,4 @@ -title: SimpleTemplate +title: ViewTemplate modifier: JeremyRuston {{title{ diff --git a/tiddlywiki5/tiddlers/Introduction.tid b/tiddlywiki5/tiddlers/Introduction.tid index 2785b250e..9608f964f 100644 --- a/tiddlywiki5/tiddlers/Introduction.tid +++ b/tiddlywiki5/tiddlers/Introduction.tid @@ -19,6 +19,7 @@ Some useful tiddlers for feature testing: * VideoTests showing how different online video formats can be embedded * SliderTests showing how sliders work * TypedBlockTests showing how embedded typed text blocks work +* ShadowTiddlers, including ViewTemplate, EditTemplate and PageTemplate Technical documentation includes: * [[Testing]] regimen