mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 03:57:21 +00:00
Removed TextProcessors() and TiddlerConverters() classes
This commit is contained in:
parent
92a1ddf2e1
commit
e02a484591
34
js/Main.js
34
js/Main.js
@ -13,31 +13,24 @@ var WikiStore = require("./WikiStore.js").WikiStore,
|
|||||||
Tiddler = require("./Tiddler.js").Tiddler,
|
Tiddler = require("./Tiddler.js").Tiddler,
|
||||||
tiddlerInput = require("./TiddlerInput.js"),
|
tiddlerInput = require("./TiddlerInput.js"),
|
||||||
tiddlerOutput = require("./TiddlerOutput.js"),
|
tiddlerOutput = require("./TiddlerOutput.js"),
|
||||||
TextProcessors = require("./TextProcessors.js").TextProcessors,
|
|
||||||
WikiTextProcessor = require("./WikiTextProcessor.js").WikiTextProcessor,
|
WikiTextProcessor = require("./WikiTextProcessor.js").WikiTextProcessor,
|
||||||
TiddlerConverters = require("./TiddlerConverters.js").TiddlerConverters,
|
|
||||||
Navigators = require("./Navigators.js").Navigators,
|
Navigators = require("./Navigators.js").Navigators,
|
||||||
StoryNavigator = require("./StoryNavigator.js").StoryNavigator;
|
StoryNavigator = require("./StoryNavigator.js").StoryNavigator;
|
||||||
|
|
||||||
var textProcessors = new TextProcessors(),
|
var store = new WikiStore(),
|
||||||
tiddlerConverters = new TiddlerConverters(),
|
|
||||||
store = new WikiStore({
|
|
||||||
textProcessors: textProcessors
|
|
||||||
}),
|
|
||||||
t;
|
t;
|
||||||
|
|
||||||
// Register the wikitext processor
|
// Register the wikitext processor
|
||||||
textProcessors.registerTextProcessor("text/x-tiddlywiki",new WikiTextProcessor({
|
store.registerTextProcessor("text/x-tiddlywiki",new WikiTextProcessor({
|
||||||
textProcessors: textProcessors
|
store: store
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Register the standard tiddler serializers and deserializers
|
// Register the standard tiddler serializers and deserializers
|
||||||
tiddlerInput.register(tiddlerConverters);
|
tiddlerInput.register(store);
|
||||||
tiddlerOutput.register(tiddlerConverters);
|
tiddlerOutput.register(store);
|
||||||
|
|
||||||
// Add the shadow tiddlers that are built into TiddlyWiki
|
// Add the shadow tiddlers that are built into TiddlyWiki
|
||||||
var shadowShadowStore = new WikiStore({
|
var shadowShadowStore = new WikiStore({
|
||||||
textProcessors: textProcessors,
|
|
||||||
shadowStore: null
|
shadowStore: null
|
||||||
}),
|
}),
|
||||||
shadowShadows = [
|
shadowShadows = [
|
||||||
@ -46,25 +39,12 @@ var shadowShadowStore = new WikiStore({
|
|||||||
{title: "MarkupPostHead", text: ""},
|
{title: "MarkupPostHead", text: ""},
|
||||||
{title: "MarkupPreBody", text: ""},
|
{title: "MarkupPreBody", text: ""},
|
||||||
{title: "MarkupPostBody", text: ""},
|
{title: "MarkupPostBody", text: ""},
|
||||||
{title: "TabTimeline", text: "<<timeline>>"},
|
|
||||||
{title: "TabAll", text: "<<list all>>"},
|
|
||||||
{title: "TabTags", text: "<<allTags excludeLists>>"},
|
|
||||||
{title: "TabMoreMissing", text: "<<list missing>>"},
|
|
||||||
{title: "TabMoreOrphans", text: "<<list orphans>>"},
|
|
||||||
{title: "TabMoreShadowed", text: "<<list shadowed>>"},
|
|
||||||
{title: "AdvancedOptions", text: "<<options>>"},
|
|
||||||
{title: "PluginManager", text: "<<plugins>>"},
|
|
||||||
{title: "SystemSettings", text: ""},
|
|
||||||
{title: "ToolbarCommands", text: "|~ViewToolbar|closeTiddler closeOthers +editTiddler > fields syncing permalink references jump|\n|~EditToolbar|+saveTiddler -cancelTiddler deleteTiddler|"},
|
|
||||||
{title: "WindowTitle", text: "<<tiddler SiteTitle>> - <<tiddler SiteSubtitle>>"},
|
{title: "WindowTitle", text: "<<tiddler SiteTitle>> - <<tiddler SiteSubtitle>>"},
|
||||||
{title: "DefaultTiddlers", text: "[[GettingStarted]]"},
|
{title: "DefaultTiddlers", text: "[[GettingStarted]]"},
|
||||||
{title: "MainMenu", text: "[[GettingStarted]]"},
|
{title: "MainMenu", text: "[[GettingStarted]]"},
|
||||||
{title: "SiteTitle", text: "My TiddlyWiki"},
|
{title: "SiteTitle", text: "My TiddlyWiki"},
|
||||||
{title: "SiteSubtitle", text: "a reusable non-linear personal web notebook"},
|
{title: "SiteSubtitle", text: "a reusable non-linear personal web notebook"},
|
||||||
{title: "SiteUrl", text: ""},
|
{title: "SiteUrl", text: ""}
|
||||||
{title: "SideBarOptions", text: '<<search>><<closeAll>><<permaview>><<newTiddler>><<newJournal "DD MMM YYYY" "journal">><<saveChanges>><<slider chkSliderOptionsPanel OptionsPanel "options \u00bb" "Change TiddlyWiki advanced options">>'},
|
|
||||||
{title: "SideBarTabs", text: '<<tabs txtMainTab "Timeline" "Timeline" TabTimeline "All" "All tiddlers" TabAll "Tags" "All tags" TabTags "More" "More lists" TabMore>>'},
|
|
||||||
{title: "TabMore", text: '<<tabs txtMoreTab "Missing" "Missing tiddlers" TabMoreMissing "Orphans" "Orphaned tiddlers" TabMoreOrphans "Shadowed" "Shadowed tiddlers" TabMoreShadowed>>'}
|
|
||||||
];
|
];
|
||||||
store.shadows.shadows = shadowShadowStore;
|
store.shadows.shadows = shadowShadowStore;
|
||||||
for(t=0; t<shadowShadows.length; t++) {
|
for(t=0; t<shadowShadows.length; t++) {
|
||||||
@ -73,7 +53,7 @@ for(t=0; t<shadowShadows.length; t++) {
|
|||||||
|
|
||||||
// Load the tiddlers built into the TiddlyWiki document
|
// Load the tiddlers built into the TiddlyWiki document
|
||||||
var storeArea = document.getElementById("storeArea"),
|
var storeArea = document.getElementById("storeArea"),
|
||||||
tiddlers = tiddlerConverters.deserialize("(DOM)",storeArea);
|
tiddlers = store.deserializeTiddlers("(DOM)",storeArea);
|
||||||
for(t=0; t<tiddlers.length; t++) {
|
for(t=0; t<tiddlers.length; t++) {
|
||||||
store.addTiddler(new Tiddler(tiddlers[t]));
|
store.addTiddler(new Tiddler(tiddlers[t]));
|
||||||
}
|
}
|
||||||
|
12
js/Recipe.js
12
js/Recipe.js
@ -51,8 +51,6 @@ var Recipe = function(options,callback) {
|
|||||||
var me = this;
|
var me = this;
|
||||||
this.filepath = options.filepath;
|
this.filepath = options.filepath;
|
||||||
this.store = options.store;
|
this.store = options.store;
|
||||||
this.tiddlerConverters = options.tiddlerConverters;
|
|
||||||
this.textProcessors = options.textProcessors;
|
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
this.recipe = [];
|
this.recipe = [];
|
||||||
this.markers = {};
|
this.markers = {};
|
||||||
@ -174,7 +172,7 @@ Recipe.prototype.processRecipeFile = function(recipe,text,contextPath) {
|
|||||||
}
|
}
|
||||||
var fields = {};
|
var fields = {};
|
||||||
if(fieldLines.length > 0) {
|
if(fieldLines.length > 0) {
|
||||||
fields = this.tiddlerConverters.deserialize("application/x-tiddler",fieldLines.join("\n"),{})[0];
|
fields = this.store.deserializeTiddlers("application/x-tiddler",fieldLines.join("\n"),{})[0];
|
||||||
}
|
}
|
||||||
recipe.push({marker: match.marker, filepath: match.value, contextPath: contextPath, fields: fields});
|
recipe.push({marker: match.marker, filepath: match.value, contextPath: contextPath, fields: fields});
|
||||||
}
|
}
|
||||||
@ -192,7 +190,7 @@ Recipe.prototype.readTiddlerFile = function(filepath,contextPath,callback) {
|
|||||||
var fields = {
|
var fields = {
|
||||||
title: data.path
|
title: data.path
|
||||||
};
|
};
|
||||||
var tiddlers = me.tiddlerConverters.deserialize(data.extname,data.text,fields);
|
var tiddlers = me.store.deserializeTiddlers(data.extname,data.text,fields);
|
||||||
// Check for the .meta file
|
// Check for the .meta file
|
||||||
if(data.extname !== ".json" && tiddlers.length === 1) {
|
if(data.extname !== ".json" && tiddlers.length === 1) {
|
||||||
var metafile = filepath + ".meta";
|
var metafile = filepath + ".meta";
|
||||||
@ -204,7 +202,7 @@ Recipe.prototype.readTiddlerFile = function(filepath,contextPath,callback) {
|
|||||||
if(!err) {
|
if(!err) {
|
||||||
var text = data.text.split("\n\n")[0];
|
var text = data.text.split("\n\n")[0];
|
||||||
if(text) {
|
if(text) {
|
||||||
fields = me.tiddlerConverters.deserialize("application/x-tiddler",text,fields)[0];
|
fields = me.store.deserializeTiddlers("application/x-tiddler",text,fields)[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
callback(null,[fields]);
|
callback(null,[fields]);
|
||||||
@ -272,7 +270,7 @@ Recipe.tiddlerOutputter = {
|
|||||||
// Ordinary tiddlers are output as a <DIV>
|
// Ordinary tiddlers are output as a <DIV>
|
||||||
for(var t=0; t<tiddlers.length; t++) {
|
for(var t=0; t<tiddlers.length; t++) {
|
||||||
var tid = this.store.getTiddler(tiddlers[t]);
|
var tid = this.store.getTiddler(tiddlers[t]);
|
||||||
out.push(this.tiddlerConverters.serialize("application/x-tiddler-html-div",tid));
|
out.push(this.store.serializeTiddler("application/x-tiddler-html-div",tid));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
javascript: function(out,tiddlers) {
|
javascript: function(out,tiddlers) {
|
||||||
@ -295,7 +293,7 @@ Recipe.tiddlerOutputter = {
|
|||||||
for(var t=0; t<tiddlers.length; t++) {
|
for(var t=0; t<tiddlers.length; t++) {
|
||||||
var title = tiddlers[t],
|
var title = tiddlers[t],
|
||||||
tid = this.store.shadows.getTiddler(title);
|
tid = this.store.shadows.getTiddler(title);
|
||||||
out.push(this.tiddlerConverters.serialize("application/x-tiddler-html-div",tid));
|
out.push(this.store.serializeTiddler("application/x-tiddler-html-div",tid));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
title: function(out,tiddlers) {
|
title: function(out,tiddlers) {
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
/*\
|
|
||||||
title: js/TextProcessors.js
|
|
||||||
|
|
||||||
\*/
|
|
||||||
(function(){
|
|
||||||
|
|
||||||
/*jslint node: true */
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var util = require("util");
|
|
||||||
|
|
||||||
var TextProcessors = function() {
|
|
||||||
this.processors = {};
|
|
||||||
};
|
|
||||||
|
|
||||||
TextProcessors.prototype.registerTextProcessor = function(type,processor) {
|
|
||||||
this.processors[type] = processor;
|
|
||||||
};
|
|
||||||
|
|
||||||
TextProcessors.prototype.parse = function(type,text) {
|
|
||||||
var processor = this.processors[type];
|
|
||||||
if(!processor) {
|
|
||||||
processor = this.processors["text/x-tiddlywiki"];
|
|
||||||
}
|
|
||||||
if(processor) {
|
|
||||||
return processor.parse(text);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.TextProcessors = TextProcessors;
|
|
||||||
|
|
||||||
})();
|
|
@ -1,54 +0,0 @@
|
|||||||
/*\
|
|
||||||
title: js/TiddlerConverters.js
|
|
||||||
|
|
||||||
\*/
|
|
||||||
(function(){
|
|
||||||
|
|
||||||
/*jslint node: true */
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var TiddlerConverters = function() {
|
|
||||||
this.serializers = {};
|
|
||||||
this.deserializers = {};
|
|
||||||
};
|
|
||||||
|
|
||||||
TiddlerConverters.prototype.registerSerializer = function(extension,mimeType,serializer) {
|
|
||||||
this.serializers[extension] = serializer;
|
|
||||||
this.serializers[mimeType] = serializer;
|
|
||||||
};
|
|
||||||
|
|
||||||
TiddlerConverters.prototype.registerDeserializer = function(extension,mimeType,deserializer) {
|
|
||||||
this.deserializers[extension] = deserializer;
|
|
||||||
this.deserializers[mimeType] = deserializer;
|
|
||||||
};
|
|
||||||
|
|
||||||
TiddlerConverters.prototype.serialize = function(type,tiddler) {
|
|
||||||
var serializer = this.serializers[type];
|
|
||||||
if(serializer) {
|
|
||||||
return serializer(tiddler);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
TiddlerConverters.prototype.deserialize = function(type,text,srcFields) {
|
|
||||||
var fields = {},
|
|
||||||
deserializer = this.deserializers[type],
|
|
||||||
t;
|
|
||||||
if(srcFields) {
|
|
||||||
for(t in srcFields) {
|
|
||||||
fields[t] = srcFields[t];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(deserializer) {
|
|
||||||
return deserializer(text,fields);
|
|
||||||
} else {
|
|
||||||
// Return a raw tiddler for unknown types
|
|
||||||
fields.text = text;
|
|
||||||
return [fields];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.TiddlerConverters = TiddlerConverters;
|
|
||||||
|
|
||||||
})();
|
|
@ -208,14 +208,14 @@ var inputTiddlerDOM = function(node) {
|
|||||||
return tiddlers;
|
return tiddlers;
|
||||||
};
|
};
|
||||||
|
|
||||||
tiddlerInput.register = function(tiddlerConverters) {
|
tiddlerInput.register = function(store) {
|
||||||
tiddlerConverters.registerDeserializer(".txt","text/plain",inputTiddlerPlain);
|
store.registerTiddlerDeserializer(".txt","text/plain",inputTiddlerPlain);
|
||||||
tiddlerConverters.registerDeserializer(".js","application/javascript",inputTiddlerJavaScript);
|
store.registerTiddlerDeserializer(".js","application/javascript",inputTiddlerJavaScript);
|
||||||
tiddlerConverters.registerDeserializer(".tiddler","application/x-tiddler-html-div",inputTiddlerDiv);
|
store.registerTiddlerDeserializer(".tiddler","application/x-tiddler-html-div",inputTiddlerDiv);
|
||||||
tiddlerConverters.registerDeserializer(".tid","application/x-tiddler",inputTiddler);
|
store.registerTiddlerDeserializer(".tid","application/x-tiddler",inputTiddler);
|
||||||
tiddlerConverters.registerDeserializer(".json","application/json",inputTiddlerJSON);
|
store.registerTiddlerDeserializer(".json","application/json",inputTiddlerJSON);
|
||||||
tiddlerConverters.registerDeserializer(".tiddlywiki","application/x-tiddlywiki",inputTiddlyWiki);
|
store.registerTiddlerDeserializer(".tiddlywiki","application/x-tiddlywiki",inputTiddlyWiki);
|
||||||
tiddlerConverters.registerDeserializer("(DOM)","(DOM)",inputTiddlerDOM);
|
store.registerTiddlerDeserializer("(DOM)","(DOM)",inputTiddlerDOM);
|
||||||
};
|
};
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@ -104,9 +104,9 @@ var outputTiddlerDiv = function(tid) {
|
|||||||
return result.join("");
|
return result.join("");
|
||||||
};
|
};
|
||||||
|
|
||||||
tiddlerOutput.register = function(tiddlerConverters) {
|
tiddlerOutput.register = function(store) {
|
||||||
tiddlerConverters.registerSerializer(".tid","application/x-tiddler",outputTiddler);
|
store.registerTiddlerSerializer(".tid","application/x-tiddler",outputTiddler);
|
||||||
tiddlerConverters.registerSerializer(".tiddler","application/x-tiddler-html-div",outputTiddlerDiv);
|
store.registerTiddlerSerializer(".tiddler","application/x-tiddler-html-div",outputTiddlerDiv);
|
||||||
};
|
};
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@ -10,17 +10,34 @@ title: js/WikiStore.js
|
|||||||
var Tiddler = require("./Tiddler.js").Tiddler,
|
var Tiddler = require("./Tiddler.js").Tiddler,
|
||||||
util = require("util");
|
util = require("util");
|
||||||
|
|
||||||
|
/* Creates a new WikiStore object
|
||||||
|
|
||||||
|
Available options are:
|
||||||
|
shadowStore: An existing WikiStore to use for shadow tiddler storage. Pass null to prevent a default shadow store from being created
|
||||||
|
*/
|
||||||
var WikiStore = function WikiStore(options) {
|
var WikiStore = function WikiStore(options) {
|
||||||
|
options = options || {};
|
||||||
this.tiddlers = {};
|
this.tiddlers = {};
|
||||||
|
this.textProcessors = {};
|
||||||
|
this.tiddlerSerializers = {};
|
||||||
|
this.tiddlerDeserializers = {};
|
||||||
this.shadows = options.shadowStore !== undefined ? options.shadowStore : new WikiStore({
|
this.shadows = options.shadowStore !== undefined ? options.shadowStore : new WikiStore({
|
||||||
shadowStore: null,
|
shadowStore: null
|
||||||
textProcessors: options.textProcessors
|
|
||||||
});
|
});
|
||||||
this.textProcessors = options.textProcessors;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
WikiStore.prototype.clear = function() {
|
WikiStore.prototype.registerTextProcessor = function(type,processor) {
|
||||||
this.tiddlers = {};
|
this.textProcessors[type] = processor;
|
||||||
|
};
|
||||||
|
|
||||||
|
WikiStore.prototype.registerTiddlerSerializer = function(extension,mimeType,serializer) {
|
||||||
|
this.tiddlerSerializers[extension] = serializer;
|
||||||
|
this.tiddlerSerializers[mimeType] = serializer;
|
||||||
|
};
|
||||||
|
|
||||||
|
WikiStore.prototype.registerTiddlerDeserializer = function(extension,mimeType,deserializer) {
|
||||||
|
this.tiddlerDeserializers[extension] = deserializer;
|
||||||
|
this.tiddlerDeserializers[mimeType] = deserializer;
|
||||||
};
|
};
|
||||||
|
|
||||||
WikiStore.prototype.getTiddler = function(title) {
|
WikiStore.prototype.getTiddler = function(title) {
|
||||||
@ -115,10 +132,49 @@ WikiStore.prototype.getShadowTitles = function() {
|
|||||||
return this.shadows ? this.shadows.getTitles() : [];
|
return this.shadows ? this.shadows.getTitles() : [];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
WikiStore.prototype.serializeTiddler = function(type,tiddler) {
|
||||||
|
var serializer = this.tiddlerSerializers[type];
|
||||||
|
if(serializer) {
|
||||||
|
return serializer(tiddler);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
WikiStore.prototype.deserializeTiddlers = function(type,text,srcFields) {
|
||||||
|
var fields = {},
|
||||||
|
deserializer = this.tiddlerDeserializers[type],
|
||||||
|
t;
|
||||||
|
if(srcFields) {
|
||||||
|
for(t in srcFields) {
|
||||||
|
fields[t] = srcFields[t];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(deserializer) {
|
||||||
|
return deserializer(text,fields);
|
||||||
|
} else {
|
||||||
|
// Return a raw tiddler for unknown types
|
||||||
|
fields.text = text;
|
||||||
|
return [fields];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
WikiStore.prototype.parseText = function(type,text) {
|
||||||
|
var processor = this.textProcessors[type];
|
||||||
|
if(!processor) {
|
||||||
|
processor = this.textProcessors["text/x-tiddlywiki"];
|
||||||
|
}
|
||||||
|
if(processor) {
|
||||||
|
return processor.parse(text);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
WikiStore.prototype.parseTiddler = function(title) {
|
WikiStore.prototype.parseTiddler = function(title) {
|
||||||
var tiddler = this.getTiddler(title);
|
var tiddler = this.getTiddler(title);
|
||||||
if(tiddler) {
|
if(tiddler) {
|
||||||
return this.textProcessors.parse(tiddler.fields.type,tiddler.fields.text);
|
return this.parseText(tiddler.fields.type,tiddler.fields.text);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ Planned:
|
|||||||
extraMacros: An array of additional macro handlers to add
|
extraMacros: An array of additional macro handlers to add
|
||||||
*/
|
*/
|
||||||
var WikiTextProcessor = function(options) {
|
var WikiTextProcessor = function(options) {
|
||||||
this.textProcessors = options.textProcessors;
|
|
||||||
this.rules = WikiTextRules.rules;
|
this.rules = WikiTextRules.rules;
|
||||||
var pattern = [];
|
var pattern = [];
|
||||||
for(var n=0; n<this.rules.length; n++) {
|
for(var n=0; n<this.rules.length; n++) {
|
||||||
|
@ -207,7 +207,7 @@ WikiTextRenderer.macros = {
|
|||||||
}
|
}
|
||||||
for(t=tiddlers.length-1; t>=last; t--) {
|
for(t=tiddlers.length-1; t>=last; t--) {
|
||||||
var tiddler = tiddlers[t],
|
var tiddler = tiddlers[t],
|
||||||
theGroupParseTree = this.parser.processor.textProcessors.parse(groupTemplateType,groupTemplateText),
|
theGroupParseTree = this.store.parseText(groupTemplateType,groupTemplateText),
|
||||||
theGroup = theGroupParseTree.render("text/plain",theGroupParseTree.children,this.store,tiddler);
|
theGroup = theGroupParseTree.render("text/plain",theGroupParseTree.children,this.store,tiddler);
|
||||||
if(theGroup !== "") {
|
if(theGroup !== "") {
|
||||||
if(ul === undefined || theGroup !== lastGroup) {
|
if(ul === undefined || theGroup !== lastGroup) {
|
||||||
@ -226,7 +226,7 @@ WikiTextRenderer.macros = {
|
|||||||
children: []
|
children: []
|
||||||
}]};
|
}]};
|
||||||
ul.children.push(item);
|
ul.children.push(item);
|
||||||
item.children[0].children = this.parser.processor.textProcessors.parse(templateType,templateText).children;
|
item.children[0].children = this.store.parseText(templateType,templateText).children;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.executeMacros(macroNode.output,title);
|
this.executeMacros(macroNode.output,title);
|
||||||
@ -260,7 +260,7 @@ WikiTextRenderer.macros = {
|
|||||||
children: []
|
children: []
|
||||||
} ]
|
} ]
|
||||||
};
|
};
|
||||||
li.children[0].children = this.parser.processor.textProcessors.parse(templateType,templateText).children;
|
li.children[0].children = this.store.parseText(templateType,templateText).children;
|
||||||
ul.children.push(li);
|
ul.children.push(li);
|
||||||
}
|
}
|
||||||
if(ul.children.length > 0) {
|
if(ul.children.length > 0) {
|
||||||
@ -325,7 +325,7 @@ WikiTextRenderer.macros = {
|
|||||||
var placeholderRegExp = new RegExp("\\$"+(t+1),"mg");
|
var placeholderRegExp = new RegExp("\\$"+(t+1),"mg");
|
||||||
text = text.replace(placeholderRegExp,withTokens[t]);
|
text = text.replace(placeholderRegExp,withTokens[t]);
|
||||||
}
|
}
|
||||||
macroNode.output = this.parser.processor.textProcessors.parse(tiddler.fields.type,text).children;
|
macroNode.output = this.store.parseText(tiddler.fields.type,text).children;
|
||||||
// Execute any macros in the copy
|
// Execute any macros in the copy
|
||||||
this.executeMacros(macroNode.output,title);
|
this.executeMacros(macroNode.output,title);
|
||||||
}
|
}
|
||||||
@ -367,7 +367,7 @@ WikiTextRenderer.macros = {
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "wikified":
|
case "wikified":
|
||||||
macroNode.output = this.parser.processor.textProcessors.parse("text/x-tiddlywiki",value).children;
|
macroNode.output = this.store.parseText("text/x-tiddlywiki",value).children;
|
||||||
// Execute any macros in the copy
|
// Execute any macros in the copy
|
||||||
this.executeMacros(macroNode.output,title);
|
this.executeMacros(macroNode.output,title);
|
||||||
break;
|
break;
|
||||||
|
@ -12,9 +12,7 @@ var WikiStore = require("./js/WikiStore.js").WikiStore,
|
|||||||
Recipe = require("./js/Recipe.js").Recipe,
|
Recipe = require("./js/Recipe.js").Recipe,
|
||||||
tiddlerInput = require("./js/TiddlerInput.js"),
|
tiddlerInput = require("./js/TiddlerInput.js"),
|
||||||
tiddlerOutput = require("./js/TiddlerOutput.js"),
|
tiddlerOutput = require("./js/TiddlerOutput.js"),
|
||||||
TextProcessors = require("./js/TextProcessors.js").TextProcessors,
|
|
||||||
WikiTextProcessor = require("./js/WikiTextProcessor.js").WikiTextProcessor,
|
WikiTextProcessor = require("./js/WikiTextProcessor.js").WikiTextProcessor,
|
||||||
TiddlerConverters = require("./js/TiddlerConverters.js").TiddlerConverters,
|
|
||||||
util = require("util"),
|
util = require("util"),
|
||||||
fs = require("fs"),
|
fs = require("fs"),
|
||||||
url = require("url"),
|
url = require("url"),
|
||||||
@ -45,27 +43,21 @@ var parseOptions = function(args,defaultSwitch) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
var textProcessors = new TextProcessors(),
|
var switches = parseOptions(Array.prototype.slice.call(process.argv,2),"dummy"),
|
||||||
tiddlerConverters = new TiddlerConverters(),
|
store = new WikiStore(),
|
||||||
switches = parseOptions(Array.prototype.slice.call(process.argv,2),"dummy"),
|
|
||||||
store = new WikiStore({
|
|
||||||
textProcessors: textProcessors
|
|
||||||
}),
|
|
||||||
recipe = null,
|
recipe = null,
|
||||||
lastRecipeFilepath = null,
|
lastRecipeFilepath = null,
|
||||||
currSwitch = 0;
|
currSwitch = 0;
|
||||||
|
|
||||||
|
store.registerTextProcessor("text/x-tiddlywiki",new WikiTextProcessor({
|
||||||
textProcessors.registerTextProcessor("text/x-tiddlywiki",new WikiTextProcessor({
|
store: store
|
||||||
textProcessors: textProcessors
|
|
||||||
}));
|
}));
|
||||||
// Register the standard tiddler serializers and deserializers
|
// Register the standard tiddler serializers and deserializers
|
||||||
tiddlerInput.register(tiddlerConverters);
|
tiddlerInput.register(store);
|
||||||
tiddlerOutput.register(tiddlerConverters);
|
tiddlerOutput.register(store);
|
||||||
|
|
||||||
// Add the shadow tiddlers that are built into TiddlyWiki
|
// Add the shadow tiddlers that are built into TiddlyWiki
|
||||||
var shadowShadowStore = new WikiStore({
|
var shadowShadowStore = new WikiStore({
|
||||||
textProcessors: textProcessors,
|
|
||||||
shadowStore: null
|
shadowStore: null
|
||||||
}),
|
}),
|
||||||
shadowShadows = [
|
shadowShadows = [
|
||||||
@ -114,9 +106,7 @@ var commandLineSwitches = {
|
|||||||
lastRecipeFilepath = args[0];
|
lastRecipeFilepath = args[0];
|
||||||
recipe = new Recipe({
|
recipe = new Recipe({
|
||||||
filepath: args[0],
|
filepath: args[0],
|
||||||
store: store,
|
store: store
|
||||||
tiddlerConverters: tiddlerConverters,
|
|
||||||
textProcessors: textProcessors
|
|
||||||
},function() {
|
},function() {
|
||||||
callback(null);
|
callback(null);
|
||||||
});
|
});
|
||||||
@ -196,9 +186,7 @@ var commandLineSwitches = {
|
|||||||
// Dumbly, this implementation wastes the recipe processing that happened on the --recipe switch
|
// Dumbly, this implementation wastes the recipe processing that happened on the --recipe switch
|
||||||
http.createServer(function(request, response) {
|
http.createServer(function(request, response) {
|
||||||
response.writeHead(200, {"Content-Type": "text/html"});
|
response.writeHead(200, {"Content-Type": "text/html"});
|
||||||
store = new WikiStore({
|
store = new WikiStore();
|
||||||
textProcessors: textProcessors
|
|
||||||
});
|
|
||||||
recipe = new Recipe(store,lastRecipeFilepath,function() {
|
recipe = new Recipe(store,lastRecipeFilepath,function() {
|
||||||
response.end(recipe.cook(), "utf8");
|
response.end(recipe.cook(), "utf8");
|
||||||
});
|
});
|
||||||
|
@ -11,11 +11,9 @@ jsmodule: ../js/ArgParser.js
|
|||||||
jsmodule: ../js/FileRetriever.js
|
jsmodule: ../js/FileRetriever.js
|
||||||
jsmodule: ../js/Utils.js
|
jsmodule: ../js/Utils.js
|
||||||
jsmodule: ../js/Tiddler.js
|
jsmodule: ../js/Tiddler.js
|
||||||
jsmodule: ../js/TiddlerConverters.js
|
|
||||||
jsmodule: ../js/TiddlerInput.js
|
jsmodule: ../js/TiddlerInput.js
|
||||||
jsmodule: ../js/TiddlerOutput.js
|
jsmodule: ../js/TiddlerOutput.js
|
||||||
jsmodule: ../js/WikiStore.js
|
jsmodule: ../js/WikiStore.js
|
||||||
jsmodule: ../js/TextProcessors.js
|
|
||||||
jsmodule: ../js/WikiTextProcessor.js
|
jsmodule: ../js/WikiTextProcessor.js
|
||||||
jsmodule: ../js/WikiTextParser.js
|
jsmodule: ../js/WikiTextParser.js
|
||||||
jsmodule: ../js/WikiTextRules.js
|
jsmodule: ../js/WikiTextRules.js
|
||||||
|
16
wikitest.js
16
wikitest.js
@ -16,9 +16,7 @@ verifying that the output matches `<tiddlername>.html` and `<tiddlername>.txt`.
|
|||||||
|
|
||||||
var Tiddler = require("./js/Tiddler.js").Tiddler,
|
var Tiddler = require("./js/Tiddler.js").Tiddler,
|
||||||
WikiStore = require("./js/WikiStore.js").WikiStore,
|
WikiStore = require("./js/WikiStore.js").WikiStore,
|
||||||
TextProcessors = require("./js/TextProcessors.js").TextProcessors,
|
|
||||||
WikiTextProcessor = require("./js/WikiTextProcessor.js").WikiTextProcessor,
|
WikiTextProcessor = require("./js/WikiTextProcessor.js").WikiTextProcessor,
|
||||||
TiddlerConverters = require("./js/TiddlerConverters.js").TiddlerConverters,
|
|
||||||
tiddlerInput = require("./js/TiddlerInput.js"),
|
tiddlerInput = require("./js/TiddlerInput.js"),
|
||||||
utils = require("./js/Utils.js"),
|
utils = require("./js/Utils.js"),
|
||||||
util = require("util"),
|
util = require("util"),
|
||||||
@ -26,24 +24,20 @@ var Tiddler = require("./js/Tiddler.js").Tiddler,
|
|||||||
path = require("path");
|
path = require("path");
|
||||||
|
|
||||||
var testdirectory = process.argv[2],
|
var testdirectory = process.argv[2],
|
||||||
textProcessors = new TextProcessors(),
|
store = new WikiStore(),
|
||||||
tiddlerConverters = new TiddlerConverters(),
|
|
||||||
store = new WikiStore({
|
|
||||||
textProcessors: textProcessors
|
|
||||||
}),
|
|
||||||
files = fs.readdirSync(testdirectory),
|
files = fs.readdirSync(testdirectory),
|
||||||
titles = [],
|
titles = [],
|
||||||
f,t,extname,basename;
|
f,t,extname,basename;
|
||||||
|
|
||||||
textProcessors.registerTextProcessor("text/x-tiddlywiki",new WikiTextProcessor({
|
store.registerTextProcessor("text/x-tiddlywiki",new WikiTextProcessor({
|
||||||
textProcessors: textProcessors
|
store: store
|
||||||
}));
|
}));
|
||||||
tiddlerInput.register(tiddlerConverters);
|
tiddlerInput.register(store);
|
||||||
|
|
||||||
for(f=0; f<files.length; f++) {
|
for(f=0; f<files.length; f++) {
|
||||||
extname = path.extname(files[f]);
|
extname = path.extname(files[f]);
|
||||||
if(extname === ".tid") {
|
if(extname === ".tid") {
|
||||||
var tiddlers = tiddlerConverters.deserialize(extname,fs.readFileSync(path.resolve(testdirectory,files[f]),"utf8"));
|
var tiddlers = store.deserializeTiddlers(extname,fs.readFileSync(path.resolve(testdirectory,files[f]),"utf8"));
|
||||||
if(tiddlers.length > 1) {
|
if(tiddlers.length > 1) {
|
||||||
throw "Cannot use .JSON files";
|
throw "Cannot use .JSON files";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user