mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-09-07 13:06:47 +00:00
Renamed SimpleTemplate to ViewTemplate
Compatibility with TiddlyWiki
This commit is contained in:
parent
42900b3aac
commit
9b145638ec
@ -21,7 +21,7 @@ exports.macro = {
|
|||||||
},
|
},
|
||||||
events: {
|
events: {
|
||||||
"tw-navigate": function(event) {
|
"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),
|
storyTiddler = this.store.getTiddler(this.params.story),
|
||||||
story = {tiddlers: []};
|
story = {tiddlers: []};
|
||||||
if(storyTiddler && storyTiddler.hasOwnProperty("text")) {
|
if(storyTiddler && storyTiddler.hasOwnProperty("text")) {
|
||||||
@ -48,7 +48,16 @@ exports.macro = {
|
|||||||
storyRecord.title = "Draft of " + event.tiddlerTitle + " at " + (new Date());
|
storyRecord.title = "Draft of " + event.tiddlerTitle + " at " + (new Date());
|
||||||
storyRecord.template = template;
|
storyRecord.template = template;
|
||||||
var tiddler = this.store.getTiddler(event.tiddlerTitle);
|
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)}));
|
this.store.addTiddler(new Tiddler(storyTiddler,{text: JSON.stringify(story)}));
|
||||||
@ -56,7 +65,7 @@ exports.macro = {
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
"tw-SaveTiddler": function(event) {
|
"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),
|
storyTiddler = this.store.getTiddler(this.params.story),
|
||||||
story = {tiddlers: []},
|
story = {tiddlers: []},
|
||||||
storyTiddlerModified = false;
|
storyTiddlerModified = false;
|
||||||
@ -72,6 +81,10 @@ exports.macro = {
|
|||||||
this.store.addTiddler(new Tiddler(tiddler,{title: tiddler["draft.title"],"draft.title": undefined}));
|
this.store.addTiddler(new Tiddler(tiddler,{title: tiddler["draft.title"],"draft.title": undefined}));
|
||||||
// Remove the draft tiddler
|
// Remove the draft tiddler
|
||||||
this.store.deleteTiddler(storyRecord.title);
|
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
|
// Make the story record point to the newly saved tiddler
|
||||||
storyRecord.title = tiddler["draft.title"];
|
storyRecord.title = tiddler["draft.title"];
|
||||||
storyRecord.template = template;
|
storyRecord.template = template;
|
||||||
@ -103,13 +116,14 @@ exports.macro = {
|
|||||||
return content;
|
return content;
|
||||||
},
|
},
|
||||||
refreshInDom: function(changes) {
|
refreshInDom: function(changes) {
|
||||||
|
var t;
|
||||||
/*jslint browser: true */
|
/*jslint browser: true */
|
||||||
if(this.dependencies.hasChanged(changes,this.tiddlerTitle)) {
|
if(this.dependencies.hasChanged(changes,this.tiddlerTitle)) {
|
||||||
// Get the tiddlers we're supposed to be displaying
|
// Get the tiddlers we're supposed to be displaying
|
||||||
var self = this,
|
var self = this,
|
||||||
story = JSON.parse(this.store.getTiddlerText(this.params.story)),
|
story = JSON.parse(this.store.getTiddlerText(this.params.story)),
|
||||||
template = this.params.template,
|
template = this.params.template,
|
||||||
t,n,domNode,
|
n,domNode,
|
||||||
findTiddler = function (childIndex,tiddlerTitle,templateTitle) {
|
findTiddler = function (childIndex,tiddlerTitle,templateTitle) {
|
||||||
while(childIndex < self.content.length) {
|
while(childIndex < self.content.length) {
|
||||||
var params = self.content[childIndex].params;
|
var params = self.content[childIndex].params;
|
||||||
|
@ -3,8 +3,8 @@ type: application/json
|
|||||||
|
|
||||||
{
|
{
|
||||||
"tiddlers": [
|
"tiddlers": [
|
||||||
{"title": "HelloThere", "template": "SimpleTemplate"},
|
{"title": "HelloThere", "template": "ViewTemplate"},
|
||||||
{"title": "Introduction", "template": "SimpleTemplate"},
|
{"title": "Introduction", "template": "ViewTemplate"},
|
||||||
{"title": "NewWikiTextFeatures", "template": "SimpleTemplate"}
|
{"title": "NewWikiTextFeatures", "template": "ViewTemplate"}
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
title: SimpleTemplate
|
title: ViewTemplate
|
||||||
modifier: JeremyRuston
|
modifier: JeremyRuston
|
||||||
|
|
||||||
{{title{
|
{{title{
|
@ -19,6 +19,7 @@ Some useful tiddlers for feature testing:
|
|||||||
* VideoTests showing how different online video formats can be embedded
|
* VideoTests showing how different online video formats can be embedded
|
||||||
* SliderTests showing how sliders work
|
* SliderTests showing how sliders work
|
||||||
* TypedBlockTests showing how embedded typed text blocks work
|
* TypedBlockTests showing how embedded typed text blocks work
|
||||||
|
* ShadowTiddlers, including ViewTemplate, EditTemplate and PageTemplate
|
||||||
|
|
||||||
Technical documentation includes:
|
Technical documentation includes:
|
||||||
* [[Testing]] regimen
|
* [[Testing]] regimen
|
||||||
|
Loading…
Reference in New Issue
Block a user