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

Change subject: Hygiene: Correctly show relationship between desktop and mobile 
page
......................................................................


Hygiene: Correctly show relationship between desktop and mobile page

Instead of disallow indexing of mobile pages, correctly show the relationship
between a mobile and desktop URL.

Fix: Don't add anything (no link and no robots policy), if mobile and desktop
url doesn't differ.

Bug: T91183
Change-Id: Ice3e67ddbb81e13c050c9d0301c24fca15e158c3
---
M includes/MobileFrontend.hooks.php
1 file changed, 35 insertions(+), 2 deletions(-)

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



diff --git a/includes/MobileFrontend.hooks.php 
b/includes/MobileFrontend.hooks.php
index baaee6c..d9a684d 100644
--- a/includes/MobileFrontend.hooks.php
+++ b/includes/MobileFrontend.hooks.php
@@ -633,11 +633,44 @@
                        $out->addLink( array( 'rel' => 'alternate', 'href' => 
$hreflink ) );
                }
 
+               $config = $context->getMFConfig();
+               $mfNoIndexPages = $config->get( 'MFNoindexPages' );
+               $mfMobileUrlTemplate = $config->get( 'MobileUrlTemplate' );
+               $tabletSize = $config->get( 'MFDeviceWidthTablet' );
+               // an alternate link is only useful, if the mobile and desktop 
URL are different
+               // and $wgMFNoindexPages needs to be true
+               // add alternate link to desktop sites - bug T91183
+               if ( $mfMobileUrlTemplate && $mfNoIndexPages ) {
+                       $desktopUrl = $context->getTitle()->getFullUrl();
+                       $out->addHeadItem(
+                               'mobilelink',
+                               Html::element(
+                                       'link',
+                                       array(
+                                               'rel' => 'alternate',
+                                               'media' => 'only screen and 
(max-width: ' . $tabletSize . 'px)',
+                                               'href' => 
$context->getMobileUrl( $desktopUrl ),
+                                       )
+                               )
+                       );
+               }
                if ( !$context->shouldDisplayMobileView() ) {
                        return true;
                }
-               if ( $context->getMFConfig()->get( 'MFNoindexPages' ) ) {
-                       $out->setRobotPolicy( 'noindex,nofollow' );
+               // an canonical link is only useful, if the mobile and desktop 
URL are different
+               // and $wgMFNoindexPages needs to be true
+               // add canonical link to mobile pages, instead of noindex - bug 
T91183
+               if ( $mfMobileUrlTemplate && $mfNoIndexPages ) {
+                       $out->addHeadItem(
+                               'desktoplink',
+                               Html::element(
+                                       'link',
+                                       array(
+                                               'rel' => 'canonical',
+                                               'href' => 
$context->getTitle()->getFullUrl(),
+                                       )
+                               )
+                       );
                }
 
                // Set X-Analytics HTTP response header if necessary

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ice3e67ddbb81e13c050c9d0301c24fca15e158c3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: Daniel Friesen <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: MaxSem <[email protected]>
Gerrit-Reviewer: Phuedx <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to