/user/nix/acre/catalogcss rename

author:

published:

updated:

Feb 7, 2008 8:32:28AM UTC

source uri:

Acre Doc /freebase/acre_doc

Handler:

Default Configuration:

Acre Doc /freebase/acre_doc

Handler:

Default Configuration:

Summary

// chop off the leading '/' in the path_info to get the community name
var hostname = acre.environ...

Content

// chop off the leading '/' in the path_info to get the community name
var hostname = acre.environ.path_info.substr(1);

// If host is specified, get its setup freebase.site and apply it's theme
var siteq = acre.mqlread({
"type" : "/user/jdouglas/freebase/site",
"name" : null,
"id" : null,
"hostname" : hostname,
"theme" : {
"id" : null,
"masthead_image":{
"id":null,
"optional":true
}
}
});


var theme_id = siteq.theme.id;

var DEFAULT_THEME_ID = "/guid/9202a8c04000641f8000000006ea9f10";
var TRANS_RAW = "http://www.freebase.com/api/trans/raw";

var themes = acre.mqlread([{
"id" : null,
"type" : "/user/jdouglas/config/theme",
"id|=" : [theme_id, DEFAULT_THEME_ID],
"background_image":{
"id":null,
"optional":true
},
"masthead_image":{
"id":null,
"optional":true
},
"background_color" : null,
"font" : null,
"link_color" : null,
"module_background_color" : null,
"module_border_color" : null,
"module_text_color" : null,
"module_link_color" : null,
"module_visited_link_color" : null,
"text_color" : null,
"visited_link_color" : null
}]);


// Figure out which is the default theme and which is the site theme
var d = (themes[0].id == DEFAULT_THEME_ID) ? themes[0] : themes[1];
var t = (themes[0].id == theme_id) ? themes[0] : themes[1];



// Overwrite missing theme values with those from the default theme
for (i in t) {
if (t[i] == null)
t[i] = d[i];
}


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

// convenience function
function insertRule(rule) { acre.write(rule + '\n'); }

var bgimage = '';
if (t.background_image)
bgimage = " url(" + TRANS_RAW + t.background_image.id + ") repeat-x top";
insertRule("body {background: " + t.background_color + bgimage + ";}");
insertRule("body {font-family: " + t.font + "}");
insertRule("body {color: " + t.text_color + "}");
insertRule("a {color: " + t.link_color + "}");
insertRule("a:visited {color: " + t.visited_link_color + "}");
insertRule("hr {background: " + t.module_border_color + "}");
insertRule(".shaded {border-color: " + t.module_border_color + "}");
insertRule(".shaded td {border-color: " + t.module_border_color + "}");
insertRule(".shaded {background: " + t.module_background_color + "}");
insertRule(".shaded {color: " + t.module_text_color + "}");
insertRule(".shaded h4 {color: " + t.module_border_color + "}");
insertRule(".shaded a {color: " + t.module_link_color + "}");
insertRule(".shaded a:visited {color: " + t.module_visited_link_color + "}");

Created by: nix Jan 23, 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/nix/acre/catalogcss
Flag this Document
Why do you want to flag this document?