pho-utensil 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/README.rdoc +4 -0
  2. data/Rakefile +47 -0
  3. data/bin/utensil +7 -0
  4. data/lib/utensil-app.rb +159 -0
  5. data/public/css/blueprint/ie.css +28 -0
  6. data/public/css/blueprint/plugins/fancy-type/screen.css +71 -0
  7. data/public/css/blueprint/print.css +30 -0
  8. data/public/css/blueprint/screen.css +252 -0
  9. data/public/css/blueprint/src/forms.css +49 -0
  10. data/public/css/blueprint/src/grid.css +269 -0
  11. data/public/css/blueprint/src/grid.png +0 -0
  12. data/public/css/blueprint/src/ie.css +61 -0
  13. data/public/css/blueprint/src/print.css +85 -0
  14. data/public/css/blueprint/src/reset.css +38 -0
  15. data/public/css/blueprint/src/typography.css +105 -0
  16. data/public/css/impromptu.css +318 -0
  17. data/public/css/spared.css +99 -0
  18. data/public/icons/script_delete.png +0 -0
  19. data/public/icons/script_edit.png +0 -0
  20. data/public/icons/script_error.png +0 -0
  21. data/public/icons/script_go.png +0 -0
  22. data/public/img/purzen_Cartoon_spatula.png +0 -0
  23. data/public/js/spared-config.js +126 -0
  24. data/public/js/spared-examples.js +13 -0
  25. data/public/js/spared-prefixes.js +85 -0
  26. data/public/js/spared-templates.js +9 -0
  27. data/public/js/spared.js +190 -0
  28. data/public/lib/jquery-1.2.6.js +3549 -0
  29. data/public/lib/jquery-impromptu.1.5.js +133 -0
  30. data/public/lib/jquery.ui.all.js +9639 -0
  31. data/public/rq/list-properties-of-type.rq +9 -0
  32. data/public/rq/list-properties.rq +7 -0
  33. data/public/rq/list-types.rq +7 -0
  34. data/views/admin.erb +37 -0
  35. data/views/configure.erb +4 -0
  36. data/views/enrich.erb +35 -0
  37. data/views/explore.erb +1 -0
  38. data/views/index.erb +33 -0
  39. data/views/layout.erb +53 -0
  40. data/views/spared.erb +66 -0
  41. data/views/update.erb +28 -0
  42. data/views/upload.erb +35 -0
  43. metadata +117 -0
