jenkins-bot has submitted this change and it was merged.

Change subject: Add resources and enable the beta feature
......................................................................


Add resources and enable the beta feature

With this change the user is able to turn on WikiLabels in the
beta features preference page.

Most of the code is a copy-paste from the WikiLabels repo [1].
This patch is a proof-of-concept patch to demonstrate that
the WikiLabels service works as a beta feature. There is room
to improve the codebase in follow-up patches.

[1] https://github.com/wiki-ai/wikilabels

Change-Id: I795003243a411718d1a587608e951493542d5b34
---
M WikiLabels.hooks.php
M extension.json
M i18n/en.json
M i18n/qqq.json
A images/beta-features-ltr.svg
A images/beta-features-rtl.svg
D modules/.gitkeep
A modules/init.js
D specials/.gitkeep
A specials/SpecialWikiLabels.php
A specials/gadget.mustache
11 files changed, 282 insertions(+), 5 deletions(-)

Approvals:
  Bmansurov: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/WikiLabels.hooks.php b/WikiLabels.hooks.php
index 9c759b9..68599ce 100644
--- a/WikiLabels.hooks.php
+++ b/WikiLabels.hooks.php
@@ -1,4 +1,10 @@
 <?php
+
+namespace WikiLabels;
+
+use ConfigFactory;
+use User;
+
 /**
  * Hooks for WikiLabels extension
  *
@@ -6,6 +12,43 @@
  * @ingroup Extensions
  */
 
-class WikiLabelsHooks {
+class Hooks {
+       /**
+        * Add a WikiLabels beta feature to the list of beta features
+        *
+        * @param User $user
+        * @param array $prefs
+        */
+       public static function onGetBetaFeaturePreferences( User $user, array 
&$prefs ) {
+               $config = ConfigFactory::getDefaultInstance()->makeConfig( 
'main' );
+               $wgExtensionAssetsPath = $config->get( 'ExtensionAssetsPath' );
 
+               $prefs['wiki-labels-enabled'] = [
+                       'label-message' => 'wikilabels-beta-features-label',
+                       'desc-message' => 'wikilabels-beta-features-desc',
+                       'screenshot' => [
+                               'ltr' => 
"$wgExtensionAssetsPath/WikiLabels/images/beta-features-ltr.svg",
+                               'rtl' => 
"$wgExtensionAssetsPath/WikiLabels/images/beta-features-rtl.svg",
+                       ],
+                       'info-link' => 
'https://www.mediawiki.org/wiki/Extension:WikiLabels',
+                       // Link to discussion about the feature - talk pages 
might work
+                       'discussion-link' => 
'https://www.mediawiki.org/wiki/Extension_talk:WikiLabels',
+               ];
+       }
+
+       /**
+        * ResourceLoaderGetConfigVars hook handler for registering enabled 
surveys
+        * @see 
https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderGetConfigVars
+        *
+        * @param array $vars
+        * @return boolean
+        */
+       public static function onResourceLoaderGetConfigVars( &$vars ) {
+               global $wgWikiLabelsServiceRootUrl;
+
+               $vars['wgWikiLabelsServiceRootUrl'] = 
$wgWikiLabelsServiceRootUrl;
+
+               return true;
+       }
 }
+
diff --git a/extension.json b/extension.json
index 6a7c104..be78cac 100644
--- a/extension.json
+++ b/extension.json
@@ -2,21 +2,28 @@
        "name": "WikiLabels",
        "version": "0.0.1",
        "author": [
-               "Baha Man"
+               "Baha"
        ],
        "url": "https://www.mediawiki.org/wiki/Extension:WikiLabels";,
        "descriptionmsg": "wikilabels-desc",
        "license-name": "MIT",
        "type": "other",
        "AutoloadClasses": {
-               "WikiLabelsHooks": "WikiLabels.hooks.php"
+               "WikiLabels\\Hooks": "WikiLabels.hooks.php",
+               "WikiLabels\\SpecialWikiLabels": 
"specials/SpecialWikiLabels.php"
        },
        "config": {
+               "WikiLabelsServiceRootUrl": "//labels.wmflabs.org"
+       },
+       "ConfigRegistry": {
+               "WikiLabels": "GlobalVarConfig::newInstance"
        },
        "ExtensionMessagesFiles": {
                "WikiLabelsAlias": "WikiLabels.i18n.alias.php"
        },
        "Hooks": {
+               "ResourceLoaderGetConfigVars": 
"WikiLabels\\Hooks::onResourceLoaderGetConfigVars",
+               "GetBetaFeaturePreferences": 
"WikiLabels\\Hooks::onGetBetaFeaturePreferences"
        },
        "MessagesDirs": {
                "WikiLabels": [
@@ -24,12 +31,18 @@
                ]
        },
        "ResourceModules": {
+               "ext.wikiLabels": {
+                       "scripts": [
+                               "modules/init.js"
+                       ]
+               }
        },
        "ResourceFileModulePaths": {
                "localBasePath": "",
                "remoteExtPath": "WikiLabels"
        },
        "SpecialPages": {
+               "WikiLabels": "WikiLabels\\SpecialWikiLabels"
        },
        "manifest_version": 1
 }
