Extension:WikibaseInWikitext

MediaWiki extensions manual
WikibaseInWikitext
Release status: beta
Implementation ContentHandler , Tag
Description Adds the "sparql" tag for rendering SPARQL with some helpful things around it such as list of entities referenced and a link to try it in a SPARQL UI.
Author(s) Adam Shorland (Addshoretalk)
MediaWiki 1.32+
License GNU General Public License 2.0 or later
Download
README
CHANGELOG
$wgWikibaseInWikitextSparqlDefaultUi
<sparql>

The WikibaseInWikitext extension adds the "sparql" tag for rendering SPARQL with some helpful things around it, such as a list of entities referenced and a link to try it in a SPARQL UI. If provided, it also hooks in with the extension Syntaxhighlight to make it look pretty.

Installation

edit
  • Download and place the file(s) in a directory called WikibaseInWikitext in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'WikibaseInWikitext' );
    
  • Configure as required.
  •   Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Configuration

edit
$wgWikibaseInWikitextSparqlDefaultUi
Location of the SPARQL UI to link to. Example: https://addshore-alpha.wiki.opencura.com/query

Usage

edit
  • Add your SPARQL query to the sparql tag. If the SyntaxHighlight extension is installed, it should show your lines of code with the appropriate syntax highlighting.
  • You can set the following attributes to show additional information and links:
    • Add list="1" to retrieve a list of entities used in your query.
    • Add tryit="1" to let readers try your code in the SPARQL query interface.

Example

edit
<sparql list="1" tryit="1">
#Cats
SELECT ?item ?itemLabel 
WHERE 
{
  ?item wdt:P31 wd:Q146.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
</sparql>