@@ -0,0 +1,99 @@
1
+ /* BUTTONS */
2
+ /* http://particletree.com/features/rediscovering-the-button-element/ */
3
+ .buttons a, .buttons button{
4
+ display:block;
5
+ float:left;
6
+ margin:0 7px 0 0;
7
+ background-color:#f5f5f5;
8
+ border:1px solid #dedede;
9
+ border-top:1px solid #eee;
10
+ border-left:1px solid #eee;
11
+
12
+ font-family:"Lucida Grande", Tahoma, Arial, Verdana, sans-serif;
13
+ font-size: 80%;
14
+ line-height:130%;
15
+ text-decoration:none;
16
+ font-weight:bold;
17
+ color:#565656;
18
+ cursor:pointer;
19
+ padding:5px 10px 6px 7px; /* Links */
20
+ }
21
+ .buttons button {
22
+ width:auto;
23
+ overflow:visible;
24
+ padding:4px 10px 3px 7px; /* IE6 */
25
+ }
26
+ .buttons button[type]{
27
+ padding:5px 10px 5px 7px; /* Firefox */
28
+ line-height:17px; /* Safari */
29
+ }
30
+ *:first-child+html button[type]{
31
+ padding:4px 10px 3px 7px; /* IE7 */
32
+ }
33
+ .buttons button img, .buttons a img{
34
+ margin:0 3px -3px 0 !important;
35
+ padding:0;
36
+ border:none;
37
+ width:16px;
38
+ height:16px;
39
+ }
40
+
41
+ /* STANDARD */
42
+
43
+ button:hover, .buttons a:hover{
44
+ background-color:#dff4ff;
45
+ border:1px solid #c2e1ef;
46
+ color:#336699;
47
+ }
48
+ .buttons a:active{
49
+ background-color:#6299c5;
50
+ border:1px solid #6299c5;
51
+ color:#fff;
52
+ }
53
+
54
+ /* POSITIVE */
55
+
56
+ button.positive, .buttons a.positive{
57
+ color:#529214;
58
+ }
59
+ .buttons a.positive:hover, button.positive:hover{
60
+ background-color:#E6EFC2;
61
+ border:1px solid #C6D880;
62
+ color:#529214;
63
+ }
64
+ .buttons a.positive:active{
65
+ background-color:#529214;
66
+ border:1px solid #529214;
67
+ color:#fff;
68
+ }
69
+
70
+ /* NEGATIVE */
71
+
72
+ .buttons a.negative, button.negative{
73
+ color:#d12f19;
74
+ }
75
+ .buttons a.negative:hover, button.negative:hover{
76
+ background:#fbe3e4;
77
+ border:1px solid #fbc2c4;
78
+ color:#d12f19;
79
+ }
80
+ .buttons a.negative:active{
81
+ background-color:#d12f19;
82
+ border:1px solid #d12f19;
83
+ color:#fff;
84
+ }
85
+
86
+ .query {
87
+ float:left;
88
+ }
89
+
90
+ /* General UI Classes */
91
+ #query { font: 1em 'andale mono', 'lucida console', monospace; line-height: 1.5; }
92
+
93
+ .tfoot { text-align: right; font-style: italic; }
94
+
95
+ .ui-tabs-hide { display: none; }
96
+
97
+ .contents { display: none; }
98
+
99
+ .box h3 { cursor:pointer; }
@@ -0,0 +1,126 @@
1
+
2
+ function populatePrefixes(id, url) {
3
+
4
+ populate(id,
5
+ url,
6
+ function(entry) {
7
+ var listItem = document.createElement("li");
8
+ $(listItem).html("<a href='" + entry.uri +
9
+ "' title='" + entry.prefix + "'>" +
10
+ entry.description +
11
+ "</a>");
12
+ return listItem;
13
+ },
14
+ function() {
15
+ var query = $("#query").val();
16
+ var prefix = $(this).attr("title");
17
+ var uri = $(this).attr("href");
18
+ if ( !new RegExp( "PREFIX " + prefix + ":").test(query) ) {
19
+ $("#query").val( "PREFIX " + prefix +
20
+ ": <" + uri + ">\n" + query );
21
+ }
22
+ return false;
23
+ }
24
+ );
25
+
26
+ }
27
+
28
+ function populateTemplates(id, url) {
29
+ populate(id,
30
+ url,
31
+ function(entry) {
32
+ var listItem = document.createElement("li");
33
+ $(listItem).html("<a href='" + entry.uri + "'>" +
34
+ entry.description +
35
+ "</a>");
36
+ return listItem;
37
+ }
38
+ ,
39
+ function() {
40
+ //var query = $("#query").val();
41
+ var uri = $(this).attr("href");
42
+ $.ajax({
43
+ type: "GET",
44
+ async: false,
45
+ url: uri,
46
+ dataType: "text",
47
+ success: function(data, textStatus) {
48
+ $("#query").val(data);
49
+ },
50
+ error: function(XMLHttpRequest, textStatus, errorThrown) {
51
+ alert("Unable to load query");
52
+ }
53
+
54
+ });
55
+ return false;
56
+ }
57
+ );
58
+ }
59
+
60
+ function populateExamples(id, url) {
61
+ populate(id,
62
+ url,
63
+ function(entry) {
64
+ var listItem = document.createElement("li");
65
+ $(listItem).html("<a href='" + entry.uri + "'>" +
66
+ entry.description +
67
+ "</a>");
68
+ return listItem;
69
+ }
70
+ ,
71
+ function() {
72
+ //var query = $("#query").val();
73
+ var uri = $(this).attr("href");
74
+ $.ajax({
75
+ type: "GET",
76
+ async: false,
77
+ url: uri,
78
+ dataType: "text",
79
+ success: function(data, textStatus) {
80
+ $("#query").val(data);
81
+ },
82
+ error: function(XMLHttpRequest, textStatus, errorThrown) {
83
+ alert("Unable to load query");
84
+ }
85
+
86
+ });
87
+ return false;
88
+ }
89
+ );
90
+ }
91
+
92
+
93
+ /*
94
+ * id - identifier of container div. Will have ul added.
95
+ * url - url of config
96
+ * createItem - function to create list item, accepts entry param
97
+ * clickHandler - click handler to add to the created item
98
+ */
99
+ function populate(id, url, createItem, clickHandler) {
100
+
101
+ var container = "#" + id;
102
+
103
+ $.ajax({
104
+ type: "GET",
105
+ url: url,
106
+ async: false,
107
+ dataType: "json",
108
+ success: function(config, textStatus) {
109
+
110
+ $(container).html("");
111
+
112
+ var list = document.createElement("ul");
113
+ //console.log("Populating: " + config.title);
114
+
115
+ jQuery.each( config.entries, function() {
116
+ $(list).append( createItem(this) );
117
+ });
118
+
119
+ $(container).append(list);
120
+
121
+ $(container).find("a").click( clickHandler );
122
+
123
+ }
124
+ });
125
+
126
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ title: "Examples",
3
+ entries: [
4
+ {
5
+ uri: "rq/list-types.rq",
6
+ description: "List Types"
7
+ },
8
+ {
9
+ uri: "rq/list-properties.rq",
10
+ description: "List Properties"
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,85 @@
1
+ {
2
+ title: "Core Prefixes",
3
+ entries: [
4
+ {
5
+ prefix: "bibo",
6
+ uri: "http://purl.org/ontology/bibo/",
7
+ description: "Bibliographic Ontology"
8
+ },
9
+ {
10
+ prefix: "dc",
11
+ uri: "http://purl.org/dc/elements/1.1/",
12
+ description: "Dublin Core Elements"
13
+ },
14
+ {
15
+ prefix: "dcterms",
16
+ uri: "http://purl.org/dc/terms/",
17
+ description: "Dublic Core Terms"
18
+ },
19
+ {
20
+ prefix: "foaf",
21
+ uri: "http://xmlns.com/foaf/0.1",
22
+ description: "FOAF"
23
+ },
24
+ {
25
+ prefix: "mo",
26
+ uri: "http://purl.org/ontology/mo/",
27
+ description: "Music Ontology"
28
+ },
29
+ {
30
+ prefix: "po",
31
+ uri: "http://purl.org/ontology/po/",
32
+ description: "Programmes Ontology"
33
+ },
34
+ {
35
+ prefix: "owl",
36
+ uri: "http://www.w3.org/2002/07/owl#",
37
+ description: "OWL"
38
+ },
39
+ {
40
+ prefix: "rdf",
41
+ uri: "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
42
+ description: "RDF Namespace"
43
+ },
44
+ {
45
+ prefix: "rdfs",
46
+ uri: "http://www.w3.org/2000/01/rdf-schema#",
47
+ description: "RDF Schema"
48
+ },
49
+ {
50
+ prefix: "rel",
51
+ uri: "http://purl.org/vocab/relationship/",
52
+ description: "Relationship"
53
+ },
54
+ {
55
+ prefix: "rev",
56
+ uri: "http://purl.org/stuff/rev#",
57
+ description: "Reviews"
58
+ },
59
+ {
60
+ prefix: "rss",
61
+ uri: "http://purl.org/rss/1.0/",
62
+ description: "RSS 1.0"
63
+ },
64
+ {
65
+ prefix: "sioc",
66
+ uri: "http://rdfs.org/sioc/ns#",
67
+ description: "SIOC Core Ontology"
68
+ },
69
+ {
70
+ prefix: "skos",
71
+ uri: "http://www.w3.org/2004/02/skos/core#",
72
+ description: "SKOS Core"
73
+ },
74
+ {
75
+ prefix: "geo",
76
+ uri: "http://www.w3.org/2003/01/geo/wgs84_pos#",
77
+ description: "W3C Geo Schema"
78
+ },
79
+ {
80
+ prefix: "xsd",
81
+ uri: "http://www.w3.org/2001/XMLSchema#",
82
+ description: "XML Schema"
83
+ }
84
+ ]
85
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ title: "Templates",
3
+ entries: [
4
+ {
5
+ uri: "rq/list-properties-of-type.rq",
6
+ description: "List Properties of Type"
7
+ }
8
+ ]
9
+ }
@@ -0,0 +1,190 @@
1
+
2
+
3
+ function displayError(container, XMLHttpRequest, textStatus, errorThrown) {
4
+ container.find(".results-table").remove();
5
+
6
+ container.append( "<div class='error'>Error Executing Query: " + XMLHttpRequest.responseText + "</div>");
7
+
8
+ }
9
+
10
+ function dumpToTextArea(container, data, elapsed) {
11
+ container.append( "<textarea class='span-24'>" + data + "</textarea>");
12
+ }
13
+
14
+ function sparqlResultsToTable(container, json, elapsed) {
15
+ container.find(".results-table").remove();
16
+ container.find(".error").remove();
17
+
18
+ //console.log(json);
19
+ var table = document.createElement("table");
20
+ var tbody = document.createElement("tbody");
21
+ var thead = document.createElement("thead");
22
+ table.appendChild(thead);
23
+ table.appendChild(tbody);
24
+
25
+ var row = document.createElement("tr");
26
+
27
+ jQuery.each( json.head.vars, function(i, val) {
28
+ var col = document.createElement("th");
29
+ row.appendChild(col);
30
+ $(col).text( val );
31
+ });
32
+
33
+ thead.appendChild(row);
34
+
35
+ var cols = json.head.vars.length;
36
+ var rows = json.results.bindings.length;
37
+
38
+ jQuery.each( json.results.bindings, function(i, binding) {
39
+ var row = document.createElement("tr");
40
+ jQuery.each( json.head.vars, function() {
41
+ var td = document.createElement("td");
42
+ var text = ""
43
+ if ( binding[this] ) {
44
+ text = binding[this].value;
45
+ }
46
+
47
+ if ( binding[this] && binding[this].type == 'uri' ) {
48
+ var anchor = document.createElement("a");
49
+ $(anchor).attr("href", text);
50
+ $(anchor).text( text );
51
+ td.appendChild( anchor );
52
+ } else {
53
+ $(td).text( text );
54
+ }
55
+ row.appendChild(td);
56
+ });
57
+ tbody.appendChild(row);
58
+ });
59
+
60
+ var footerRow = document.createElement("tr");
61
+ var footer = document.createElement("td");
62
+ footerRow.appendChild(footer);
63
+ $(footer).text( json.results.bindings.length + " Results in " + elapsed + " msecs");
64
+ $(footer).attr("colspan", json.head.vars.length);
65
+ $(footer).addClass("tfoot");
66
+ tbody.appendChild(footerRow);
67
+
68
+ $(container).append(table);
69
+ $(table).attr("border", 1);
70
+ $(table).addClass("results-table");
71
+
72
+ }
73
+
74
+ /**
75
+ * Click handler for the load button. Uses the impromptu jquery plugin to
76
+ * display a dialog
77
+ */
78
+ function loadQueryClickHandler() {
79
+ var txt = 'Please enter query URL:<br /><input type="text" id="query-url" name="query-url" value="" />';
80
+
81
+ $.prompt(txt,{
82
+ prefix: "blueprint",
83
+ buttons: { Ok: true, Cancel: false },
84
+ callback: function (value,m){
85
+ if (value) {
86
+ $.get( m.children("#query-url").val(),
87
+ function(data, textStatus) {
88
+ $("#query").val( data );
89
+ },
90
+ "text"
91
+ );
92
+ }
93
+ }
94
+
95
+ });
96
+ return false;
97
+ }
98
+
99
+ function doQuery() {
100
+ $("#results").find(".error").remove();
101
+ $("#results").find(".results-table").remove();
102
+ $("#results").find("textarea").remove();
103
+
104
+ if ( !$("#inline").is(":checked") ) {
105
+
106
+ return true;
107
+ }
108
+
109
+ var form = $(".spared");
110
+
111
+ var q = $(form).find("#query").val();
112
+ //console.log( "Query: " + q );
113
+
114
+ var startTime = new Date().getTime();
115
+
116
+
117
+ if ( q.match(/SELECT /i) ) {
118
+ $.ajax({
119
+ type: "GET",
120
+ url: $(form).attr("action"),
121
+ data: {
122
+ query: q,
123
+ output: "json"
124
+ },
125
+ dataType: "json",
126
+ success: function(data, textStatus) {
127
+ var elapsed = new Date().getTime() - startTime;
128
+ sparqlResultsToTable( $("#results"), data, elapsed );
129
+
130
+ },
131
+ error: function(XMLHttpRequest, textStatus, errorThrown) {
132
+ displayError( $("#results"), XMLHttpRequest, textStatus, errorThrown );
133
+ }
134
+
135
+ });
136
+ } else {
137
+ $.ajax({
138
+ type: "GET",
139
+ url: $(form).attr("action"),
140
+ data: {
141
+ query: q
142
+ },
143
+ dataType: "text",
144
+ success: function(data, textStatus) {
145
+ var elapsed = new Date().getTime() - startTime;
146
+ dumpToTextArea($("#results"), data, elapsed);
147
+ },
148
+ error: function(XMLHttpRequest, textStatus, errorThrown) {
149
+ displayError( $("#results"), XMLHttpRequest, textStatus, errorThrown );
150
+ }
151
+
152
+ });
153
+ }
154
+
155
+
156
+ return false;
157
+ }
158
+
159
+ /**
160
+ * Setup the event handlers for the form
161
+ */
162
+ $(document).ready(function(){
163
+ populatePrefixes("prefixes", "js/spared-prefixes.js");
164
+ populateTemplates("templates", "js/spared-templates.js");
165
+ populateTemplates("examples", "js/spared-examples.js");
166
+
167
+ $("#query").resizable({
168
+ autoHide: true
169
+ });
170
+
171
+ $("#clear-query").click( function() {
172
+ var form = $(".spared");
173
+ $(form).find("#query").val("");
174
+ return false;
175
+ });
176
+
177
+ $("#load-query").click( loadQueryClickHandler );
178
+
179
+ $("#run-query").click( doQuery );
180
+
181
+ $(".box h3").toggle(
182
+ function() {
183
+ $(this).parent().find(".contents").show();
184
+ },
185
+ function() {
186
+ $(this).parent().find(".contents").hide();
187
+ }
188
+ );
189
+
190
+ });