/guid/9202a8c04000641f8000000007c8b50c rename

author:

contributor:

published:

updated:

source uri:

Acre Doc /freebase/acre_doc

Handler:

Default Configuration:

Acre Doc /freebase/acre_doc

Handler:

Default Configuration:

Summary

var params = acre.environ.params || {};

var code = params.template || getDoc(params.templateId) ||...

Content

var params = acre.environ.params || {};

var code = params.template || getDoc(params.templateId) || getDefaultTemplate();

code = apply_template_args(code,params);
//acre.log(code);
eval(code);

acre.exit();


///////

function getDefaultTemplate() {
return "\
acre.start_response(404, { 'content-type': 'application/json; charset=\"UTF-8\"' }); \
acre.print('No template or templateId was specified');\
";
}

function getDoc(id) {
if (!id) { return null; }
var url = acre.environ.freebase_service_url + '/api/trans/raw' + id;
var response = acre.urlopen('GET', url);
return response.body;
}

function apply_template_args(code,params) {
for (var param in params) {
code = code.replace('${'+param+'}',params[param]);
}
return code;
}

function die(message) {
acre.start_response(200, { 'content-type': 'application/json; charset="UTF-8"' });
acre.print('uuuurrrrgggg ... dying of '+message || 'something');
acre.exit();
}

Created by: willmoffat Apr 2, 2008
Last edited by: Constant Gardener Process Aug 18, 2009

Recent Discussions about None

There is no discussion about this document.

Start the Discussion »
Explore the Data
View all the data we have for /guid/9202a8c04000641f8000000007c8b50c
Flag this Document
Why do you want to flag this document?