To include YASGUI, simply take this HTML file. If you'd like to remove the endpoint selector widget, uncommment the CSS part in the head of the HTML
var test = function() { | |
//foo is typed, so we need ts | |
var foo:Function = function() {}; | |
var bar = function baz() {}; | |
//this comparison is not supported by ts, but it is supported by babel. So, we need babel | |
//See: https://kangax.github.io/compat-table/es6/#typescript , function "name" property -> variables (function) | |
return foo.name === "foo" && bar.name === "baz"; | |
} | |
console.log(test()) |
A simple example on how to extend the YASQE autocompletion functionality, by parsing the RDF/XML file of an ontology
The easiest way to run YASR is to download the packaged version which includes all the dependencies. However, if you already have several dependencies on your webpage, you could consider using the 'depedency-less' version of YASR, and include the remaining libraries manually. This way you avoid including the same library twice, and you would save your users's bandwidth. This gist shows which libraries to include (and in what order).
This gist shows how you can manipulate and combine columns of the table plugin. Instead of showing the URIs directly, this gist checks whether the SPARQL response contains a projection variable with the corresponding label for that URI. If this is the case, that label is used as text for this URI link. E.g., a SPARQL result with projection variables ?car and ?carLabel (where ?car is a URI), will hide the ?carLabel column in the table, and will use the ?carLabel as text for the ?car hyperlink.
ps. This feature is recently added to YASR as well (see the 'mergeLabelsWithUris' setting), though slightly different: for this gist the cell content changes on hover
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Hide YASQE via URL arg</title> | |
<link href='http://cdn.jsdelivr.net/g/[email protected](yasqe.min.css),[email protected](yasr.min.css)' rel='stylesheet' type='text/css'/> | |
</head> | |
<body> | |
<div id="yasqe"></div> | |
<div id="yasr"></div> |
This example shows to build your own autocompletion plugin. Here, the default property and class autocompleters are extended to fetch a list of possible completions from the SPARQL endpoint itself. To try it out, go e.g. to the predicate position, and type '<http'.
This particular example does not execute a (relatively expensive) query to fetch all predicates and classes, but queries for Bio2RDF dataset metrics data instead. This is cheaper/faster, though of course the dataset needs to publish this particular type of dataset metric.
In some use cases, it is useful to fetch the YASQE configuration from an external URL. This allows you to e.g. fetch the shown YASQE query from an externally hosted page. This might be interesting when you've published your SPARQL queries in separate files as part of your documentation, and you would like to use YASQE as a means of accessing it. This example gist does exactly that: when a 'queryRef' URL parameter is passed, it fetches the YASQE query with an asynchronous call from the URL.
A simple example on how to combine YASQE and YASR. Any SPARQL result received via YASQE are passed on to YASR. YASR, uses any prefixes defined in YASQE to prettify the SPARQL results.