jenkins-bot has submitted this change and it was merged.
Change subject: Hygiene: Standardise on time i10n parameter
......................................................................
Hygiene: Standardise on time i10n parameter
Change-Id: I6a5376ea131aea7cdcdefcdb71af4d8e415f9347
---
M handlebars/compiled/flow_block_topiclist.handlebars.php
M handlebars/compiled/flow_post.handlebars.php
M handlebars/flow_post_meta_actions.handlebars
M handlebars/flow_topic_titlebar_content.handlebars
M i18n/en.json
M includes/TemplateHelper.php
M modules/new/flow-handlebars.js
M tests/qunit/new/test_flow-handlebars.js
8 files changed, 37 insertions(+), 71 deletions(-)
Approvals:
Matthias Mullie: Looks good to me, approved
Jdlrobson: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/handlebars/compiled/flow_block_topiclist.handlebars.php
b/handlebars/compiled/flow_block_topiclist.handlebars.php
index 5ba0fe6..7872202 100644
--- a/handlebars/compiled/flow_block_topiclist.handlebars.php
+++ b/handlebars/compiled/flow_block_topiclist.handlebars.php
@@ -184,9 +184,9 @@
'.LCRun3::ch($cx, 'l10n',
Array(Array('flow-topic-comments',((is_array($in) && isset($in['reply_count']))
? $in['reply_count'] : null)),Array()), 'encq').' •
'.((LCRun3::ifvar($cx, ((is_array($in) && isset($in['last_updated'])) ?
$in['last_updated'] : null))) ? '
- <!--span class="wikiglyph wikiglyph-speech-bubbles"></span-->
'.LCRun3::ch($cx, 'timestamp', Array(Array(((is_array($in) &&
isset($in['last_updated'])) ? $in['last_updated'] :
null),'active_ago'),Array()), 'encq').'
+ <!--span class="wikiglyph wikiglyph-speech-bubbles"></span-->
'.LCRun3::ch($cx, 'timestamp', Array(Array(((is_array($in) &&
isset($in['last_updated'])) ? $in['last_updated'] :
null),'flow-active-ago'),Array()), 'encq').'
' : '
- <!--span class="wikiglyph wikiglyph-speech-bubble"></span-->
'.LCRun3::ch($cx, 'uuidTimestamp', Array(Array(((is_array($in) &&
isset($in['postId'])) ? $in['postId'] : null),'started_ago'),Array()), 'encq').'
+ <!--span class="wikiglyph wikiglyph-speech-bubble"></span-->
'.LCRun3::ch($cx, 'uuidTimestamp', Array(Array(((is_array($in) &&
isset($in['postId'])) ? $in['postId'] : null),'flow-started-ago'),Array()),
'encq').'
').'
</div>
<span class="flow-reply-count"><span class="wikiglyph
wikiglyph-speech-bubble"></span><span
class="flow-reply-count-number">'.htmlentities(((is_array($in) &&
isset($in['reply_count'])) ? $in['reply_count'] : null), ENT_QUOTES,
'UTF-8').'</span></span>
@@ -516,4 +516,4 @@
</div>
';
}
-?>
+?>
\ No newline at end of file
diff --git a/handlebars/compiled/flow_post.handlebars.php
b/handlebars/compiled/flow_post.handlebars.php
index e5b51bb..b270234 100644
--- a/handlebars/compiled/flow_post.handlebars.php
+++ b/handlebars/compiled/flow_post.handlebars.php
@@ -118,13 +118,13 @@
class="mw-ui-progressive mw-ui-quiet"
title="'.htmlentities(((is_array($in['links']['diff-prev']) &&
isset($in['links']['diff-prev']['title'])) ? $in['links']['diff-prev']['title']
: null), ENT_QUOTES, 'UTF-8').'">
' : '').'
- '.LCRun3::ch($cx, 'uuidTimestamp',
Array(Array(((is_array($in) && isset($in['revisionId'])) ? $in['revisionId'] :
null),'edited_ago'),Array()), 'encq').'
+ '.LCRun3::ch($cx, 'uuidTimestamp',
Array(Array(((is_array($in) && isset($in['revisionId'])) ? $in['revisionId'] :
null),'flow-edited-ago'),Array()), 'encq').'
'.((LCRun3::ifvar($cx, ((is_array($in['links']) &&
isset($in['links']['diff-prev'])) ? $in['links']['diff-prev'] : null))) ? '
</a>
' : '').'
•
' : '').'
- '.LCRun3::ch($cx, 'uuidTimestamp', Array(Array(((is_array($in) &&
isset($in['postId'])) ? $in['postId'] : null),'time_ago'),Array()), 'encq').'
+ '.LCRun3::ch($cx, 'uuidTimestamp', Array(Array(((is_array($in) &&
isset($in['postId'])) ? $in['postId'] : null),'flow-time-ago'),Array()),
'encq').'
</div>
<div class="flow-menu">
diff --git a/handlebars/flow_post_meta_actions.handlebars
b/handlebars/flow_post_meta_actions.handlebars
index 5186539..00d6f67 100644
--- a/handlebars/flow_post_meta_actions.handlebars
+++ b/handlebars/flow_post_meta_actions.handlebars
@@ -38,11 +38,11 @@
class="mw-ui-progressive mw-ui-quiet"
title="{{links.diff-prev.title}}">
{{/if}}
- {{uuidTimestamp revisionId "edited_ago"}}
+ {{uuidTimestamp revisionId "flow-edited-ago"}}
{{#if links.diff-prev}}
</a>
{{/if}}
•
{{/if}}
- {{uuidTimestamp postId "time_ago"}}
+ {{uuidTimestamp postId "flow-time-ago"}}
</div>
diff --git a/handlebars/flow_topic_titlebar_content.handlebars
b/handlebars/flow_topic_titlebar_content.handlebars
index 0f0dc90..e546faf 100644
--- a/handlebars/flow_topic_titlebar_content.handlebars
+++ b/handlebars/flow_topic_titlebar_content.handlebars
@@ -20,9 +20,9 @@
{{l10n "flow-topic-comments" reply_count}} •
{{#if last_updated}}
- <!--span class="wikiglyph wikiglyph-speech-bubbles"></span-->
{{timestamp last_updated "active_ago"}}
+ <!--span class="wikiglyph wikiglyph-speech-bubbles"></span-->
{{timestamp last_updated "flow-active-ago"}}
{{else}}
- <!--span class="wikiglyph wikiglyph-speech-bubble"></span-->
{{uuidTimestamp postId "started_ago"}}
+ <!--span class="wikiglyph wikiglyph-speech-bubble"></span-->
{{uuidTimestamp postId "flow-started-ago"}}
{{/if}}
</div>
<span class="flow-reply-count"><span class="wikiglyph
wikiglyph-speech-bubble"></span><span
class="flow-reply-count-number">{{reply_count}}</span></span>
diff --git a/i18n/en.json b/i18n/en.json
index c2d1a02..954d4d7 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -330,7 +330,6 @@
"flow-started-ago-minute": "Started $1 {{PLURAL:$1|minute|minutes}} ago",
"flow-started-ago-second": "Started $1 {{PLURAL:$1|second|seconds}} ago",
"flow-started-ago-week": "Started $1 {{PLURAL:$1|week|weeks}} ago",
- "flow-edited-ago": "Edited $1",
"flow-edited-ago-day": "Edited $1 {{PLURAL:$1|day|days}} ago",
"flow-edited-ago-hour": "Edited $1 {{PLURAL:$1|hour|hours}} ago",
"flow-edited-ago-minute": "Edited $1 {{PLURAL:$1|minute|minutes}} ago",
diff --git a/includes/TemplateHelper.php b/includes/TemplateHelper.php
index d8ab6b1..8f133c3 100644
--- a/includes/TemplateHelper.php
+++ b/includes/TemplateHelper.php
@@ -214,40 +214,19 @@
);
break;
- case '_time': // ???
- break;
-
- case 'timeago':
- $ts = new \MWTimestamp( $args[0] );
- return $ts->getHumanTimestamp();
-
- case 'active_ago':
- $ts = new \MWTimestamp( $args[0] );
- $message = wfMessage(
- 'flow-active-ago',
- $ts->getHumanTimestamp()
- );
- break;
-
- case 'started_ago':
- $ts = new \MWTimestamp( $args[0] );
- $message = wfMessage(
- 'flow-started-ago',
- $ts->getHumanTimestamp()
- );
- break;
-
- case 'edited_ago':
- $ts = new \MWTimestamp( $args[0] );
- $message = wfMessage(
- 'flow-edited-ago',
- $ts->getHumanTimestamp()
- );
+ case 'time':
+ // This one is not used right now. The parsing of
+ // "x time ago" is done client-side (see its radically
different
+ // implementation of the "timestamp" helper, which is
the only place
+ // these l10n's are used)
break;
case 'datetime':
- $ts = new \MWTimestamp( $args[0] );
- return $ts->getHumanTimestamp();
+ // This one is not really used right now. The parsing of
+ // "x time ago" is done client-side (see its radically
different
+ // implementation of the "timestamp" helper, which is
the only place
+ // these l10n's are used)
+ break;
}
if ( $message ) {
diff --git a/modules/new/flow-handlebars.js b/modules/new/flow-handlebars.js
index 8cf268b..f6d0e65 100644
--- a/modules/new/flow-handlebars.js
+++ b/modules/new/flow-handlebars.js
@@ -203,20 +203,6 @@
return mw.msg.call( this, msgKeyPrefix
+ suffix, Math.floor( new_time ) );
},
- // FIXME: Kill the above 4 in favour of the
generic time helper parameter
- "time_ago": function ( secondsAgo ) {
- return this.time( 'flow-time-ago',
secondsAgo );
- },
- "active_ago": function ( secondsAgo ) {
- return this.time( 'flow-active-ago',
secondsAgo );
- },
- "started_ago": function ( secondsAgo ) {
- return this.time( 'flow-started-ago',
secondsAgo );
- },
- "edited_ago": function ( secondsAgo ) {
- return this.time( 'flow-edited-ago',
secondsAgo );
- },
-
"datetime": function ( timestamp ) {
return ( new Date( timestamp )
).toLocaleString();
}
@@ -268,9 +254,10 @@
/**
* Parses the timestamp out of a base-36 UUID, and calls timestamp with
it.
- * @example {{uuidTimestamp id "started_ago"}}
+ * @example {{uuidTimestamp id "flow-message-x-"}}
* @param {String} uuid id
- * @param {String} str
+ * @param {String} str a message key prefix which when combined with
'second', 'minute', 'hour',
+ * 'week' matches an i18n message
* @param {bool} [timeAgoOnly]
* @returns {String}
*/
@@ -284,9 +271,10 @@
/**
* Generates markup for an "nnn sssss ago" and date/time string.
- * @example {{timestamp start_time "started_ago"}}
+ * @example {{timestamp start_time "flow-message-x-"}}
* @param {int} timestamp milliseconds
- * @param {String} str
+ * @param {String} str a message key prefix which when combined with
'second', 'minute', 'hour',
+ * 'week' matches an i18n message
* @param {bool} [timeAgoOnly]
* @returns {String|undefined}
*/
@@ -301,7 +289,7 @@
if ( seconds_ago < 2419200 ) {
// Return "n ago" for only dates less than 4 weeks ago
- time_ago = FlowHandlebars.prototype.l10n( str,
seconds_ago );
+ time_ago = FlowHandlebars.prototype.l10n( 'time', str,
seconds_ago );
if ( timeAgoOnly === true ) {
// timeAgoOnly: return only this text
diff --git a/tests/qunit/new/test_flow-handlebars.js
b/tests/qunit/new/test_flow-handlebars.js
index 62b2d90..4934d93 100644
--- a/tests/qunit/new/test_flow-handlebars.js
+++ b/tests/qunit/new/test_flow-handlebars.js
@@ -152,18 +152,18 @@
} );
QUnit.test( 'FlowHandlebars.prototype.l10n', 11, function( assert ) {
- assert.strictEqual( this.handlebarsProto.l10n( 'time_ago', 2 ), '2
seconds ago', 'Check seconds.' );
- assert.strictEqual( this.handlebarsProto.l10n( 'time_ago', 120 ), '2
minutes ago', 'Check minutes.' );
- assert.strictEqual( this.handlebarsProto.l10n( 'time_ago', 60 * 60 * 2
), '2 hours ago', 'Check hour.' );
- assert.strictEqual( this.handlebarsProto.l10n( 'time_ago', 60 * 60 * 24
* 2 ), '2 days ago', 'Check day.' );
- assert.strictEqual( this.handlebarsProto.l10n( 'time_ago', 60 * 60 * 24
* 7 * 2 ), '2 weeks ago', 'Check week.' );
- assert.strictEqual( this.handlebarsProto.l10n( 'active_ago', 60 * 60 *
24 * 7 * 2 ), 'Active 2 weeks ago', 'Check week.' );
- assert.strictEqual( this.handlebarsProto.l10n( 'started_ago', 60 * 60 *
24 * 7 * 2 ), 'Started 2 weeks ago', 'Check week.' );
- assert.strictEqual( this.handlebarsProto.l10n( 'edited_ago', 60 * 60 *
24 * 7 * 2 ), 'Edited 2 weeks ago', 'Check week.' );
+ assert.strictEqual( this.handlebarsProto.l10n( 'time', 'flow-time-ago',
2 ), '2 seconds ago', 'Check seconds.' );
+ assert.strictEqual( this.handlebarsProto.l10n( 'time', 'flow-time-ago',
120 ), '2 minutes ago', 'Check minutes.' );
+ assert.strictEqual( this.handlebarsProto.l10n( 'time', 'flow-time-ago',
60 * 60 * 2 ), '2 hours ago', 'Check hour.' );
+ assert.strictEqual( this.handlebarsProto.l10n( 'time', 'flow-time-ago',
60 * 60 * 24 * 2 ), '2 days ago', 'Check day.' );
+ assert.strictEqual( this.handlebarsProto.l10n( 'time', 'flow-time-ago',
60 * 60 * 24 * 7 * 2 ), '2 weeks ago', 'Check week.' );
+ assert.strictEqual( this.handlebarsProto.l10n( 'time',
'flow-active-ago', 60 * 60 * 24 * 7 * 2 ), 'Active 2 weeks ago', 'Check week.'
);
+ assert.strictEqual( this.handlebarsProto.l10n( 'time',
'flow-started-ago', 60 * 60 * 24 * 7 * 2 ), 'Started 2 weeks ago', 'Check
week.' );
+ assert.strictEqual( this.handlebarsProto.l10n( 'time',
'flow-edited-ago', 60 * 60 * 24 * 7 * 2 ), 'Edited 2 weeks ago', 'Check week.'
);
- assert.strictEqual( this.handlebarsProto.l10n( 'active_ago', 1 ),
'Active 1 second ago', 'Check non-plural.' );
- assert.strictEqual( this.handlebarsProto.l10n( 'started_ago', 60 * 60 *
24 * 7 * 1 ), 'Started 1 week ago', 'Check non-plural' );
- assert.strictEqual( this.handlebarsProto.l10n( 'edited_ago', 60 * 60 *
24 * 1 ), 'Edited 1 day ago', 'Check non-plural' );
+ assert.strictEqual( this.handlebarsProto.l10n( 'time',
'flow-active-ago', 1 ), 'Active 1 second ago', 'Check non-plural.' );
+ assert.strictEqual( this.handlebarsProto.l10n( 'time',
'flow-started-ago', 60 * 60 * 24 * 7 * 1 ), 'Started 1 week ago', 'Check
non-plural' );
+ assert.strictEqual( this.handlebarsProto.l10n( 'time',
'flow-edited-ago', 60 * 60 * 24 * 1 ), 'Edited 1 day ago', 'Check non-plural' );
} );
} ( jQuery ) );
--
To view, visit https://gerrit.wikimedia.org/r/155672
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I6a5376ea131aea7cdcdefcdb71af4d8e415f9347
Gerrit-PatchSet: 10
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: Bsitu <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: SG <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits