r99725 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99724‎ | r99725 | r99726 >
Date:19:55, 13 October 2011
Author:jpostlethwaite
Status:deferred (Comments)
Tags:
Comment:
Added i18n message. Renamed javascript variables to be more intuitive. Checking that $title is instance of Title. Updated Special page to better use i18n.
Modified paths:
  • /trunk/extensions/LastModified/LastModified.i18n.php (modified) (history)
  • /trunk/extensions/LastModified/LastModified.php (modified) (history)
  • /trunk/extensions/LastModified/SpecialLastModified.php (modified) (history)
  • /trunk/extensions/LastModified/modules/lastmodified.js (modified) (history)

Diff [purge]

Index: trunk/extensions/LastModified/LastModified.i18n.php
@@ -36,6 +36,7 @@
3737 'lastmodified-label-months' => 'months',
3838 'lastmodified-label-years' => 'years',
3939 'lastmodified-options' => 'Options',
 40+ 'lastmodified-display' => 'Display:',
4041 'lastmodified-display-range-value' => 'Display range value:',
4142 'lastmodified-title-tag' => 'View the revision history for this article.',
4243 'lastmodified-seconds' => 'Last updated $1 seconds ago',
Index: trunk/extensions/LastModified/modules/lastmodified.js
@@ -24,9 +24,9 @@
2525 */
2626 function extensionsLastModified() {
2727
28 - // Get the last-edit value
29 - var lastEdited = extensionsLastModifiedGetMetaLastEdited();
30 - //console.log( 'lastEdited: ' + lastEdited );
 28+ // Get the last-modified-timestamp value
 29+ var lastModifiedTimestamp = extensionsLastModifiedGetMetaLastModifiedTimestamp();
 30+ //console.log( 'lastModifiedTimestamp: ' + lastModifiedTimestamp );
3131
3232 // Get the last-modified-range value
3333 var displayRange = extensionsLastModifiedGetMetaRange();
@@ -37,7 +37,7 @@
3838 //console.log( 'nowStamp: ' + nowStamp );
3939
4040 // Get the difference in the time from when it was last edited.
41 - var modifiedDifference = nowStamp - lastEdited;
 41+ var modifiedDifference = nowStamp - lastModifiedTimestamp;
4242 //console.log( 'modifiedDifference: ' + modifiedDifference );
4343
4444 // Get the last modified text
@@ -87,14 +87,14 @@
8888 }
8989
9090 /**
91 - * Get the value from the meta tag: last-edited
 91+ * Get the value from the meta tag: last-modified-timestamp
9292 *
9393 * @return integer
9494 */
95 -function extensionsLastModifiedGetMetaLastEdited() {
 95+function extensionsLastModifiedGetMetaLastModifiedTimestamp() {
9696
9797 // Fetch the meta tag
98 - var metaTag = $("meta[name=last-edited]");
 98+ var metaTag = $("meta[name=last-modified-timestamp]");
9999
100100 // If the tag was found, parse the value
101101 if ( metaTag ) {
@@ -137,7 +137,7 @@
138138
139139 // minutes
140140 if ( displayRange <= 4 ) {
141 - lastEdit = parseInt( modifiedDifference / 60 );
 141+ myLastEdit = parseInt( modifiedDifference / 60 );
142142 message = ( mw.msg( 'lastmodified-minutes', myLastEdit ) );
143143 }
144144
Index: trunk/extensions/LastModified/LastModified.php
@@ -84,9 +84,10 @@
8585 $title = $context->getTitle();
8686 $article = Article::newFromTitle( $title, $context );
8787
88 - if ( $article && ( method_exists( $title, 'getNamespace' ) && $title->getNamespace() == 0 ) ) {
89 - $timestamp = $article->getTimestamp();
90 - $out->addMeta( 'last-edited', wfTimestamp ( TS_UNIX, $timestamp ) );
 88+ if ( $article && ( ( $title instanceof Title ) && $title->getNamespace() == 0 ) ) {
 89+ $timestamp = wfTimestamp ( TS_UNIX, $article->getTimestamp() );
 90+ $out->addMeta( 'http:last-modified', date( 'r', $timestamp ) );
 91+ $out->addMeta( 'last-modified-timestamp', $timestamp );
9192 $out->addMeta( 'last-modified-range', $wgLastModifiedRange );
9293 $out->addModules( 'last.modified' );
9394 }
Index: trunk/extensions/LastModified/SpecialLastModified.php
@@ -49,7 +49,7 @@
5050 $out->addHTML( wfMsg( 'lastmodified-display-range-value' ) . ' ' . $wgLastModifiedRange );
5151 $out->addHTML( Xml::closeElement( 'p' ) );
5252
53 - $rangeMessage = '<p>Display: ';
 53+ $rangeMessage = wfMsg( 'lastmodified-display' ) . ' ';
5454 $rangeMessageDatetime = '';
5555
5656 $displayRange = array(
@@ -62,7 +62,6 @@
6363 );
6464
6565 // Display seconds
66 -
6766 foreach ( $displayRange as $key => $value ) {
6867
6968 // Check to see which values to display.
@@ -77,8 +76,9 @@
7877 }
7978
8079 $rangeMessage .= $rangeMessageDatetime;
81 - $rangeMessage .= '</p>';
8280
 81+ $out->addHTML( Xml::openElement( 'p' ) );
8382 $out->addHTML( $rangeMessage );
 83+ $out->addHTML( Xml::closeElement( 'p' ) );
8484 }
8585 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r99734Added message documentation for extension LastModified.jpostlethwaite20:49, 13 October 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r99522Adding new extension LastModified.jpostlethwaite18:30, 11 October 2011

Comments

#Comment by Jpostlethwaite (talk | contribs)   19:57, 13 October 2011

Also added meta tag: http:last-modified

#Comment by Siebrand (talk | contribs)   20:12, 13 October 2011

Please add message documentation for the newly added messages. Thanks.

#Comment by Jpostlethwaite (talk | contribs)   20:50, 13 October 2011

Updated with documentation in r99734.

Status & tagging log