mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RevisionSlider
synced 2024-11-15 03:33:45 +00:00
Merge "Drop wikitext comment in favor of parsedcomment
"
This commit is contained in:
commit
72ef3975c7
|
@ -122,7 +122,7 @@ $.extend( Api.prototype, {
|
|||
action: 'query',
|
||||
prop: 'revisions',
|
||||
format: 'json',
|
||||
rvprop: 'ids|timestamp|user|comment|parsedcomment|size|flags|tags',
|
||||
rvprop: 'ids|timestamp|user|parsedcomment|size|flags|tags',
|
||||
titles: pageName,
|
||||
formatversion: 2,
|
||||
continue: '',
|
||||
|
|
|
@ -3,7 +3,7 @@ let userOffset;
|
|||
/* global moment:false */
|
||||
/**
|
||||
* @class Revision
|
||||
* @param {Object} data - Containing keys `id`, `size`, `comment`, `parsedcomment`, `timestamp`, `user` and `minor`
|
||||
* @param {Object} data - Containing keys `id`, `size`, `parsedcomment`, `timestamp`, `user` and `minor`
|
||||
* @constructor
|
||||
*/
|
||||
function Revision( data ) {
|
||||
|
@ -13,21 +13,10 @@ function Revision( data ) {
|
|||
this.minor = !!data.minor || data.minor === '';
|
||||
|
||||
// Comments, tags, and users can be suppressed thus we must check if they exist
|
||||
if ( 'comment' in data ) {
|
||||
this.comment = data.comment;
|
||||
}
|
||||
if ( 'parsedcomment' in data ) {
|
||||
this.parsedComment = data.parsedcomment;
|
||||
}
|
||||
if ( 'tags' in data ) {
|
||||
this.tags = data.tags;
|
||||
}
|
||||
if ( 'user' in data ) {
|
||||
this.user = data.user;
|
||||
if ( 'userGender' in data ) {
|
||||
this.userGender = data.userGender;
|
||||
}
|
||||
}
|
||||
this.parsedComment = data.parsedcomment || '';
|
||||
this.tags = data.tags || [];
|
||||
this.user = data.user || '';
|
||||
this.userGender = data.userGender || '';
|
||||
}
|
||||
|
||||
$.extend( Revision.prototype, {
|
||||
|
@ -41,11 +30,6 @@ $.extend( Revision.prototype, {
|
|||
*/
|
||||
size: 0,
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
comment: '',
|
||||
|
||||
/**
|
||||
* @type {string[]}
|
||||
*/
|
||||
|
@ -109,20 +93,6 @@ $.extend( Revision.prototype, {
|
|||
return this.parsedComment;
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
hasEmptyComment: function () {
|
||||
return this.getComment().trim().length === 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
getComment: function () {
|
||||
return this.comment;
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {string[]}
|
||||
*/
|
||||
|
|
|
@ -483,16 +483,15 @@ $.extend( RevisionListView.prototype, {
|
|||
* @return {string|jQuery}
|
||||
*/
|
||||
makeCommentLine: function ( rev ) {
|
||||
if ( rev.hasEmptyComment() ) {
|
||||
const html = rev.getParsedComment();
|
||||
if ( !html.trim().length ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $( '<p>' ).append(
|
||||
$( '<strong>' ).text( mw.msg( 'revisionslider-label-comment' ) + mw.msg( 'colon-separator' ) ),
|
||||
$( '<em>' ).append(
|
||||
$( '<bdi>' ).append(
|
||||
rev.getParsedComment()
|
||||
)
|
||||
$( '<bdi>' ).append( html )
|
||||
)
|
||||
);
|
||||
},
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
QUnit.test( 'create Revision', function ( assert ) {
|
||||
const data = {
|
||||
size: 5,
|
||||
comment: 'hello',
|
||||
parsedcomment: '<b>hello</b>',
|
||||
timestamp: '2016-04-26T10:27:14Z', // 10:27, 26 Apr 2016
|
||||
user: 'meh',
|
||||
|
@ -18,7 +17,6 @@
|
|||
SliderModule.setUserOffset( 0 );
|
||||
|
||||
assert.strictEqual( rev.getSize(), data.size );
|
||||
assert.strictEqual( rev.getComment(), data.comment );
|
||||
assert.strictEqual( rev.getParsedComment(), data.parsedcomment );
|
||||
assert.strictEqual( rev.getUser(), data.user );
|
||||
assert.strictEqual( rev.getUserGender(), 'female' );
|
||||
|
@ -83,28 +81,4 @@
|
|||
|
||||
assert.strictEqual( rev.getFormattedDate(), '26 April 2016 3:27 AM' );
|
||||
}, mw.config.get( 'wgUserLanguage' ) !== 'en' );
|
||||
|
||||
QUnit.test( 'hasEmptyComment comment with whitespaces', function ( assert ) {
|
||||
const rev = new Revision( {
|
||||
comment: ' '
|
||||
} );
|
||||
|
||||
assert.true( rev.hasEmptyComment() );
|
||||
} );
|
||||
|
||||
QUnit.test( 'hasEmptyComment comment with chars', function ( assert ) {
|
||||
const rev = new Revision( {
|
||||
comment: ' comment '
|
||||
} );
|
||||
|
||||
assert.false( rev.hasEmptyComment() );
|
||||
} );
|
||||
|
||||
QUnit.test( 'hasEmptyComment comment with unicode chars', function ( assert ) {
|
||||
const rev = new Revision( {
|
||||
comment: 'ברוכים'
|
||||
} );
|
||||
|
||||
assert.false( rev.hasEmptyComment() );
|
||||
} );
|
||||
}() );
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
revision = new Revision( {
|
||||
revid: 1,
|
||||
size: 230,
|
||||
comment: 'Hello',
|
||||
parsedcomment: '<strong>Hello</strong>',
|
||||
timestamp: '2016-04-26T10:27:14Z', // 10:27, 26 Apr 2016
|
||||
user: 'User1',
|
||||
|
@ -56,7 +55,6 @@
|
|||
revision = new Revision( {
|
||||
revid: 1,
|
||||
size: 2300,
|
||||
comment: 'Hello',
|
||||
parsedcomment: '<strong>Hello</strong>',
|
||||
timestamp: '2016-04-26T10:27:14Z', // 10:27, 26 Apr 2016
|
||||
user: 'User1',
|
||||
|
@ -108,7 +106,6 @@
|
|||
const revisionListView = new RevisionListView();
|
||||
|
||||
const $commentHtml = revisionListView.makeCommentLine( new Revision( {
|
||||
comment: ' ',
|
||||
parsedcomment: ' '
|
||||
} ) );
|
||||
|
||||
|
@ -119,7 +116,6 @@
|
|||
const revisionListView = new RevisionListView();
|
||||
|
||||
const $commentLineHtml = revisionListView.makeCommentLine( new Revision( {
|
||||
comment: 'Hello',
|
||||
parsedcomment: '<strong>Hello</strong>'
|
||||
} ) );
|
||||
|
||||
|
|
Loading…
Reference in a new issue