From 8c2941673800513ad7136bd164b49729094c1c21 Mon Sep 17 00:00:00 2001 From: alistair3149 Date: Wed, 1 Jan 2025 15:34:09 -0500 Subject: [PATCH] =?UTF-8?q?feat(share):=20=E2=9C=A8=20do=20not=20show=20sh?= =?UTF-8?q?are=20button=20if=20page=20is=20not=20a=20content=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- includes/Components/CitizenComponentPageTools.php | 1 + resources/skins.citizen.scripts/share.js | 6 +----- templates/PageTools.mustache | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/includes/Components/CitizenComponentPageTools.php b/includes/Components/CitizenComponentPageTools.php index b9888572e..4d36ccb96 100644 --- a/includes/Components/CitizenComponentPageTools.php +++ b/includes/Components/CitizenComponentPageTools.php @@ -154,6 +154,7 @@ public function getTemplateData(): array { */ 'is-uls-ready' => false, 'int-language-count' => $this->numLanguages, + 'is-sharable' => $this->title->exists() && $this->title->isContentPage(), 'msg-citizen-share' => $this->localizer->msg( "citizen-share" )->text() ]; } diff --git a/resources/skins.citizen.scripts/share.js b/resources/skins.citizen.scripts/share.js index 85be716b3..c0d778260 100644 --- a/resources/skins.citizen.scripts/share.js +++ b/resources/skins.citizen.scripts/share.js @@ -4,13 +4,9 @@ * @return {void} */ function init() { - if ( !mw.config.get( 'wgIsArticle' ) ) { - return; - } - const shareButton = document.getElementById( 'citizen-share' ); if ( !shareButton ) { - mw.log.error( '[Citizen] Unable to find share button (#shareButton not found)' ); + // Citizen will not add the citizen-share element if the share button is undesirable return; } diff --git a/templates/PageTools.mustache b/templates/PageTools.mustache index da854dcdd..7c477172e 100644 --- a/templates/PageTools.mustache +++ b/templates/PageTools.mustache @@ -4,7 +4,7 @@ object data-page-actions }}
- {{>Share}} + {{#is-sharable}}{{>Share}}{{/is-sharable}} {{#has-languages}}{{>PageTools__languages}}{{/has-languages}} {{#is-visible}} {{#data-portlets.data-views}}{{>Menu}}{{/data-portlets.data-views}}