LinkedWiki-Mediawiki Extension
- Extension Link: https://www.mediawiki.org/wiki/Extension:LinkedWiki
The LinkedWiki extension lets you reuse Linked Data in your wiki. You can get data from Wikidata or another source directly with a SPARQL query. This extension also provides Lua functions for building your modules so that you can write your data in your RDF database.
installation
You will need to install yarn , I have followed the instructions in https://classic.yarnpkg.com/en/docs/install/#debian-stable which as I have problems with the yarn packed from the Debian Stable apt source.
cd extensions git clone https://github.com/wikimedia/mediawiki-extensions-LinkedWiki.git LinkedWiki cd LinkedWiki
Install composer (locally). I prefer not to have composer installed system wide, so I will install it in the LinkedData extension dir.
curl -sS https://getcomposer.org/installer | php
Run composer install, to install the dependencies
php composer.phar install --no-dev
And finally run yarn install:
yarn install --production=true
Load the extension in LocalSettings.php, by adding to it:
wfLoadExtension( 'LinkedWiki' );
Check the installation by going to Special:Interwiki and Special:LinkedWikiConfig pages, note that the extension does not appear in Special:Version.
If not installed, you are need to install php-curl, :
sudo apt-get install php-curl
And restart the webserver:
sudo systemctl restart apache2
Test
And we can make a Test SPARQL query against Wikidata in Special:SparqlQuery, with the following query, which asks for the European capitals with a population of the more that 1 million, which can be seen embedded in the wiki page LinkedWiki-Sandbox
SELECT DISTINCT ?country ?countryName ?capital ?capitalName ?capitalPop
WHERE
{
?country wdt:P31 wd:Q6256 .
?country rdfs:label ?countryName .
FILTER (LANG(?countryName) = "en").
?country wdt:P30 wd:Q46 .
?country wdt:P36 ?capital .
?capital rdfs:label ?capitalName .
FILTER (LANG(?capitalName) = "en")
?capital wdt:P1082 ?pop .
FILTER ( abs(?pop) > 1000000)
BIND(round(?pop) as ?capitalPop )
}
ORDER BY DESC(?capitalPop)
LIMIT 20
Setting up & Config
As administrator I have to add myself to the group "Data" in Special:UserRights in order to write on the LinkedWiki created namespaces: Data and UserData
I like to add the LinkedWiki important pages to the side bar so i add to Mediawiki:Sidebar
* LinkedWiki ** Special:LinkedWikiConfig|LinkedWikiConfig ** Special:SparqlQuery|SparqlQuery
And if I want to add this wiki's triplestorage SPARQL-endpoing, as a default option to Special:SparqlQuery
I to follow the LinkedWiki configuraion instruction[1], and add to the wiki's LocalSettings.php
$wgLinkedWikiConfigSPARQLServices["http://sparql.oooooooooo.io/wiki/query"] = array(
"isReadOnly" => true,
"typeRDFDatabase" => "fuseki",
"endpointRead" => "http://sparql.oooooooooo.io/wiki/query",
"HTTPMethodForRead" => "POST"
);
$wgLinkedWikiSPARQLServiceByDefault="http://sparql.oooooooooo.io/wiki/query";
Test SPARQL query this wiki triplestorage
And we can make a Test SPARQL query against the Triple storage, SPARQL endpoint of this wiki http://sparql.oooooooooo.io/wiki/query, using Special:SparqlQuery. Asking what subjects(pages) have the property foaf:homepage and what are their values.
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT * WHERE
{ ?page foaf:homepage ?value . }
LIMIT 15
And we can also embed the query onto a wiki page, with
{{#sparql: PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT * WHERE { ?page foaf:homepage ?value . } LIMIT 15 |config=http://sparql.oooooooooo.io/wiki/query |chart=bordercloud.visualization.DataTable |options=width=50%!height=500px |log=2 }}
{{#sparql: PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT * WHERE
{ ?page foaf:homepage ?value . }
LIMIT 15 |config=http://sparql.oooooooooo.io/wiki/query |chart=bordercloud.visualization.DataTable |options=width=50%!height=500px |log=2 }}