Denny Vrandecic has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/112921

Change subject: (bug 60537) Adds a deep link to a mobile app if so configured
......................................................................

(bug 60537) Adds a deep link to a mobile app if so configured

Adds, if an App-ID is configured, a link to the respective
page in order to allow deep linking from the Web to a
mobile app, like the Wikipedia app, as per
https://developers.google.com/app-indexing/webmasters/details
If no App-ID is configured, no link will be created.

Change-Id: Icadc7ab1e050e1e3d28cbd9d41c1b35b42e3fcca
---
M MobileFrontend.php
M includes/MobileFrontend.hooks.php
2 files changed, 24 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/21/112921/1

diff --git a/MobileFrontend.php b/MobileFrontend.php
index a6b6c71..7189123 100644
--- a/MobileFrontend.php
+++ b/MobileFrontend.php
@@ -464,3 +464,14 @@
  * Controls whether the "Minerva as a desktop skin" beta feature is enabled
  */
 $wgMFEnableMinervaBetaFeature = false;
+
+/**
+ * ID of the App to deep link to replacing the browser. Set 'false' to have no 
such link.
+ * See https://developers.google.com/app-indexing/webmasters/details
+ */
+$wgMFAppPackageId = false;
+
+/**
+ * Scheme to use for the deep link. Per default, 'http' is used.
+ */
+$wgMFAppScheme = 'http';
diff --git a/includes/MobileFrontend.hooks.php 
b/includes/MobileFrontend.hooks.php
index f4b2afe..d549d6b 100644
--- a/includes/MobileFrontend.hooks.php
+++ b/includes/MobileFrontend.hooks.php
@@ -510,10 +510,22 @@
         * @return bool
         */
        public static function onBeforePageDisplay( &$out, &$sk ) {
-               global $wgMFEnableXAnalyticsLogging;
+               global $wgMFEnableXAnalyticsLogging,
+                         $wgMFAppPackageId, $wgMFAppScheme;;
                wfProfileIn( __METHOD__ );
 
                $context = MobileContext::singleton();
+
+               # Add deep link to a mobile app specified by $wgMFAppScheme
+               if ( $wgMFAppPackageId !== false ) {
+                       $scheme = isset($wgMFAppScheme) ? $wgMFAppScheme : 
'http';
+                       $title = $sk->getTitle();
+                       $path = $title->getFullURL( $args );
+                       $path = $context->getMobileUrl( $path );
+                       $hreflink = 'android-app://' . $wgMFAppPackageId . '/' 
. $scheme . '/' . $path;
+                       $out->addLink( array( 'rel' => 'alternate', 'href' => 
$hreflink ) );
+               }
+
                if ( !$context->shouldDisplayMobileView() ) {
                        if ( class_exists( 'BetaFeatures' ) &&
                                BetaFeatures::isFeatureEnabled( 
$out->getSkin()->getUser(), 'betafeatures-geonotahack' ) ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icadc7ab1e050e1e3d28cbd9d41c1b35b42e3fcca
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Denny Vrandecic <vrande...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to