jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/373076 )
Change subject: Disable wikitext editor on non-wikitext content models
......................................................................
Disable wikitext editor on non-wikitext content models
Do not allow editing via JavaScript on non-wikitext content models
For these pages ?action=edit will be used
Bug: T173800
Change-Id: Ic62a0c1397ab8a6a59e5382c2999b63b3c60a19f
---
M includes/skins/SkinMinerva.php
M resources/skins.minerva.editor/init.js
2 files changed, 18 insertions(+), 3 deletions(-)
Approvals:
Pmiazga: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php
index d108b48..ade588c 100644
--- a/includes/skins/SkinMinerva.php
+++ b/includes/skins/SkinMinerva.php
@@ -19,6 +19,9 @@
const OPTION_BACK_TO_TOP = 'backToTop';
const OPTION_TOGGLING = 'toggling';
const OPTIONS_MOBILE_BETA = 'beta';
+ /** @const LEAD_SECTION_NUMBER integer which corresponds to the lead
section
+ in editing mode */
+ const LEAD_SECTION_NUMBER = 0;
/** @var string $skinname Name of this skin */
public $skinname = 'minerva';
@@ -1063,6 +1066,13 @@
* @return array A map compatible with BaseTemplate#makeListItem
*/
protected function createEditPageAction() {
+ $title = $this->getTitle();
+ $editArgs = [ 'action' => 'edit' ];
+ if ( $title->isWikitextPage() ) {
+ // If the content model is wikitext we'll default to
editing the lead section.
+ // Full wikitext editing is not possible via the api
and hard on mobile devices.
+ $editArgs['section'] = self::LEAD_SECTION_NUMBER;
+ }
return [
'id' => 'ca-edit',
'text' => '',
@@ -1070,7 +1080,7 @@
'class' => MobileUI::iconClass( 'edit-enabled',
'element' ),
'links' => [
'edit' => [
- 'href' =>
$this->getTitle()->getLocalURL( [ 'action' => 'edit', 'section' => 0 ] )
+ 'href' => $title->getLocalURL(
$editArgs )
],
],
'is_js_only' => false
@@ -1240,7 +1250,7 @@
if ( !$title->isTalkPage() ) {
$title = $title->getTalkPage();
}
- return $title->getContentModel() === CONTENT_MODEL_WIKITEXT;
+ return $title->isWikitextPage();
}
/**
diff --git a/resources/skins.minerva.editor/init.js
b/resources/skins.minerva.editor/init.js
index c6b5b6d..862180b 100644
--- a/resources/skins.minerva.editor/init.js
+++ b/resources/skins.minerva.editor/init.js
@@ -24,6 +24,7 @@
popup = M.require( 'mobile.startup/toast' ),
// FIXME: Disable on IE < 10 for time being
blacklisted = /MSIE \d\./.test( navigator.userAgent ),
+ contentModel = mw.config.get( 'wgPageContentModel' ),
isEditingSupported = router.isSupported() && !blacklisted,
// FIXME: Use currentPage.getId()
isNewPage = currentPage.options.id === 0,
@@ -345,7 +346,11 @@
} );
}
- if ( !isEditingSupported ) {
+ if ( contentModel !== 'wikitext' ) {
+ // Only load the wikitext editor on wikitext. Otherwise we'll
rely on the fallback behaviour
+ // (You can test this on MediaWiki:Common.css) ?action=edit url
(T173800)
+ return;
+ } else if ( !isEditingSupported ) {
// Editing is disabled (or browser is blacklisted)
$caEdit.removeClass( 'hidden' );
showSorryToast( mw.msg( 'mobile-frontend-editor-unavailable' )
);
--
To view, visit https://gerrit.wikimedia.org/r/373076
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic62a0c1397ab8a6a59e5382c2999b63b3c60a19f
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/skins/MinervaNeue
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Pmiazga <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits