Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/90443
Change subject: Story 1262: Adding user to last modified
......................................................................
Story 1262: Adding user to last modified
A second pass at Kaldari's 1st attempt on this tricky piece
of coding. This one only adds the user profile with JavaScript which
simplifies the i18n messages somewhat.
Also breaks out common functionality between lastModified in beta
and stable and ensures they do not run at the same time.
Minimal changes to the skin itself.
TODO: Make lazy loaded pages work.
Also changing sibling-link class to return-link since the history
link is no longer a block element, i.e. it is no longer a shared
CSS class.
Change-Id: I0874956d593c02bea38d45eafebbba781dc5ab9a
---
M MobileFrontend.i18n.php
M includes/Resources.php
M includes/skins/MinervaTemplate.php
M includes/skins/SkinMinerva.php
M includes/skins/SkinMobile.php
M includes/skins/SkinMobileBeta.php
A javascripts/modules/lastEdited/lastEdited.js
A javascripts/modules/lastEdited/lastEditedBeta.js
A javascripts/modules/lastEdited/time.js
D javascripts/modules/lastModifiedBeta.js
D javascripts/modules/mf-last-modified.js
M less/common/common.less
12 files changed, 325 insertions(+), 113 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/43/90443/1
diff --git a/MobileFrontend.i18n.php b/MobileFrontend.i18n.php
index 0ec6ab5..868dad6 100644
--- a/MobileFrontend.i18n.php
+++ b/MobileFrontend.i18n.php
@@ -77,13 +77,22 @@
'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',
- 'mobile-frontend-last-modified-hours' => 'Last modified {{PLURAL:$1|$1
hour|$1 hours}} ago',
- 'mobile-frontend-last-modified-days' => 'Last modified {{PLURAL:$1|$1
day|$1 days}} ago',
- 'mobile-frontend-last-modified-months' => 'Last modified {{PLURAL:$1|$1
month|$1 months}} ago',
- 'mobile-frontend-last-modified-years' => 'Last modified {{PLURAL:$1|$1
year|$1 years}} ago',
+ 'mobile-frontend-last-modified-date' => 'Last edited on $1, at $2',
+ 'mobile-frontend-last-modified-seconds' => 'Last edited {{PLURAL:$1|$1
second|$1 seconds}} ago',
+ 'mobile-frontend-last-modified-minutes' => 'Last edited {{PLURAL:$1|$1
minute|$1 minutes}} ago',
+ 'mobile-frontend-last-modified-hours' => 'Last edited {{PLURAL:$1|$1
hour|$1 hours}} ago',
+ 'mobile-frontend-last-modified-days' => 'Last edited {{PLURAL:$1|$1
day|$1 days}} ago',
+ 'mobile-frontend-last-modified-months' => 'Last edited {{PLURAL:$1|$1
month|$1 months}} ago',
+ 'mobile-frontend-last-modified-years' => 'Last edited {{PLURAL:$1|$1
year|$1 years}} ago',
+ 'mobile-frontend-last-modified-just-now' => 'Last edited just now',
+ 'mobile-frontend-last-modified-with-user-date' => '<a $5>Last
{{GENDER:$4|edited}}</a> on $1, at $2 by $3',
+ 'mobile-frontend-last-modified-with-user-seconds' => '[$4 Last
{{GENDER:$1|edited}}] {{PLURAL:$5|by [$6 $2]|0=by an anonymous user}}
{{PLURAL:$3|$3 second|$3 seconds}} ago.',
+ 'mobile-frontend-last-modified-with-user-minutes' => '[$4 Last
{{GENDER:$1|edited}}] {{PLURAL:$5|by [$6 $2]|0=by an anonymous user}}
{{PLURAL:$3|$3 minute|$3 minutes}} ago.',
+ 'mobile-frontend-last-modified-with-user-hours' => '[$4 Last
{{GENDER:$1|edited}}] {{PLURAL:$5|by [$6 $2]|0=by an anonymous user}}
{{PLURAL:$3|$3 hour|$3 hours}} ago.',
+ 'mobile-frontend-last-modified-with-user-days' => '[$4 Last
{{GENDER:$1|edited}}] {{PLURAL:$5|by [$6 $2]|0=by an anonymous user}}
{{PLURAL:$3|$3 day|$3 days}} ago.',
+ 'mobile-frontend-last-modified-with-user-months' => '[$4 Last
{{GENDER:$1|edited}}] {{PLURAL:$5|by [$6 $2]|0=by an anonymous user}}
{{PLURAL:$3|$3 month|$3 months}} ago.',
+ 'mobile-frontend-last-modified-with-user-years' => '[$4 Last
{{GENDER:$1|edited}}] {{PLURAL:$5|by [$6 $2]|0=by an anonymous user}}
{{PLURAL:$3|$3 year|$3 years}} ago.',
+ 'mobile-frontend-last-modified-with-user-just-now' => '[$4 Last
{{GENDER:$1|edited}}] just now {{PLURAL:$5|by [$6 $2]|0=by an anonymous
user}}.',
'mobile-frontend-learn-more' => 'Learn more',
// account creation
'mobile-frontend-account-create-submit' => 'Sign up',
@@ -485,6 +494,61 @@
'mobile-frontend-last-modified-years' => 'Text displayed on page to
show how long ago the page was updated. Parameters:
* $1 - number of years
{{Related|Mobile-frontend-last-modified}}',
+ 'mobile-frontend-last-modified-just-now' => 'Text displayed on page to
show that the page was edited within the last few seconds.',
+ 'mobile-frontend-last-modified-with-user-date' => 'Text that displays
the date the page was last modified and who modified it. Parameters:
+* $1 - date
+* $2 - time
+* $3 - link to user profile
+* $4 - gender of user who performed the edit
+* $5 - parameters for link to page history',
+ 'mobile-frontend-last-modified-with-user-seconds' => "Text displayed on
page to show how long ago the page was updated and who updated it. Parameters:
+* $1 - user's gender
+* $2 - username
+* $3 - number of seconds
+* $4 - link to page history
+* $5 - Integer. When 0 the user is anonymous. When 1 the user is named
+* $6 - link to user's profile.",
+ 'mobile-frontend-last-modified-with-user-minutes' => "Text displayed on
page to show how long ago the page was updated and who updated it. Parameters:
+* $1 - user's gender
+* $2 - username
+* $3 - number of minutes
+* $4 - link to page history
+* $5 - Integer. When 0 the user is anonymous. When 1 the user is named
+* $6 - link to user's profile.",
+ 'mobile-frontend-last-modified-with-user-hours' => "Text displayed on
page to show how long ago the page was updated and who updated it. Parameters:
+* $1 - user's gender
+* $2 - username
+* $3 - number of hours
+* $4 - link to page history
+* $5 - Integer. When 0 the user is anonymous. When 1 the user is named
+* $6 - link to user's profile.",
+ 'mobile-frontend-last-modified-with-user-days' => "Text displayed on
page to show how long ago the page was updated and who updated it. Parameters:
+* $1 - user's gender
+* $2 - username
+* $3 - number of days
+* $4 - link to page history
+* $5 - Integer. When 0 the user is anonymous. When 1 the user is named
+* $6 - link to user's profile.",
+ 'mobile-frontend-last-modified-with-user-months' => "Text displayed on
page to show how long ago the page was updated and who updated it. Parameters:
+* $1 - user's gender
+* $2 - username
+* $3 - number of months
+* $4 - link to page history
+* $5 - Integer. When 0 the user is anonymous. When 1 the user is named
+* $6 - link to user's profile.",
+ 'mobile-frontend-last-modified-with-user-years' => "Text displayed on
page to show how long ago the page was updated and who updated it. Parameters:
+* $1 - user's gender
+* $2 - username
+* $3 - number of years
+* $4 - link to page history
+* $5 - Integer. When 0 the user is anonymous. When 1 the user is named
+* $6 - link to user's profile.",
+ 'mobile-frontend-last-modified-with-user-just-now' => "Text displayed
on page to show when a page was very recently updated and who updated it.
Parameters:
+* $1 - user's gender
+* $2 - username
+* $4 - link to page history
+* $5 - Integer. When 0 the user is anonymous. When 1 the user is named
+* $6 - link to user's profile.",
'mobile-frontend-learn-more' => 'A caption of a button or a link
leading to details about a given piece of information.
{{Identical|Learn more}}',
'mobile-frontend-account-create-submit' => 'Text in account creation
submit button.
diff --git a/includes/Resources.php b/includes/Resources.php
index a25a471..7760565 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -339,8 +339,8 @@
'javascripts/modules/languages/preferred.js',
'javascripts/modules/tutorials/PageActionOverlay.js',
'javascripts/modules/tutorials/newbie.js',
- 'javascripts/modules/lastModifiedBeta.js',
'javascripts/modules/keepgoing/keepgoing.js',
+ 'javascripts/modules/lastEdited/lastEditedBeta.js',
),
'position' => 'bottom',
'messages' => array(
@@ -360,6 +360,16 @@
// notifications.js (defined in Echo)
'echo-none',
'notifications',
+
+ // LastEditedBeta.js
+ 'mobile-frontend-last-modified-with-user-seconds',
+ 'mobile-frontend-last-modified-with-user-minutes',
+ 'mobile-frontend-last-modified-with-user-hours',
+ 'mobile-frontend-last-modified-with-user-days',
+ 'mobile-frontend-last-modified-with-user-months',
+ 'mobile-frontend-last-modified-with-user-years',
+ 'mobile-frontend-last-modified-with-user-just-now',
+ 'mobile-frontend-anonymous-user',
),
),
@@ -521,6 +531,17 @@
'mobile-frontend-editor-edit',
// modules/editor/EditorOverlay.js and modules/talk.js
'mobile-frontend-editor-save',
+ // PageApi.js
+ 'mobile-frontend-last-modified-with-user-date',
+ ),
+ ),
+
+ 'mobile.lastEdited.stable' => $wgMFMobileResourceBoilerplate + array(
+ 'dependencies' => array(
+ 'mobile.stable',
+ ),
+ 'scripts' => array(
+ 'javascripts/modules/lastEdited/lastEdited.js',
),
),
@@ -538,7 +559,7 @@
'javascripts/modules/mf-toggle.js',
'javascripts/modules/issues/issues.js',
'javascripts/modules/languages/languages.js',
- 'javascripts/modules/mf-last-modified.js',
+ 'javascripts/modules/lastEdited/time.js',
'javascripts/modules/uploads/lead-photo-init.js',
'javascripts/modules/mainmenutweaks.js',
'javascripts/modules/search/search.js',
@@ -555,7 +576,7 @@
'mobile-frontend-meta-data-issues',
'mobile-frontend-meta-data-issues-header',
- // mf-last-modified.js
+ // lastEdited.js
'mobile-frontend-last-modified-seconds',
'mobile-frontend-last-modified-hours',
'mobile-frontend-last-modified-minutes',
@@ -563,6 +584,7 @@
'mobile-frontend-last-modified-days',
'mobile-frontend-last-modified-months',
'mobile-frontend-last-modified-years',
+ 'mobile-frontend-last-modified-just-now',
// leadphoto.js
'mobile-frontend-photo-upload-disabled',
diff --git a/includes/skins/MinervaTemplate.php
b/includes/skins/MinervaTemplate.php
index 08b5cea..132e1c2 100644
--- a/includes/skins/MinervaTemplate.php
+++ b/includes/skins/MinervaTemplate.php
@@ -1,10 +1,22 @@
<?php
class MinervaTemplate extends BaseTemplate {
+ /**
+ * @var Boolean
+ */
+ protected $isSpecialPage = false;
+ /**
+ * @var Boolean
+ */
+ protected $isMainPage = false;
+
public function getPersonalTools() {
return $this->data['personal_urls'];
}
public function execute() {
+ $title = $this->getSkin()->getTitle();
+ $this->isSpecialPage = $title->isSpecialPage();
+ $this->isMainPage = $title->isMainPage();
$this->getSkin()->prepareData( $this );
wfRunHooks( 'MinervaPreRender', array( $this ) );
$this->render( $this->data );
@@ -74,7 +86,7 @@
}
protected function renderFooter( $data ) {
- if ( !$this->getSkin()->getTitle()->isSpecialPage() ) {
+ if ( !$this->isSpecialPage ) {
?>
<div id="footer">
<?php
@@ -97,6 +109,10 @@
?></ul><?php
}
+ /**
+ * Outputs the 'Last edited' message, e.g. 'Last edited on...'
+ * @param Array $data Data used to build the page
+ */
protected function renderHistoryLink( $data ) {
if ( isset( $data['historyLink'] ) ) {
$historyLink = $data['historyLink'];
@@ -111,11 +127,10 @@
}
protected function renderContentWrapper( $data ) {
- $isSpecialPage = $this->getSkin()->getTitle()->isSpecialPage();
?>
<div id="content_wrapper">
<?php
- if ( !$isSpecialPage ) {
+ if ( !$this->isSpecialPage ) {
echo $data['prebodytext'];
// FIXME: Temporary solution until we
have design
if ( isset(
$data['_old_revision_warning'] ) ) {
@@ -170,7 +185,6 @@
}
protected function render( $data ) { // FIXME: replace with template
engines
- $isSpecialPage = $this->getSkin()->getTitle()->isSpecialPage();
// begin rendering
echo $data[ 'headelement' ];
@@ -190,7 +204,7 @@
<div class="header">
<?php
$this->html( 'menuButton' );
- if ( $isSpecialPage ) {
+ if ( $this->isSpecialPage ) {
echo
$data['specialPageHeader'];
} else {
?>
diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php
index 696942f..d20f1a7 100644
--- a/includes/skins/SkinMinerva.php
+++ b/includes/skins/SkinMinerva.php
@@ -186,6 +186,50 @@
);
}
+ /**
+ * Prepare the content for the 'last edited' message, e.g. 'Last edited
on 30 August
+ * 2013, at 23:31'. This message is different for the main page since
main page
+ * content is typically transcuded rather than edited directly.
+ * @param Title $title The Title object of the page being viewed
+ */
+ protected function getHistoryLink( Title $title ) {
+ $user = $this->getUser();
+ $isMainPage = $title->isMainPage();
+ // add last modified timestamp
+ $revId = $this->getRevisionId();
+ $timestamp = Revision::getTimestampFromId( $this->getTitle(),
$revId );
+ // Main pages tend to include transclusions (see bug 51924)
+ if ( $isMainPage ) {
+ $lastModified = wfMessage( 'mobile-frontend-history'
)->plain();
+ } else {
+ $lastModified = wfMessage(
+ 'mobile-frontend-last-modified-date',
+ $this->getLanguage()->userDate( $timestamp,
$user ),
+ $this->getLanguage()->userTime( $timestamp,
$user )
+ )->parse();
+ }
+ $unixTimestamp = wfTimestamp( TS_UNIX, $timestamp );
+ $historyUrl = $this->mobileContext->getMobileUrl(
$title->getFullURL( 'action=history' ) );
+ $link = array(
+ 'id' => 'mw-mf-last-modified',
+ 'data-timestamp' => $isMainPage ? '' : $unixTimestamp,
+ 'href' => $historyUrl,
+ 'text' => $lastModified,
+ );
+ $rev = Revision::newFromId( $this->getRevisionId() );
+ if ( $rev ) {
+ $userId = $rev->getUser();
+ if ( $userId ) {
+ $revUser = User::newFromId( $userId );
+ $link += array(
+ 'data-user-name' => $revUser->getName(),
+ 'data-user-gender' =>
$revUser->getOption( 'gender' ),
+ );
+ }
+ }
+ return $link;
+ }
+
public function prepareData( BaseTemplate $tpl ) {
global $wgMFEnableSiteNotice;
$title = $this->getTitle();
@@ -206,6 +250,11 @@
} else {
$preBodyText = Html::rawElement( 'h1', array( 'id' =>
'section_0' ), $pageHeading );
$tpl->set( 'prebodytext', $preBodyText );
+
+ // If it's a page that exists, add last edited timestamp
+ if ( $this->getWikiPage()->exists() ) {
+ $tpl->set( 'historyLink',
$this->getHistoryLink( $title ) );
+ }
}
// set defaults
@@ -370,6 +419,7 @@
$modules['watch'] = array();
$modules['search'] = array();
+ $modules['stableonly'] = array( 'mobile.lastEdited.stable' );
$title = $this->getTitle();
// modules based on context
diff --git a/includes/skins/SkinMobile.php b/includes/skins/SkinMobile.php
index 0a310ba..1d818c4 100644
--- a/includes/skins/SkinMobile.php
+++ b/includes/skins/SkinMobile.php
@@ -315,38 +315,13 @@
*/
function prepareTemplatePageContent( QuickTemplate $tpl ) {
$title = $this->getTitle();
- $isSpecialPage = $title->isSpecialPage();
- $isMainPage = $title->isMainPage();
- $user = $this->getUser();
- if ( !$isSpecialPage && $this->getWikiPage()->exists() ) {
-
- // add last modified timestamp
- $revId = $this->getRevisionId();
- $timestamp = Revision::getTimestampFromId(
$this->getTitle(), $revId );
- // 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 = $this->mobileContext->getMobileUrl(
$title->getFullURL( 'action=history' ) );
- $historyLink = array(
- 'id' => 'mw-mf-last-modified',
- 'data-timestamp' => $isMainPage ? '' :
$timestamp,
- 'href' => $historyUrl,
- 'text' => $lastModified,
- 'class' => 'sibling-page',
- );
- $tpl->set( 'historyLink', $historyLink );
- }
+ // If it's a talk page, add a link to the main namespace page
if ( $title->isTalkPage() ) {
$tpl->set( 'subject-page', Linker::link(
$title->getSubjectPage(),
wfMessage( 'mobile-frontend-talk-back-to-page',
$title->getText() ),
- array( 'class' => 'sibling-page' )
+ array( 'class' => 'return-link' )
) );
}
}
diff --git a/includes/skins/SkinMobileBeta.php
b/includes/skins/SkinMobileBeta.php
index 888f553..e835ade 100644
--- a/includes/skins/SkinMobileBeta.php
+++ b/includes/skins/SkinMobileBeta.php
@@ -17,6 +17,13 @@
$vars = parent::getSkinConfigVariables();
// force cta on in beta
$vars['wgMFEnablePhotoUploadCTA'] = true;
+ // Kill this when we fix the functionality in PageApi.js
+ $user = $this->getUser();
+ if ( $user->isLoggedIn() ) {
+ $vars['wgMFUserGender'] = $this->getUser()->getOption(
'gender' );
+ } else {
+ $vars['wgMFUserGender'] = 'unknown';
+ }
return $vars;
}
@@ -27,7 +34,8 @@
$modules['beta'][] = 'mobile.notifications.overlay';
}
$modules['beta'][] = 'mobile.geonotahack';
-
+ // turn off stable only modules
+ $modules['stableonly'] = array();
return $modules;
}
diff --git a/javascripts/modules/lastEdited/lastEdited.js
b/javascripts/modules/lastEdited/lastEdited.js
new file mode 100644
index 0000000..c66c44a
--- /dev/null
+++ b/javascripts/modules/lastEdited/lastEdited.js
@@ -0,0 +1,47 @@
+( function( M, $ ) {
+
+M.assertMode( [ 'stable' ] );
+var module = ( function() {
+ var time = M.require( 'modules/lastEdited/time' );
+
+ /**
+ * Initialisation function for last modified module.
+ *
+ * Enhances #mw-mf-last-modified element
+ * to show a human friendly date in seconds, minutes, hours, days
+ * months or years
+ *
+ */
+ 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',
+ hours: 'mobile-frontend-last-modified-hours',
+ days: 'mobile-frontend-last-modified-days',
+ months: 'mobile-frontend-last-modified-months',
+ years: 'mobile-frontend-last-modified-years'
+ },
+ message, delta;
+
+ if ( ts ) {
+ delta = time.getTimeAgoDelta( parseInt( ts, 10 ) );
+ if ( time.isNow( delta ) ) {
+ message = mw.msg(
'mobile-frontend-last-modified-just-now' );
+ } else {
+ message = mw.msg( keys[ delta.unit ],
mw.language.convertNumber( delta.value ) );
+ }
+ $lastModified.text( message );
+ }
+ }
+ M.on( 'page-loaded', init );
+
+ return {
+ init: init
+ };
+}() );
+
+M.define( 'last-modified', module );
+
+}( mw.mobileFrontend, jQuery ) );
diff --git a/javascripts/modules/lastEdited/lastEditedBeta.js
b/javascripts/modules/lastEdited/lastEditedBeta.js
new file mode 100644
index 0000000..5242924
--- /dev/null
+++ b/javascripts/modules/lastEdited/lastEditedBeta.js
@@ -0,0 +1,62 @@
+( function( M, $ ) {
+
+M.assertMode( [ 'beta', 'alpha' ] );
+
+var module = ( function() {
+ var time = M.require( 'modules/lastEdited/time' );
+
+ /**
+ * Initialisation function for last modified module.
+ *
+ * Enhances #mw-mf-last-modified element
+ * to show a human friendly date in seconds, minutes, hours, days
+ * months or years
+ *
+ */
+ function init() {
+ var $lastModified = $( '#mw-mf-last-modified' ),
+ historyUrl = $lastModified.attr( 'href' ),
+ ts = $lastModified.data( 'timestamp' ),
+ username = $lastModified.data( 'user-name' ) || false,
+ gender = $lastModified.data( 'user-gender' ),
+ keys = {
+ seconds:
'mobile-frontend-last-modified-with-user-seconds',
+ minutes:
'mobile-frontend-last-modified-with-user-minutes',
+ hours:
'mobile-frontend-last-modified-with-user-hours',
+ days:
'mobile-frontend-last-modified-with-user-days',
+ months:
'mobile-frontend-last-modified-with-user-months',
+ years:
'mobile-frontend-last-modified-with-user-years'
+ },
+ delta, args = [];
+
+ if ( ts ) {
+ delta = time.getTimeAgoDelta( parseInt( ts, 10 ) );
+ if ( time.isNow( delta ) ) {
+ args = args.concat( [
'mobile-frontend-last-modified-with-user-just-now', gender, username ] );
+ } else {
+ args = args.concat( [ keys[ delta.unit ],
gender, username,
+ mw.language.convertNumber(
delta.value ) ] );
+ }
+
+ args = args.concat( [ historyUrl,
+ // Abuse PLURAL support to determine if
the user is anonymous or not
+ mw.language.convertNumber( username ? 1
: 0 ),
+ // I'll abuse of PLURAL support means
we have to pass the relative URL rather than construct it from a wikilink
+ username ? mw.util.wikiGetlink(
'Special:UserProfile/' + username ) : '' ] );
+
+ $( '<div>' ).attr( 'id', 'mw-mf-last-modified' ).
+ html( mw.message.apply( this, args ).parse() ).
+ insertBefore( $lastModified );
+ $lastModified.remove();
+ }
+ }
+ M.on( 'page-loaded', init );
+
+ return {
+ init: init
+ };
+}() );
+
+M.define( 'last-modified-beta', module );
+
+}( mw.mobileFrontend, jQuery ) );
diff --git a/javascripts/modules/lastEdited/time.js
b/javascripts/modules/lastEdited/time.js
new file mode 100644
index 0000000..4d40741
--- /dev/null
+++ b/javascripts/modules/lastEdited/time.js
@@ -0,0 +1,28 @@
+( function( M ) {
+ var units = ['seconds', 'minutes', 'hours', 'days', 'months', 'years'],
+ limits = [1, 60, 3600, 86400, 2592000, 31536000];
+
+ function timeAgo( timestampDelta ) {
+ var i = 0;
+ while ( i < limits.length && timestampDelta > limits[i + 1] ) {
+ ++i;
+ }
+ return { value: Math.round( timestampDelta / limits[i] ), unit:
units[i] };
+ }
+
+ function getTimeAgoDelta( timestamp ) {
+ var currentTimestamp = Math.round( new Date().getTime() / 1000
),
+ delta = timeAgo( currentTimestamp - timestamp );
+ return delta;
+ }
+
+ function isNow( delta ) {
+ return delta.unit === 'seconds' && delta.value < 10;
+ }
+
+ M.define( 'modules/lastEdited/time', {
+ getTimeAgoDelta: getTimeAgoDelta,
+ isNow: isNow
+ } );
+
+}( mw.mobileFrontend ) );
diff --git a/javascripts/modules/lastModifiedBeta.js
b/javascripts/modules/lastModifiedBeta.js
deleted file mode 100644
index 347d9de..0000000
--- a/javascripts/modules/lastModifiedBeta.js
+++ /dev/null
@@ -1,11 +0,0 @@
-( function( M ) {
- var schema = M.require( 'loggingSchemas/MobileWebClickTracking' );
-
- function addClickTracking() {
- schema.hijackLink( '#mw-mf-last-modified', 'page-history' );
- }
-
- M.on( 'page-loaded', addClickTracking );
- addClickTracking();
-
-}( mw.mobileFrontend ) );
diff --git a/javascripts/modules/mf-last-modified.js
b/javascripts/modules/mf-last-modified.js
deleted file mode 100644
index 5b49414..0000000
--- a/javascripts/modules/mf-last-modified.js
+++ /dev/null
@@ -1,54 +0,0 @@
-( function( M, $ ) {
-
-var module = ( function() {
- var units = ['seconds', 'minutes', 'hours', 'days', 'months', 'years'],
- limits = [1, 60, 3600, 86400, 2592000, 31536000];
-
- function timeAgo( timestampDelta ) {
- var i = 0;
- while ( i < limits.length && timestampDelta > limits[i + 1] ) {
- ++i;
- }
- return { value: Math.round( timestampDelta / limits[i] ), unit:
units[i] };
- }
-
- /**
- * Initialisation function for last modified module.
- *
- * Enhances #mw-mf-last-modified element
- * to show a human friendly date in seconds, minutes, hours, days
- * months or years
- *
- */
- 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',
- hours: 'mobile-frontend-last-modified-hours',
- days: 'mobile-frontend-last-modified-days',
- months: 'mobile-frontend-last-modified-months',
- years: 'mobile-frontend-last-modified-years'
- },
- message, pageTimestamp, currentTimestamp, delta;
-
- if ( ts ) {
- pageTimestamp = parseInt( ts, 10 );
- currentTimestamp = Math.round( new Date().getTime() /
1000 );
- delta = timeAgo( currentTimestamp - pageTimestamp );
- message = mw.msg( keys[ delta.unit ],
mw.language.convertNumber( delta.value ) );
- $lastModified.text( message );
- }
- }
- M.on( 'page-loaded', init );
-
- return {
- timeAgo: timeAgo,
- init: init
- };
-}() );
-
-M.define( 'last-modified', module );
-
-}( mw.mobileFrontend, jQuery ) );
diff --git a/less/common/common.less b/less/common/common.less
index 7492b7a..2886ba0 100644
--- a/less/common/common.less
+++ b/less/common/common.less
@@ -136,11 +136,6 @@
border: 1px solid #ccc;
}
-.sibling-page {
- display: block;
- font-size: .9em;
- margin-top: 1.5em;
-}
/* Plainlinks - this can be used to switch
* off special external link styling */
@@ -198,6 +193,18 @@
div.magnify {
display: none;
}
+
+ .return-link,
+ #mw-mf-last-modified {
+ display: block;
+ }
+
+ .return-link,
+ #last-edited,
+ #mw-mf-last-modified {
+ font-size: .9em;
+ margin-top: 1.5em;
+ }
}
.jsonly {
--
To view, visit https://gerrit.wikimedia.org/r/90443
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0874956d593c02bea38d45eafebbba781dc5ab9a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: Kaldari <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits