jenkins-bot has submitted this change and it was merged.

Change subject: Link to Special:Nearby out of the article
......................................................................


Link to Special:Nearby out of the article

If the article has coordinates.

Also cleanup rendering of page secondary section to make it easier
to add new link/button elements.

Bug: 72864
Change-Id: Id76fd55a6fcfe14870c44fdc599161f0e6d66c6a
---
M i18n/en.json
M i18n/qqq.json
M includes/skins/MinervaTemplate.php
M includes/skins/MinervaTemplateAlpha.php
M less/ui.less
5 files changed, 68 insertions(+), 12 deletions(-)

Approvals:
  Jdlrobson: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/i18n/en.json b/i18n/en.json
index 3abef62..7b301bf 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -185,6 +185,7 @@
        "mobile-frontend-nearby-requirements": "Sorry! Your web browser doesn't 
support {{SITENAME}} Nearby.",
        "mobile-frontend-nearby-requirements-guidance": "Try a different 
browser or enable JavaScript if you've disabled it.",
        "mobile-frontend-nearby-title": "Nearby",
+       "mobile-frontend-nearby-sectiontext": "Near this page",
        "mobile-frontend-news-items": "In the news",
        "mobile-frontend-opt-in-explain": "By joining the beta, you will get 
access to experimental features, at the risk of encountering bugs and issues.",
        "mobile-frontend-overlay-close": "Close",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 8daed67..73a85fc 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -212,6 +212,7 @@
        "mobile-frontend-nearby-requirements": "Message shown to users who have 
no JavaScript or a browser that is not capable",
        "mobile-frontend-nearby-requirements-guidance": "Message explaining 
actions user can take when keying error 
{{msg-mw|mobile-frontend-nearby-requirements}}",
        "mobile-frontend-nearby-title": "Title of 
[[Special:Nearby]].\n{{Identical|Nearby}}",
+       "mobile-frontend-nearby-sectiontext": "Name of the link, which links 
the user to [[Special:Nearby]] if the article has coordinates.",
        "mobile-frontend-news-items": "The title that will appear before the 
element with the mf-itn selector.",
        "mobile-frontend-opt-in-explain": "Used as description for the \"Beta\" 
in [[Special:MobileOptions]], if the beta is not enabled.",
        "mobile-frontend-overlay-close": "Text for the button in an overlay 
that, when clicked, dismisses the overlay.\n{{Identical|Close}}",
diff --git a/includes/skins/MinervaTemplate.php 
b/includes/skins/MinervaTemplate.php
index dce1a4f..0d1f41a 100644
--- a/includes/skins/MinervaTemplate.php
+++ b/includes/skins/MinervaTemplate.php
@@ -176,23 +176,39 @@
        }
 
        /**
-        * Render secondary page actions like language selector
+        * Get page secondary actions
         */
-       protected function renderMetaSections() {
-               echo Html::openElement( 'div', array( 'id' => 
'page-secondary-actions' ) );
+       protected function getSecondaryActions() {
+               $result = array();
 
-               // If languages are available, render a languages link
+               // If languages are available, add a languages link
                if ( $this->getLanguages() || $this->getLanguageVariants() ) {
                        $languageUrl = SpecialPage::getTitleFor(
                                'MobileLanguages',
                                $this->getSkin()->getTitle()
                        )->getLocalURL();
-                       $languageLabel = wfMessage( 
'mobile-frontend-language-article-heading' )->text();
 
+                       $result['language'] = array(
+                               'class' => 'languageSelector',
+                               'url' => $languageUrl,
+                               'label' => wfMessage( 
'mobile-frontend-language-article-heading' )->text()
+                       );
+               }
+
+               return $result;
+       }
+
+       /**
+        * Render secondary page actions like language selector
+        */
+       protected function renderSecondaryActions() {
+               echo Html::openElement( 'div', array( 'id' => 
'page-secondary-actions' ) );
+
+               foreach( $this->getSecondaryActions() as $el ) {
                        echo Html::element( 'a', array(
-                               'class' => 'mw-ui-button mw-ui-progressive 
button languageSelector',
-                               'href' => $languageUrl
-                       ), $languageLabel );
+                               'class' => 'mw-ui-button mw-ui-progressive 
button ' . $el['class'],
+                               'href' => $el['url']
+                       ), $el['label'] );
                }
 
                echo Html::closeElement( 'div' );
@@ -216,7 +232,7 @@
                                        echo $data['subject-page'];
                                }
                                echo $data[ 'bodytext' ];
-                               $this->renderMetaSections();
+                               $this->renderSecondaryActions();
                                $this->renderHistoryLinkBottom( $data );
                        ?>
                        </div>
diff --git a/includes/skins/MinervaTemplateAlpha.php 
b/includes/skins/MinervaTemplateAlpha.php
index 53cd771..580d1c9 100644
--- a/includes/skins/MinervaTemplateAlpha.php
+++ b/includes/skins/MinervaTemplateAlpha.php
@@ -32,10 +32,43 @@
        }
 
        /**
-        * Add categories section to Meta section in page
+        * Render secondary page actions
         */
-       protected function renderMetaSections() {
+       protected function renderSecondaryActions() {
+               // FIXME: This should be a button like language button (bug 
73008)
                $this->renderCategories();
-               parent::renderMetaSections();
+
+               parent::renderSecondaryActions();
+       }
+
+       /**
+        * Get button information to link to Special:Nearby to find articles
+        * (geographically) related to this
+        */
+       public function getNearbyButton() {
+               global $wgMFNearby;
+               $title = $this->getSkin()->getTitle();
+               $result = array();
+
+               if ( $wgMFNearby && class_exists( 'GeoData' ) && 
GeoData::getPageCoordinates( $title ) ) {
+                       $result['nearby'] = array(
+                               'url' => SpecialPage::getTitleFor( 'Nearby' 
)->getFullUrl() . '#/page/' . $title->getText(),
+                               'class' => 'nearbyButton',
+                               'label' => wfMessage( 
'mobile-frontend-nearby-sectiontext' )->text()
+                       );
+               }
+
+               return $result;
+       }
+
+       /**
+        * Get page secondary actions
+        */
+       protected function getSecondaryActions() {
+               $result = parent::getSecondaryActions();
+
+               $result += $this->getNearbyButton();
+
+               return $result;
        }
 }
diff --git a/less/ui.less b/less/ui.less
index a308c08..1c4487e 100644
--- a/less/ui.less
+++ b/less/ui.less
@@ -181,6 +181,11 @@
        }
 }
 
+#page-secondary-actions {
+       a {
+               margin: 10px 2px 2px 0;
+       }
+}
 .truncated-text {
        white-space: nowrap;
        overflow: hidden;

-- 
To view, visit https://gerrit.wikimedia.org/r/170431
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Id76fd55a6fcfe14870c44fdc599161f0e6d66c6a
Gerrit-PatchSet: 9
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: Awjrichards <[email protected]>
Gerrit-Reviewer: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to