Skip to content

Instantly share code, notes, and snippets.

View LaurensRietveld's full-sized avatar

Laurens Rietveld LaurensRietveld

View GitHub Profile
@LaurensRietveld
LaurensRietveld / README.md
Last active January 31, 2019 16:57
#YASGUI: Creating a YASGUI page

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

@LaurensRietveld
LaurensRietveld / ecma6AndTs.ts
Created March 2, 2016 16:15
Babel en TS runtime register
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())
@LaurensRietveld
LaurensRietveld / README.md
Last active September 21, 2018 09:34
Fetch autocompletions from ontology XML

A simple example on how to extend the YASQE autocompletion functionality, by parsing the RDF/XML file of an ontology

@LaurensRietveld
LaurensRietveld / README.md
Last active August 29, 2015 14:11
#YASR: Using the core YASR library, by providing your own dependencies

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).

@LaurensRietveld
LaurensRietveld / README.md
Last active August 29, 2015 14:09
#YASR: Manipulate table visualization and merge columns

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

@LaurensRietveld
LaurensRietveld / index.html
Last active August 29, 2015 14:09
Hide YASQE via URL parameter
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Hide YASQE via URL arg</title>
<link href='http://cdn.jsdelivr.net/g/yasqe@2.0(yasqe.min.css),yasr@2.0(yasr.min.css)' rel='stylesheet' type='text/css'/>
</head>
<body>
<div id="yasqe"></div>
<div id="yasr"></div>
@LaurensRietveld
LaurensRietveld / README.md
Last active November 22, 2019 14:41
#YASQE: Using your own SPARQL query to fetch auto-completions

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.

@LaurensRietveld
LaurensRietveld / README.md
Last active August 29, 2015 14:07
#YASQE: Update YASQE configuration via ajax call

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.

@LaurensRietveld
LaurensRietveld / README.md
Last active September 14, 2018 02:44
Combining #YASQE and #YASR

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.