Added a temporary hack to get pegs working serverside

print-window-tiddler
Jeremy Ruston 2011-12-28 22:21:31 +00:00
rodzic ed2e2ab14c
commit 04dc396f2a
3 zmienionych plików z 10 dodań i 3 usunięć

Wyświetl plik

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

Wyświetl plik

@ -56,6 +56,10 @@ store.registerTextProcessor("text/x-tiddlywiki",new WikiTextProcessor({
tiddlerInput.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
var shadowShadowStore = new WikiStore({
shadowStore: null

Wyświetl plik

@ -34,6 +34,10 @@ store.registerTextProcessor("text/x-tiddlywiki",new WikiTextProcessor({
}));
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++) {
extname = path.extname(files[f]);
if(extname === ".tid") {