close
The Wayback Machine - https://web.archive.org/web/20191022112702/https://github.com/azatoth/twinkle
Skip to content
The wikipedia twinkle javascript helper
JavaScript Perl Other
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Image modules block: Correct NOTHERE label Oct 17, 2019
Image .editorconfig Update ESLint and remove superfluous files Sep 3, 2018
Image .eslintrc.json Greatly expand style guidelines, enforce linting rules (#657) Jun 12, 2019
Image .gitattributes Remove trailing whitespace Jun 9, 2015
Image .gitignore warn: use jquery.chosen on select box (#641) May 31, 2019
Image .mailmap adding .mailmap Feb 17, 2015
Image .travis.yml Add linting to Travis Jan 10, 2018
Image Makefile fix makefile Jun 4, 2019
Image README.md Convert mw.RegExp.escape to mw.util.escapeRegExp as the former is bei… Sep 26, 2019
Image morebits-test.js Greatly expand style guidelines, enforce linting rules (#657) Jun 12, 2019
Image morebits.css morebits.css: attempt at cross-platform, cross-browser vertical align… Oct 6, 2015
Image morebits.js morebits: Use csrfToken in mw.user.tokens (#712) Sep 26, 2019
Image oldtwinkle.js oldtwinkle: comment fix May 22, 2011
Image package-lock.json build(deps): bump eslint-utils from 1.3.1 to 1.4.2 Sep 3, 2019
Image package.json Greatly expand style guidelines, enforce linting rules (#657) Jun 12, 2019
Image sync.pl sync.pl: Show the five most recent git logs instead of just one Sep 30, 2019
Image twinkle-pagestyles.css twinkle: increase width of TW menu in Vector following recent UI update Nov 13, 2017
Image twinkle.css
Image twinkle.js Greatly expand style guidelines, enforce linting rules (#657) Jun 12, 2019

README.md

Twinkle Build Status

Twinkle is a JavaScript library and application that gives Wikipedians a quick way of performing common maintenance tasks, such as nominating pages for deletion and cleaning up vandalism.

It is based upon the morebits.js library, which forms the basis for many Wikipedia scripts and editing tools.

See Wikipedia:Twinkle on the English Wikipedia for more information.

AzaToth is the original author and maintainer of the tool, as well as the morebits.js library.

Layout of this repository

  • morebits.js: The central library used by Twinkle and many other scripts. Contains code to interact with the MediaWiki API, display forms and dialogs, generate status logs, and do various other useful things. The vast majority of code in here is not Twinkle-specific.
  • morebits.css: Styling to accompany morebits.js. The portlet styles relating to the Modern skin are Twinkle-specific and should arguably be in a twinkle.css file.
  • sync.pl: A Perl script to update on-wiki gadgets, or update the repository based on on-wiki changes. See below for full documentation.
  • 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.

Other files not mentioned here are probably obsolete.

Updating scripts on Wikipedia

There are two ways to upload Twinkle scripts to Wikipedia or another destination. You can do it manually (recommended) or with a Perl script.

After the files are synced, MediaWiki:Gadgets-definition should contain the following lines:

* Twinkle[ResourceLoader|dependencies=mediawiki.user,mediawiki.util,mediawiki.notify,jquery.ui.dialog,jquery.tipsy,jquery.chosen,moment|rights=autoconfirmed|type=general|peers=Twinkle-pagestyles]|morebits.js|morebits.css|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-pagestyles[hidden|skins=vector]|Twinkle-pagestyles.css

Twinkle-pagestyles is a hidden peer gadget 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".

Manual synchronization

Each Twinkle module and dependency lives on the wiki as a separate file. The list of modules and what pages they should be on are as follows:

Synchronization using sync.pl

There is a synchronization script called sync.pl, which can be used to pull and push files to Wikipedia.

The program depends on a few modules, namely MediaWiki::API, Git::Repository, File::Slurper, and Getopt::Long::Descriptive. These can be installed easily using App::cpanminus:

cpanm --sudo install MediaWiki::API Git::Repository File::Slurper Getopt::Long::Descriptive

You may prefer to install them through your operating system's packaing tool (e.g. apt-get install libgetopt-long-descriptive-perl) although you can install them through cpanm too.

When running the program, you can enter your credentials on the command line using the --username and --password parameters, but it is recommended to save them in a file called ~/.twinklerc using the following format:

username = username
password = password
lang     = en
family   = wikipedia
base     = User:Username

where base is the wiki path to prefix the files for pull and push. The script ignores the modules/ part of the file path when downloading/uploading.

Notice that your working directory must be clean; if not, either stash or commit your changes.

To pull user Foobar's changes (i.e. User:Foobar/morebits.js), do:

./sync.pl --base User:Foobar --pull twinkle.js morebits.js ...

To push your changes to Foobar's wiki page, do:

./sync.pl --base User:Foobar --push twinkle.js morebits.js ...

There is also a deploy command for interface-admins to deploy Twinkle files live to their MediaWiki:Gadget locations. You will need to set up a bot password at Special:BotPasswords.

./sync.pl --deploy twinkle.js morebits.js ...

You may also deploy all files via

make deploy

Note that for syncing to a custom wiki (read: not the English Wikipedia), you will also need to specify the --lang and --family parameters too. For instance, to sync the files with test.wmflabs.org you should specify --lang=test --family=wmflabs. If you intend to use make deploy to deploy all the files at once, you may also need to pass the necessary parameters through the makefile to the sync script like this example:

make ARGS="--lang=test --family=wmflabs" deploy

When deploying or pushing, the script will attempt to parse the latest on-wiki edit summary to find the most recently used commit, and will use that to create an edit summary from the commits since then. If it cannot find anything that looks like a commit hash, it will prompt you to enter one for each file.

Style guideline

While old legacy code previously had many different and incoherent styles, it has been decided to utilize a more coherent style throughout the code, both for consistency and to cut down on potential errors. eslint can be used to check your code before submission and even repair many common issues. To install via npm, just run npm install from the main Twinkle directory in your terminal. You can then freely check your code by running npm run lint, and if you run npm run lint -- --fix then eslint will clean up some (but not all!) style differences. More information on specific style rules can be seen in issue #500 and in .eslintrc.json, but the best advice is to just follow the style of surrounding code!

You can’t perform that action at this time.