diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..c04450b --- /dev/null +++ b/pom.xml @@ -0,0 +1,111 @@ + + + 4.0.0 + + + org.sonatype.oss + oss-parent + 7 + + + + jar + org.webjars + snorql + 1.0.0 + SNORQL Sparql Explorer + WebJar for SNORQL + https://github.com/kurtjx/SNORQL + + + + kurtjx + https://github.com/kurtjx + + + Richard Cyganaik + http://richard.cyganiak.de/ + + + + + + Jakob Frank + jakob.frank@salzburgresearch.at + https://github.com/ja-fra + Salzburg Research Forschungsges.m.b.H + http://www.salzburgresearch.at/ + + + + + + Apache-2 license + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + http://github.com/kurtjx/SNORQL + scm:git:https://github.com/kurtjx/SNORQL.git + scm:git:https://github.com/kurtjx/SNORQL.git + HEAD + + + + + + + UTF-8 + ${project.build.outputDirectory}/META-INF/resources/webjars/${project.artifactId}/${project.version} + + + + + + org.apache.maven.plugins + maven-release-plugin + 2.4.2 + + + org.apache.maven.scm + maven-scm-provider-gitexe + 1.9 + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.5.1 + true + + sonatype-nexus-staging + https://oss.sonatype.org/ + true + + + + + + ${project.basedir}/snorql + ${destDir} + false + + + ${project.basedir} + ${project.build.outputDirectory}/META-INF + false + + README + LICENSE + + + + + + diff --git a/snorql/index.html b/snorql/index.html index 2ff03eb..2987496 100644 --- a/snorql/index.html +++ b/snorql/index.html @@ -9,6 +9,9 @@ + diff --git a/snorql/snorql.js b/snorql/snorql.js index d80c828..a325ce1 100644 --- a/snorql/snorql.js +++ b/snorql/snorql.js @@ -1,4 +1,3 @@ -var snorql = new Snorql(); String.prototype.trim = function () { return this.replace(/^\s*/, "").replace(/\s*$/, ""); @@ -8,25 +7,26 @@ String.prototype.startsWith = function(str) { return (this.match("^"+str) == str); } -function Snorql() { - // modify this._endpoint to point to your SPARQL endpoint - this._endpoint = document.location.href.match(/^([^?]*)snorql\//)[1] + 'sparql'; - // modify these to your likeing - this._poweredByLink = 'http://www4.wiwiss.fu-berlin.de/bizer/d2r-server/'; - this._poweredByLabel = 'D2R Server'; - this._enableNamedGraphs = false; +function Snorql(options) { + options = options || {}; - this._browserBase = null; - this._namespaces = {}; - this._graph = null; - this._xsltDOM = null; + this._endpoint = options['endpoint'] || undefined; + + this._poweredByLink = options['poweredByLink'] || 'http://www4.wiwiss.fu-berlin.de/bizer/d2r-server/'; + this._poweredByLabel = options['poweredByLabel'] || 'D2R Server'; + this._enableNamedGraphs = options['enableNamedGraphs'] || false; + + this._browserBase = options['browserBase'] || null; + this._namespaces = options['namespaces'] || D2R_namespacePrefixes; + this._graph = options['graph'] || null; + this._xsltDOM = options['xsltDOM'] || null; this.start = function() { // TODO: Extract a QueryType class this.setBrowserBase(document.location.href.replace(/\?.*/, '')); this._displayEndpointURL(); this._displayPoweredBy(); - this.setNamespaces(D2R_namespacePrefixes); + this.setNamespaces(this._namespaces); this.updateOutputMode(); var match = document.location.href.match(/\?(.*)/); var queryString = match ? match[1] : ''; @@ -104,6 +104,10 @@ function Snorql() { } document.getElementById('querytext').value = querytext; this.displayBusyMessage(); + if (!this._endpoint) { + this.displayErrorMessage("No SPARQL Endpoint provided!"); + return; + } var service = new SPARQL.Service(this._endpoint); if (this._graph) { service.addDefaultGraph(this._graph); @@ -232,6 +236,10 @@ function Snorql() { } this.submitQuery = function() { + if (!this._endpoint) { + this.displayErrorMessage("No SPARQL Endpoint defined!"); + } + var mode = this._selectedOutputMode(); if (mode == 'browse') { document.getElementById('queryform').action = this._browserBase;