Merge "Add beta feature preference"

This commit is contained in:
jenkins-bot 2020-02-21 22:00:44 +00:00 committed by Gerrit Code Review
commit fcb935a2ba
6 changed files with 115 additions and 1 deletions

View file

@ -184,6 +184,7 @@
"BeforePageDisplay": [
"DiscussionToolsHooks::onBeforePageDisplay"
],
"GetBetaFeaturePreferences": "DiscussionToolsHooks::onGetBetaPreferences",
"ListDefinedTags": "DiscussionToolsHooks::onListDefinedTags",
"ChangeTagsListActive": "DiscussionToolsHooks::onListDefinedTags",
"RecentChange_save": "DiscussionToolsHooks::onRecentChangeSave"
@ -193,6 +194,10 @@
"value": true,
"description": "Enable DiscussionTools on talk pages."
},
"DiscussionToolsBeta": {
"value": false,
"description": "Make DiscussionTools a BetaFeature."
},
"DiscussionToolsUseVisualEditor": {
"value": false,
"description": "Use VisualEditor for editing replies (both visual and wikitext)."

View file

@ -5,6 +5,10 @@
"discussiontools": "Discussion tools",
"discussiontools-defaultsummary-reply": "Reply",
"discussiontools-desc": "Tools to enhance discussion pages.",
"discussiontools-preference-label": "Discussion tools",
"discussiontools-preference-description": "Enable a new workflow for [//www.mediawiki.org/wiki/Talk_pages_project/replying replying to specific comments] on talk pages.\n\nPlease note that over time new tools for interacting with talk pages will be added.\n\nUpdates about these features will be posted on the [//www.mediawiki.org/wiki/Talk_pages_project/Updates talk pages project's updates page].",
"discussiontools-preference-info-link": "\/\/mediawiki.org\/wiki\/Talk_pages_project",
"discussiontools-preference-discussion-link": "\/\/mediawiki.org\/wiki\/Talk:Talk_pages_project",
"discussiontools-replylink": "Reply",
"discussiontools-replywidget-anon-warning": "<strong>You are not logged in.</strong> To receive attribution with your name instead of your IP address, you can [$1 log in] or [$2 create an account].",
"discussiontools-replywidget-cancel": "Cancel",

View file

@ -9,6 +9,10 @@
"discussiontools": "{{name}}",
"discussiontools-defaultsummary-reply": "Default edit summary for a reply.\n\n'''Note that this is a noun (''a reply''), not a verb (''to reply''). Alternatively you can use a paste tense verb if that's more natural in your language.'''",
"discussiontools-desc": "{{desc\n| name = DiscussionTools\n| url = https://www.mediawiki.org/wiki/Extension:DiscussionTools\n}}",
"discussiontools-preference-description": "Used in [[Special:Preferences]].\n\nUsed as description for the checkbox to enable discussion tools.\n\nThe label for this checkbox is {{msg-mw|discussiontools-preference-label}}.",
"discussiontools-preference-discussion-link": "{{optional|Used on [[Special:Preferences]] as a link to a page where users can discuss this Beta Feature. Defaults to a page on MediaWiki.org.}}",
"discussiontools-preference-info-link": "{{optional|Used on [[Special:Preferences]] as a link to a page where users can learn about this Beta Feature. Defaults to a page on MediaWiki.org.}}",
"discussiontools-preference-label": "Used in [[Special:Preferences]].\n\nUsed as label for checkbox to enable discussion tools.\n\nThe description for this checkbox is: {{msg-mw|discussiontools-preference-description}}",
"discussiontools-replylink": "Label for the reply link added after each comment.",
"discussiontools-replywidget-anon-warning": "Warning message to be displayed when anonymous user starts writing a new topic or reply.\n* $1 is a URL to log in.\n* $2 is a URL to register an account.",
"discussiontools-replywidget-cancel": "Label for the cancel button in the reply widget",

View file

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1" viewBox="0 0 264 162" xmlns="http://www.w3.org/2000/svg" width="264" height="162">
<defs>
<clipPath id="jagged-edge">
<path d="M0 0v152l12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10V0z"/>
</clipPath>
</defs>
<g clip-path="url(#jagged-edge)" fill="#eaecf0">
<path id="background" d="m0 0h264v162h-264" fill="#fff"/>
<path id="logo" d="m11 22c0-8 6-14 14-14s14 6 14 14-6 14-14 14-14-6-14-14m27 23v-5h-25v5h25"/>
<path id="sidebar" d="m38 163v-105h-25v106h25"/>
<path id="personal-tools" d="m233 5h26v6h-26zm-24 0h22v6h-22zm-24 0h22v6h-22zm-23 0h13v6h-13zm15 0h6v6h-6zm-23 0h6v6h-6z"/>
<g id="search">
<path id="input" d="m258 16v4h-92v-4h92m1-1h-94v6h94z"/>
<path id="icon" d="m168 17h2v2h-2z"/>
</g>
<path id="article" d="m252 162v-133h-204v133z"/>
<path id="border" d="m0 0v162h264v-162zm1 1h262v150.53l-11 9.166-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-11-9z"/>
</g>
<path d="m60.828 43.534h179.14v3h-179.14zm0 10h179.14v3h-179.14zm0 10h52.137v3h-52.137z" fill="#c8ccd1" stroke-width="1.1562"/>
<path d="m80.172 73.534h159.79v3h-159.79zm0 10h46.507v3h-46.507z" fill="#c8ccd1" stroke-width="1.092"/>
<g>
<g fill-rule="evenodd">
<rect x="131.03" y="81.763" width="19.94" height="6.9046" color="#000000" fill="#36c"/>
<rect x="91.77" y="93.329" width="147.2" height="34.549" color="#000000" fill="#fff" stroke="#36c" stroke-width="2"/>
<rect x="214.92" y="133.01" width="25.045" height="8.6724" color="#000000" fill="#36c"/>
</g>
<path d="m99.143 100.61h132.18v3h-132.18zm0 10h38.469v3h-38.469z" fill="#7a818e" stroke-width=".99317"/>
<rect x="117.03" y="61.763" width="19.94" height="6.9046" color="#000000" fill="#36c" fill-rule="evenodd"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View file

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1" viewBox="0 0 264 162" xmlns="http://www.w3.org/2000/svg" width="264" height="162">
<defs>
<clipPath id="jagged-edge">
<path d="M0 0v152l12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10V0z"/>
</clipPath>
</defs>
<g transform="matrix(-1,0,0,1,264,0)" clip-path="url(#jagged-edge)" fill="#eaecf0">
<path id="background" d="m0 0h264v162h-264" fill="#fff"/>
<path id="logo" d="m11 22c0-8 6-14 14-14s14 6 14 14-6 14-14 14-14-6-14-14m27 23v-5h-25v5h25"/>
<path id="sidebar" d="m38 163v-105h-25v106h25"/>
<path id="personal-tools" d="m233 5h26v6h-26zm-24 0h22v6h-22zm-24 0h22v6h-22zm-23 0h13v6h-13zm15 0h6v6h-6zm-23 0h6v6h-6z"/>
<g id="search">
<path id="input" d="m258 16v4h-92v-4h92m1-1h-94v6h94z"/>
<path id="icon" d="m168 17h2v2h-2z"/>
</g>
<path id="article" d="m252 162v-133h-204v133z"/>
<path id="border" d="m0 0v162h264v-162zm1 1h262v150.53l-11 9.166-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-11-9z"/>
</g>
<path d="m203.17 43.534h-179.14v3h179.14zm0 10h-179.14v3h179.14zm0 10h-52.137v3h52.137z" fill="#c8ccd1" stroke-width="1.1562"/>
<path d="m183.83 73.534h-159.79v3h159.79zm0 10h-46.507v3h46.507z" fill="#c8ccd1" stroke-width="1.092"/>
<g>
<g fill-rule="evenodd">
<rect transform="scale(-1,1)" x="-132.97" y="81.763" width="19.94" height="6.9046" color="#000000" fill="#36c"/>
<rect transform="scale(-1,1)" x="-172.23" y="93.329" width="147.2" height="34.549" color="#000000" fill="#fff" stroke="#36c" stroke-width="2"/>
<rect transform="scale(-1,1)" x="-49.079" y="133.01" width="25.045" height="8.6724" color="#000000" fill="#36c"/>
</g>
<path d="m164.86 100.61h-132.18v3h132.18zm0 10h-38.469v3h38.469z" fill="#7a818e" stroke-width=".99317"/>
<rect transform="scale(-1,1)" x="-146.97" y="61.763" width="19.94" height="6.9046" color="#000000" fill="#36c" fill-rule="evenodd"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2 KiB

View file

@ -50,6 +50,11 @@ class DiscussionToolsHooks {
$title = $output->getTitle();
$actionName = Action::getActionName( $output->getContext() );
$req = $output->getRequest();
$user = $skin->getUser();
$enabled = $dtConfig->get( 'DiscussionToolsEnable' ) && (
!$dtConfig->get( 'DiscussionToolsBeta' ) ||
$user->getOption( 'discussiontools-betaenable' )
);
if (
// Don't show on edit pages
@ -61,7 +66,7 @@ class DiscussionToolsHooks {
// Query parameter to load on any wikitext page for testing
$req->getVal( 'dtenable' ) ||
// If configured, load on all talk pages
( $dtConfig->get( 'DiscussionToolsEnable' ) && $title->isTalkPage() )
( $enabled && $title->isTalkPage() )
// TODO: Allow non talk pages to be treated as talk pages
// using a magic word.
)
@ -72,6 +77,40 @@ class DiscussionToolsHooks {
}
}
/**
* Handler for the GetBetaPreferences hook, to add and hide user beta preferences as configured
*
* @param User $user The user object
* @param array &$preferences Their preferences object
*/
public static function onGetBetaPreferences( User $user, array &$preferences ) {
$coreConfig = RequestContext::getMain()->getConfig();
$iconpath = $coreConfig->get( 'ExtensionAssetsPath' ) . '/DiscussionTools/images';
$dtConfig = MediaWikiServices::getInstance()->getConfigFactory()
->makeConfig( 'discussiontools' );
if (
$dtConfig->get( 'DiscussionToolsEnable' ) &&
$dtConfig->get( 'DiscussionToolsBeta' )
) {
$preferences['discussiontools-betaenable'] = [
'version' => '1.0',
'label-message' => 'discussiontools-preference-label',
'desc-message' => 'discussiontools-preference-description',
'screenshot' => [
'ltr' => "$iconpath/betafeatures-icon-DiscussionTools-ltr.svg",
'rtl' => "$iconpath/betafeatures-icon-DiscussionTools-rtl.svg",
],
'info-message' => 'discussiontools-preference-info-link',
'discussion-message' => 'discussiontools-preference-discussion-link',
'requirements' => [
'javascript' => true
]
];
}
}
/**
* Implements the ListDefinedTags and ChangeTagsListActive hooks, to
* populate core Special:Tags with the change tags in use by DiscussionTools.