diff --git a/i18n/en.json b/i18n/en.json
index feab6de..844cfae 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -2,6 +2,10 @@
        "@metadata": {
                "authors": []
        },
+       "wikilabels": "WikiLabels",
        "wikilabels-desc": "WikiLabels extension",
-       "wikilabels-i18n-welcome": "Welcome to the localization file of the 
WikiLabels extension."
+       "wikilabels-beta-features-label": "Wiki labels",
+       "wikilabels-beta-features-desc": "Allows to collaboratively label wiki 
artifacts quickly and easily.",
+       "wikilabels-beta-features-not-enabled-title": "WikiLabels is not 
enabled.",
+       "wikilabels-beta-features-not-enabled-desc": "Please enable [$1 
WikiLabels beta feature] to view this page."
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 6dac57e..a90cb1c 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -2,6 +2,10 @@
        "@metadata": {
                "authors": []
        },
+       "wikilabels": "Extension name",
        "wikilabels-desc": 
"{{desc|name=WikiLabels|url=https://www.mediawiki.org/wiki/Extension:WikiLabels}}";,
-       "wikilabels-i18n-welcome": "Used to greet the user when reading the 
i18n/??.json file."
+       "wikilabels-beta-features-label": "Label of the beta feature",
+       "wikilabels-beta-features-desc": "Description of the beta feature",
+       "wikilabels-beta-features-not-enabled-title": "Title of the page when 
WikiLabels beta feature is not enabled",
+       "wikilabels-beta-features-not-enabled-desc": "Description of the page 
when WikiLabels beta feature is not enabled. $1 is the link to the BetaFeatures 
page."
 }
