Merge "Enable DT server side via a cookie to preserve user enable hack"

This commit is contained in:
jenkins-bot 2020-10-19 21:51:56 +00:00 committed by Gerrit Code Review
commit 83b6f3b6ce
3 changed files with 20 additions and 7 deletions

View file

@ -45,6 +45,7 @@
{
"name": "config.json",
"config": {
"enable": "DiscussionToolsEnable",
"enable2017Wikitext": "DiscussionToolsEnable2017Wikitext"
}
},
@ -71,6 +72,7 @@
"mediawiki.util",
"mediawiki.storage",
"mediawiki.String",
"mediawiki.cookie",
"ext.visualEditor.core.utils.parsing"
],
"messages": [

View file

@ -76,9 +76,11 @@ class Hooks {
$dtConfig = $services->getConfigFactory()->makeConfig( 'discussiontools' );
$isBeta = $dtConfig->get( 'DiscussionToolsBeta' );
$userEnabled = $dtConfig->get( 'DiscussionToolsEnable' ) && (
( $isBeta && $optionsLookup->getOption( $user, 'discussiontools-betaenable' ) ) ||
( !$isBeta && $optionsLookup->getOption( $user, 'discussiontools-replytool' ) )
$userEnabled = $output->getRequest()->getCookie( 'discussiontools-tempenable' ) || (
$dtConfig->get( 'DiscussionToolsEnable' ) && (
( $isBeta && $optionsLookup->getOption( $user, 'discussiontools-betaenable' ) ) ||
( !$isBeta && $optionsLookup->getOption( $user, 'discussiontools-replytool' ) )
)
);
// Finally check the user has the tool enabled and that the page

View file

@ -1,4 +1,6 @@
var controller = require( './controller.js' );
var controller = require( './controller.js' ),
config = require( './config.json' ),
uri = new mw.Uri();
/**
* @class mw.dt
@ -16,15 +18,22 @@ mw.dt.init = function ( $container ) {
}
};
if ( new mw.Uri().query.dtdebug ) {
if ( uri.query.dtdebug ) {
mw.loader.load( 'ext.discussionTools.debug' );
} else if ( mw.config.get( 'wgIsProbablyEditable' ) ) {
// Don't use an anonymous function, because ReplyWidget needs to be able to remove this handler
mw.hook( 'wikipage.content' ).add( mw.dt.init );
}
// If the tool is not enabled on this wiki, then the user
// is using a local hack to load this code. Set a cookie
// so reply links are added on the server.
if ( !config.enable && !uri.query.dtenable ) {
mw.cookie.set( 'discussiontools-tempenable', 1 );
}
module.exports = {
controller: require( './controller.js' ),
controller: controller,
Parser: require( './Parser.js' ),
modifier: require( './modifier.js' ),
ThreadItem: require( './ThreadItem.js' ),
@ -32,5 +41,5 @@ module.exports = {
CommentItem: require( './CommentItem.js' ),
utils: require( './utils.js' ),
logger: require( './logger.js' ),
config: require( './config.json' )
config: config
};