mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 10:07:19 +00:00
Added a temporary hack to get pegs working serverside
This commit is contained in:
parent
ed2e2ab14c
commit
04dc396f2a
@ -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 + " **}}";
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
@ -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") {
|
||||||
|
Loading…
Reference in New Issue
Block a user