Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F31671836
raw.txt
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
awight
Mar 8 2020, 10:20 PM
2020-03-08 22:20:44 (UTC+0)
Size
3 KB
Referenced Files
None
Subscribers
None
raw.txt
View Options
mw.loader.using( [
'oojs-ui-core',
'mediawiki.api',
'moment'
] ).done( function () {
$( function () {
var conflictTitleParams = /^Conflict:(.*)\/(\d+)\/(\d+)/.exec( mw.config.get('wgPageName' ) );
if ( conflictTitleParams !== null ) {
var baseTitle = conflictTitleParams[1],
baseRevisionId = conflictTitleParams[2] /*,
conflictSequence = conflictTitleParams[3] */;
var form = new OO.ui.FormLayout( {
// TODO: urlencode the title, or build the query using a helper.
action: mw.config.get('wgScript' ) + '?title=' + baseTitle + '&action=submit',
method: 'post'
} );
form.addItems( [
new OO.ui.FieldsetLayout( {
label: 'Conflict',
items: [
new OO.ui.ButtonWidget( {
label: 'Recreate conflict',
title: 'Submit',
} ).on( 'click', function () {
// TODO: clean up binding
form.$element.submit();
} )
]
} )
] );
var postFields = {
wpUnicodeCheck: 'ℳ𝒲♥𝓊𝓃𝒾𝒸ℴ𝒹ℯ',
// TODO: get content and metadata from API call for current page.
editRevId: baseRevisionId,
parentRevId: baseRevisionId,
// TODO: stored / input / automatic summary field.
//wpSummary: '',
wpSave: 'Save changes',
mode: 'text',
wpUltimateParam: '1',
};
var api = new mw.Api();
Promise.all( [
api.getEditToken().then(
function ( editToken ) {
postFields.wpEditToken = editToken;
}
),
// Pull content from the conflict page.
api.get( {
action: 'query',
prop: 'revisions',
revids: mw.config.get( 'wgCurRevisionId' ),
rvprop: 'content'
} ).then(
function ( data ) {
for ( var pageId in data.query.pages ) {
for ( var index in data.query.pages[pageId].revisions ) {
var revision = data.query.pages[pageId].revisions[index];
postFields.wpTextbox1 = revision['*'];
postFields.format = revision.contentformat;
postFields.model = revision.contentmodel;
return;
}
}
}
),
// Get timestamp of the original base revision, to convince EditPage we need to conflict.
// Edit time turns out to be important, conflict cannot be triggered without it!
api.get( {
action: 'query',
prop: 'revisions',
revids: baseRevisionId,
rvprop: 'timestamp'
} ).then(
function ( data ) {
for ( var pageId in data.query.pages ) {
for ( var index in data.query.pages[pageId].revisions ) {
var revision = data.query.pages[pageId].revisions[index];
// FIXME: date conversion from a library
postFields.wpEdittime = moment( revision.timestamp ).format( 'YYYYMMDDHHmmss' );
return;
}
}
}
)
] ).then(
function ( ) {
var keys = Object.keys( postFields );
for ( var i = 0; i < keys.length; i++ ) {
form.addItems( [
new OO.ui.HiddenInputWidget( {
name: keys[i],
value: postFields[keys[i]],
} )
] );
}
$( '#bodyContent' ).prepend( form.$element );
}
);
}
});
});
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
8345884
Default Alt Text
raw.txt (3 KB)
Attached To
Mode
P10653 User script to replay conflicts
Attached
Detach File
Event Timeline
Log In to Comment