mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-23 23:24:39 +00:00
Remove last modified line
Note this is a breaking change in the sense that it breaks the function signature for createModel which no longer needs to be passed the last modified time. Given this change is in the mpga branch at current time and hasnt been exposed for public use I have deemed this okay. The change removes tests relating to the last modified bar, removes lines in the templates and updates existing tests and code to reflect the new function signature for create model. Settings icon is floated to right which will be flipped for RTL users. Bug: T137775 Change-Id: I7737e37d956c62f1f1c0694d7a25a58d91651f4d
This commit is contained in:
parent
cfa0a4dd55
commit
09ccfa9a13
|
@ -116,7 +116,6 @@
|
|||
"resources/ext.popups/styles/ext.popups.settings.less"
|
||||
],
|
||||
"messages": [
|
||||
"popups-last-edited",
|
||||
"popups-settings-title",
|
||||
"popups-settings-description",
|
||||
"popups-settings-option-simple",
|
||||
|
@ -140,7 +139,6 @@
|
|||
"mediawiki.ui.button",
|
||||
"mediawiki.ui.icon",
|
||||
"mediawiki.Uri",
|
||||
"moment",
|
||||
"jquery.hidpi",
|
||||
"ext.popups.lib"
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
},
|
||||
"popups-message": "Hovercards",
|
||||
"popups-desc": "Displays hovercards with summaries of page contents when the user hovers over a page link",
|
||||
"popups-last-edited": "Edited $1",
|
||||
"popups-redirects": "redirects to <h3>$1</h3>",
|
||||
"popups-settings-title": "Page preview",
|
||||
"popups-settings-description": "This tool lets you preview links to wiki pages and to references.",
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
},
|
||||
"popups-message": "Name shown in user preference for this extension",
|
||||
"popups-desc": "{{desc|name=Popups|url=https://www.mediawiki.org/wiki/Extension:Popups}}",
|
||||
"popups-last-edited": "Message to show time span since the page was last edited. Need not include the word \"last\". Parameters:\n* $1 - the timespan in words (localized). e.g. \"3 months ago\"",
|
||||
"popups-redirects": "Unused at this time.\n\nMessage shown when the hovercard is showing a redirected page.\n\nParameters:\n* $1 - Redirect target page",
|
||||
"popups-settings-title": "Title used for the setting's dialog",
|
||||
"popups-settings-description": "Description for the setting's dialog",
|
||||
|
|
|
@ -76,19 +76,12 @@
|
|||
* @returns {ext.popups.PreviewModel}
|
||||
*/
|
||||
function convertPageToModel( page ) {
|
||||
var lastModified;
|
||||
|
||||
if ( page.revisions && page.revisions.length ) {
|
||||
lastModified = new Date( page.revisions[ 0 ].timestamp );
|
||||
}
|
||||
|
||||
return mw.popups.preview.createModel(
|
||||
page.title,
|
||||
page.canonicalurl,
|
||||
page.pagelanguagehtmlcode,
|
||||
page.pagelanguagedir,
|
||||
page.extract,
|
||||
lastModified,
|
||||
page.thumbnail
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
( function ( mw ) {
|
||||
|
||||
var ONE_DAY = 24 * 60 * 60 * 1000, // ms.
|
||||
TYPE_GENERIC = 'generic',
|
||||
var TYPE_GENERIC = 'generic',
|
||||
TYPE_EXTRACT = 'extract';
|
||||
|
||||
/**
|
||||
|
@ -14,10 +13,6 @@
|
|||
* viable, e.g. if it's empty after having ellipsis and parentheticals
|
||||
* removed
|
||||
* @property {String} type Either "EXTRACT" or "GENERIC"
|
||||
* @property {Date|Number|undefined} lastModified
|
||||
* @property {Bool|undefined} isRecent If `lastModified` is `undefined`, then
|
||||
* this will also be undefined; otherwise, whether or not `lastModified` is
|
||||
* less than 24 hours ago
|
||||
* @property {Object|undefined} thumbnail
|
||||
*/
|
||||
|
||||
|
@ -39,7 +34,6 @@
|
|||
* @param {String} languageCode
|
||||
* @param {String} languageDirection Either "ltr" or "rtl"
|
||||
* @param {String} extract
|
||||
* @param {Date|Number|undefined} lastModified
|
||||
* @param {Object|undefined} thumbnail
|
||||
* @return {ext.popups.PreviewModel}
|
||||
*/
|
||||
|
@ -49,7 +43,6 @@
|
|||
languageCode,
|
||||
languageDirection,
|
||||
extract,
|
||||
lastModified,
|
||||
thumbnail
|
||||
) {
|
||||
var processedExtract = processExtract( extract ),
|
||||
|
@ -63,11 +56,6 @@
|
|||
thumbnail: thumbnail
|
||||
};
|
||||
|
||||
if ( lastModified ) {
|
||||
result.lastModified = lastModified;
|
||||
result.isRecent = mw.now() - lastModified < ONE_DAY;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
|
|
|
@ -140,7 +140,6 @@
|
|||
$el;
|
||||
|
||||
templateData = $.extend( {}, model, {
|
||||
lastModifiedMsg: mw.msg( 'popups-last-edited', moment( model.lastModified ).fromNow() ),
|
||||
hasThumbnail: hasThumbnail
|
||||
} );
|
||||
|
||||
|
|
|
@ -101,12 +101,8 @@
|
|||
/* @noflip */
|
||||
left: 0;
|
||||
|
||||
.mwe-popups-timestamp-older {
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.mwe-popups-timestamp-recent {
|
||||
color: #00af89;
|
||||
.mwe-popups-icon {
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
{{/hasThumbnail}}
|
||||
<a dir="{{languageDirection}}" lang="{{languageCode}}" class="mwe-popups-extract" href="{{url}}"></a>
|
||||
<footer>
|
||||
<span class="{{#isRecent}}mwe-popups-timestamp-recent{{/isRecent}}{{^isRecent}}mwe-popups-timestamp-older{{/isRecent}}">{{lastModifiedMsg}}</span>
|
||||
<a class="mwe-popups-icon mwe-popups-settings-icon"></a>
|
||||
</footer>
|
||||
</div>
|
||||
|
|
|
@ -123,7 +123,6 @@
|
|||
'en',
|
||||
'ltr',
|
||||
'Richard Paul "Rick" Astley is an English singer, songwriter, musician, and radio personality. His 1987 song, "Never Gonna Give You Up" was a No. 1 hit single in 25 countries. By the time of his retirement in 1993, Astley had sold approximately 40 million records worldwide.\nAstley made a comeback in 2007, becoming an Internet phenomenon when his video "Never Gonna Give You Up" became integral to the meme known as "rickrolling". Astley was voted "Best Act Ever" by Internet users at the',
|
||||
new Date( '2016-11-10T00:14:14Z' ),
|
||||
{
|
||||
height: 300,
|
||||
source: 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6d/Rick_Astley_-_Pepsifest_2009.jpg/200px-Rick_Astley_-_Pepsifest_2009.jpg',
|
||||
|
@ -159,7 +158,6 @@
|
|||
'en',
|
||||
'ltr',
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
) );
|
||||
|
||||
|
|
|
@ -5,15 +5,13 @@
|
|||
QUnit.module( 'ext.popups.preview#createModel' );
|
||||
|
||||
QUnit.test( 'it should copy the basic properties', function ( assert ) {
|
||||
var lastModified = mw.now(),
|
||||
thumbnail = {},
|
||||
var thumbnail = {},
|
||||
model = createModel(
|
||||
'Foo',
|
||||
'https://en.wikipedia.org/wiki/Foo',
|
||||
'en',
|
||||
'ltr',
|
||||
'Foo bar baz.',
|
||||
lastModified,
|
||||
thumbnail
|
||||
);
|
||||
|
||||
|
@ -21,51 +19,9 @@
|
|||
assert.strictEqual( model.url, 'https://en.wikipedia.org/wiki/Foo' );
|
||||
assert.strictEqual( model.languageCode, 'en' );
|
||||
assert.strictEqual( model.languageDirection, 'ltr' );
|
||||
assert.strictEqual( model.lastModified, lastModified );
|
||||
assert.strictEqual( model.thumbnail, thumbnail );
|
||||
} );
|
||||
|
||||
QUnit.test( 'it computes the isRecent property', function ( assert ) {
|
||||
var now = mw.now(),
|
||||
twelveHours = 12 * 60 * 60 * 1000, // ms
|
||||
model;
|
||||
|
||||
function createModelWithLastModified( lastModified ) {
|
||||
return createModel(
|
||||
'Foo',
|
||||
'https://en.wikipedia.org/wiki/Foo',
|
||||
'en',
|
||||
'ltr',
|
||||
'Foo bar baz.',
|
||||
lastModified
|
||||
);
|
||||
}
|
||||
|
||||
model = createModelWithLastModified( now - twelveHours );
|
||||
|
||||
assert.ok( model.isRecent );
|
||||
|
||||
// ---
|
||||
|
||||
model = createModelWithLastModified( now - 2 * twelveHours );
|
||||
|
||||
assert.notOk(
|
||||
model.isRecent,
|
||||
'The page isn\'t considered recent if it was touched more than 24 hours ago.'
|
||||
);
|
||||
|
||||
// ---
|
||||
|
||||
model = createModelWithLastModified( undefined );
|
||||
|
||||
assert.strictEqual( model.lastModified, undefined );
|
||||
assert.strictEqual(
|
||||
model.isRecent,
|
||||
undefined,
|
||||
'It shouldn\'t compute the isRecent property if it\'s not clear when the page was touched.'
|
||||
);
|
||||
} );
|
||||
|
||||
QUnit.test( 'it computes the extract property', function ( assert ) {
|
||||
var cases = [
|
||||
// removeEllipsis
|
||||
|
@ -89,8 +45,7 @@
|
|||
'https://en.wikipedia.org/wiki/Foo',
|
||||
'en',
|
||||
'ltr',
|
||||
extract,
|
||||
mw.now()
|
||||
extract
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -221,7 +221,6 @@
|
|||
'en',
|
||||
'ltr',
|
||||
'',
|
||||
mw.now(),
|
||||
{}
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue