User:Karima Rafes/draft:Extension LinkedWiki 3.0

DRAFT of the future page

The LinkedWiki extension allows to print the Linked Data of Wikidata or another source with a SPARQL query on your Mediawiki.

Work in progress

 * Add autocompletion tools for Wikidata
 * Tools to configure any RDF database

Mediawiki Master : 2.1.1

 * Ready for Wikidata (version Beta) https://query.wikidata.org

What can this extension do?
So for the moment you can :
 * read remote endpoint with SPARQL 1.1 or 1.0
 * help you to build and test a SPARQL query with a special page
 * print the result of your query in a page with a parser function. Example:
 * print the result of your query in a mediawiki widget. Thus, you can build by yourself new widgets for your linked data in your Linked Wiki. Example with the Google maps widget with Worldwide Earthquakes :

Installation
To install this extension, add the following to LocalSettings.php:

TODO

TODO for PHP7 If, after the installation, you have errors about CURL in the log, probably you need to install the lib php5-curl in your server.

Usage
TODO

Graph visualization
With the tag name lwgraph, you can build quickly a graph.

Options :
 * type : select your graph
 * height : the height of graph in the page (px or percent).
 * width : the width of graph in the page (px or percent). By default : 100%
 * debug : with debug="true" (for developers)

Type : flow
Example of graph :

With this code :  Ecole Maternelle==>Primaire==>Collège=Brevet=>Lycée=Bac=>Université Collège=Brevet=>Lycée Pro=Bac PRO=>IUT Lycée Pro=Bac PRO=>Université

You can click on the page's name in the graph. If the page doesn't exist, the link is red.

Special page: SPARQL editor for Wiki
This editor can help you to write the wikitext with the magic word #sparql.

CHECK:

Special page: SPARQL Flint Editor
This editor can help you to write quickly your first query on DBpedia.

CHECK:

Basic Use: #sparql
Print a simple Array with the following results:

CHECK: OK
 * Querying of the default endpoint and all the graphs of this endpoint. (Test: #sparql_T1)

CHECK: OK
 * Querying without the parameter "endpoint" is possible but the variable $wgLinkedWikiConfigDefaultEndpoint has to be in the localsettings (see installation). By default the extension uses the endpoint of Wikidata. (Test: #sparql_T2)

CHECK: TODO
 * Querying the properties of the current page (3 equivalent queries) (Test: #sparql_T4) :

Parameter: headers
CHECK: OK (bug version 2.1.1)
 * Change the headers.(Test: #sparql_T5)

Parameter: classHeaders
CHECK: ok
 * You can hide or change the style of your headers. Here, the first column has no header and is unsortable.(Test: #sparql_T6)

Example:



Parameter: templates
With an example of template like Template:Test1 , and

CHECK:
 * You can use this template in the following way:(Test: #sparql_T7)

CHECK:
 * And you can use a different template for each column:(Test: #sparql_T8)

Parameter: cache
CHECK:
 * Your data may be very volatile and you need accordingly to refresh the result of this query each time. To do so, you can disable the cache with the cache parameter, as follows:(Test: #sparql_T9)

Parameter: debug
CHECK:
 * Well, you can add several parameters at the same time but doing so, the wiki text can be very hard to debug. This parameter gives you the result of this parser before the last parsing of mediawiki:(Test: #sparql_T10)

Parameter: footer
CHECK:
 * you can remove the footer of array:(Test: #sparql_T11)

Parameter: templateBare
CHECK:
 * you can remove the footer and the header. With the value "tableCell", you can catch only the cells.(Test: #sparql_T12)

Usage
You want to use your SPARQL results with Google Maps, Youtube, Flickr, etc. It's very hard if not impossible to develop all the possibilities in a mediawiki extension. So, the wsparql function can pre-format the parameters for a widget.

CHECK:
 * The parameters of the query, endpoint, cache and debug are the same as for #sparql, with a slightly different syntax:(Test: #wsparql_T1)

CHECK:
 * Example with the Google Static Maps widget:

CHECK:
 * Result of wsparql before the parsing of mediawiki:

And after parsing:



As you can see, the wsparql aggregates the sparql results in one list, with this pattern : rows.NUMBER_LINE.VARIABLE_NAME = VARIABLE_VALUE rows.0.point=43.30, 5.38 | rows.1.point=48.83, 2.3 | rows.2.point=49.93, 2.3
 * Like that:

You have to find a widget compatible with this syntax or you can create/change a widget of mediawikiwidgets.

Build your widget
This widget allows you to embed Google Static Maps on your wiki page.
 * 1) Install the  extension Widgets
 * 2) Create the page Widget:NAME_OF_YOUR_WIDGET
 * 3) Insert your code, example with google static maps :

Sample result
CHECK:



And to share your widget in mediawikiwidgets.org.

Now, let's summarize!
 * To read one list like rows.NUMBER_LINE.VARIABLE_NAME = VARIABLE_VALUE, you have to perform a foreach of rows and read keys and items, like that:

It's a bit hard the first time. Use the group google, if you face a problem.

= Mailing list / Google Group =
 * FAQ and problems : http://groups.google.com/group/linkedwiki

=See also= TODO
 * Wikidata examples
 * SPARQL examples
 * Tutorial SPARQL in french (Wikiversity)
 * W3C Recommendation Sparql 1.0
 * W3C Working Draft Sparql 1.1
 * Stats and tree Git of LinkedWiki