A platform-agnostic, configurable, and brandable SPARQL editor and visualization interface.
- Autocompletion of your entire ontology
- Result visualizations modes including; a table, an image grid, a pie chart, and a map
- Integration with your query library
- Shareable queries / URLs
- A resizable code editor
- An interactive tour of the GUI
- A configurable color scheme
- ...and plenty more...
Thor is a set of static files and all you need to get started is to serve it and a configuration file at config/config.json
.
To create a configuration file you can start from an existing configuration or create on from scratch using the reference below.
Example configurations:
The FornPunkt project does contain a full configuration for the Caddy webserver showing how to serve Thor and the necessary configuration files. You can also read more about deploying static files in the guides below:
Not that nothing is stopping you form serving Thor configuration from a non-static source. You can therefore dynamicly change your endpoint or provide an interface for updating the configuration if you want to.
{
"sparql_endpoint": "",
"query_library_endpoint": "",
"title": "",
"demo_tour": {
"demo_query": "",
"demo_query_cursor_position": {
"line": 1,
"ch": 1
}
},
"map_background": {
"url_template": "",
"attribution": ""
},
"color_scheme": {
"main_brand": "",
"main_brand_darkened": "",
"secondary_brand": "",
"secondary_brand_darkened": "",
"main_text": "",
"main_text_lighted": "",
"secondary_text": "",
"background": "",
"background_shaded": "",
"border": ""
},
"favicons": {
"favicon_success": "",
"favicon_error": "",
"favicon_progess": ""
},
"autocomplete": {
"classes": [],
"prefixes": [],
"properties": [],
"services": [],
"uris": []
}
}
The SPARQL endpoint to use. If left out, the user will be able to input their own endpoint.
The endpoint to use for the query library. If left out, the query library will be disabled.
The title of the editor.
An object for the demo tour configuration. If left out, the demo tour will be disabled. Note that the demo_query
and demo_query_cursor_position
can be used to trigger/demo autocompletion features as if a real user would be typing.
demo_query
: The query to use for the demo tour. Use\n
for newlines.demo_query_cursor_position
: The cursor position to use for the demo tour.line
: The line number for the cursor position.ch
: The character number for the cursor position.
Optional map background settings.
url_template
: URL template for map tiles. See URL template at leafletjs.com.attribution
: String to use for map attribution, can take HTML.
An object for the autocompletion configuration.
classes
: An array of plain-class-URIs to autocomplete,http://schema.org/CreativeWork
notschema:CreativeWork
.prefixes
: An array of prefixes to autocomplete, following SPARQL format,rdfs: <http://www.w3.org/2000/01/rdf-schema#>
, etc.properties
: An array of plain-property-URIs to autocomplete,http://www.w3.org/2000/01/rdf-schema#label
notrdfs:label
.services
: An array of federated endpoints to autocomplete,http://dbpedia.org/sparql
, etc.uris
: An array of URIs to autocomplete.
An object for the color scheme configuration. These are all exposed as root
CSS variables so you can tweak the defaults in the browser's dev tools before adding them to the configuration.
main_brand
main_brand_darkened
secondary_brand
secondary_brand_darkened
main_text
main_text_lighted
secondary_text
background
background_shaded
border
Thor uses the same comment system as the Wikidata Query Service GUI to allow users to control the page title and default visualization.
The defaultView
comment allows users to pick one of the following as the default result visualization: Table
, Map
, PieChart
, and ImageGrid
.
Example: #defaultView:Map
The Title
comment sets the page title.
Example: #title:My best query
The config
parameter allows a single Thor instance to use multiply configuirations. This parameter is only used if alternative configurations extists in the config
directory. Note that the value of the parameter should be the configuration filename minus the file-suffix.
The query
URI fragment can be set to populate the editor with text. The text should be URL encoded. Example: #query=Hello%20World
A query library is a JSON file containing an array of queries. Each query is an object with the following properties:
title
: The title of the query.tags
: An array of tags for the query.body
: The query body.
It's common to generate this JSON file from a code-snippet library or from induvidual SPARQL query files. Here is an example, generating a library from .rq
files using Python.
[
{
"title": "List users by the number of monuments registered with a given tag",
"tags": [
"monuments",
"users",
"tags"
],
"body": "PREFIX schema: <http://schema.org/>\n\nSELECT ?creator (COUNT(?monument) AS ?monument_count) WHERE {\n BIND(<https://fornpunkt.se/tagg/stensattning> AS ?tag)\n ?monument schema:keywords ?tag ;\n a schema:CreativeWork ;\n schema:creator ?creator .\n}\nGROUP BY ?creator\nORDER BY DESC(?monument_count)\n"
},
]