GithubHelp home page GithubHelp logo

professionalwiki / wikibaselocalmedia Goto Github PK

View Code? Open in Web Editor NEW
12.0 9.0 6.0 202 KB

MediaWiki extension that adds support for local media files to Wikibase via a new data type.

Home Page: https://wikibase.consulting

License: GNU General Public License v2.0

PHP 84.25% JavaScript 15.75%
wikibase mediawiki mediawiki-extension wikidata wikibase-extension

wikibaselocalmedia's Introduction

Wikibase Local Media

GitHub Workflow Status Latest Stable Version Download count GitHub

MediaWiki extension that adds support for local media files to Wikibase via a new data type.

Professional.Wiki created and maintains Wikibase Local Media. We provide Wikibase hosting, Wikibase development and Wikibase consulting.

Rhizome commissioned and funded initial development of the extension. Wikibase Local Media is an open source project and contributions are welcome!

Demo and screenshot

Also see this animated gif.

Platform requirements

See the release notes for more information on the different versions of this extension.

Installation

First install MediaWiki and Wikibase Repository.

Using Composer (option 1/2)

The recommended way to install Wikibase Local Media 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-local-media:*
composer update professional-wiki/wikibase-local-media --no-dev -o

Manual download (option 2/2)

You can also install the extension via git clone or download. Place the WikibaseLocalMedia directory into extensions.

Enabling the extension

Then enable the extension by adding the following to the bottom of your wikis LocalSettings.php file:

wfLoadExtension( 'WikibaseLocalMedia' );

You can verify the extension was enabled successfully by opening your wikis Special:Version page in your browser.

Finally, please consider sponsoring the project.

Running the tests

  • PHP tests: php tests/phpunit/phpunit.php extensions/WikibaseLocalMedia/tests/
  • JS tests: index.php?title=Special%3AJavaScriptTest&filter=jquery.ui.mediasuggester

Release notes

Version 1.0.3

Released on March 30, 2023

  • Added support for MediaWiki and Wikibase 1.38 and 1.39
  • Translation updates

Version 1.0.2

Released on October 4th 2022

  • Added support for MediaWiki and Wikibase 1.37
  • Translation updates

Version 1.0.1

Released on March 17th 2021

  • Allowed installation with PHP 7.2.x
  • Translation updates

Version 1.0.0

Released on October 5th 2020

  • Added optional integration with Wikibase Client
  • Translation updates

Version 0.2.1

Released on September 28th 2020

  • Fixed support for PHP 7.3.x

Version 0.2

Released on September 26th 2020

  • Added support for MediaWiki/Wikibase 1.35
  • The extension is now listed in the Wikibase group on Special:Version

Version 0.1

Released on September 26th 2020

wikibaselocalmedia's People

Contributors

addshore avatar jeroendedauw avatar kghbln avatar malberts avatar rti avatar toban avatar translatewiki avatar universal-omega avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wikibaselocalmedia's Issues

Is this extension ready for MW / WB 1.36?

Reading the readme currently 1.34/1.35 are specifically mentioned.
Should this also work with 1.36?
Do we just need to fix the docs or also do some additional testing etc first?

WikibaseRepo::getDefaultInstance() has been removed on master

Setup

  • Wikibase Local Media version: head of master
  • Wikibase version: head of master
  • MediaWiki version: head of master
  • PHP version: 7.3

Issue

WikibaseRepo::getDefaultInstance() has been removed as of https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/+/682951

visting Special:NewProperty with WikibaseLocalMedia results in

[3d56ca57adf3e1ae5900b952] /wiki/Special:NewProperty Error: Call to undefined method Wikibase\Repo\WikibaseRepo::getDefaultInstance()

Backtrace:

