professional-wiki / wikibase-rdf
Wikibase extension that allows defining RDF mappings for Wikibase Entities
Installs: 3 757
Dependents: 0
Suggesters: 0
Security: 0
Stars: 14
Watchers: 8
Forks: 4
Open Issues: 7
Type:mediawiki-extension
Requires
- php: >=8.0
- composer/installers: ^2|^1.0.1
Requires (Dev)
- mediawiki/mediawiki-codesniffer: ^39.0.0
- phpstan/phpstan: ^1.4.8
- vimeo/psalm: ^4.22.0
This package is auto-updated.
Last update: 2024-11-05 14:27:18 UTC
README
Wikibase extension that allows defining RDF mappings for Wikibase Entities.
Professional.Wiki created and maintains Wikibase RDF. We provide Wikibase hosting, Wikibase development and Wikibase consulting.
The Wikibase Stakeholder Group concieved and funded the extension.
Table of Contents
Usage
When the extension is enabled, Item and Property pages show a "Mapping to other ontologies" section. This section is located in between the "In more languages" and "Statements" sections.
Users with editing permissions can add, edit or remove mappings.
A mapping consists of a predicate and a URL. The predicate can only be one out of a preconfigured set of values. The URL has to be a valid URL.
Mapping predicates can be configured via the MediaWiki:MappingPredicates
page by anyone with interface-admin permissions.
You can also configure mapping predicates via PHP Configuration.
REST API
This extension provides REST API endpoints for getting and setting the RDF mappings for a Wikibase entity.
For more information, refer to the REST API documentation.
Installation
Platform requirements:
- PHP 8.0 or later (tested up to 8.1)
- MediaWiki 1.37 or later (tested up to 1.37)
- Wikibase 1.37 or later (tested up to 1.37)
The recommended way to install Wikibase RDF is using Composer with MediaWiki's built-in support for Composer.
On the commandline, go to your wikis root directory. Then run these two commands:
COMPOSER=composer.local.json composer require --no-update professional-wiki/wikibase-rdf:~1.0
composer update professional-wiki/wikibase-rdf --no-dev -o
Then enable the extension by adding the following to the bottom of your wikis LocalSettings.php file:
wfLoadExtension( 'WikibaseRDF' );
You can verify the extension was enabled successfully by opening your wikis Special:Version page in your browser.
PHP Configuration
Configuration can be changed via LocalSettings.php.
Allowed predicates
List of allowed predicates.
Variable: $wgWikibaseRdfPredicates
Default: []
Example:
$wgWikibaseRdfPredicates = [ 'owl:sameAs', 'owl:SymmetricProperty', 'rdfs:subClassOf', 'rdfs:subPropertyOf', ];
You can also configure what predicates are allowed via the MediaWiki:MappingPredicates
page.
Development
To ensure the dev dependencies get installed, have this in your composer.local.json
:
{ "require": { "vimeo/psalm": "^4", "phpstan/phpstan": "^1.4.9" }, "extra": { "merge-plugin": { "include": [ "extensions/WikibaseRDF/composer.json" ] } } }
Running tests and CI checks
You can use the Makefile
by running make commands in the WikibaseRDF
directory.
make ci
: Run everythingmake test
: Run all testsmake cs
: Run all style checks and static analysis
Alternatively, you can execute commands from the MediaWiki root directory:
- PHPUnit:
php tests/phpunit/phpunit.php -c extensions/WikibaseRDF/
- Style checks:
vendor/bin/phpcs -p -s --standard=extensions/WikibaseRDF/phpcs.xml
- PHPStan:
vendor/bin/phpstan analyse --configuration=extensions/WikibaseRDF/phpstan.neon --memory-limit=2G
- Psalm:
php vendor/bin/psalm --config=extensions/WikibaseRDF/psalm.xml
Release notes
Version 1.1.0 - 2022-11-25
- Added translations for various languages
- Added notification about SPARQL store behavior that shows on first edit
Version 1.0.0 - 2022-10-04
Initial release for Wikibase 1.37 with these features:
- Ability to add mappings to Items and Properties via an on-page UI
- Inclusion of mappings in the RDF output
- Configurable relationships (predicates), including configuration UI on
MediaWiki:MappingPredicates
- API endpoint to retrieve or update the mappings for an Entity
- API endpoint to retrieve all mappings defined on the wiki
- TranslateWiki integration
- Support for PHP 8.0 and 8.1