Extension:LinkedWiki/lua

LinkedWiki provides a Lua Scribunto interface that implements functions to access data from RDF databases with SPARQL endpoints. If Scribunto is installed in your wiki, Lua modules and wiki templates can invoke these functions and the Linkedwiki Class.

Quick start


Usually, the part Lua of LinkedWiki used in infoboxes. Here, you can see an example.

The objective of this module is to create an infobox that is able to save directly in a RDF database and where data are marked with a red flag when data are different of another RDF database such as Wikidata.

The module uses the Extension:Capiunto and uses several CSS classes (to put in MediaWiki:Common.css) :

The first part saves the infobox's parameters. The second part searches the data of Wikidata. The last part builds an infobox and compare data of Wikidata with the parameters.

You can test your module in the lua console with this code :

Constructor : build a new object
uses the configuration by default uses the configuration of     uses the configuration of   but with the language of

Returns a LinkedWiki object.

select the subject of triples

select the configuration in order to read/write or delete the triples of this object in the database.If nil, it uses the configuration by default.

If nil, it uses the language in the configuration.

Enable the debug mode.

Examples :

Config
Returns configuration id (string) used by this instance.(see details about configurations)

Returns nil. It changes the configuration of this instance.



Example :

Lang
Returns lang tag (string) used by this instance.

Returns nil. It changes the lang tag of this instance.



Example :

Subject
Returns subject (iri/string) used by this instance.

Returns nil. It changes the subject of this instance.

Example :

initConfig
Returns nil

Useful only before using a static function in order to initialize the configuration, the language and the debug mode.

Iri or litteral without language tag
Returns the value IRI or litteral without language tag of current subject with this property.



Example :

litteral with language tag
Returns the litteral with this language tag in function of current subject with this property.



If nil, it uses the lang tag by default.

Example :

Iri
Returns the response of the database. It saves one IRI in function of the storage method defined in the configuration.





Example :

Value without language tag
Returns the response of the database. It saves one value without a lang tag in function of the storage method defined in the configuration.





If nil, the database will use the SPARQL standard in order to choose the type. For example, if the value is 7, the database will use xsd:integer but with the value 7.1, it will use xsd:float or xsd:double.

Example without explicit type :

Example with a date :

Example with a double :

String
Returns the response of the database. It saves one string with a lang tag in function of the storage method defined in the configuration.





If nil, the default lang tag in the configuration will be used.

Example :

Other cases
Returns the response of the database. It saves one litteral with a specific type and tag language tag in function of the storage method defined in the configuration.

Delete data
Returns the response of the database. It deletes all triples with the current subject of the instance in function of the storage method defined in the configuration.

Example :

Litteral without language tag
Returns wiki text. This function compares the value of this  with the parameter.

Litteral with language tag
Returns wiki text. This function compares the value of this  with the parameter.

Lang tag of value with this property. If nil, it uses the lang tag of the current configuration.

Label with language tag
Returns wiki text. This function compares the rdfs:label of object linked via  with the parameter.

Lang tag of label. If nil, it uses the lang tag of the current configuration.

Intern Link
Returns wiki text. This function insert an intern link.

Url of link

Property in order to read the label

label of link

Lang tag of label. If nil, it uses the lang tag of the current configuration.

Extern Link
Returns wiki text. This function insert an external link.

label of link

Property in order to read the url of link in the database

Url of link

Lang tag of label. If nil, it uses the lang tag of the current configuration.

User
Returns wiki text. This function compares the list of users in the database with the parameter. This function creates links to the user's pages and add a link to emails when its exist in the database with the property vcard:email.

Date
Returns wiki text. This function compares the date of this  with the parameter.

Format in output the date with the parser #Time

Image
Returns wiki text. This function compares the value of this  with the parameter.

image width

image height

Wikidata item
Returns wiki text. This function compares the list of Wikidata ID in the database with the parameter.

getCurrentTitle
Returns Title of the page

getCurrentIRI
Returns IRI of the page

isEmpty
Returns Boolean. Check if  is empty (nil or "").

explode
Returns a list.

Example :

Debug
You can use setDebug in order to see the errors in the SPARQL queries.

With this function, you can see the last SPARQL query used by the precedent function.