• Topic
  • Discussion
  • VOS.VirtDeployLinkedWikiV2(1.1) -- DAVWikiAdmin? , 2017-06-13 05:42:45 Edit WebDAV System Administrator 2017-06-13 05:42:45

    Installing The LinkedWiki Extension Version 2.0.1 Alpha

    The LinkedWiki extension allows you to embed a SPARQL query and display the results in your wiki page.

    Prerequisites

    Step 1. Download the Extension.

    Go to the LinkedWik Extension page. Using the links in the box on the right hand side, download the v2.0.1Alpha1 LinkedWiki extension.

    Step 2. Extract.

    Move the downloaded zip file into your MediaWiki extensions folder. You will find this folder in your Virtuoso installation directory/vsp/vad/vsp/MediaWiki/extension. Extract the extension.

    Step 3. Enable and Configure.

    The LinkedWiki extension is enabled by adding the following line to the your Virtuoso installation directory/vsp/vad/vsp/MediaWiki/LocalSettings.php file


    require_once( "{$IP}/extensions/LinkedWiki/LinkedWiki.php" );
    $wgLinkedWikiGraphWiki = 'http://example.org/mydefaultgraphname'; 
    

    Using LinkedWiki

    LinkedWiki lets you embed a SPARQL query in a wiki page and display the results as a table. If you have the Widgets extension installed you can also display the results using one of the widgets.

    Simple Query Examples

    A simple query to get all the triples in all the graphs on a specified endpoint looks like this:
    {{#sparql:select * where { ?x ?y ?z . } LIMIT 5 | endpoint=http://localhost:8890/sparql}}
    

    This displays the first 5 triples from the specified endpoint. The results will look something like this:

    The properties of the current page can be queried using either of the following:


    {{#sparql:PREFIX a:<http://localhost:8890/MediaWiki/index.php?title=Special:URIResolver/>  select * where { a:{{PAGENAMEE}} ?y ?z . } | endpoint = http://localhost:8890/sparql }}
    

    or


    {{#sparql:select * where { <http://localhost:8890/MediaWiki/index.php?title=Special:URIResolver/{{PAGENAMEE}}> ?y ?z . }  | endpoint = http://localhost:8890/sparql }}
    

    The results will look something like:

    You can specify which endpoint you want to query so, this example queries the sparql endpoint on dbpedia to find the number of nations participating in each Olympic games:


    {{#sparql:select distinct ?Games ?Olympiad ?NumberOfNations {?s a <http://dbpedia.org/ontology/Olympics> .
    ?s <http://www.w3.org/2000/01/rdf-schema#label> ?Games .
    ?s <http://dbpedia.org/property/years> ?Olympiad .
    ?s <http://dbpedia.org/ontology/numberOfParticipatingNations> ?NumberOfNations
    FILTER (lang(?Games) = "en")}
    order by ?Games | endpoint = http://dbpedia.org/sparql }}
    

    and returns results something like this:

    Using LinkedWiki with the Widget Extension

    First ensure you have the Widget Extension installed and configured. You will have to add any widgets that you want to use to display the results. The LinkedWiki extension parses the result set from the sparql query so it becomes a set of key value pairs that are then included as parameters to the widget. So, for example, a query that selects location information as a point would result in a set of parameters something like this.
    rows.0.point=43.30, 5.38 | rows.1.point=48.83, 2.3 | rows.2.point=49.93, 2.3
    

    The widget must be able to handle parameters of this form.

    One example is a Google maps widget developed specifically for displaying LinkedWiki results. This widget can be found here.

    To use the widget to display the results from a sparql query on a map you would do something like this


    {{#wsparql:Google_Static_Maps
    |query=SELECT ?s ?point ?label
    WHERE {
    ?s <http://www.georss.org/georss/point> ?point .
    ?s a <http://schema.org/StadiumOrArena> .
    ?s <http://www.w3.org/2000/01/rdf-schema#label> ?label .
    FILTER bif:contains(?label, "Olympic and Stadium") .
    FILTER (lang(?label) ='en')
    }
    limit 20
    |endpoint = http://dbpedia.org/sparql 
    |defaultcolor=blue
    |zoom=2
    |size=512x512
    |maptype=roadmap}}
    

    The result will be a map embedded in the wiki page that show the location of Olympic stadia around the world.