public
Last active

schemacache lookup ubiquity command

  • Download Gist
x
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
CmdUtils.CreateCommand({
name: "schemacache",
takes: {"term": noun_arb_text},
homepage: "http://schemacache.com/",
author: { name: "Keith Alexander", email: "keith.alexander@talis.com"},
license: "MPL",
description: "performs a lookup on SchemaCache (http://schemacache.com)",
preview: function(previewBlock, term) {
previewBlock.innerHTML = "Looking up " + term.text + " at SchemaCache ... ";
var baseURI = "http://schemacache.com/Search.json?q=" + term.text;
//displayMessage(sparams.q);
jQuery.ajax({
type: "GET",
url: baseURI,
datatype: "string",
error: function(responseData) {
previewBlock.innerHTML = "<em>Error:" + responseData+ "</em>";
},
success: function(responseData) {
var rdf = Utils.decodeJson(responseData);
var list = '<ol>';
jQuery.each(rdf, function(uri, props){
CmdUtils.log(uri);
try { label = props['http://www.w3.org/2000/01/rdf-schema#label'][0]['value']; } catch (e) { label = uri }
try {
types = '';
jQuery.each(props['http://www.w3.org/1999/02/22-rdf-syntax-ns#type'], function(){ types+=' '+this.value.match(/[^\/#]+$/)[0]});
} catch(e) { types = 'Resource'}
var description = ''
if(props['http://www.w3.org/2000/01/rdf-schema#comment']){
description = props['http://www.w3.org/2000/01/rdf-schema#comment'][0]['value'];
}
var linkType = 'Res';
if(types.match('Ontology')) linkType = 'Schema';
list+='<li><a href="'+uri+'">'+label+'</a> <strong>'+types.replace(' item ', ' ')+'</strong> <div><em>'+description+'</em></div> <div><a href="http://schemacache.test.talis.com/'+linkType+'/?uri='+encodeURIComponent(uri)+'">cache</a></div> </li>';
 
});
CmdUtils.log(rdf, list);
previewBlock.innerHTML = list;
 
}
});
},
execute: function(term) {
Utils.openUrlInBrowser("http://schemacache.com/Search?q=" + term.text);
}
})

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.