mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Adopted a saner convention for handling modules that export a single class
This commit is contained in:
parent
c4ab9ec218
commit
a2831eb203
8
cook.js
8
cook.js
@ -3,13 +3,13 @@
|
|||||||
// Usage: node cook.js <recipefile>
|
// Usage: node cook.js <recipefile>
|
||||||
|
|
||||||
var sys = require("sys"),
|
var sys = require("sys"),
|
||||||
tiddlywiki = require("./js/TiddlyWiki.js"),
|
TiddlyWiki = require("./js/TiddlyWiki.js").TiddlyWiki,
|
||||||
recipe = require("./js/Recipe.js");
|
Recipe = require("./js/Recipe.js").Recipe;
|
||||||
|
|
||||||
var filename = process.argv[2];
|
var filename = process.argv[2];
|
||||||
|
|
||||||
var store = new tiddlywiki.TiddlyWiki();
|
var store = new TiddlyWiki();
|
||||||
|
|
||||||
var theRecipe = new recipe.Recipe(store,filename);
|
var theRecipe = new Recipe(store,filename);
|
||||||
|
|
||||||
process.stdout.write(theRecipe.cook());
|
process.stdout.write(theRecipe.cook());
|
||||||
|
4
ginsu.js
4
ginsu.js
@ -8,7 +8,7 @@
|
|||||||
var sys = require("sys"),
|
var sys = require("sys"),
|
||||||
fs = require("fs"),
|
fs = require("fs"),
|
||||||
path = require("path"),
|
path = require("path"),
|
||||||
tiddler = require("./js/Tiddler.js"),
|
Tiddler = require("./js/Tiddler.js").Tiddler,
|
||||||
tiddlyWikiInput = require("./js/TiddlyWikiInput.js"),
|
tiddlyWikiInput = require("./js/TiddlyWikiInput.js"),
|
||||||
tiddlerOutput = require("./js/TiddlerOutput.js");
|
tiddlerOutput = require("./js/TiddlerOutput.js");
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ var tiddlers = tiddlyWikiInput.parseTiddlyWiki(tiddlywikidoc);
|
|||||||
|
|
||||||
var recipe = [];
|
var recipe = [];
|
||||||
for(var t=0; t<tiddlers.length; t++) {
|
for(var t=0; t<tiddlers.length; t++) {
|
||||||
var tid = new tiddler.Tiddler(tiddlers[t]);
|
var tid = new Tiddler(tiddlers[t]);
|
||||||
var filename = encodeURIComponent(tid.fields.title.replace(/ /g,"_")) + ".tid";
|
var filename = encodeURIComponent(tid.fields.title.replace(/ /g,"_")) + ".tid";
|
||||||
fs.writeFileSync(path.join(outputdir,filename),tiddlerOutput.outputTiddler(tid));
|
fs.writeFileSync(path.join(outputdir,filename),tiddlerOutput.outputTiddler(tid));
|
||||||
recipe.push("tiddler: " + filename + "\n");
|
recipe.push("tiddler: " + filename + "\n");
|
||||||
|
@ -27,11 +27,11 @@ this.ingredients = {
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var tiddler = require("./Tiddler.js"),
|
var Tiddler = require("./Tiddler.js").Tiddler,
|
||||||
tiddlerInput = require("./TiddlerInput.js"),
|
tiddlerInput = require("./TiddlerInput.js"),
|
||||||
tiddlerOutput = require("./TiddlerOutput.js"),
|
tiddlerOutput = require("./TiddlerOutput.js"),
|
||||||
utils = require("./Utils.js"),
|
utils = require("./Utils.js"),
|
||||||
tiddlywiki = require("./TiddlyWiki.js"),
|
TiddlyWiki = require("./TiddlyWiki.js").TiddlyWiki,
|
||||||
fs = require("fs"),
|
fs = require("fs"),
|
||||||
path = require("path"),
|
path = require("path"),
|
||||||
util = require("util");
|
util = require("util");
|
||||||
@ -86,7 +86,7 @@ Recipe.prototype.readIngredientPostProcess = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Recipe.prototype.addIngredient = function(marker,tiddlerFields) {
|
Recipe.prototype.addIngredient = function(marker,tiddlerFields) {
|
||||||
var ingredientTiddler = new tiddler.Tiddler(tiddlerFields);
|
var ingredientTiddler = new Tiddler(tiddlerFields);
|
||||||
this.store.addTiddler(ingredientTiddler);
|
this.store.addTiddler(ingredientTiddler);
|
||||||
if(marker in this.ingredients) {
|
if(marker in this.ingredients) {
|
||||||
this.ingredients[marker].push(ingredientTiddler);
|
this.ingredients[marker].push(ingredientTiddler);
|
||||||
@ -192,7 +192,7 @@ Recipe.ingredientOutputter = {
|
|||||||
var title = tid.fields.title;
|
var title = tid.fields.title;
|
||||||
var tweakedTiddler;
|
var tweakedTiddler;
|
||||||
if(title.indexOf(".shadow") === title.length - 7) {
|
if(title.indexOf(".shadow") === title.length - 7) {
|
||||||
tweakedTiddler = new tiddler.Tiddler(tid,{
|
tweakedTiddler = new Tiddler(tid,{
|
||||||
title: title.substr(0, title.length-7)
|
title: title.substr(0, title.length-7)
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
Functions concerned with parsing representations of tiddlers
|
Functions concerned with parsing representations of tiddlers
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var argParser = require("./ArgParser.js"),
|
var ArgParser = require("./ArgParser.js").ArgParser,
|
||||||
utils = require("./Utils.js");
|
utils = require("./Utils.js");
|
||||||
|
|
||||||
var tiddlerInput = exports;
|
var tiddlerInput = exports;
|
||||||
@ -143,7 +143,7 @@ tiddlerInput.parseMetaDataItem = function(field,value) {
|
|||||||
result = utils.convertFromYYYYMMDDHHMMSS(value);
|
result = utils.convertFromYYYYMMDDHHMMSS(value);
|
||||||
break;
|
break;
|
||||||
case "tags":
|
case "tags":
|
||||||
var parser = new argParser.ArgParser(value,{noNames: true});
|
var parser = new ArgParser(value,{noNames: true});
|
||||||
result = parser.getValuesByName("","");
|
result = parser.getValuesByName("","");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -2,8 +2,7 @@
|
|||||||
Functions concerned with parsing representations of tiddlers
|
Functions concerned with parsing representations of tiddlers
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var argParser = require("./ArgParser.js"),
|
var utils = require("./Utils.js");
|
||||||
utils = require("./Utils.js");
|
|
||||||
|
|
||||||
var tiddlerOutput = exports;
|
var tiddlerOutput = exports;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
var tiddler = require("./Tiddler.js");
|
var Tiddler = require("./Tiddler.js").Tiddler;
|
||||||
|
|
||||||
var TiddlyWiki = function() {
|
var TiddlyWiki = function() {
|
||||||
this.tiddlers = {};
|
this.tiddlers = {};
|
||||||
@ -10,7 +10,7 @@ TiddlyWiki.prototype.clear = function() {
|
|||||||
|
|
||||||
TiddlyWiki.prototype.fetchTiddler = function(title) {
|
TiddlyWiki.prototype.fetchTiddler = function(title) {
|
||||||
var t = this.tiddlers[title];
|
var t = this.tiddlers[title];
|
||||||
return t instanceof tiddler.Tiddler ? t : null;
|
return t instanceof Tiddler ? t : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
TiddlyWiki.prototype.deleteTiddler = function(title) {
|
TiddlyWiki.prototype.deleteTiddler = function(title) {
|
||||||
@ -25,7 +25,7 @@ TiddlyWiki.prototype.forEachTiddler = function(callback) {
|
|||||||
var t;
|
var t;
|
||||||
for(t in this.tiddlers) {
|
for(t in this.tiddlers) {
|
||||||
var tiddler = this.tiddlers[t];
|
var tiddler = this.tiddlers[t];
|
||||||
if(tiddler instanceof tiddler.Tiddler)
|
if(tiddler instanceof Tiddler)
|
||||||
callback.call(this,t,tiddler);
|
callback.call(this,t,tiddler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
//
|
//
|
||||||
// Usage: node server.js <recipefile>
|
// Usage: node server.js <recipefile>
|
||||||
|
|
||||||
var tiddlywiki = require("./js/TiddlyWiki.js"),
|
var TiddlyWiki = require("./js/TiddlyWiki.js").TiddlyWiki,
|
||||||
recipe = require("./js/Recipe.js"),
|
Recipe = require("./js/Recipe.js").Recipe,
|
||||||
sys = require("sys"),
|
sys = require("sys"),
|
||||||
http = require("http"),
|
http = require("http"),
|
||||||
fs = require("fs"),
|
fs = require("fs"),
|
||||||
@ -14,8 +14,8 @@ var filename = process.argv[2];
|
|||||||
|
|
||||||
http.createServer(function (request, response) {
|
http.createServer(function (request, response) {
|
||||||
response.writeHead(200, {"Content-Type": "text/html"});
|
response.writeHead(200, {"Content-Type": "text/html"});
|
||||||
var store = new tiddlywiki.TiddlyWiki();
|
var store = new TiddlyWiki();
|
||||||
var theRecipe = new recipe.Recipe(store,filename);
|
var theRecipe = new Recipe(store,filename);
|
||||||
response.end(theRecipe.cook(), "utf-8");
|
response.end(theRecipe.cook(), "utf-8");
|
||||||
}).listen(8000);
|
}).listen(8000);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user