1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-27 03:57:21 +00:00

Added a temporary hack to get pegs working serverside

This commit is contained in:
Jeremy Ruston 2011-12-28 22:21:31 +00:00
parent ed2e2ab14c
commit 04dc396f2a
3 changed files with 10 additions and 3 deletions

View File

@ -40,14 +40,13 @@ Sandbox.prototype.execute = function(code,globals) {
out.push(code); out.push(code);
out.push(";})"); out.push(";})");
// Parse the code // Parse the code
var code = out.join(""), var compiledCode = out.join(""),
tree = this.parser.parse(out.join("")); tree = this.parser.parse(out.join(""));
// XXX: Sanitise the code by checking for references to globals, stripping out eval() // XXX: Sanitise the code by checking for references to globals, stripping out eval()
console.log(tree);
// Execute it // Execute it
var result; var result;
try { try {
result = eval(code).apply(null,globalValues); result = eval(compiledCode).apply(null,globalValues);
} catch(err) { } catch(err) {
result = "{{** Evaluation error: " + err + " **}}"; result = "{{** Evaluation error: " + err + " **}}";
} }

View File

@ -56,6 +56,10 @@ store.registerTextProcessor("text/x-tiddlywiki",new WikiTextProcessor({
tiddlerInput.register(store); tiddlerInput.register(store);
tiddlerOutput.register(store); tiddlerOutput.register(store);
// Frightful temporary hack, but setup the sandbox for evaluated macro parameters
var Sandbox = require("./js/Sandbox.js").Sandbox;
store.sandbox = new Sandbox(fs.readFileSync("parsers/javascript.pegjs","utf8"));
// 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({
shadowStore: null shadowStore: null

View File

@ -34,6 +34,10 @@ store.registerTextProcessor("text/x-tiddlywiki",new WikiTextProcessor({
})); }));
tiddlerInput.register(store); tiddlerInput.register(store);
// Frightful temporary hack, but setup the sandbox for evaluated macro parameters
var Sandbox = require("./js/Sandbox.js").Sandbox;
store.sandbox = new Sandbox(fs.readFileSync("parsers/javascript.pegjs","utf8"));
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") {