from /var/www/html/extensions/WikibaseLocalMedia/src/WikibaseLocalMedia.php(42)
#0 /var/www/html/extensions/WikibaseLocalMedia/src/HookHandlers.php(23): Wikibase\LocalMedia\WikibaseLocalMedia->getFormatterBuilder()
#1 [internal function]: Wikibase\LocalMedia\HookHandlers::Wikibase\LocalMedia\{closure}(string, ValueFormatters\FormatterOptions)
#2 /var/www/html/extensions/Wikibase/lib/includes/Formatters/OutputFormatValueFormatterFactory.php(158): call_user_func(Closure, string, ValueFormatters\FormatterOptions)
#3 /var/www/html/extensions/Wikibase/lib/includes/Formatters/OutputFormatValueFormatterFactory.php(138): Wikibase\Lib\Formatters\OutputFormatValueFormatterFactory->buildDefinedFormatters(string, ValueFormatters\FormatterOptions)
#4 /var/www/html/extensions/Wikibase/lib/includes/Formatters/OutputFormatSnakFormatterFactory.php(108): Wikibase\Lib\Formatters\OutputFormatValueFormatterFactory->getValueFormatter(string, ValueFormatters\FormatterOptions)
#5 /var/www/html/extensions/Wikibase/repo/WikibaseRepo.ServiceWiring.php(1637): Wikibase\Lib\Formatters\OutputFormatSnakFormatterFactory->getSnakFormatter(string, ValueFormatters\FormatterOptions)
#6 /var/www/html/vendor/wikimedia/services/src/ServiceContainer.php(447): Wikimedia\Services\ServiceContainer->{closure}(MediaWiki\MediaWikiServices)
#7 /var/www/html/vendor/wikimedia/services/src/ServiceContainer.php(416): Wikimedia\Services\ServiceContainer->createService(string)
#8 /var/www/html/includes/MediaWikiServices.php(266): Wikimedia\Services\ServiceContainer->getService(string)
#9 /var/www/html/vendor/wikimedia/services/src/ServiceContainer.php(424): MediaWiki\MediaWikiServices->getService(string)
#10 /var/www/html/vendor/wikimedia/object-factory/src/ObjectFactory/ObjectFactory.php(209): Wikimedia\Services\ServiceContainer->get(string)
#11 /var/www/html/vendor/wikimedia/object-factory/src/ObjectFactory/ObjectFactory.php(150): Wikimedia\ObjectFactory\ObjectFactory::getObjectFromSpec(array, array)
#12 /var/www/html/includes/specialpage/SpecialPageFactory.php(1222): Wikimedia\ObjectFactory\ObjectFactory->createObject(array, array)
#13 /var/www/html/includes/MediaWiki.php(272): MediaWiki\SpecialPage\SpecialPageFactory->getPage(string)
#14 /var/www/html/includes/MediaWiki.php(916): MediaWiki->performRequest()
#15 /var/www/html/includes/MediaWiki.php(550): MediaWiki->main()
#16 /var/www/html/index.php(53): MediaWiki->run()
#17 /var/www/html/index.php(46): wfIndexMain()
#18 {main}

use local media in grid view

Hello,

we have a Wikibase with LocalMedia integrated which works very well.
Now we would like to produce a grid view, which seems to expect Wikimedia Commons as a source.

Is there a bugfix or did we make a mistake?

This is the query:
https://tinyurl.com/yjorahyw

Creating claims of local media to items through api interface

Is there an appropriate syntax to claim an image programmatically to an item ?

When i try doing the following,

site = pwb.Site('localwiki:en')
#site.login()

token = pwb.data.api.Request(site=site, parameters={'action': 'query', 'meta': 'tokens'}).submit()
csrf_token = token['query']['tokens']['csrftoken']


result = pwb.data.api.Request(site=site, parameters={'action': 'wbcreateclaim', 'token': csrf_token,
                              'entity': 'P1','property': 'P50', 'snaktype': 'value', 
                              'datatype': 'localMedia', 'type': 'statement',
                             'value': {'value': 'Neo.jpg', 'type': 'localMedia'}}).submit()

I get the following error

APIError: invalid-snak: Invalid snak data.
[param: action=wbcreateclaim&entity=P1&property=P50&snaktype=value&datatype=localMedia&type=statement&value=value%7Ctype&assert=user&maxlag=1&format=json&token=6caed2ab16ab837896c5a17b01d6fee7652fb29e%2B%5C;
 messages: [{'name': 'wikibase-api-invalid-snak', 'parameters': [], 'html': {'*': 'Invalid snak data.'}}];

When i create the claim over the web interface, the json data of the item contains the claim as the following

'claims': <class 'pywikibot.page._collections.ClaimCollection'>(
    {
        'P50': [Claim.fromJSON(DataSite("en", "localwiki"), 
                               {'mainsnak': {'snaktype': 'value', 
                                             'property': 'P50', 
                                             'datatype': 'localMedia', 
                                             'datavalue': {'value': 'Jpg3.jpg', 'type': 'localMedia'}
                                            }, 
                                'type': 'statement', 
                                'id': 'P1$ceabb6c6-4ba1-f31b-d2e1-b18cdb78050e', 
                                'rank': 'normal'}), 
                Claim(DataSite("en", "localwiki"), 'P50'), 
                Claim(DataSite("en", "localwiki"), 'P50')]    
    }
)

Feature request: get images from any wiki

This extension allows getting images from the wiki where the WikiBase Repository is installed. Nevertheless I think it would be useful to be able to get images from another wiki that is neither Commons, nor the local Repository. For instance, in my case, I have a MW instance acting as a Repository, and a separate MW instance with Wikibase Client: I would like to reference images in the Repo instance, but images are actually at the Client one.

Ideally, it should be possible to setup the source wiki somewhere, I assume it should be enough to have the API endpoint of a remote wiki to obtain images' information.

If any of the extension programmer could point in the right direction, I would be willing to work on this modification by myself for my own purpose and eventually release the modified code.

Thanks

Luca

Not loading on Wikibase 1.37.6

Setup

  • Wikibase Local Media version: latest (installed using composer, professional-wiki/wikibase-local-media:*)
  • Wikibase version: 1.37 (97d07b1)
  • MediaWiki version: 1.37.6
  • PHP version: 8.0.23

Issue

When extension is loaded, it is trying to call Wikibase\Repo\WikibaseRepo::getDefaultInstance() which apparently is not supported anymore.

[bf9f832a57800df03450b5c5] /wiki/Special:SpecialPages Error: Call to undefined method Wikibase\Repo\WikibaseRepo::getDefaultInstance()

Backtrace:

from /var/www/html/extensions/WikibaseLocalMedia/src/WikibaseLocalMedia.php(42)
#0 /var/www/html/extensions/WikibaseLocalMedia/src/HookHandlers.php(23): Wikibase\LocalMedia\WikibaseLocalMedia->getFormatterBuilder()
#1 [internal function]: Wikibase\LocalMedia\HookHandlers::Wikibase\LocalMedia\{closure}(string, ValueFormatters\FormatterOptions)
#2 /var/www/html/extensions/Wikibase/lib/includes/Formatters/OutputFormatValueFormatterFactory.php(158): call_user_func(Closure, string, ValueFormatters\FormatterOptions)
#3 /var/www/html/extensions/Wikibase/lib/includes/Formatters/OutputFormatValueFormatterFactory.php(138): Wikibase\Lib\Formatters\OutputFormatValueFormatterFactory->buildDefinedFormatters(string, ValueFormatters\FormatterOptions)
#4 /var/www/html/extensions/Wikibase/lib/includes/Formatters/OutputFormatSnakFormatterFactory.php(108): Wikibase\Lib\Formatters\OutputFormatValueFormatterFactory->getValueFormatter(string, ValueFormatters\FormatterOptions)
#5 /var/www/html/extensions/Wikibase/repo/WikibaseRepo.ServiceWiring.php(1815): Wikibase\Lib\Formatters\OutputFormatSnakFormatterFactory->getSnakFormatter(string, ValueFormatters\FormatterOptions)
#6 /var/www/html/vendor/wikimedia/services/src/ServiceContainer.php(447): Wikimedia\Services\ServiceContainer->{closure}(MediaWiki\MediaWikiServices)
#7 /var/www/html/vendor/wikimedia/services/src/ServiceContainer.php(416): Wikimedia\Services\ServiceContainer->createService(string)
#8 /var/www/html/includes/MediaWikiServices.php(279): Wikimedia\Services\ServiceContainer->getService(string)
#9 /var/www/html/vendor/wikimedia/services/src/ServiceContainer.php(424): MediaWiki\MediaWikiServices->getService(string)
#10 /var/www/html/vendor/wikimedia/object-factory/src/ObjectFactory/ObjectFactory.php(209): Wikimedia\Services\ServiceContainer->get(string)
#11 /var/www/html/vendor/wikimedia/object-factory/src/ObjectFactory/ObjectFactory.php(150): Wikimedia\ObjectFactory\ObjectFactory::getObjectFromSpec(array, array)
#12 /var/www/html/includes/specialpage/SpecialPageFactory.php(1218): Wikimedia\ObjectFactory\ObjectFactory->createObject(array, array)
#13 /var/www/html/includes/specialpage/SpecialPageFactory.php(1253): MediaWiki\SpecialPage\SpecialPageFactory->getPage(string)
#14 /var/www/html/includes/specials/SpecialSpecialpages.php(53): MediaWiki\SpecialPage\SpecialPageFactory->getUsablePages(User)
#15 /var/www/html/includes/specials/SpecialSpecialpages.php(42): SpecialSpecialpages->getPageGroups()
#16 /var/www/html/includes/specialpage/SpecialPage.php(647): SpecialSpecialpages->execute(NULL)
#17 /var/www/html/includes/specialpage/SpecialPageFactory.php(1366): SpecialPage->run(NULL)
#18 /var/www/html/includes/MediaWiki.php(314): MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, RequestContext)
#19 /var/www/html/includes/MediaWiki.php(932): MediaWiki->performRequest()
#20 /var/www/html/includes/MediaWiki.php(563): MediaWiki->main()
#21 /var/www/html/index.php(53): MediaWiki->run()
#22 /var/www/html/index.php(46): wfIndexMain()
#23 {main}

Fix deprecation warning on MW 37+

https://github.com/ProfessionalWiki/WikibaseLocalMedia/runs/4402770912?check_suite_focus=true

PHP Notice: Deprecated PHP entry point used for Wikibase Repository extension. Please use wfLoadExtension instead, seehttps://www.mediawiki.org/wiki/Extension_registration for more details. [Called from require_once in /home/runner/work/WikibaseLocalMedia/WikibaseLocalMedia/mediawiki/extensions/Wikibase/repo/Wikibase.php at line 17] in /home/runner/work/WikibaseLocalMedia/WikibaseLocalMedia/mediawiki/includes/debug/MWDebug.php on line 498

Notice: Deprecated PHP entry point used for Wikibase Repository extension. Please use wfLoadExtension instead, seehttps://www.mediawiki.org/wiki/Extension_registration for more details. [Called from require_once in /home/runner/work/WikibaseLocalMedia/WikibaseLocalMedia/mediawiki/extensions/Wikibase/repo/Wikibase.php at line 17] in /home/runner/work/WikibaseLocalMedia/WikibaseLocalMedia/mediawiki/includes/debug/MWDebug.php on line 498

Compatibility with federated properties in 1.35?

It seems with the new setting in 1.35: $wgWBRepoSettings['federatedPropertiesEnabled'] = true; that creating a wiki with this enabled will mean that a property for local media cannot be created. Is that correct? Does it mean that this feature/extension cannot be used with federated properties at all? Is there a way the extension can be developed to work alongside federated properties?

Manual installation => Fatal error occurs

Setup

  • Wikibase Local Media version: the latest from GitHub, 1.0.1?
  • Wikibase version: 1.35
  • MediaWiki version: 1.35.1
  • PHP version: 7.3.26

Issue

Tried to install WikibaseLocalMedia manually. Added wfLoadExtension( 'WikibaseLocalMedia' ); to LocalSettings.php.template at RaiseWikibase and mounted folder WikibaseLocalMedia to /var/www/html/extensions/WikibaseLocalMedia.

I cannot open localhost:8181, the error occurs:

Fatal error: Uncaught UnexpectedValueException: callback 'Wikibase\LocalMedia\HookHandlers::onExtensionRegistration' is not callable in /var/www/html/includes/registration/ExtensionRegistry.php:539 Stack trace: #0 /var/www/html/includes/registration/ExtensionRegistry.php(232): ExtensionRegistry->exportExtractedData(Array) #1 /var/www/html/includes/Setup.php(161): ExtensionRegistry->loadFromQueue() #2 /var/www/html/includes/WebStart.php(89): require_once('/var/www/html/i...') #3 /var/www/html/index.php(44): require('/var/www/html/i...') #4 {main} thrown in /var/www/html/includes/registration/ExtensionRegistry.php on line 539

Wikibase Local Media breaks requests for .ttl format at Special:EntityData

I created a phabricator ticket: https://phabricator.wikimedia.org/T306288
but I feel like this might be a more appropriate place to report this

Setup

  • Wikibase Local Media version: master
  • Wikibase version: REL_37
  • MediaWiki version: 1.37.2
  • PHP version: 8.08

Issue

When the local media extension is enabled requesting .ttl format from Special:EntityData will return a undescriptive error, disabling the extension allows for the request to be successful, images can be found in the phabricator ticket linked above.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.