// This command looks up the current page in Google Social Graph API, an aggregate of
// public FOAF and XFN data. Example call:
// http://socialgraph.apis.google.com/otherme?pretty=1&q=danbri.org
// useful stuff: chrome://ubiquity/content/builtincmds.js
CmdUtils.CreateCommand({
name: "foaf",
homepage: "http://danbri.org/2008/ubisg/",
author: { name: "Dan Brickley", email: "danbri@danbri.org"},
license: "MPL",
description: "Displays merged information about this page(owner), from Google.",
help: "Google offer an experimental 'social graph' service that merges information about people from their public pages. This command takes the currently viewed page and gets URLs and photos from the Google service.",
_url: function(){
return CmdUtils.getDocumentInsecure().location;
},
preview: function( previewBlock ) {
var msg = 'Looking up info about this page, "${url}"';
displayMessage( CmdUtils.renderTemplate( msg, {url: CmdUtils.getDocumentInsecure().location } ) );
var apiUrl = "http://socialgraph.apis.google.com/otherme";
var apiParams = {
pretty: 1,
q: CmdUtils.getDocumentInsecure().location
};
jQuery.ajax({
type: "GET",
url: apiUrl,
data: apiParams,
datatype: "string",
error: function() {
previewBlock.innerHTML = "<i>Error searching sgapi.</i>";
},
success: function(responseData) {
sg = Utils.decodeJson(responseData);
var accounts = {}; // not used yet
var sg_atom = {};
var sg_foaf = {};
var sg_rss = {};;
var sg_photo = {};
var sg_url = {};
var sg_profile = {};
var sg_fn = {};
var out = "";
for (var account in sg) {
//displayMessage( "> "+account );
out += "<a href='" + account + "'>"+account+"</a><br/>\n"
px = sg[account]['attributes']['photo'];
if (typeof px != "undefined")
{
out += "<img src='" + px + "'/>\n"
};
profile = sg[account]['attributes']['profile'];
if (typeof profile != "undefined")
{
out += "<a href='" + profile + "'> <b>"+profile+"</b></a> \n"
};
// name
fn = sg[account]['attributes']['fn'];
if (typeof fn != "undefined")
{
out += "<em>"+fn+"\n"
};
} ;
previewBlock.innerHTML += out;
}
});
},
execute: function() {
displayMessage("K THX BYE");
}
})