1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +00:00

Adopted a saner convention for handling modules that export a single class

This commit is contained in:
Jeremy Ruston 2011-11-27 09:46:02 +00:00
parent c4ab9ec218
commit a2831eb203
7 changed files with 20 additions and 21 deletions

View File

@ -3,13 +3,13 @@
// Usage: node cook.js <recipefile>
var sys = require("sys"),
tiddlywiki = require("./js/TiddlyWiki.js"),
recipe = require("./js/Recipe.js");
TiddlyWiki = require("./js/TiddlyWiki.js").TiddlyWiki,
Recipe = require("./js/Recipe.js").Recipe;
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());

View File

@ -8,7 +8,7 @@
var sys = require("sys"),
fs = require("fs"),
path = require("path"),
tiddler = require("./js/Tiddler.js"),
Tiddler = require("./js/Tiddler.js").Tiddler,
tiddlyWikiInput = require("./js/TiddlyWikiInput.js"),
tiddlerOutput = require("./js/TiddlerOutput.js");
@ -20,7 +20,7 @@ var tiddlers = tiddlyWikiInput.parseTiddlyWiki(tiddlywikidoc);
var recipe = [];
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";
fs.writeFileSync(path.join(outputdir,filename),tiddlerOutput.outputTiddler(tid));
recipe.push("tiddler: " + filename + "\n");

View File

@ -27,11 +27,11 @@ this.ingredients = {
*/
var tiddler = require("./Tiddler.js"),
var Tiddler = require("./Tiddler.js").Tiddler,
tiddlerInput = require("./TiddlerInput.js"),
tiddlerOutput = require("./TiddlerOutput.js"),
utils = require("./Utils.js"),
tiddlywiki = require("./TiddlyWiki.js"),
TiddlyWiki = require("./TiddlyWiki.js").TiddlyWiki,
fs = require("fs"),
path = require("path"),
util = require("util");
@ -86,7 +86,7 @@ Recipe.prototype.readIngredientPostProcess = {
};
Recipe.prototype.addIngredient = function(marker,tiddlerFields) {
var ingredientTiddler = new tiddler.Tiddler(tiddlerFields);
var ingredientTiddler = new Tiddler(tiddlerFields);
this.store.addTiddler(ingredientTiddler);
if(marker in this.ingredients) {
this.ingredients[marker].push(ingredientTiddler);
@ -192,7 +192,7 @@ Recipe.ingredientOutputter = {
var title = tid.fields.title;
var tweakedTiddler;
if(title.indexOf(".shadow") === title.length - 7) {
tweakedTiddler = new tiddler.Tiddler(tid,{
tweakedTiddler = new Tiddler(tid,{
title: title.substr(0, title.length-7)
});
} else {

View File

@ -2,7 +2,7 @@
Functions concerned with parsing representations of tiddlers
*/
var argParser = require("./ArgParser.js"),
var ArgParser = require("./ArgParser.js").ArgParser,
utils = require("./Utils.js");
var tiddlerInput = exports;
@ -143,7 +143,7 @@ tiddlerInput.parseMetaDataItem = function(field,value) {
result = utils.convertFromYYYYMMDDHHMMSS(value);
break;
case "tags":
var parser = new argParser.ArgParser(value,{noNames: true});
var parser = new ArgParser(value,{noNames: true});
result = parser.getValuesByName("","");
break;
default:

View File

@ -2,8 +2,7 @@
Functions concerned with parsing representations of tiddlers
*/
var argParser = require("./ArgParser.js"),
utils = require("./Utils.js");
var utils = require("./Utils.js");
var tiddlerOutput = exports;

View File

@ -1,4 +1,4 @@
var tiddler = require("./Tiddler.js");
var Tiddler = require("./Tiddler.js").Tiddler;
var TiddlyWiki = function() {
this.tiddlers = {};
@ -10,7 +10,7 @@ TiddlyWiki.prototype.clear = function() {
TiddlyWiki.prototype.fetchTiddler = function(title) {
var t = this.tiddlers[title];
return t instanceof tiddler.Tiddler ? t : null;
return t instanceof Tiddler ? t : null;
}
TiddlyWiki.prototype.deleteTiddler = function(title) {
@ -25,7 +25,7 @@ TiddlyWiki.prototype.forEachTiddler = function(callback) {
var t;
for(t in this.tiddlers) {
var tiddler = this.tiddlers[t];
if(tiddler instanceof tiddler.Tiddler)
if(tiddler instanceof Tiddler)
callback.call(this,t,tiddler);
}
}

View File

@ -2,8 +2,8 @@
//
// Usage: node server.js <recipefile>
var tiddlywiki = require("./js/TiddlyWiki.js"),
recipe = require("./js/Recipe.js"),
var TiddlyWiki = require("./js/TiddlyWiki.js").TiddlyWiki,
Recipe = require("./js/Recipe.js").Recipe,
sys = require("sys"),
http = require("http"),
fs = require("fs"),
@ -14,8 +14,8 @@ var filename = process.argv[2];
http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/html"});
var store = new tiddlywiki.TiddlyWiki();
var theRecipe = new recipe.Recipe(store,filename);
var store = new TiddlyWiki();
var theRecipe = new Recipe(store,filename);
response.end(theRecipe.cook(), "utf-8");
}).listen(8000);