diff --git a/images/beta-features-ltr.svg b/images/beta-features-ltr.svg
new file mode 100644
index 0000000..3a6ae4c
--- /dev/null
+++ b/images/beta-features-ltr.svg
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg width="264px" height="162px" viewBox="0 0 264 162" version="1.1" 
xmlns="http://www.w3.org/2000/svg"; xmlns:xlink="http://www.w3.org/1999/xlink";>
+    <!-- Generator: Sketch 3.7.2 (28276) - 
http://www.bohemiancoding.com/sketch -->
+    <title>wb-otherprojects-beta-ltr</title>
+    <desc>Created with Sketch.</desc>
+    <defs></defs>
+    <g id="Page-1" stroke="none" stroke-width="1" fill="none" 
fill-rule="evenodd">
+        <g id="Group">
+            <g id="Shape">
+                <polygon fill="#FFFFFF" points="13.366 161.357 0.5 151.749 0.5 
0.5 263.5 0.5 263.5 152.249 254.5 158.954 254.5 42.5 215.5 42.5 215.5 155.1 
211.107 151.369 203.5 156.699 203.5 22.5 48.5 22.5 48.5 153.349 38.749 161.38 
24.833 151.362"></polygon>
+                <path d="M263,1 L263,151.998 L255,157.958 L255,43 L255,42 
L254,42 L216,42 L215,42 L215,43 L215,154.019 L211.726,151.24 L211.137,150.741 
L210.504,151.181 L204,155.738 L204,43 L204,42 L203,42 L49,42 L48,42 L48,43 
L48,153.099 L38.743,160.76 L25.448,151.191 L24.804,150.726 L24.206,151.247 
L13.342,160.717 L1,151.499 L1,1 L263,1 L263,1 L263,1 Z M264,0 L0,0 L0,152 
L13.391,162 L24.864,152 L38.755,162 L49,153.6 L49,43 L203,43 L203,157.66 
L211.078,152 L216,156.18 L216,43 L254,43 L254,159.95 L264,152.5 L264,0 L264,0 
L264,0 L264,0 L264,0 Z" fill="#E5E5E5"></path>
+            </g>
+            <polygon id="Shape" fill="#E5E5E5" points="203 156.894118 203 22 
49 22 49 152.117647 51.145 150.235294 63.7 162 77.509 150.235294 91.738 162 
104.71 150.235294 117.683 162 131.494 150.235294 143.63 162 157.021 150.235294 
171.25 162 184.222 150.235294 197.196 162 203 156.894118 203 156.894118 203 
156.894118"></polygon>
+            <path d="M11,36 C11,28.268 17.268,22 25,22 C32.732,22 39,28.268 
39,36 C39,43.732 32.732,50 25,50 C17.268,50 11,43.732 11,36 C11,36 11,43.732 
11,36 L11,36 L11,36 L11,36 Z" id="Shape" fill="#E5E5E5"></path>
+            <polygon id="Shape" fill="#E5E5E5" points="254 22 216 22 216 
155.152941 223.551 162 237.362 150.235294 251.253 162 254 159.588235"></polygon>
+            <polygon id="Shape" fill="#E5E5E5" points="38 132 38 72 13 72 13 
132 38 132 38 132 38 132"></polygon>
+            <polygon id="Shape" fill="#E5E5E5" points="233 5 259 5 259 11 233 
11 233 5 233 5 233 5"></polygon>
+            <path d="M142,6 L142,10 L50,10 L50,6 L142,6 L142,6 L142,6 Z M143,5 
L49,5 L49,11 L143,11 L143,5 L143,5 L143,5 L143,5 L143,5 Z" id="Shape" 
fill="#E5E5E5"></path>
+            <rect id="Rectangle-path" fill="#E5E5E5" x="9" y="5" width="32" 
height="6"></rect>
+            <path d="M2,15 L262,15" id="Shape" stroke="#E5E5E5" 
fill="#E5E5E5"></path>
+            <rect id="Rectangle-path" fill="#E5E5E5" x="52" y="7" width="2" 
height="2"></rect>
+            <polygon id="Shape" fill="#E5E5E5" points="38 59 38 54 13 54 13 59 
38 59 38 59 38 59"></polygon>
+            <polygon id="Shape" fill="#D8D8D8" points="228.51 5 228.51 11 216 
11 216 5"></polygon>
+            <polygon id="Shape" fill="#D8D8D8" points="212.51 5 212.51 11 200 
11 200 5"></polygon>
+            <polygon id="Shape" fill="#D8D8D8" points="196.51 5 196.51 11 184 
11 184 5"></polygon>
+        </g>
+        <path d="M112,64.59375 L112,71 L118.40625,71 L137.308958,52.0972917 
L130.902708,45.6910417 L112,64.59375 L112,64.59375 Z M142.246042,47.1602083 
C142.912292,46.4939583 142.912292,45.4091667 142.246042,44.7429167 
L138.257083,40.7539583 C137.590833,40.0877083 136.506042,40.0877083 
135.839792,40.7539583 L132.713542,43.8802083 L139.119792,50.2864583 
L142.246042,47.1602083 L142.246042,47.1602083 Z" fill="#347BFF"></path>
+        <path d="M68,90 L116.46514,90 C119.215616,90 121.677934,82.1886513 
124.42841,82.1886513 C127.439669,82.1886513 130.739086,90 133.750345,90 L184,90 
L184,137 L68,137 L68,90 Z" id="Rectangle-3" fill="#347BFF"></path>
+        <g transform="translate(82.000000, 98.000000)" fill="#FFFFFF">
+            <g id="Group-3">
+                <path d="M16.102,31.398 C7.551,31.398 0.578,24.422 
0.578,15.875 C0.578,7.324 7.555,0.352 16.102,0.352 C24.652,0.352 31.625,7.328 
31.625,15.875 C31.625,24.426 24.648,31.398 16.102,31.398 L16.102,31.398 Z 
M16.102,1.852 C8.375,1.852 2.078,8.152 2.078,15.875 C2.078,23.602 8.379,29.898 
16.102,29.898 C23.828,29.898 30.125,23.598 30.125,15.875 C30.125,8.148 
23.824,1.852 16.102,1.852 L16.102,1.852 Z" id="Fill-1"></path>
+                <path d="M10.398,13.25 C10.324,12.949 10.547,12.648 
10.848,12.648 L13.699,12.648 C14,12.648 14.223,12.949 14.148,13.25 C13.922,14 
13.172,14.602 12.273,14.602 C11.375,14.602 10.625,14.074 10.398,13.25 
L10.398,13.25 Z" id="Fill-3"></path>
+                <path d="M19.477,22.926 L12.727,22.926 C12.352,22.926 
12.125,22.625 12.203,22.324 C12.504,20.449 14.152,18.949 16.18,18.949 
C18.203,18.949 19.855,20.375 20.156,22.324 C20.074,22.625 19.852,22.926 
19.477,22.926 L19.477,22.926 Z" id="Fill-4"></path>
+                <path d="M21.801,13.25 C21.574,14 20.824,14.602 19.926,14.602 
C19.027,14.602 18.352,14 18.051,13.25 C17.977,12.949 18.199,12.648 18.5,12.648 
L21.352,12.648 C21.727,12.648 21.949,12.949 21.801,13.25 L21.801,13.25 Z" 
id="Fill-5"></path>
+            </g>
+            <g id="Group-2" transform="translate(56.000000, 0.000000)">
+                <path d="M16.273,31.398 C7.727,31.398 0.75,24.426 0.75,15.875 
C0.75,7.324 7.727,0.352 16.273,0.352 C24.824,0.352 31.797,7.328 31.797,15.875 
C31.797,24.426 24.824,31.398 16.273,31.398 L16.273,31.398 Z M16.273,1.852 
C8.551,1.852 2.25,8.148 2.25,15.875 C2.25,23.602 8.551,29.898 16.273,29.898 
C24,29.898 30.297,23.598 30.297,15.875 C30.301,8.148 24,1.852 16.273,1.852 
L16.273,1.852 Z" id="Fill-2"></path>
+                <path d="M14.324,12.648 C14.324,15.25 10.426,15.25 
10.426,12.648 C10.426,10.051 14.324,10.051 14.324,12.648" id="Fill-6"></path>
+                <path d="M16.273,23.898 C13.875,23.898 11.848,22.098 
11.473,19.848 C11.398,19.473 11.699,19.098 12.148,19.098 L20.398,19.098 
C20.773,19.098 21.148,19.473 21.074,19.848 C20.699,22.176 18.676,23.898 
16.273,23.898 L16.273,23.898 Z" id="Fill-7"></path>
+                <path d="M22.199,12.648 C22.199,15.25 18.301,15.25 
18.301,12.648 C18.301,10.051 22.199,10.051 22.199,12.648" id="Fill-8"></path>
+            </g>
+        </g>
+    </g>
+</svg>
\ No newline at end of file
diff --git a/images/beta-features-rtl.svg b/images/beta-features-rtl.svg
new file mode 100644
index 0000000..099a9a9
--- /dev/null
+++ b/images/beta-features-rtl.svg
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg width="264px" height="162px" viewBox="0 0 264 162" version="1.1" 
xmlns="http://www.w3.org/2000/svg"; xmlns:xlink="http://www.w3.org/1999/xlink";>
+    <!-- Generator: Sketch 3.7.2 (28276) - 
http://www.bohemiancoding.com/sketch -->
+    <title>wb-otherprojects-beta-ltr</title>
+    <desc>Created with Sketch.</desc>
+    <defs></defs>
+    <g id="Page-1" stroke="none" stroke-width="1" fill="none" 
fill-rule="evenodd">
+        <g id="Group">
+            <g id="Shape">
+                <polygon fill="#FFFFFF" points="13.366 161.357 0.5 151.749 0.5 
0.5 263.5 0.5 263.5 152.249 254.5 158.954 254.5 42.5 215.5 42.5 215.5 155.1 
211.107 151.369 203.5 156.699 203.5 22.5 48.5 22.5 48.5 153.349 38.749 161.38 
24.833 151.362"></polygon>
+                <path d="M263,1 L263,151.998 L255,157.958 L255,43 L255,42 
L254,42 L216,42 L215,42 L215,43 L215,154.019 L211.726,151.24 L211.137,150.741 
L210.504,151.181 L204,155.738 L204,43 L204,42 L203,42 L49,42 L48,42 L48,43 
L48,153.099 L38.743,160.76 L25.448,151.191 L24.804,150.726 L24.206,151.247 
L13.342,160.717 L1,151.499 L1,1 L263,1 L263,1 L263,1 Z M264,0 L0,0 L0,152 
L13.391,162 L24.864,152 L38.755,162 L49,153.6 L49,43 L203,43 L203,157.66 
L211.078,152 L216,156.18 L216,43 L254,43 L254,159.95 L264,152.5 L264,0 L264,0 
L264,0 L264,0 L264,0 Z" fill="#E5E5E5"></path>
+            </g>
+            <polygon id="Shape" fill="#E5E5E5" points="203 156.894118 203 22 
49 22 49 152.117647 51.145 150.235294 63.7 162 77.509 150.235294 91.738 162 
104.71 150.235294 117.683 162 131.494 150.235294 143.63 162 157.021 150.235294 
171.25 162 184.222 150.235294 197.196 162 203 156.894118 203 156.894118 203 
156.894118"></polygon>
+            <path d="M11,36 C11,28.268 17.268,22 25,22 C32.732,22 39,28.268 
39,36 C39,43.732 32.732,50 25,50 C17.268,50 11,43.732 11,36 C11,36 11,43.732 
11,36 L11,36 L11,36 L11,36 Z" id="Shape" fill="#E5E5E5"></path>
+            <polygon id="Shape" fill="#E5E5E5" points="254 22 216 22 216 
155.152941 223.551 162 237.362 150.235294 251.253 162 254 159.588235"></polygon>
+            <polygon id="Shape" fill="#E5E5E5" points="38 132 38 72 13 72 13 
132 38 132 38 132 38 132"></polygon>
+            <polygon id="Shape" fill="#E5E5E5" points="233 5 259 5 259 11 233 
11 233 5 233 5 233 5"></polygon>
+            <path d="M142,6 L142,10 L50,10 L50,6 L142,6 L142,6 L142,6 Z M143,5 
L49,5 L49,11 L143,11 L143,5 L143,5 L143,5 L143,5 L143,5 Z" id="Shape" 
fill="#E5E5E5"></path>
+            <rect id="Rectangle-path" fill="#E5E5E5" x="9" y="5" width="32" 
height="6"></rect>
+            <path d="M2,15 L262,15" id="Shape" stroke="#E5E5E5" 
fill="#E5E5E5"></path>
+            <rect id="Rectangle-path" fill="#E5E5E5" x="52" y="7" width="2" 
height="2"></rect>
+            <polygon id="Shape" fill="#E5E5E5" points="38 59 38 54 13 54 13 59 
38 59 38 59 38 59"></polygon>
+            <polygon id="Shape" fill="#D8D8D8" points="228.51 5 228.51 11 216 
11 216 5"></polygon>
+            <polygon id="Shape" fill="#D8D8D8" points="212.51 5 212.51 11 200 
11 200 5"></polygon>
+            <polygon id="Shape" fill="#D8D8D8" points="196.51 5 196.51 11 184 
11 184 5"></polygon>
+        </g>
+        <path d="M112,64.59375 L112,71 L118.40625,71 L137.308958,52.0972917 
L130.902708,45.6910417 L112,64.59375 L112,64.59375 Z M142.246042,47.1602083 
C142.912292,46.4939583 142.912292,45.4091667 142.246042,44.7429167 
L138.257083,40.7539583 C137.590833,40.0877083 136.506042,40.0877083 
135.839792,40.7539583 L132.713542,43.8802083 L139.119792,50.2864583 
L142.246042,47.1602083 L142.246042,47.1602083 Z" fill="#347BFF" 
transform="translate(127.372865, 55.627135) scale(-1, 1) translate(-127.372865, 
-55.627135) "></path>
+        <path d="M68,90 L116.46514,90 C119.215616,90 121.677934,82.1886513 
124.42841,82.1886513 C127.439669,82.1886513 130.739086,90 133.750345,90 L184,90 
L184,137 L68,137 L68,90 Z" id="Rectangle-3" fill="#347BFF"></path>
+        <g transform="translate(82.000000, 98.000000)" fill="#FFFFFF">
+            <g id="Group-3">
+                <path d="M16.102,31.398 C7.551,31.398 0.578,24.422 
0.578,15.875 C0.578,7.324 7.555,0.352 16.102,0.352 C24.652,0.352 31.625,7.328 
31.625,15.875 C31.625,24.426 24.648,31.398 16.102,31.398 L16.102,31.398 Z 
M16.102,1.852 C8.375,1.852 2.078,8.152 2.078,15.875 C2.078,23.602 8.379,29.898 
16.102,29.898 C23.828,29.898 30.125,23.598 30.125,15.875 C30.125,8.148 
23.824,1.852 16.102,1.852 L16.102,1.852 Z" id="Fill-1"></path>
+                <path d="M10.398,13.25 C10.324,12.949 10.547,12.648 
10.848,12.648 L13.699,12.648 C14,12.648 14.223,12.949 14.148,13.25 C13.922,14 
13.172,14.602 12.273,14.602 C11.375,14.602 10.625,14.074 10.398,13.25 
L10.398,13.25 Z" id="Fill-3"></path>
+                <path d="M19.477,22.926 L12.727,22.926 C12.352,22.926 
12.125,22.625 12.203,22.324 C12.504,20.449 14.152,18.949 16.18,18.949 
C18.203,18.949 19.855,20.375 20.156,22.324 C20.074,22.625 19.852,22.926 
19.477,22.926 L19.477,22.926 Z" id="Fill-4"></path>
+                <path d="M21.801,13.25 C21.574,14 20.824,14.602 19.926,14.602 
C19.027,14.602 18.352,14 18.051,13.25 C17.977,12.949 18.199,12.648 18.5,12.648 
L21.352,12.648 C21.727,12.648 21.949,12.949 21.801,13.25 L21.801,13.25 Z" 
id="Fill-5"></path>
+            </g>
+            <g id="Group-2" transform="translate(56.000000, 0.000000)">
+                <path d="M16.273,31.398 C7.727,31.398 0.75,24.426 0.75,15.875 
C0.75,7.324 7.727,0.352 16.273,0.352 C24.824,0.352 31.797,7.328 31.797,15.875 
C31.797,24.426 24.824,31.398 16.273,31.398 L16.273,31.398 Z M16.273,1.852 
C8.551,1.852 2.25,8.148 2.25,15.875 C2.25,23.602 8.551,29.898 16.273,29.898 
C24,29.898 30.297,23.598 30.297,15.875 C30.301,8.148 24,1.852 16.273,1.852 
L16.273,1.852 Z" id="Fill-2"></path>
+                <path d="M14.324,12.648 C14.324,15.25 10.426,15.25 
10.426,12.648 C10.426,10.051 14.324,10.051 14.324,12.648" id="Fill-6"></path>
+                <path d="M16.273,23.898 C13.875,23.898 11.848,22.098 
11.473,19.848 C11.398,19.473 11.699,19.098 12.148,19.098 L20.398,19.098 
C20.773,19.098 21.148,19.473 21.074,19.848 C20.699,22.176 18.676,23.898 
16.273,23.898 L16.273,23.898 Z" id="Fill-7"></path>
+                <path d="M22.199,12.648 C22.199,15.25 18.301,15.25 
18.301,12.648 C18.301,10.051 22.199,10.051 22.199,12.648" id="Fill-8"></path>
+            </g>
+        </g>
+    </g>
+</svg>
\ No newline at end of file
diff --git a/modules/.gitkeep b/modules/.gitkeep
deleted file mode 100644
index e69de29..0000000
--- a/modules/.gitkeep
+++ /dev/null
diff --git a/modules/init.js b/modules/init.js
new file mode 100644
index 0000000..ac86c85
--- /dev/null
+++ b/modules/init.js
@@ -0,0 +1,35 @@
+( function ( mw, $ ) {
+       $( function () {
+               var $wikilabelsHome = $( '#wikilabels-home' ),
+                       serviceRootUrl = mw.config.get( 
'wgWikiLabelsServiceRootUrl' );
+
+               // Check if we should try to load Wiki Labels
+               if ( $wikilabelsHome.length ) {
+                       // FIXME: move over the gadget styles to this extension
+                       mw.loader.load( serviceRootUrl + 
'/gadget/WikiLabels.css', 'text/css' );
+                       mw.loader.using(
+                               [
+                                       'oojs',
+                                       'oojs-ui',
+                                       'json',
+                                       'jquery.spinner',
+                                       'mediawiki.action.history.diff',
+                                       'mediawiki.util',
+                                       'mediawiki.language'
+                               ],
+                               function () {
+                                       $.getScript(
+                                               // FIXME: move over the gadget 
scripts to this extension
+                                               serviceRootUrl + 
'/gadget/WikiLabels.js',
+                                               function () {
+                                                       
wikiLabels.config.update( {
+                                                               serverRoot: 
serviceRootUrl
+                                                       } );
+                                                       wikiLabels.home = new 
wikiLabels.Home( $wikilabelsHome );
+                                               }
+                                       );
+                               }
+                       );
+               }
+       } );
+}( mediaWiki, jQuery ) );
diff --git a/specials/.gitkeep b/specials/.gitkeep
deleted file mode 100644
index e69de29..0000000
--- a/specials/.gitkeep
+++ /dev/null
diff --git a/specials/SpecialWikiLabels.php b/specials/SpecialWikiLabels.php
new file mode 100644
index 0000000..9972725
--- /dev/null
+++ b/specials/SpecialWikiLabels.php
@@ -0,0 +1,41 @@
+<?php
+
+namespace WikiLabels;
+
+use BetaFeatures;
+use SpecialPage;
+use TemplateParser;
+
+/**
+ * Class SpecialWikiLabels
+ * @package WikiLabels
+ */
+class SpecialWikiLabels extends SpecialPage {
+       public function __construct() {
+               parent::__construct( 'WikiLabels' );
+       }
+
+       public function execute( $subPage ) {
+               $out = $this->getOutput();
+               $templateData = [ 'error' => false ];
+
+               if ( $subPage ) {
+                       $out->redirect( SpecialPage::getTitleFor( 'WikiLabels' 
)->getLocalURL() );
+               } elseif ( class_exists( 'BetaFeatures' ) &&
+                       BetaFeatures::isFeatureEnabled( $this->getUser(), 
'wiki-labels-enabled' ) ) {
+                       $out->addModules( 'ext.wikiLabels' );
+               } else {
+                       $templateData = array_merge( $templateData, [
+                               'error' => true,
+                               'errorTitle' => $this->msg( 
'wikilabels-beta-features-not-enabled-title' )->text(),
+                               'errorDesc' => $this->msg(
+                                       
'wikilabels-beta-features-not-enabled-desc',
+                                       SpecialPage::getTitleFor( 'Preferences' 
)->getInternalURL() . '#mw-prefsection-betafeatures'
+                               )->parse()
+                       ] );
+               }
+
+               $templateParser = new TemplateParser( __DIR__ );
+               $out->addHTML( $templateParser->processTemplate( 'gadget', 
$templateData ) );
+       }
+}
diff --git a/specials/gadget.mustache b/specials/gadget.mustache
new file mode 100644
index 0000000..24b92a7
--- /dev/null
+++ b/specials/gadget.mustache
@@ -0,0 +1,49 @@
+{{#error}}
+       <h2>{{{errorTitle}}}</h2>
+       <p>{{{errorDesc}}}</p>
+{{/error}}
+{{^error}}
+       <div id="wikilabels-home">
+               <div class="lead">
+                       <p>
+                               <strong class="selflink">Wiki-Labels</strong> 
is a
+                               <a href="/wiki/Human_computation"
+                                  title="Human computation"
+                                  class="mw-redirect">human computation</a>
+                               service for Wikipedia. In order perform 
difficult analyses and
+                               train intelligent wiki-tools (e.g. for
+                               <a href="#Detecting_vandalism">detecting 
vandalism</a> and
+                               <a href="#Assessing_the_quality_of_articles">
+                                       assessing the quality of articles
+                               </a>), we need
+                               <a href="/wiki/Coding_(social_sciences)"
+                                  title="Coding (social sciences)">labeled 
data</a>
+                               and lots of it. Wiki-Labels is a tool that 
makes it easy to
+                               collaboratively label wiki artifacts (like 
revisions) quickly
+                               and easily.
+                       </p>
+                       <ul>
+                               <li>
+                                       <a 
href="/wiki/Wikipedia:Labels/Documentation"
+                                          
title="Wikipedia:Labels/Documentation"
+                                          class="mw-redirect">
+                                               Documentation
+                                       </a>
+                               </li>
+                               <li>
+                                       <a rel="nofollow" class="external text"
+                                          
href="https://github.com/halfak/Wiki-Labels";>
+                                               github repo
+                                       </a>
+                               </li>
+                       </ul>
+               </div>
+               <div class="wikilabels-menu">
+                       <div style="padding-top: 2em;">
+                               <span style="font-size: 200%;">OMG button</span>
+                       </div>
+               </div>
+               <div class="wikilabels-workspace" style="clear:both;">
+               </div>
+       </div>
+{{/error}}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I795003243a411718d1a587608e951493542d5b34
Gerrit-PatchSet: 17
Gerrit-Project: mediawiki/extensions/WikiLabels
Gerrit-Branch: master
Gerrit-Owner: Bmansurov <[email protected]>
Gerrit-Reviewer: Bmansurov <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Jhernandez <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Phuedx <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to