Skip to content

Commit

Permalink
Add select2 library (v4.0.12) to better handle options in warn and xfd
Browse files Browse the repository at this point in the history
chosen (https://harvesthq.github.io/chosen/, https://github.com/harvesthq/chosen), which has been in use since wikimedia-gadgets#580 (xfd) and wikimedia-gadgets#641 (warn), has been causing some consistent CSS issues in the warn modules (wikimedia-gadgets#665), and has recently been deprecated: harvesthq/chosen@91041bc.  select2 (https://select2.org/, https://github.com/select2/select2) is an alternative to chosen that resolves those issues and is better maintained, albeit larger even without using the full version.

select2, however, is not part of MediaWiki's core ResourceLoader modules (T53443), so have to upload it ourselves as a gadget, as we once did for moment (67e24a5).  We could technically use the [Toolserver CDN](https://tools.wmflabs.org/cdnjs/) but that is potentially prone to occasional unreliability and is not whitelisted by the CSP (https://phabricator.wikimedia.org/T223840); that's still in 'report only' mode but users will have to opt-themselves out so it's not long-term reliable (https://phabricator.wikimedia.org/T208188).  Uploading it as a gadget avoids all that and makes use of the advantages of the ResourceLoader.

Uploaded under the terms of the MIT license:

The MIT License (MIT)

Copyright (c) 2012-2017 Kevin Brown, Igor Vaynberg, and Select2 contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
  • Loading branch information
Amorymeltzer committed Jan 19, 2020
1 parent d2496cc commit 0597602
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"mw": true,
"moment": true
},
"ignorePatterns": "select2*",
"rules": {
"no-console": "error",
"no-extra-parens": ["error", "all", { "nestedBinaryExpressions": false }],
Expand Down
11 changes: 8 additions & 3 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ There are two ways to upload Twinkle scripts to Wikipedia or another destination

After the files are synced, ensure that [MediaWiki:Gadgets-definition][] contains the following lines:

* Twinkle[ResourceLoader|dependencies=mediawiki.notify,jquery.chosen,moment,ext.gadget.morebits|rights=autoconfirmed|type=general|peers=Twinkle-pagestyles]|Twinkle.js|twinkleprod.js|twinkleimage.js|twinklebatchundelete.js|twinklewarn.js|twinklespeedy.js|friendlyshared.js|twinklediff.js|twinkleunlink.js|friendlytag.js|twinkledeprod.js|friendlywelcome.js|twinklexfd.js|twinklebatchdelete.js|twinklebatchprotect.js|twinkleconfig.js|twinklefluff.js|twinkleprotect.js|twinklearv.js|twinkleblock.js|friendlytalkback.js|Twinkle.css
* Twinkle[ResourceLoader|dependencies=mediawiki.notify,jquery.chosen,moment,ext.gadget.morebits,ext.gadget.select2|rights=autoconfirmed|type=general|peers=Twinkle-pagestyles]|Twinkle.js|twinkleprod.js|twinkleimage.js|twinklebatchundelete.js|twinklewarn.js|twinklespeedy.js|friendlyshared.js|twinklediff.js|twinkleunlink.js|friendlytag.js|twinkledeprod.js|friendlywelcome.js|twinklexfd.js|twinklebatchdelete.js|twinklebatchprotect.js|twinkleconfig.js|twinklefluff.js|twinkleprotect.js|twinklearv.js|twinkleblock.js|friendlytalkback.js|Twinkle.css
* morebits[ResourceLoader|dependencies=mediawiki.user,mediawiki.util,jquery.ui,jquery.tipsy|hidden]|morebits.js|morebits.css
* Twinkle-pagestyles[hidden|skins=vector]|Twinkle-pagestyles.css
* select2[ResourceLoader|hidden]|select2.min.js|select2.min.css

This loads the `morebits` library as a hidden gadget, making it efficiently available for other tools to use. `Twinkle-pagestyles` is a hidden [peer gadget](https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_(users)#Gadget_peers) of Twinkle. Before Twinkle has loaded, it adds space where the TW menu would go in the Vector skin, so that the top bar does not "jump".
This loads the `morebits` library as a hidden gadget, making it efficiently available for other tools to use. `Twinkle-pagestyles` is a hidden [peer gadget](https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_(users)#Gadget_peers) of Twinkle. Before Twinkle has loaded, it adds space where the TW menu would go in the Vector skin, so that the top bar does not "jump". [select2][] is also uploaded as a hidden gadget for better menus and to take advantage of the Resource Loader over the [Toolforge CDN](https://tools.wmflabs.org/cdnjs/); it is done so under the [MIT license](https://github.com/select2/select2/blob/develop/LICENSE.md).

### Manual synchronization

Expand All @@ -32,6 +33,8 @@ Each Twinkle module and dependency lives on the wiki as a separate file. The lis
* `twinkle-pagestyles.css` → [MediaWiki:Gadget-Twinkle-pagestyles.css][]
* `morebits.js` → [MediaWiki:Gadget-morebits.js][]
* `morebits.css` → [MediaWiki:Gadget-morebits.css][]
* `select2.min.js` → [MediaWiki:Gadget-select2.min.js][]
* `select2.min.css` → [MediaWiki:Gadget-select2.min.css][]
* `modules/twinkleprod.js` → [MediaWiki:Gadget-twinkleprod.js][]
* `modules/twinkleimage.js` → [MediaWiki:Gadget-twinkleimage.js][]
* `modules/twinklebatchundelete.js` → [MediaWiki:Gadget-twinklebatchundelete.js][]
Expand Down Expand Up @@ -105,6 +108,8 @@ When `deploy`ing or `push`ing, the script will attempt to parse the latest on-wi
[MediaWiki:Gadget-Twinkle-pagestyles.css]: https://en.wikipedia.org/wiki/MediaWiki:Gadget-Twinkle-pagestyles.css
[MediaWiki:Gadget-morebits.js]: https://en.wikipedia.org/wiki/MediaWiki:Gadget-morebits.js
[MediaWiki:Gadget-morebits.css]: https://en.wikipedia.org/wiki/MediaWiki:Gadget-morebits.css
[MediaWiki:Gadget-select2.min.js]: https://en.wikipedia.org/wiki/MediaWiki:Gadget-select2.min.js
[MediaWiki:Gadget-select2.min.css]: https://en.wikipedia.org/wiki/MediaWiki:Gadget-select2.min.css
[MediaWiki:Gadget-twinkleprod.js]: https://en.wikipedia.org/wiki/MediaWiki:Gadget-twinkleprod.js
[MediaWiki:Gadget-twinkleimage.js]: https://en.wikipedia.org/wiki/MediaWiki:Gadget-twinkleimage.js
[MediaWiki:Gadget-twinklebatchundelete.js]: https://en.wikipedia.org/wiki/MediaWiki:Gadget-twinklebatchundelete.js
Expand All @@ -126,7 +131,7 @@ When `deploy`ing or `push`ing, the script will attempt to parse the latest on-wi
[MediaWiki:Gadget-friendlytalkback.js]: https://en.wikipedia.org/wiki/MediaWiki:Gadget-friendlytalkback.js
[MediaWiki:Gadget-twinkleblock.js]: https://en.wikipedia.org/wiki/MediaWiki:Gadget-twinkleblock.js
[User:AzaToth/twinkle.js]: https://en.wikipedia.org/wiki/User:AzaToth/twinkle.js
[MediaWiki:Gadgets-definition]: https://en.wikipedia.org/wiki/MediaWiki:Gadgets-definition
[select2]: https://github.com/select2/select2
[MediaWiki::API]: https://metacpan.org/pod/MediaWiki::API
[Git::Repository]: https://metacpan.org/pod/Git::Repository
[File::Slurper]: https://metacpan.org/pod/File::Slurper
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ modules = modules/twinklearv.js \
modules/friendlytalkback.js \
modules/friendlywelcome.js

deploy: twinkle.js twinkle.css twinkle-pagestyles.css morebits.js morebits.css $(modules)
deploy: twinkle.js twinkle.css twinkle-pagestyles.css morebits.js morebits.css select2.min.js select2.min.css $(modules)
./sync.pl ${ARGS} --deploy $^

.PHONY: deploy all
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ If you'd like to start contributing, awesome! Check out [CONTRIBUTING.md](CONTR
* `twinkle.js`: General Twinkle-specific code, mostly related to preferences and exposing Twinkle in the UI. Significantly, it contains the default set of preferences of Twinkle.
* `modules`: Contains the individual Twinkle modules. Descriptions for these can be found in header comments or in the [Twinkle documentation][]. The module `twinkleconfig.js` powers the [Twinkle preferences panel][WP:TWPREFS].


[select2][] is added under the [MIT license](https://github.com/select2/select2/blob/develop/LICENSE.md).

[Wikipedia:Twinkle]: https://en.wikipedia.org/wiki/Wikipedia:Twinkle
[AzaToth]: https://en.wikipedia.org/wiki/User:AzaToth
[Wikipedia talk:Twinkle]: https://en.wikipedia.org/wiki/Wikipedia_talk:Twinkle
[Twinkle documentation]: https://en.wikipedia.org/wiki/Wikipedia:Twinkle/doc
[WP:TWPREFS]: https://en.wikipedia.org/wiki/Wikipedia:Twinkle/Preferences
[select2]: https://github.com/select2/select2
Loading

0 comments on commit 0597602

Please sign in to comment.