jenkins-bot has submitted this change and it was merged. Change subject: Adds a beta feature for "Other project" sidebar ......................................................................
Adds a beta feature for "Other project" sidebar It introduce an optional dependance to BetaFeature extension Adds two boolean configuration options: otherProjectsLinksBeta to activate the beta feature otherProjectsLinksByDefault to activate the other project sidebar by default Relies on change I170e7253825c8dab5cad38e6b0ba59f28572efbf in MW core "Expands" change I93767d3db76f694f2d37bbf2f2fecaf7643f4e3b in Wikimedia config Change-Id: Ib4014253016db1c3d6b624be9ebbdaf452115145 (cherry picked from commit 0b6a5bf6dca9c2986511947283e3d57aa6e13738) --- M client/WikibaseClient.hooks.php M client/WikibaseClient.php M client/config/WikibaseClient.default.php M client/i18n/en.json M client/i18n/qqq.json A client/resources/images/wb-otherprojects-beta-ltr.png A client/resources/images/wb-otherprojects-beta-ltr.svg A client/resources/images/wb-otherprojects-beta-rtl.png 8 files changed, 119 insertions(+), 3 deletions(-) Approvals: Hoo man: Looks good to me, approved WikidataJenkins: Verified jenkins-bot: Verified diff --git a/client/WikibaseClient.hooks.php b/client/WikibaseClient.hooks.php index d91fc47..26372b4 100644 --- a/client/WikibaseClient.hooks.php +++ b/client/WikibaseClient.hooks.php @@ -4,6 +4,7 @@ use Action; use BaseTemplate; +use BetaFeatures; use ChangesList; use FormOptions; use IContextSource; @@ -621,7 +622,10 @@ $settings = WikibaseClient::getDefaultInstance()->getSettings(); $siteIdsToOutput = $settings->getSetting( 'otherProjectsLinks' ); - if ( count( $siteIdsToOutput ) === 0 ) { + if ( + !$settings->getSetting( 'otherProjectsLinksBeta' ) && !$settings->getSetting( 'otherProjectsLinksByDefault' ) || + count( $siteIdsToOutput ) === 0 + ) { return true; } @@ -641,6 +645,65 @@ } /** + * Filters the display of "other project" sidebar according to the beta feature + * + * @since 0.5 + * + * @param Skin $skin + * @param array $sidebar + * + * @return bool + */ + public static function onSidebarBeforeOutput( Skin $skin, array &$sidebar ) { + $settings = WikibaseClient::getDefaultInstance()->getSettings(); + if ( + $settings->getSetting( 'otherProjectsLinksBeta' ) && + !$settings->getSetting( 'otherProjectsLinksByDefault' ) && + class_exists( '\BetaFeatures' ) && + !BetaFeatures::isFeatureEnabled( $skin->getUser(), 'wikibase-otherprojects' ) + ) { + unset( $sidebar['wikibase-otherprojects'] ); + } + + return true; + } + + /** + * Initialise beta feature preferences + * + * @since 0.5 + * + * @param User $user + * @param array $betaPreferences + * + * @return bool + */ + public static function onGetBetaFeaturePreferences( User $user, array &$betaPreferences ) { + global $wgExtensionAssetsPath; + + $remoteExtPathParts = explode( DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR , __DIR__, 2 ); + $assetsPath = $wgExtensionAssetsPath . '/' . $remoteExtPathParts[1]; + + $settings = WikibaseClient::getDefaultInstance()->getSettings(); + if ( !$settings->getSetting( 'otherProjectsLinksBeta' ) || $settings->getSetting( 'otherProjectsLinksByDefault' ) ) { + return true; + } + + $betaPreferences['wikibase-otherprojects'] = array( + 'label-message' => 'wikibase-otherprojects-beta-message', + 'desc-message' => 'wikibase-otherprojects-beta-description', + 'screenshot' => array( + 'ltr' => $assetsPath . '/resources/images/wb-otherprojects-beta-ltr.png', + 'rtl' => $assetsPath . '/resources/images/wb-otherprojects-beta-rtl.png' + ), + 'info-link' => 'https://www.mediawiki.org/wiki/Wikibase/Beta_Features/Other_projects_sidebar', + 'discussion-link' => 'https://www.mediawiki.org/wiki/Talk:Wikibase/Beta_Features/Other_projects_sidebar' + ); + + return true; + } + + /** * Adds a toggle for showing/hiding Wikidata entries in recent changes * * @param SpecialRecentChanges $special diff --git a/client/WikibaseClient.php b/client/WikibaseClient.php index 4efa0c7..5f775b8 100644 --- a/client/WikibaseClient.php +++ b/client/WikibaseClient.php @@ -111,6 +111,8 @@ $wgHooks['InfoAction'][] = '\Wikibase\ClientHooks::onInfoAction'; $wgHooks['TitleMoveComplete'][] = '\Wikibase\ClientHooks::onTitleMoveComplete'; $wgHooks['BaseTemplateAfterPortlet'][] = '\Wikibase\ClientHooks::onBaseTemplateAfterPortlet'; + $wgHooks['GetBetaFeaturePreferences'][] = '\Wikibase\ClientHooks::onGetBetaFeaturePreferences'; + $wgHooks['SidebarBeforeOutput'][] = '\Wikibase\ClientHooks::onSidebarBeforeOutput'; // extension hooks $wgHooks['WikibaseDeleteData'][] = '\Wikibase\ClientHooks::onWikibaseDeleteData'; diff --git a/client/config/WikibaseClient.default.php b/client/config/WikibaseClient.default.php index fd91e61..7bb6780 100644 --- a/client/config/WikibaseClient.default.php +++ b/client/config/WikibaseClient.default.php @@ -38,6 +38,8 @@ 'allowDataTransclusion' => true, 'propagateChangesToRepo' => true, 'otherProjectsLinks' => array(), + 'otherProjectsLinksByDefault' => false, + 'otherProjectsLinksBeta' => false, // List of additional CSS class names for site links that have badges, e.g. // array( 'Q101' => 'wb-badge-goldstar' ). 'badgeClassNames' => array(), diff --git a/client/i18n/en.json b/client/i18n/en.json index 660763a..bda97dc 100644 --- a/client/i18n/en.json +++ b/client/i18n/en.json @@ -62,5 +62,7 @@ "wikibase-pageinfo-entity-id": "{{WBREPONAME}} item ID", "wikibase-pageinfo-entity-id-none": "None", "wikibase-property-render-error": "Failed to render property $1: $2", - "wikibase-otherprojects": "Other projects" + "wikibase-otherprojects": "Other projects", + "wikibase-otherprojects-beta-message": "Other projects sidebar", + "wikibase-otherprojects-beta-description": "Adds a \"{{int:wikibase-otherprojects}}\" section to the sidebar that provides links to the other Wikimedia projects based on {{WBREPONAME}} data." } diff --git a/client/i18n/qqq.json b/client/i18n/qqq.json index e3a0403..f4f6848 100644 --- a/client/i18n/qqq.json +++ b/client/i18n/qqq.json @@ -67,5 +67,7 @@ "wikibase-pageinfo-entity-id": "A link to the corresponding Wikibase Item", "wikibase-pageinfo-entity-id-none": "The page is not linked with a wikibase item.\n{{Identical|None}}", "wikibase-property-render-error": "Error message shown when the #property parser function fails to render a property value.\n\nParameters:\n* $1 - the property ID or name\n* $2 - the original error message (this is typically in English and may be rather technical)", - "wikibase-otherprojects": "Label of the sidebar section containing links to other projects.\n{{Identical|Other project}}" + "wikibase-otherprojects": "Label of the sidebar section containing links to other projects.\n{{Identical|Other project}}", + "wikibase-otherprojects-beta-message": "Used as checkbox label for the \"other projects\" beta feature.\n\nThe description for this label is {{msg-mw|wikibase-otherprojects-beta-description}}", + "wikibase-otherprojects-beta-description": "Description for the \"other projects\" beta feature.\n\nThis description is for the checkbox label {{msg-mw|wikibase-otherprojects-beta-label}}." } diff --git a/client/resources/images/wb-otherprojects-beta-ltr.png b/client/resources/images/wb-otherprojects-beta-ltr.png new file mode 100644 index 0000000..30f9cb1 --- /dev/null +++ b/client/resources/images/wb-otherprojects-beta-ltr.png Binary files differ diff --git a/client/resources/images/wb-otherprojects-beta-ltr.svg b/client/resources/images/wb-otherprojects-beta-ltr.svg new file mode 100644 index 0000000..1af7315 --- /dev/null +++ b/client/resources/images/wb-otherprojects-beta-ltr.svg @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg width="264px" height="162px" viewBox="0 0 264 162" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns"> + <!-- Generator: Sketch 3.0.1 (7597) - http://www.bohemiancoding.com/sketch --> + <title>Slice 1</title> + <description>Created with Sketch.</description> + <defs/> + <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage"> + <g id="Group" sketch:type="MSLayerGroup"> + <path d="M24.833,151.362 L13.366,161.357 L0.5,151.749 L0.5,0.5 L263.5,0.5 L263.5,152.249 L254.5,158.954 L254.5,42.5 L215.5,42.5 L215.5,155.1 L211.107,151.369 L203.5,156.699 L203.5,42.5 L48.5,42.5 L48.5,153.349 L38.749,161.38 L24.833,151.362 Z" id="Shape" fill="#FFFFFF" sketch:type="MSShapeGroup"/> + <path d="M263,1 L263,151.998 L255,157.958 L255,43 L255,42 L254,42 L216,42 L215,42 L215,43 L215,154.019 L211.726,151.24 L211.137,150.741 L210.504,151.181 L204,155.738 L204,43 L204,42 L203,42 L49,42 L48,42 L48,43 L48,153.099 L38.743,160.76 L25.448,151.191 L24.804,150.726 L24.206,151.247 L13.342,160.717 L1,151.499 L1,1 L263,1 L263,1 Z M264,0 L0,0 L0,152 L13.391,162 L24.864,152 L38.755,162 L49,153.6 L49,43 L203,43 L203,157.66 L211.078,152 L216,156.18 L216,43 L254,43 L254,159.95 L264,152.5 L264,0 L264,0 L264,0 L264,0 Z" id="Shape" fill="#E5E5E5" sketch:type="MSShapeGroup"/> + </g> + <path d="M203,157.66 L203,43 L49,43 L49,153.6 L51.145,152 L63.7,162 L77.509,152 L91.738,162 L104.71,152 L117.683,162 L131.494,152 L143.63,162 L157.021,152 L171.25,162 L184.222,152 L197.196,162 L203,157.66 L203,157.66 L203,157.66 L203,157.66 Z" id="Shape" fill="#E5E5E5" sketch:type="MSShapeGroup"/> + <path d="M11,36 C11,28.268 17.268,22 25,22 C32.732,22 39,28.268 39,36 C39,43.732 32.732,50 25,50 C17.268,50 11,43.732 11,36 C11,36 11,43.732 11,36 L11,36 L11,36 Z" id="Ellipse" fill="#E5E5E5" sketch:type="MSShapeGroup"/> + <path d="M254,159.95 L254,43 L216,43 L216,156.18 L223.551,162 L237.362,152 L251.253,162 L254,159.95 L254,159.95 L254,159.95 L254,159.95 Z" id="Shape" fill="#E5E5E5" sketch:type="MSShapeGroup"/> + <path d="M38,99 L38,72 L13,72 L13,99 L38,99 L38,99 L38,99 L38,99 Z" id="Shape" fill="#E5E5E5" sketch:type="MSShapeGroup"/> + <path d="M38,136 L38,120 L13,120 L13,136 L38,136 L38,136 L38,136 L38,136 Z" id="Shape-2" fill="#E5E5E5" sketch:type="MSShapeGroup"/> + <path d="M38,117 L38,101 L13,101 L13,117 L38,117 L38,117 L38,117 L38,117 Z" id="Shape-3" fill="#347BFF" sketch:type="MSShapeGroup"/> + <path d="M233,5 L259,5 L259,11 L233,11 L233,5 L233,5 L233,5 L233,5 Z" id="Shape" fill="#E5E5E5" sketch:type="MSShapeGroup"/> + <path d="M142,6 L142,10 L50,10 L50,6 L142,6 L142,6 Z M143,5 L49,5 L49,11 L143,11 L143,5 L143,5 L143,5 L143,5 Z" id="Shape" fill="#E5E5E5" sketch:type="MSShapeGroup"/> + <rect id="Rectangle" fill="#E5E5E5" sketch:type="MSShapeGroup" x="9" y="5" width="32" height="6"/> + <path d="M2,15 L262,15" id="Shape" stroke="#E5E5E5" fill="#E5E5E5" sketch:type="MSShapeGroup"/> + <rect id="Rectangle" fill="#E5E5E5" sketch:type="MSShapeGroup" x="52" y="7" width="2" height="2"/> + <path d="M38,59 L38,54 L13,54 L13,59 L38,59 L38,59 L38,59 L38,59 Z" id="Shape" fill="#E5E5E5" sketch:type="MSShapeGroup"/> + <path d="M228.51,5 L228.51,11 L216,11 L216,5 L228.51,5 Z" id="Path-3" fill="#D8D8D8" sketch:type="MSShapeGroup"/> + <path d="M212.51,5 L212.51,11 L200,11 L200,5 L212.51,5 Z" id="Path-2" fill="#D8D8D8" sketch:type="MSShapeGroup"/> + <path d="M196.51,5 L196.51,11 L184,11 L184,5 L196.51,5 Z" id="Path-4" fill="#D8D8D8" sketch:type="MSShapeGroup"/> + <g id="Triangle-1-+-Rectangle-23" sketch:type="MSLayerGroup" transform="translate(34.000000, 104.500000) rotate(-315.000000) translate(-34.000000, -104.500000) translate(31.000000, 102.000000)" fill="#FFFFFF"> + <polygon id="Triangle-1" sketch:type="MSShapeGroup" points="3 0 6 3 0 3 "/> + <rect id="Rectangle-23" sketch:type="MSShapeGroup" x="2" y="2.5" width="2" height="2.5"/> + </g> + <g id="Triangle-1-+-Rectangle-26" sketch:type="MSLayerGroup" transform="translate(34.000000, 112.500000) rotate(-225.000000) translate(-34.000000, -112.500000) translate(31.000000, 110.000000)" fill="#FFFFFF"> + <polygon id="Triangle-1" sketch:type="MSShapeGroup" points="3 0 6 3 0 3 "/> + <rect id="Rectangle-23" sketch:type="MSShapeGroup" x="2" y="2.5" width="2" height="2.5"/> + </g> + <g id="Triangle-1-+-Rectangle-24" sketch:type="MSLayerGroup" transform="translate(17.000000, 112.500000) rotate(-135.000000) translate(-17.000000, -112.500000) translate(14.000000, 110.000000)" fill="#FFFFFF"> + <polygon id="Triangle-1" sketch:type="MSShapeGroup" points="3 0 6 3 0 3 "/> + <rect id="Rectangle-23" sketch:type="MSShapeGroup" x="2" y="2.5" width="2" height="2.5"/> + </g> + <g id="Triangle-1-+-Rectangle-25" sketch:type="MSLayerGroup" transform="translate(17.000000, 104.500000) rotate(-45.000000) translate(-17.000000, -104.500000) translate(14.000000, 102.000000)" fill="#FFFFFF"> + <polygon id="Triangle-1" sketch:type="MSShapeGroup" points="3 0 6 3 0 3 "/> + <rect id="Rectangle-23" sketch:type="MSShapeGroup" x="2" y="2.5" width="2" height="2.5"/> + </g> + <circle id="Oval-2" fill="#FFFFFF" sketch:type="MSShapeGroup" cx="25.5" cy="108.5" r="3.5"/> + </g> +</svg> \ No newline at end of file diff --git a/client/resources/images/wb-otherprojects-beta-rtl.png b/client/resources/images/wb-otherprojects-beta-rtl.png new file mode 100644 index 0000000..30d038f --- /dev/null +++ b/client/resources/images/wb-otherprojects-beta-rtl.png Binary files differ -- To view, visit https://gerrit.wikimedia.org/r/150197 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib4014253016db1c3d6b624be9ebbdaf452115145 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: mw1.24-wmf14 Gerrit-Owner: Hoo man <h...@online.de> Gerrit-Reviewer: Hoo man <h...@online.de> Gerrit-Reviewer: Siebrand <siebr...@kitano.nl> Gerrit-Reviewer: Tpt <thoma...@hotmail.fr> Gerrit-Reviewer: WikidataJenkins <wikidata-servi...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits