mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Minor corrections and refactorings
This commit is contained in:
parent
6202e64eaa
commit
4b3548e7bb
@ -21,6 +21,9 @@ as a TiddlyWiki quoted string (eg, "one [[two three]]").
|
||||
|
||||
"use strict";
|
||||
|
||||
var utils = require("./Utils.js"),
|
||||
ArgParser = require("./ArgParser.js").ArgParser;
|
||||
|
||||
var Tiddler = function(/* tiddler,fields */) {
|
||||
this.fields = {};
|
||||
for(var c=0; c<arguments.length; c++) {
|
||||
|
@ -4,8 +4,7 @@ Functions concerned with parsing representations of tiddlers
|
||||
|
||||
"use strict";
|
||||
|
||||
var ArgParser = require("./ArgParser.js").ArgParser,
|
||||
utils = require("./Utils.js"),
|
||||
var utils = require("./Utils.js"),
|
||||
util = require("util");
|
||||
|
||||
var tiddlerInput = exports;
|
||||
@ -71,16 +70,17 @@ tiddlerInput.parseTiddlerFileByMimeType = {
|
||||
return [fields];
|
||||
},
|
||||
"application/json": function(text,fields) {
|
||||
var tiddlers = JSON.parse(text);
|
||||
var result = [];
|
||||
for(var t=0; t<tiddlers.length; t++) {
|
||||
var tid = tiddlers[t],
|
||||
fields = {};
|
||||
// Just whitelist the fields we know that we want
|
||||
var tiddlers = JSON.parse(text),
|
||||
result = [],
|
||||
getKnownFields = function(tid) {
|
||||
var fields = {};
|
||||
"title text created creator modified modifier type tags".split(" ").forEach(function(value) {
|
||||
fields[value] = tid[value];
|
||||
});
|
||||
result.push(fields);
|
||||
return fields;
|
||||
};
|
||||
for(var t=0; t<tiddlers.length; t++) {
|
||||
result.push(getKnownFields(tiddlers[t]));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -9,7 +9,8 @@ var TiddlyWiki = require("./js/TiddlyWiki.js").TiddlyWiki,
|
||||
http = require("http"),
|
||||
fs = require("fs"),
|
||||
url = require("url"),
|
||||
path = require("path");
|
||||
path = require("path"),
|
||||
util = require("util");
|
||||
|
||||
var filename = process.argv[2];
|
||||
|
||||
@ -21,4 +22,4 @@ http.createServer(function(request, response) {
|
||||
});
|
||||
}).listen(8000);
|
||||
|
||||
sys.puts("Server running at http://127.0.0.1:8000/");
|
||||
util.puts("Server running at http://127.0.0.1:8000/");
|
||||
|
Loading…
Reference in New Issue
Block a user