Jdlrobson has uploaded a new change for review.

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


Change subject: Bug 51924: Special case main page history link
......................................................................

Bug 51924: Special case main page history link

Change-Id: Ie223558ba9078424b2406f667639c3fc7b5077f2
---
M MobileFrontend.i18n.php
M includes/skins/SkinMobile.php
M javascripts/modules/mf-last-modified.js
3 files changed, 20 insertions(+), 10 deletions(-)


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

diff --git a/MobileFrontend.i18n.php b/MobileFrontend.i18n.php
index 2a6b3e4..ca70ff5 100644
--- a/MobileFrontend.i18n.php
+++ b/MobileFrontend.i18n.php
@@ -67,6 +67,7 @@
        'mobile-frontend-username-placeholder' => 'Username',
        'mobile-frontend-password-placeholder' => 'Password',
        'mobile-frontend-login' => 'Sign in',
+       'mobile-frontend-history' => 'View edit history of this page.',
        'mobile-frontend-last-modified-date' => 'Last modified on $1, at $2',
        'mobile-frontend-last-modified-seconds' => 'Last modified 
{{PLURAL:$1|$1 second|$1 seconds}} ago',
        'mobile-frontend-last-modified-minutes' => 'Last modified 
{{PLURAL:$1|$1 minute|$1 minutes}} ago',
@@ -398,6 +399,7 @@
 {{Identical|Password}}',
        'mobile-frontend-login' => 'Button text for login in Wikimedia mobile 
user interface.
 {{Identical|Log in}}',
+       'mobile-frontend-history' => 'This is shown on the Main Page in place 
of a last modified label to avoid confusion caused by transclusions.',
        'mobile-frontend-last-modified-date' => 'Text that displays the date 
the page was last modified. Parameters:
 * $1 - date
 * $2 - time
diff --git a/includes/skins/SkinMobile.php b/includes/skins/SkinMobile.php
index 0944f95..c5b54a8 100644
--- a/includes/skins/SkinMobile.php
+++ b/includes/skins/SkinMobile.php
@@ -336,6 +336,7 @@
        function prepareTemplatePageContent( QuickTemplate $tpl ) {
                $title = $this->getTitle();
                $isSpecialPage = $title->isSpecialPage();
+               $isMainPage = $title->isMainPage();
                $user = $this->getUser();
                $ctx = MobileContext::singleton();
 
@@ -344,15 +345,18 @@
                        // add last modified timestamp
                        $revId = $this->getRevisionId();
                        $timestamp = Revision::getTimestampFromId( 
$this->getTitle(), $revId );
-                       $lastModified = wfMessage( 
'mobile-frontend-last-modified-date',
-                               $this->getLanguage()->userDate( $timestamp, 
$user ),
-                               $this->getLanguage()->userTime( $timestamp, 
$user )
-                       )->parse();
+                       // Main pages tend to include transclusions (see bug 
51924)
+                       $lastModified = $isMainPage ?
+                               wfMessage( 'mobile-frontend-history' ) :
+                               wfMessage( 'mobile-frontend-last-modified-date',
+                                       $this->getLanguage()->userDate( 
$timestamp, $user ),
+                                       $this->getLanguage()->userTime( 
$timestamp, $user ) )->parse();
+
                        $timestamp = wfTimestamp( TS_UNIX, $timestamp );
                        $historyUrl = $ctx->getMobileUrl( $title->getFullURL( 
'action=history' ) );
                        $historyLink = array(
                                'id' => 'mw-mf-last-modified',
-                               'data-timestamp' => $timestamp,
+                               'data-timestamp' => $isMainPage ? '' : 
$timestamp,
                                'href' => $historyUrl,
                                'text' => $lastModified,
                        );
diff --git a/javascripts/modules/mf-last-modified.js 
b/javascripts/modules/mf-last-modified.js
index a8d27d4..d7729d6 100644
--- a/javascripts/modules/mf-last-modified.js
+++ b/javascripts/modules/mf-last-modified.js
@@ -22,6 +22,7 @@
         */
        function init() {
                var $lastModified = $( '#mw-mf-last-modified' ),
+                       ts = $lastModified.data( 'timestamp' ),
                        keys = {
                                seconds: 
'mobile-frontend-last-modified-seconds',
                                minutes: 
'mobile-frontend-last-modified-minutes',
@@ -30,12 +31,15 @@
                                months: 'mobile-frontend-last-modified-months',
                                years: 'mobile-frontend-last-modified-years'
                        },
-                       pageTimestamp = parseInt( $lastModified.data( 
'timestamp' ), 10 ),
-                       currentTimestamp = Math.round( new Date().getTime() / 
1000 ),
-                       delta = timeAgo( currentTimestamp - pageTimestamp ),
-                       message = mw.msg( keys[ delta.unit ], delta.value );
+                       message, pageTimestamp, currentTimestamp, delta;
 
-               $lastModified.text( message );
+               if ( ts ) {
+                       pageTimestamp = parseInt( ts, 10 );
+                       currentTimestamp = Math.round( new Date().getTime() / 
1000 );
+                       delta = timeAgo( currentTimestamp - pageTimestamp );
+                       message = mw.msg( keys[ delta.unit ], delta.value );
+                       $lastModified.text( message );
+               }
        }
        M.on( 'page-loaded', init );
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie223558ba9078424b2406f667639c3fc7b5077f2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>

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

Reply via email to