topic_list 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 topicid = acre.environ.params.id;

var PROPSCHEMAQUERY = {
"id" : null,
"name" : null,
...

Content

var topicid = acre.environ.params.id;

var PROPSCHEMAQUERY = {
"id" : null,
"name" : null,
"unique" : null,
"expected_type" : {
"id" : null,
"name" : null,
"/freebase/type_hints/mediator" : null,
"properties" : [{
"id" : null,
"name" : null,
"unique" : null,
"expected_type" : {
"id":null
},
"/freebase/property_hints/disambiguator" : true,
"/freebase/property_hints/display_none" : {
"optional" : "forbidden",
"value" : true
},
"index" : null,
"sort" : "index",
"optional" : true
}],
"/freebase/property_hints/display_none" : {
"optional" : "forbidden",
"value" : true
}
}
};

function subPropQuery(p){
switch (p.expected_type.id) {
case "/type/int":
case "/type/float":
case "/type/boolean":
case "/type/rawstring":
case "/type/uri":
case "/type/text":
case "/type/datetime":
case "/type/bytestring":
case "/type/id":
case "/type/key":
case "/type/value":
return [{"value":null, "optional":true}];
// Localization?
case "type/text":
return [{"id":null,"name":null,"lang":"lang/en","optional":true}];
default:
return [{"id":null,"name":null,"optional":true}];
}
};

function propQuery(p){
var q = subPropQuery(p);
for (sp in p.expected_type.properties) {
q[0][p.expected_type.properties[sp].id] = subPropQuery(p.expected_type.properties[sp]);
}
return q;
};

function addCriteria(p,id,q){
if (typeof(q) == 'undefined') {
q = [{}];
}
q[0]["criteria:" + p] = {"id" : id};
return q;
};



function constructQuery(schema){
var q = [{"limit":schema.max_topics}];
addCriteria('type',schema.topic_type.id,q);

q[0]['id'] = null;
q[0][schema.image.property_to_label] = [{}];
q[0][schema.title.property_to_label] = null;

for (p in schema.featured_properties) {
q[0][schema.featured_properties[p].property_to_label.id] = propQuery(schema.featured_properties[p].property_to_label);
}
return (q);
}

var schemaIntrospection = acre.mqlread({
"id" : topicid,
"type" : "/user/jdouglas/config/minitopic",
"max_topics" : null,
"topic_type" : {
"id" : null
},
"title" : {
"label" : null,
"property_to_label" : null
},
"image" : {
"label" : null,
"property_to_label" : null
},
"featured_properties" : [{
"label" : null,
"property_to_label" : PROPSCHEMAQUERY,
"index" : null,
"sort" : "index"
}]
});

acre.start_response(200, {
'content-type': 'application/json; charset="UTF-8"'
});

var data = acre.mqlread(constructQuery(schemaIntrospection));

acre.write(JSON.stringify(data));

Created by: jdouglas Feb 28, 2008
Last edited by: Constant Gardener Process Aug 18, 2009

Recent Discussions about topic_list

There is no discussion about this document.

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