A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/alangrafu/lodspeakr/wiki/Example:-How-to-set-up-a-service below:

How to set up a service · alangrafu/lodspeakr Wiki · GitHub

utils/lodspk.sh helps set up new model/view pairs.

First, let's check the usage:

/var/www/datafaqs/DataFAQs-lodspeakr$ utils/lodspk.sh
Usage: utils/lodspk.sh create|delete uri|class|service foo [html|rdf|ttl|nt|json]

Here, we want to make a service called "epochs", and we only want an html template (the machine formats come for free):

/var/www/datafaqs/DataFAQs-lodspeakr$ utils/lodspk.sh create service epochs html
...
service.epochs created/modified successfully!

We'll want to modify the model query and the view template that lodspk.sh made for us:

Usually, you want to develop the SPARQL query that you want using the endpoint's UI. Once you have the essential structure, plop it into the main.query:

PREFIX void:     <http://rdfs.org/ns/void#>
PREFIX sd:       <http://www.w3.org/ns/sparql-service-description#>
PREFIX datafaqs: <http://purl.org/twc/vocab/datafaqs#>

SELECT DISTINCT ?epoch
WHERE {
  GRAPH ?name {
    ?epoch a datafaqs:Epoch .
  }
}

Then, visit the service with a web browser: http://aquarius.tw.rpi.edu/datafaqs/epochs

You'll probably see a list of empty values.

Go edit the view template

The default view template will be something like:

    <ul>
    {% for row in models.main %}
        <li><a href="{{lodspk.baseUrl}}special/instances/{{ row.resource.curie }}">{{row.resource.curie}}</a></li>
    {% endfor %}
    </ul>

But our SPARQL query selects ?epoch, so we need to change row.resource to row.epoch to access the query result.

change it to:

    <ul>
    {% for row in models.main %}
        <li><a href="{{row.epoch.value}}">{{row.epoch.curie}}</a></li>
    {% endfor %}
    </ul>

See Creating services with slashes


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.3