/user/willmoffat/apps/d_image_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

acre.load('libWill','http://www.freebase.com/api/trans/raw/user/willmoffat/apps/libWill');
// set...

Content

acre.load('libWill','http://www.freebase.com/api/trans/raw/user/willmoffat/apps/libWill');
// set query from url

var data = acre.mqlread(JSON.parse(query));

var h=[];

function link(item) {
if (item.id) { return ''+ item.name +''; }
return item.name;
}

function listItem(item) {
if (!item) { return; }
if (item.name) { h.push(''+link(item) ); }
search_img(item,item);
for (prop in item) {
var val = item[prop];
if (val) { listItem(val); }
}
if (item.name) { h.push(''); }
}

function search_img(item,owner) {
var img = item.image || item['/common/topic/image'] || null;
if (!img) { return; }
if ("length" in img) {
for (var i=0;i Missing image'); }
h.push('');
}


var header = [
'',
' ',
' List of Stuff',
' ',
' div { padding-left: 2em; } ',
' .box { float:left; width:10em; height:10em; text-align:center; } a { text-decoration:none; } a img { border:none; }',
' .missing { width:5em; height:5em; margin:auto; background:lightgrey }',
' ',
' ',
' ',
' '];

var footer = [
' ',
''];


if (data) {
listItem(data); // fills h[]
} else {
h=['ERROR - mql query has no data']
}

var htmlList = header.concat(h, footer);
var html = htmlList.join('\n');

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

acre.write(html);


Created by: willmoffat Apr 12, 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 /user/willmoffat/apps/d_image_list
Flag this Document
Why do you want to flag this document?