diff --git a/extensions/wikidata/build.xml b/extensions/wikidata/build.xml new file mode 100644 index 000000000..fa5f142b1 --- /dev/null +++ b/extensions/wikidata/build.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extensions/wikidata/module/scripts/menu-bar-extension.js b/extensions/wikidata/module/scripts/menu-bar-extension.js new file mode 100644 index 000000000..b1c8de899 --- /dev/null +++ b/extensions/wikidata/module/scripts/menu-bar-extension.js @@ -0,0 +1,119 @@ +/* +ExporterManager.MenuItems.push({});//add separator +ExporterManager.MenuItems.push( + { + "id" : "exportRdfXml", + "label":"RDF as RDF/XML", + "click": function() { RdfExporterMenuBar.exportRDF("rdf", "rdf");} + } +); +ExporterManager.MenuItems.push( + { + "id" : "exportRdfTurtle", + "label":"RDF as Turtle", + "click": function() { RdfExporterMenuBar.exportRDF("Turtle", "ttl"); } + } +); + +RdfExporterMenuBar = {}; + +RdfExporterMenuBar.exportRDF = function(format, ext) { + if (!theProject.overlayModels.rdfSchema) { + alert( + "You haven't done any RDF schema alignment yet!" + ); + } else { + RdfExporterMenuBar.rdfExportRows(format, ext); + } +}; + +RdfExporterMenuBar.rdfExportRows = function(format, ext) { + var name = $.trim(theProject.metadata.name.replace(/\W/g, ' ')).replace(/\s+/g, '-'); + var form = document.createElement("form"); + $(form) + .css("display", "none") + .attr("method", "post") + .attr("action", "command/core/export-rows/" + name + "." + ext) + .attr("target", "gridworks-export"); + + $('') + .attr("name", "engine") + .attr("value", JSON.stringify(ui.browsingEngine.getJSON())) + .appendTo(form); + $('') + .attr("name", "project") + .attr("value", theProject.id) + .appendTo(form); + $('') + .attr("name", "format") + .attr("value", format) + .appendTo(form); + + document.body.appendChild(form); + + window.open("about:blank", "gridworks-export"); + form.submit(); + + document.body.removeChild(form); +}; + +RdfExporterMenuBar.editRdfSchema = function(reset) { + new RdfSchemaAlignmentDialog(reset ? null : theProject.overlayModels.rdfSchema); +}; +*/ + +ExporterManager.MenuItems.push( + { + "id" : "exportQuickStatements", + "label":"QuickStatements", + "click": function() { WikibaseExporterMenuBar.exportTo("quickstatements"); } + } +); + +WikibaseExporterMenuBar = {}; + +WikibaseExporterMenuBar.exportTo = function(format) { + var form = document.createElement("form"); + $(form).css("display", "none") + .attr("method", "post") + .attr("action", "command/core/export-rows/statements.txt") + .attr("target", "gridworks-export"); + $('') + .attr("name", "engine") + .attr("value", JSON.stringify(ui.browsingEngine.getJSON())) + .appendTo(form); + $('') + .attr("name", "project") + .attr("value", theProject.id) + .appendTo(form); + $('') + .attr("name", "format") + .attr("value", format) + .appendTo(form); + + document.body.appendChild(form); + + window.open("about:blank", "gridworks-export"); + form.submit(); + + document.body.removeChild(form); +}; + +//extend the column header menu +$(function(){ + + ExtensionBar.MenuItems.push( + { + "id":"reconcile", + "label": "Wikidata", + "submenu" : [ + { + "id": "wikidata/edit-schema", + label: "Edit Wikibase schema...", + click: function() { SchemaAlignmentDialog.launch(false); } + }, + ] + } + ); +}); +