Legoktm has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/390176 )
Change subject: Migrate to extension.json
......................................................................
Migrate to extension.json
This just migrates the entrypoint into extension.json, and keeps a
backwards-compatible PHP entrypoint behind.
The intialization check to see whether Wikibase is installed is now
moved to the onBeforePageDisplay hook since that's what actually depends
upon Wikibase.
And the WIKIDATA_ORG_VERSION constant was removed since it wasn't used
anywhere outside of the credits, and double loading is not possible with
extension.json.
Change-Id: I29709dd603e796b3aba5b7f5dcfc683975ed2008
---
M WikidataOrg.hooks.php
M WikidataOrg.php
A extension.json
D resources/Resources.php
4 files changed, 47 insertions(+), 103 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikidata.org
refs/changes/76/390176/1
diff --git a/WikidataOrg.hooks.php b/WikidataOrg.hooks.php
index 864f06a..f1eb8cf 100644
--- a/WikidataOrg.hooks.php
+++ b/WikidataOrg.hooks.php
@@ -2,6 +2,7 @@
namespace WikidataOrg;
+use Exception;
use Html;
use OutputPage;
use QuickTemplate;
@@ -30,6 +31,9 @@
* @param Skin $skin
*/
public static function onBeforePageDisplay( OutputPage &$out, Skin
&$skin ) {
+ if ( !class_exists( WikibaseRepo::class ) ) {
+ throw new Exception( 'The Wikidata.org extension
requires Wikibase to be installed' );
+ }
$entityNamespaceLookup =
WikibaseRepo::getDefaultInstance()->getEntityNamespaceLookup();
$ns = $out->getTitle()->getNamespace();
diff --git a/WikidataOrg.php b/WikidataOrg.php
index 30a3f0f..9ef6a0a 100644
--- a/WikidataOrg.php
+++ b/WikidataOrg.php
@@ -1,76 +1,14 @@
<?php
-/**
- * Configuration for and customizations to Wikibase
- * that are specific to wikidata.org
- *
- * ## ##### ##### ## ## ##### ## ##### ## ##
- * ## ##### ##### ## ## ##### ## ##### ## ##
- * ## ##### ##### ## ## ##### ## ##### ## ##
- * ## ##### ##### ## ## ##### ## ##### ## ##
- * ## ##### ##### ## ## ##### ## ##### ## ##
- * ## ##### ##### ## ## ##### ## ##### ## ##
- * ## ##### ##### ## ## ##### ## ##### ## ##
- * ## ##### ##### ## ## ##### ## ##### ## ##
- * ## ##### ##### ## ## ##### ## ##### ## ##
- * ## ##### ##### ## ## ##### ## ##### ## ##
- * __ _____ _ _____ ___ _ _____ _
- * \ \ / /_ _| |/ /_ _| \ /_\_ _/_\
- * \ \/\/ / | || ' < | || |) / _ \| |/ _ \
- * \_/\_/ |___|_|\_\___|___/_/ \_\_/_/ \_\
- */
-
-/**
- * Entry point for for the Wikidata.org extension.
- *
- * @see README.md
- * @see https://github.com/wmde/Wikidata.org
- * @license GPL-2.0+
- */
-
-if ( !defined( 'MEDIAWIKI' ) ) {
- die( 'Not an entry point.' );
+if ( function_exists( 'wfLoadExtension' ) ) {
+ wfLoadExtension( 'Wikidata.org' );
+ // Keep i18n globals so mergeMessageFileList.php doesn't break
+ $wgMessagesDirs['Wikidata.org'] = __DIR__ . '/i18n';
+ /* wfWarn(
+ 'Deprecated PHP entry point used for Wikidata.org extension.
Please use wfLoadExtension ' .
+ 'instead, see
https://www.mediawiki.org/wiki/Extension_registration for more details.'
+ ); */
+ return true;
+} else {
+ die( 'This version of the Wikidata.org extension requires MediaWiki
1.29+' );
}
-
-if ( defined( 'WIKIDATA_ORG_VERSION' ) ) {
- // Do not initialize more than once.
- return 1;
-}
-
-define( 'WIKIDATA_ORG_VERSION', '1.0.0' );
-
-// This is the path to the autoloader generated by composer in case of a
composer install.
-if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) {
- require_once __DIR__ . '/vendor/autoload.php';
-}
-
-$GLOBALS['wgMessagesDirs']['Wikidata.org'] = __DIR__ . '/i18n';
-
-$GLOBALS['wgExtensionFunctions'][] = function() {
- global $wgExtensionCredits, $wgHooks, $wgResourceModules;
-
- if ( !defined( 'WB_VERSION' ) ) {
- throw new Exception( 'The Wikidata.org extension requires
Wikibase to be installed.' );
- }
-
- $wgExtensionCredits['wikibase'][] = [
- 'path' => __DIR__,
- 'name' => 'Wikidata.org',
- 'version' => WIKIDATA_ORG_VERSION,
- 'author' => '[https://www.mediawiki.org/wiki/User:Bene* Bene*]',
- 'url' => 'https://github.com/wmde/Wikidata.org',
- 'descriptionmsg' => 'wikidata-org-desc',
- 'license-name' => 'GPL-2.0+'
- ];
-
- // Hooks
- $wgHooks['BeforePageDisplay'][] =
'WikidataOrg\Hooks::onBeforePageDisplay';
- $wgHooks['SkinTemplateOutputPageBeforeExec'][] =
- 'WikidataOrg\Hooks::onSkinTemplateOutputPageBeforeExec';
-
- // Resource Loader modules
- $wgResourceModules = array_merge(
- $wgResourceModules,
- include __DIR__ . '/resources/Resources.php'
- );
-};
diff --git a/extension.json b/extension.json
new file mode 100644
index 0000000..ec01486
--- /dev/null
+++ b/extension.json
@@ -0,0 +1,32 @@
+{
+ "name": "Wikidata.org",
+ "version": "1.0.0",
+ "author": "[https://www.mediawiki.org/wiki/User:Bene* Bene*]",
+ "url": "https://github.com/wmde/Wikidata.org",
+ "descriptionmsg": "wikidata-org-desc",
+ "license-name": "GPL-2.0+",
+ "type": "wikibase",
+ "MessagesDirs": {
+ "Wikidata.org": [
+ "i18n"
+ ]
+ },
+ "ResourceModules": {
+ "ext.wikidata-org.badges": {
+ "position": "bottom",
+ "styles": [
+ "themes/default/wikidata-org.badges.css"
+ ]
+ }
+ },
+ "ResourceFileModulePaths": {
+ "localBasePath": "resources",
+ "remoteExtPath": "Wikidata.org/resources"
+ },
+ "Hooks": {
+ "BeforePageDisplay": "WikidataOrg\\Hooks::onBeforePageDisplay",
+ "SkinTemplateOutputPageBeforeExec":
"WikidataOrg\\Hooks::onSkinTemplateOutputPageBeforeExec"
+ },
+ "load_composer_autoloader": true,
+ "manifest_version": 2
+}
diff --git a/resources/Resources.php b/resources/Resources.php
deleted file mode 100644
index 0dec58d..0000000
--- a/resources/Resources.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-
-/**
- * Wikidata.org ResourceLoader modules
- *
- * @since 0.1
- *
- * @license GNU GPL v2+
- * @author Bene* < [email protected] >
- */
-return call_user_func( function() {
- $remoteExtPathParts = explode(
- DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR,
__DIR__, 2
- );
- $moduleTemplate = [
- 'localBasePath' => __DIR__,
- 'remoteExtPath' => $remoteExtPathParts[1]
- ];
-
- $modules = [
- 'ext.wikidata-org.badges' => $moduleTemplate + [
- 'position' => 'bottom',
- 'styles' => [
- 'themes/default/wikidata-org.badges.css',
- ]
- ]
- ];
-
- return $modules;
-} );
--
To view, visit https://gerrit.wikimedia.org/r/390176
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I29709dd603e796b3aba5b7f5dcfc683975ed2008
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikidata.org
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits