Esanders has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/78795


Change subject: [WIP] Integrate with BetaPreferences
......................................................................

[WIP] Integrate with BetaPreferences

TODO:
* Proper messages
* Screenshot
* Separate out into multiple sub-features

Bug: 52686
Change-Id: I3cfada2ea264184698de5f322c1fe5041b37b8c8
---
M VisualEditor.hooks.php
M VisualEditor.i18n.php
M VisualEditor.php
M modules/ve-mw/init/ve.init.mw.Target.js
4 files changed, 24 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/95/78795/1

diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php
index 3fee364..8dc5314 100644
--- a/VisualEditor.hooks.php
+++ b/VisualEditor.hooks.php
@@ -252,6 +252,19 @@
                return true;
        }
 
+       public static function onGetBetaPreferences( $user, &$preferences ) {
+               global $wgExtensionAssetsPath;
+
+               $preferences['visualeditor-enable-experimental'] = array(
+                       'version' => '1.0',
+                       'label-message' => 
'visualeditor-preference-experimental-label',
+                       'desc-message' => 
'visualeditor-preference-experimental-description',
+                       'info-link' => 
'visualeditor-preference-experimental-info-link',
+                       'discussion-link' => 
'visualeditor-preference-experimental-discussion-link',
+                       //'screenshot' => $wgExtensionAssetsPath . 
'/VisualEditor/screenshot.png',
+               );
+       }
+
        public static function onListDefinedTags( &$tags ) {
                $tags[] = 'visualeditor';
                $tags[] = 'visualeditor-needcheck';
@@ -297,8 +310,9 @@
                        'namespaces' => $wgVisualEditorNamespaces,
                        'pluginModules' => $wgVisualEditorPluginModules,
                        'defaultUserOptions' => array(
-                               'enable' => 
$wgDefaultUserOptions['visualeditor-enable'],
                                'betatempdisable' => 
$wgDefaultUserOptions['visualeditor-betatempdisable'],
+                               'enable' => 
$wgDefaultUserOptions['visualeditor-enable'],
+                               'experimental' => 
$wgDefaultUserOptions['visualeditor-enable-experimental'],
                        ),
                        'skins' => self::$supportedSkins,
                        'tabPosition' => $wgVisualEditorTabPosition,
diff --git a/VisualEditor.i18n.php b/VisualEditor.i18n.php
index 2949b30..c46bdb4 100644
--- a/VisualEditor.i18n.php
+++ b/VisualEditor.i18n.php
@@ -159,6 +159,8 @@
        'visualeditor-parameter-search-unknown' => 'Unknown parameter',
        'visualeditor-preference-betatempdisable' => 'Temporarily disable 
VisualEditor while it is in beta',
        'visualeditor-preference-enable' => 'Enable VisualEditor (only in the 
[[{{MediaWiki:visualeditor-mainnamespacepagelink}}|main]] and 
[[{{MediaWiki:visualeditor-usernamespacepagelink}}|user]] namespaces)',
+       'visualeditor-preference-experimental-description' => 'Cutting-edge VE 
fun times!',
+       'visualeditor-preference-experimental-label' => 'VisualEditor\'s 
experimental features',
        'visualeditor-reference-input-placeholder' => 'What do you want to 
reference?',
        'visualeditor-referencelist-isempty' => 'There are no references with 
the group "$1" on this page.',
        'visualeditor-referencelist-missingref' => 'This reference is defined 
in a template or other generated block, and for now can only be edited in 
source mode.',
diff --git a/VisualEditor.php b/VisualEditor.php
index 9a00f6b..b5b35fe 100644
--- a/VisualEditor.php
+++ b/VisualEditor.php
@@ -47,6 +47,7 @@
 // Register Hooks
 $wgHooks['BeforePageDisplay'][] = 'VisualEditorHooks::onBeforePageDisplay';
 $wgHooks['DoEditSectionLink'][] = 'VisualEditorHooks::onDoEditSectionLink';
+$wgHooks['GetBetaFeaturePreferences'][] = 
'VisualEditorHooks::onGetBetaPreferences';
 $wgHooks['GetPreferences'][] = 'VisualEditorHooks::onGetPreferences';
 $wgHooks['ListDefinedTags'][] = 'VisualEditorHooks::onListDefinedTags';
 $wgHooks['MakeGlobalVariablesScript'][] = 
'VisualEditorHooks::onMakeGlobalVariablesScript';
@@ -60,6 +61,7 @@
 
 // Set default values for new preferences
 $wgDefaultUserOptions['visualeditor-enable'] = 0;
+$wgDefaultUserOptions['visualeditor-enable-experimental'] = 0;
 $wgDefaultUserOptions['visualeditor-betatempdisable'] = 0;
 
 // Register resource modules
diff --git a/modules/ve-mw/init/ve.init.mw.Target.js 
b/modules/ve-mw/init/ve.init.mw.Target.js
index cdd638d..96b6100 100644
--- a/modules/ve-mw/init/ve.init.mw.Target.js
+++ b/modules/ve-mw/init/ve.init.mw.Target.js
@@ -20,6 +20,8 @@
  *  revision id here. Defaults to loading the latest version (see #load).
  */
 ve.init.mw.Target = function VeInitMwTarget( $container, pageName, revisionId 
) {
+       var conf = mw.config.get( 'wgVisualEditorConfig' );
+
        // Parent constructor
        ve.init.Target.call( this, $container );
 
@@ -33,7 +35,9 @@
        this.submitUrl = ( new mw.Uri( mw.util.wikiGetlink( this.pageName ) ) )
                .extend( { 'action': 'submit' } );
        this.modules = [
-                       mw.config.get( 'wgVisualEditorConfig' 
).enableExperimentalCode ?
+                       ( mw.config.get( 'wgUserName' ) === null ?
+                               conf.defaultUserOptions.experimental :
+                               mw.user.options.get( 
'visualeditor-enable-experimental', conf.defaultUserOptions.experimental ) ) ?
                                'ext.visualEditor.experimental' : 
'ext.visualEditor.core',
                        'ext.visualEditor.specialMessages'
                ]

-- 
To view, visit https://gerrit.wikimedia.org/r/78795
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3cfada2ea264184698de5f322c1fe5041b37b8c8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to