jenkins-bot has submitted this change and it was merged. Change subject: Makes VE -> Wikieditor switch work ......................................................................
Makes VE -> Wikieditor switch work Adds a simple Wikitext serialization parser We should probably move to an API call in the future (see Id34b2c10bbf0cb23643b3b300e3182a4a12c9933 ) Change-Id: I315468a493ba1c770bd1d1fd89e883e9bb5ab53f --- M modules/ve/pageTarget/ve.init.mw.ProofreadPagePageTarget.js 1 file changed, 54 insertions(+), 0 deletions(-) Approvals: Jforrester: Looks good to me, but someone else must approve Esanders: Looks good to me, approved jenkins-bot: Verified diff --git a/modules/ve/pageTarget/ve.init.mw.ProofreadPagePageTarget.js b/modules/ve/pageTarget/ve.init.mw.ProofreadPagePageTarget.js index ea16f92..9265751 100644 --- a/modules/ve/pageTarget/ve.init.mw.ProofreadPagePageTarget.js +++ b/modules/ve/pageTarget/ve.init.mw.ProofreadPagePageTarget.js @@ -145,6 +145,60 @@ }; /** + * @inheritdoc + */ +ve.init.mw.ProofreadPagePageTarget.prototype.submit = function ( wikitext, fields ) { + var content; + if ( this.submitting ) { + return false; + } + + content = this.parseWikitext( wikitext ); + ve.extendObject( fields, { + model: 'proofread-page', + wpHeaderTextbox: content.header, + wpTextbox1: content.body, + wpFooterTextbox: content.footer, + wpQuality: content.level.level + } ); + + return ve.init.mw.ProofreadPagePageTarget.super.prototype.submit.call( this, wikitext, fields ); +}; + +/** + * Parse Wikitext into the JSON serialization + */ +ve.init.mw.ProofreadPagePageTarget.prototype.parseWikitext = function ( wikitext ) { + var structureMatchResult, headerMatchResult, result = { + header: '', + body: '', + footer: '', + level: { + level: 1, + user: null + } + }; + + structureMatchResult = wikitext.match( /^<noinclude>([\s\S]*)\n*<\/noinclude>([\s\S]*)<noinclude>([\s\S]*)<\/noinclude>$/ ); + if ( structureMatchResult === null ) { + result.body = wikitext; + return result; + } + result.body = structureMatchResult[ 2 ]; + result.footer = structureMatchResult[ 3 ]; + + headerMatchResult = structureMatchResult[ 1 ].match( /^<pagequality level="([0-4])" user="(.*)" *(\/>|> *<\/pagequality>)([\s\S]*)$/ ); + if ( headerMatchResult === null ) { + result.header = structureMatchResult[ 1 ]; + return result; + } + result.level.level = parseInt( headerMatchResult[ 1 ] ); + result.level.user = headerMatchResult[ 2 ]; + result.header = headerMatchResult[ 4 ]; + return result; +}; + +/** * Split a document into balanced header, body and footer sections * * @param {HTMLDocument} doc Document -- To view, visit https://gerrit.wikimedia.org/r/295716 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I315468a493ba1c770bd1d1fd89e883e9bb5ab53f Gerrit-PatchSet: 5 Gerrit-Project: mediawiki/extensions/ProofreadPage Gerrit-Branch: master Gerrit-Owner: Tpt <thoma...@hotmail.fr> Gerrit-Reviewer: Alex Monk <kren...@gmail.com> Gerrit-Reviewer: Esanders <esand...@wikimedia.org> Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org> Gerrit-Reviewer: Tpt <thoma...@hotmail.fr> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits