Florianschmidtwelzow has uploaded a new change for review. https://gerrit.wikimedia.org/r/180122
Change subject: Hygiene: Move anonymousEditing config to EditorOptions ...................................................................... Hygiene: Move anonymousEditing config to EditorOptions Replace wgMFAnonymousEditing into the new editor config array wgMFEditorOptions. This gives us the possibility to group all editor related configurations to one array. Change-Id: I8d11fa1521e317aa2f069d87bb49adb6fff3e4be --- M MobileFrontend.php M includes/skins/SkinMinerva.php M includes/skins/SkinMinervaAlpha.php M javascripts/api.js M javascripts/modules/editor/init.js M tests/qunit/modules/talk/test_TalkSectionAddOverlay.js M tests/qunit/test_api.js 7 files changed, 24 insertions(+), 24 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/22/180122/1 diff --git a/MobileFrontend.php b/MobileFrontend.php index 4f8debf..08b9aed 100644 --- a/MobileFrontend.php +++ b/MobileFrontend.php @@ -434,13 +434,18 @@ $wgMFEnableXAnalyticsLogging = false; /** - * Whether or not anonymous (not logged in) users should be able to edit. - * Note this is highly experimental and comes without any warranty and may introduce bugs - * until anonymous editing experience is addressed in this extension. Anonymous editing - * on mobile is still a big unknown. See bug 53069. - * Thoughts welcomed on https://www.mediawiki.org/wiki/Mobile_wikitext_editing#Anonymous_editing + * Options to control several functions of the mobile editor. + * Possible values: + * - 'anonymousEditing': + * Whether or not anonymous (not logged in) users should be able to edit. + * Note this is highly experimental and comes without any warranty and may introduce bugs + * until anonymous editing experience is addressed in this extension. Anonymous editing + * on mobile is still a big unknown. See bug 53069. + * Thoughts welcomed on https://www.mediawiki.org/wiki/Mobile_wikitext_editing#Anonymous_editing */ -$wgMFAnonymousEditing = false; +$wgMFEditorOptions = array( + 'anonymousEditing' => false, +); /** * A css selector which is used by mf-photo.js to test whether to prompt the user photo uploads on diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php index 4214e68..e85f784 100644 --- a/includes/skins/SkinMinerva.php +++ b/includes/skins/SkinMinerva.php @@ -827,7 +827,7 @@ $wgMFUseCentralAuthToken, $wgMFDeviceWidthTablet, $wgMFAjaxUploadProgressSupport, - $wgMFAnonymousEditing, + $wgMFEditorOptions, $wgMFPhotoUploadEndpoint, $wgMFPhotoUploadAppendToDesc, $wgMFCollapseSectionsByDefault, $wgMFShowRedLinksAnon, $wgMFShowRedLinks; @@ -838,7 +838,7 @@ $vars = array( 'wgMFUseCentralAuthToken' => $wgMFUseCentralAuthToken, 'wgMFAjaxUploadProgressSupport' => $wgMFAjaxUploadProgressSupport, - 'wgMFAnonymousEditing' => $wgMFAnonymousEditing, + 'wgMFEditorOptions' => $wgMFEditorOptions, 'wgMFPhotoUploadAppendToDesc' => $wgMFPhotoUploadAppendToDesc, 'wgMFLeadPhotoUploadCssSelector' => $wgMFLeadPhotoUploadCssSelector, 'wgMFEnableCssAnimations' => $wgMFEnableCssAnimations, diff --git a/includes/skins/SkinMinervaAlpha.php b/includes/skins/SkinMinervaAlpha.php index e056b3b..07f86ab 100644 --- a/includes/skins/SkinMinervaAlpha.php +++ b/includes/skins/SkinMinervaAlpha.php @@ -88,7 +88,7 @@ */ public function getSkinConfigVariables() { $vars = parent::getSkinConfigVariables(); - $vars['wgMFAnonymousEditing'] = true; + $vars['wgMFEditorOptions']['anonymousEditing'] = true; return $vars; } } diff --git a/javascripts/api.js b/javascripts/api.js index ba9aa2a..2daa845 100644 --- a/javascripts/api.js +++ b/javascripts/api.js @@ -130,7 +130,8 @@ easyTokens = [ 'edit', 'watch', 'patrol' ]; tokenType = tokenType || 'edit'; - isCacheable = tokenType !== 'centralauth'; + isCacheable = tokenType !== 'centralauth', + editorConfig = mw.config.get( 'wgMFEditorOptions' ); if ( !this.tokenCache[ endpoint ] ) { this.tokenCache[ endpoint ] = {}; @@ -140,7 +141,7 @@ // FIXME: Per the separation of concerns design principle, we should probably // not be worrying about whether or not the user is anonymous within getToken. // We'll need to check upstream usage though before removing this. - if ( user.isAnon() && !mw.config.get( 'wgMFAnonymousEditing' ) ) { + if ( user.isAnon() && !editorConfig.anonymousEditing ) { return d.reject( 'Token requested when not logged in.' ); // If the token is cached, return it from cache. } else if ( isCacheable && this.tokenCache[ endpoint ].hasOwnProperty( tokenType ) ) { @@ -148,7 +149,7 @@ // If the token is available from mw.user.tokens, get it from there. } else if ( $.inArray( tokenType, easyTokens ) > -1 && !endpoint && !caToken ) { token = user.tokens.get( tokenType + 'Token' ); - if ( token && ( token !== '+\\' || mw.config.get( 'wgMFAnonymousEditing' ) ) ) { + if ( token && ( token !== '+\\' || editorConfig.anonymousEditing ) ) { d.resolve( token ); } else { d.reject( 'Anonymous token.' ); @@ -173,7 +174,7 @@ } ).done( function ( tokenData ) { if ( tokenData && tokenData.tokens && !tokenData.warnings ) { token = tokenData.tokens[ tokenType + 'token' ]; - if ( token && ( token !== '+\\' || mw.config.get( 'wgMFAnonymousEditing' ) ) ) { + if ( token && ( token !== '+\\' || editorConfig.anonymousEditing ) ) { d.resolve( token ); } else { d.reject( 'Anonymous token.' ); diff --git a/javascripts/modules/editor/init.js b/javascripts/modules/editor/init.js index 6410117..9c2c47e 100644 --- a/javascripts/modules/editor/init.js +++ b/javascripts/modules/editor/init.js @@ -233,7 +233,7 @@ } else { if ( user.isAnon() ) { // Cta's will be rendered in EditorOverlay, if anonymous editing is enabled. - if ( mw.config.get( 'wgMFAnonymousEditing' ) ) { + if ( mw.config.get( 'wgMFEditorOptions' ).anonymousEditing ) { init( M.getCurrentPage() ); } else { initCta(); diff --git a/tests/qunit/modules/talk/test_TalkSectionAddOverlay.js b/tests/qunit/modules/talk/test_TalkSectionAddOverlay.js index f08d25c..6571f14 100644 --- a/tests/qunit/modules/talk/test_TalkSectionAddOverlay.js +++ b/tests/qunit/modules/talk/test_TalkSectionAddOverlay.js @@ -5,14 +5,7 @@ QUnit.module( 'MobileFrontend TalkSectionAddOverlay', { setup: function() { - // tokens for anonymous users only when anonymous editing is allowed - this.anonEditing = mw.config.get( 'wgMFAnonymousEditing' ); - mw.config.set( 'wgMFAnonymousEditing', true ); this.sandbox.stub( api, 'postWithToken' ).returns( $.Deferred().resolve() ); - }, - teardown: function() { - // restore old value of wgMFAnonymousEditing - mw.config.set( 'wgMFAnonymousEditing', this.anonEditing ); } } ); @@ -37,4 +30,4 @@ assert.strictEqual( overlay._saveHit, true, 'The save was recognized' ); } ); -}( mw.mobileFrontend, jQuery ) ); \ No newline at end of file +}( mw.mobileFrontend, jQuery ) ); diff --git a/tests/qunit/test_api.js b/tests/qunit/test_api.js index eb4bed7..6c2437b 100644 --- a/tests/qunit/test_api.js +++ b/tests/qunit/test_api.js @@ -135,14 +135,15 @@ } ); QUnit.test( '#getTokenWithEndpoint - get anon token (stable)', 1, function( assert ) { - mw.config.set( 'wgMFAnonymousEditing', false ); + mw.config.set( 'wgMFEditorOptions', { + 'anonymousEditing': false + } ); this.api.getTokenWithEndpoint( 'upload' ).fail( function( msg ) { assert.strictEqual( msg, 'Anonymous token.', 'No token given - user must be anon' ); } ); } ); QUnit.test ( '#getTokenWithEndpoint - get anon token (alpha)', 1, function( assert ) { - mw.config.set( 'wgMFAnonymousEditing', true ); this.api.getTokenWithEndpoint( 'edit' ).done( function( token ) { assert.strictEqual( token, '123', 'Got a token for anonymous editing' ); } ); -- To view, visit https://gerrit.wikimedia.org/r/180122 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8d11fa1521e317aa2f069d87bb49adb6fff3e4be Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Florianschmidtwelzow <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
