[MediaWiki-commits] [Gerrit] Lua support to access the repo data and implement getEntity - change (mediawiki...Wikibase)
Daniel Kinzler has submitted this change and it was merged. Change subject: Lua support to access the repo data and implement getEntity .. Lua support to access the repo data and implement getEntity Change-Id: I9fd05c36f32bffdeb15fb793e7c3332032b3541e --- M client/WikibaseClient.hooks.php M client/WikibaseClient.i18n.php M client/WikibaseClient.php A client/includes/WikibaseLibrary.php A client/resources/mw.wikibase.lua 5 files changed, 131 insertions(+), 3 deletions(-) Approvals: Daniel Kinzler: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/client/WikibaseClient.hooks.php b/client/WikibaseClient.hooks.php index 6908b36..65007ec 100644 --- a/client/WikibaseClient.hooks.php +++ b/client/WikibaseClient.hooks.php @@ -397,6 +397,20 @@ } /** +* External library for Scribunto +* +* @since 0.4 +* +* @param $engine +* @param array $extraLibraries +* @return bool +*/ + public static function onScribuntoExternalLibraries ( $engine, array $extraLibraries ) { + $extraLibraries['mw.wikibase'] = 'Scribunto_LuaWikibaseLibrary'; + return true; + } + + /** * Hook for modifying the query for fetching recent changes * @see https://www.mediawiki.org/wiki/Manual:Hooks/SpecialRecentChangesQuery * @@ -710,7 +724,7 @@ if ( $special-getName() === 'Watchlist' ) { $context = $special-getContext(); - if ( $context-getRequest()-getBool( 'enhanced', $context-getUser()-getOption( 'usenewrc' ) ) === false ) { + if ( $context-getRequest()-getBool( 'enhanced', $context-getUser()-getOption( 'usenewrc' ) ) === false ) { $special-getOutput()-addModules( array( 'wbclient.watchlist.css', 'wbclient.watchlist', diff --git a/client/WikibaseClient.i18n.php b/client/WikibaseClient.i18n.php index 74885e5..876ccf7 100644 --- a/client/WikibaseClient.i18n.php +++ b/client/WikibaseClient.i18n.php @@ -53,7 +53,8 @@ 'wikibase-property-notsupportedyet' = 'Wikibase does not yet support property type for $1 property.', 'wikibase-rc-hide-wikidata' = '$1 Wikidata', 'wikibase-rc-show-wikidata-pref' = 'Show Wikidata edits in recent changes', - 'wikibase-watchlist-show-changes-pref' = 'Show Wikidata edits in my watchlist', + 'wikibase-watchlist-show-changes-pref' = 'Show Wikidata edits in your watchlist', + 'wikibase-error-invalid-entity-id' = 'The ID entered is unknown to the system. Please use a valid entity ID.', ); /** Message documentation (Message documentation) @@ -136,6 +137,7 @@ * $1 - a link with the text {{msg-mw|show}} or {{msg-mw|hide}}', 'wikibase-rc-show-wikidata-pref' = 'Option in the recent changes section of preferences to show wikibase changes by default in recent changes.', 'wikibase-watchlist-show-changes-pref' = 'Option in the watchlist section of preferences to always show wikibase edits by default in the watchlist.', + 'wikibase-error-invalid-entity-id' = 'Generic error message when an invalid entity ID was entered.', ); /** Afrikaans (Afrikaans) diff --git a/client/WikibaseClient.php b/client/WikibaseClient.php index 1f80e62..59dd8bf 100644 --- a/client/WikibaseClient.php +++ b/client/WikibaseClient.php @@ -65,6 +65,7 @@ $wgAutoloadClasses['Wikibase\LangLinkHandler'] = $dir . 'includes/LangLinkHandler.php'; $wgAutoloadClasses['Wikibase\ChangeHandler'] = $dir . 'includes/ChangeHandler.php'; $wgAutoloadClasses['Wikibase\NamespaceChecker']= $dir . 'includes/NamespaceChecker.php'; +$wgAutoloadClasses['Scribunto_LuaWikibaseLibrary'] = $dir . 'includes/WikibaseLibrary.php'; // includes/api $wgAutoloadClasses['Wikibase\ApiClientInfo'] = $dir . 'includes/api/ApiClientInfo.php'; @@ -111,7 +112,7 @@ $wgHooks['GetPreferences'][] = '\Wikibase\ClientHooks::onGetPreferences'; $wgHooks['BeforePageDisplay'][]= '\Wikibase\ClientHooks::onBeforePageDisplay'; $wgHooks['SpecialPageBeforeExecute'][] = '\Wikibase\ClientHooks::onSpecialPageBeforeExecute'; - +$wgHooks['ScribuntoExternalLibraries'][] = '\Wikibase\ClientHooks::onScribuntoExternalLibraries'; // extension hooks $wgHooks['WikibasePollHandle'][]= '\Wikibase\ClientHooks::onWikibasePollHandle'; $wgHooks['WikibaseDeleteData'][] = '\Wikibase\ClientHooks::onWikibaseDeleteData'; diff --git a/client/includes/WikibaseLibrary.php b/client/includes/WikibaseLibrary.php new file mode 100644 index 000..3b276fe --- /dev/null +++
[MediaWiki-commits] [Gerrit] Lua support to access the repo data and implement getEntity - change (mediawiki...Wikibase)
Jens Ohlig has uploaded a new change for review. https://gerrit.wikimedia.org/r/53570 Change subject: Lua support to access the repo data and implement getEntity .. Lua support to access the repo data and implement getEntity Change-Id: I9fd05c36f32bffdeb15fb793e7c3332032b3541e --- M client/WikibaseClient.hooks.php M client/WikibaseClient.php A client/includes/WikibaseLibrary.php A client/resources/mw.wikibase.lua 4 files changed, 47 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/70/53570/1 diff --git a/client/WikibaseClient.hooks.php b/client/WikibaseClient.hooks.php index f2b005e..7538650 100644 --- a/client/WikibaseClient.hooks.php +++ b/client/WikibaseClient.hooks.php @@ -398,6 +398,16 @@ return true; } +/** + * External library for Scribunto + * + * @return bool + */ +public static function onScribuntoExternalLibraries ( $engine, array $extraLibraries ) { +$extraLibraries['mw.wikibase'] = 'Scribunto_LuaWikibaseLibrary'; +return true; +} + /** * Hook for modifying the query for fetching recent changes * @see https://www.mediawiki.org/wiki/Manual:Hooks/SpecialRecentChangesQuery diff --git a/client/WikibaseClient.php b/client/WikibaseClient.php index 2345169..e86ac06 100644 --- a/client/WikibaseClient.php +++ b/client/WikibaseClient.php @@ -65,6 +65,7 @@ $wgAutoloadClasses['Wikibase\LangLinkHandler'] = $dir . 'includes/LangLinkHandler.php'; $wgAutoloadClasses['Wikibase\ChangeHandler'] = $dir . 'includes/ChangeHandler.php'; $wgAutoloadClasses['Wikibase\NamespaceChecker']= $dir . 'includes/NamespaceChecker.php'; +$wgAutoloadClasses['Scribunto_LuaWikibaseLibrary'] = $dir . 'includes/WikibaseLibrary.php'; // includes/api $wgAutoloadClasses['Wikibase\ApiClientInfo'] = $dir . 'includes/api/ApiClientInfo.php'; @@ -114,7 +115,7 @@ $wgHooks['GetPreferences'][] = '\Wikibase\ClientHooks::onGetPreferences'; $wgHooks['BeforePageDisplay'][]= '\Wikibase\ClientHooks::onBeforePageDisplay'; $wgHooks['SpecialPageBeforeExecute'][] = '\Wikibase\ClientHooks::onSpecialPageBeforeExecute'; - +$wgHooks['ScribuntoExternalLibraries'][] = '\Wikibase\ClientHooks::onScribuntoExternalLibraries'; // extension hooks $wgHooks['WikibasePollHandle'][]= '\Wikibase\ClientHooks::onWikibasePollHandle'; $wgHooks['WikibaseDeleteData'][] = '\Wikibase\ClientHooks::onWikibaseDeleteData'; diff --git a/client/includes/WikibaseLibrary.php b/client/includes/WikibaseLibrary.php new file mode 100644 index 000..4e2cfe1 --- /dev/null +++ b/client/includes/WikibaseLibrary.php @@ -0,0 +1,23 @@ +?php +class Scribunto_LuaWikibaseLibrary extends Scribunto_LuaLibraryBase { +protected static $moduleName = 'wikibase'; +public function register() { +$lib = array( 'getEntity' = array( $this, 'getEntity' ) ); +$this-getEngine()-registerInterface( dirname( __FILE__ ) . '/../resources/' . 'mw.wikibase.lua', $lib, array() ); +} + + public function getEntity( $entity ) { + $this-checkType( 'getEntity', 1, $entity, 'string' ); +$entityObject = Wikibase\ClientStoreFactory::getStore()-newEntityLookup()-getEntity( Wikibase\EntityId::newFromPrefixedId( $entity ) ); + +$serializerFactory = new \Wikibase\Lib\Serializers\SerializerFactory(); +$serializer =$serializerFactory-newSerializerForObject( $entityObject ); + +$opt = new \Wikibase\Lib\Serializers\EntitySerializationOptions(); +$serializer-setOptions( $opt ); + +$entityArr = $serializer-getSerialized( $entityObject ); +MWDebug::log( serialize($entityArr) ); + return array( $entityArr ); +} +} diff --git a/client/resources/mw.wikibase.lua b/client/resources/mw.wikibase.lua new file mode 100644 index 000..4c54835 --- /dev/null +++ b/client/resources/mw.wikibase.lua @@ -0,0 +1,12 @@ +wikibase = {} + +function wikibase.setupInterface() + for k, v in pairs( mw_interface ) do +wikibase[k] = v + end + mw = mw or {} + mw.wikibase = wikibase + package.loaded['mw.wikibase'] = wikibase +end + +return wikibase -- To view, visit https://gerrit.wikimedia.org/r/53570 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9fd05c36f32bffdeb15fb793e7c3332032b3541e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jens Ohlig jens.oh...@wikimedia.de ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org