Skip to content

Commit

Permalink
Merge from upstream (#50)
Browse files Browse the repository at this point in the history
* docs: update CONTRIBUTING.md (wikimedia-gadgets#1756)

* docs: mention git branches, GitHub forks, manual testing

* space

* remove advice about squashing and merging. not needed imo

* mention "fixes 123" trick for closing GitHub issues

* xfd: fix "undefined" error in userspace log XfD CfDS edit summary (wikimedia-gadgets#1768)

* build(deps-dev): bump eslint from 8.33.0 to 8.37.0 (wikimedia-gadgets#1766)

Bumps [eslint](https://github.com/eslint/eslint) from 8.33.0 to 8.37.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](eslint/eslint@v8.33.0...v8.37.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* tag: rename {{More footnotes}} to {{More footnotes needed}} (wikimedia-gadgets#1760)

* warn: Add uw-translation (wikimedia-gadgets#1740)

* block: fix extra period in {{uw-botuhblock}} edit summary (wikimedia-gadgets#1774)

* fix edit summary for uw-wrongsummary (wikimedia-gadgets#1773)

* Add welcome-copyright (wikimedia-gadgets#1758)

* Update friendlywelcome.js

Add welcome-copyright to the welcome module

* Update friendlywelcome.js

add comma

* fix template parameters

---------

Co-authored-by: NovemLinguae <[email protected]>

* build(deps-dev): bump eslint from 8.37.0 to 8.39.0 (wikimedia-gadgets#1772)

Bumps [eslint](https://github.com/eslint/eslint) from 8.37.0 to 8.39.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](eslint/eslint@v8.37.0...v8.39.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* protect: add generic ECP option to protection module (wikimedia-gadgets#1762)

* warn: add uw-fringe 1-4 (wikimedia-gadgets#1742)

* add uw-fringe1-4

* add commas

* fix lint

* Update twinklewarn.js

del uw-fringe4

* Update twinklewarn.js

rm stray comma

* ci: always run unit tests (wikimedia-gadgets#1781)

* bump jest from v27 to v29 (wikimedia-gadgets#1787)

- bump jest from v27 to v29
- bump mock-mediawiki to v1.4.0
- install jest-environment-jsdom, needed for jest v29 to work
- adjust snapshot test syntax a bit, to work with jest v29

* add dependency notes to DEVELOPER.md (wikimedia-gadgets#1777)

* add dependency notes to DEVELOPER.md

* add jest-environment-jsdom

* Rename friendlyshared.js to friendlyshared-disabled.js

* Rename friendlytag.js to friendlytag-disabled.js

* Rename friendlytalkback.js to friendlytalkback-disabled.js

* Rename twinklearv.js to twinklearv-disabled.js

* Rename twinkleblock.js to twinkleblock-disabled.js

* Delete friendlywelcome.js

* Delete twinkledeprod.js

* Delete twinkleprod.js

* Rename twinkleprotect.js to twinkleprotect-disabled.js

* Rename twinklewarn.js to twinklewarn-disabled.js

* Rename twinklexfd.js to twinklexfd-disabled.js

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: NovemLinguae <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: anupvs77 <[email protected]>
Co-authored-by: earlt612 <[email protected]>
Co-authored-by: Red-tailed hawk <[email protected]>
Co-authored-by: NovemLinguae <[email protected]>
Co-authored-by: lomrjyo <[email protected]>
  • Loading branch information
8 people authored Jun 13, 2023
1 parent ddc297b commit 33b9387
Show file tree
Hide file tree
Showing 11 changed files with 2,586 additions and 2,554 deletions.
14 changes: 1 addition & 13 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
name: Unit tests

on:
push:
paths:
- 'morebits.js'
- 'tests/**'
- 'package.json'
- 'package-lock.json'
pull_request:
paths:
- 'morebits.js'
- 'tests/**'
- 'package.json'
- 'package-lock.json'
on: [push, pull_request]

jobs:
lint:
Expand Down
15 changes: 11 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ If you'd like to help with Twinkle's development, wonderful! Anyone can contrib

- Download and install Node.js if you don't have it already (https://nodejs.org/en/download/).
- Set up your code editor or IDE to work with JavaScript so that you get proper syntax highlightening and code completion.
- Clone the repository: `git clone https://github.com/wikimedia-gadgets/twinkle`
- Log in to GitHub, then fork this repository using the "Fork" button at the top right.
- Clone your fork by typing this into the command line, changing YourGitHubUserName to the correct username: `git clone https://github.com/YourGitHubUserName/twinkle.git`
- Create a new branch in git. This will make it easier to have multiple pull requests pending at the same time: `git branch your-branch-name`
- Install eslint and other dependencies: `npm install` while inside Twinkle directory.

First, familiarize yourself with the code; most likely, the changes you want are to one of the [modules](./modules); you can also check out the [individual Gadget pages][twinkle_gadget] onwiki. If the changes are to the [Morebits library](./morebits.js), you can view the full docs at <http://wikimedia-gadgets.github.io/twinkle> or on the [GitHub Wiki](https://github.com/wikimedia-gadgets/twinkle/wiki/morebits). If you want to propose changes yourself, [fork the repository](https://help.github.com/articles/fork-a-repo/) to make sure you always have the latest versions. If you're new to GitHub or Git in general, you probably want to read [Getting started with GitHub](https://help.github.com/en/github/getting-started-with-github) first.


### Testing your code

Manually testing your patch (such as by running Twinkle on localhost using `npm start`, loading it in your testwiki common.js, then clicking around and testing the module that you modified) is required. Please do not submit untested code. Twinkle has 40,000 users, so it is important to keep bugs out of production.

Once you have made your changes, run `npm start`. This launches a webserver listening on `http://127.0.0.1:5500`. So, to load the local version of Twinkle on-wiki, you need to run `mw.loader.load('http://127.0.0.1:5500')` in your browser console. A more permanent solution would be to add that line in your [common.js page](https://en.wikipedia.org/wiki/Special:MyPage/common.js), since code entered in the console does not persist on page navigation.

You can also test your code by simply pasting it into the browser console, but that's not recommended.
Expand All @@ -61,13 +64,17 @@ As Twinkle is used many thousands of times a day, changes to how Twinkle works m

### Submitting your pull request

When you are ready to submit, commit your changes on a new branch, then [initiate a pull request (PR)](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork). The title of your pull request should be the module you are proposing changes to, followed by a brief but descriptive explanation of what the changes do, such as:
When you are ready to submit, make sure you created a new branch, commit your changes, push your changes to your GitHub fork, then [initiate a pull request (PR)](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) by visiting one of the GitHub repos and clicking "Compare & pull request" in the message that appears at the top.

The title of your pull request should be the module you are proposing changes to, a colon and a space, followed by a brief but descriptive explanation of what the changes do, such as:

xfd: Prevent sysops from deleting the main page

The usual rule of thumb is that a good subject line will complete the sentence "*If applied, this commit will...*" The full commit message is a good place to explain further details, both for reviewers and anyone in the future, specifically focusing on *why* the changes are being made, not *how*. There are many guides to writing good commit messages, one particularly helpful one is by @cbeams: <https://chris.beams.io/posts/git-commit/>.

If you made multiple commits while working on the same feature, it's a good idea to [squash and rebase your commits](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History) before submitting your PR. Separate ideas or enhancements should be different commits, and entirely separate concepts should be different pull requests. For example, if you made three commits while changing the pulldown options in `twinkleprotect.js` and `twinklebatchprotect.js`, those should be squashed into one commit, but if you also disabled loading `twinklespeedy.js` and `twinklexfd.js` on the mainpage, that should be a separate pull request. See also [how to file a bug report or feature request](README.md#how-to-file-a-bug-report-or-feature-request).
For quicker and easier reviewing, please consider splitting large pull requests into multiple smaller ones.

If your pull request should close an issue in the issue tracker, don't forget to add text such as `Fixes #1682` to the body text of the pull request. This will tell GitHub to close that issue when the pull request is merged.

### Style guideline

Expand Down
11 changes: 11 additions & 0 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,14 @@ The `--base` flag operates as a *prefix*; note the presence of the trailing `/`.
[App::cpanminus]: https://metacpan.org/pod/App::cpanminus
[intadmin]: https://en.wikipedia.org/wiki/Wikipedia:Interface_administrators
[special_botpass]: https://en.wikipedia.org/wiki/Special:BotPasswords

### Dependencies

All the dependencies that Twinkle uses are JavaScript **dev** dependencies. They are not used at all on-wiki and are just used during development. Here's what they are and what they do. This may help with evaluating dependabot patches (dependabot is a GitHub bot that helps keep libraries up to date by submitting pull requests).

- eslint - Used by continuous integration for enforcing code linting rules.
- jest - Used by continuous integration for unit testing.
- jest-environment-jsdom - Needed for Jest to work.
- mock-mediawiki - Used by continuous integration for unit testing.
- mwn - Used when you run `npm start`. `npm start` is what enables localhost testing.
- Everything else - Dependabot will not usually try to update these unless one of the 5 above dependencies gets out of date. It is probably best to update the above dependencies instead.
2 changes: 1 addition & 1 deletion modules/friendlytag-disabled.js
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ Twinkle.tag.article.tagList = {
'Referencing technique': [
{ tag: 'Citation style', description: 'unclear or inconsistent citation style' },
{ tag: 'Cleanup bare URLs', description: 'uses bare URLs for references, which are prone to link rot' },
{ tag: 'More footnotes', description: 'has some references, but insufficient inline citations' },
{ tag: 'More footnotes needed', description: 'has some references, but insufficient inline citations' },
{ tag: 'No footnotes', description: 'has references, but lacks inline citations' }
],
'Categories': [
Expand Down
2 changes: 1 addition & 1 deletion modules/twinkleblock-disabled.js
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ Twinkle.block.blockPresetsInfo = {
forRegisteredOnly: true,
nocreate: true,
reason: '{{uw-botuhblock}} <!-- Username implies a bot, hard block -->',
summary: 'You have been indefinitely blocked from editing because your username is a blatant violation of the [[WP:U|username policy]].'
summary: 'You have been indefinitely blocked from editing because your username is a blatant violation of the [[WP:U|username policy]]'
},
'uw-causeblock': {
expiry: 'infinity',
Expand Down
8 changes: 8 additions & 0 deletions modules/twinkleprotect-disabled.js
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ Twinkle.protect.protectionTypes = [
{
label: 'Extended confirmed protection',
list: [
{ label: 'Generic (ECP)', value: 'pp-30-500' },
{ label: 'Arbitration enforcement (ECP)', selected: true, value: 'pp-30-500-arb' },
{ label: 'Persistent vandalism (ECP)', value: 'pp-30-500-vandalism' },
{ label: 'Disruptive editing (ECP)', value: 'pp-30-500-disruptive' },
Expand Down Expand Up @@ -841,6 +842,12 @@ Twinkle.protect.protectionPresetsInfo = {
reason: 'Persistent [[WP:Sock puppetry|sock puppetry]]',
template: 'pp-extended'
},
'pp-30-500': {
edit: 'extendedconfirmed',
move: 'extendedconfirmed',
reason: null,
template: 'pp-extended'
},
'pp-semi-vandalism': {
edit: 'autoconfirmed',
reason: 'Persistent [[WP:Vandalism|vandalism]]',
Expand Down Expand Up @@ -1241,6 +1248,7 @@ Twinkle.protect.callback.evaluate = function twinkleprotectCallbackEvaluate(e) {
case 'pp-30-500-disruptive':
case 'pp-30-500-blp':
case 'pp-30-500-sock':
case 'pp-30-500':
typename = 'extended confirmed protection';
break;
case 'pp-semi-vandalism':
Expand Down
20 changes: 19 additions & 1 deletion modules/twinklewarn-disabled.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,20 @@ Twinkle.warn.messages = {
summary: 'Final warning: Introducing deliberate factual errors'
}
},
'uw-fringe': {
level1: {
label: 'Introducing fringe theories',
summary: 'General note: Introducing fringe theories'
},
level2: {
label: 'Introducing fringe theories',
summary: 'Caution: Introducing fringe theories'
},
level3: {
label: 'Introducing fringe theories',
summary: 'Warning: Introducing fringe theories'
}
},
'uw-genre': {
level1: {
label: 'Frequent or mass changes to genres without consensus or references',
Expand Down Expand Up @@ -1082,6 +1096,10 @@ Twinkle.warn.messages = {
label: 'Posting at the top of talk pages',
summary: 'Notice: Posting at the top of talk pages'
},
'uw-translation': {
label: 'Adding translations without proper attribution',
summary: 'Notice: Attribution required when translating articles'
},
'uw-unattribcc': {
label: 'Copying from compatibly-licensed sources without attribution',
summary: 'Notice: Copying from compatibly-licensed sources without attribution'
Expand All @@ -1100,7 +1118,7 @@ Twinkle.warn.messages = {
},
'uw-wrongsummary': {
label: 'Using inaccurate or inappropriate edit summaries',
summary: 'Warning: Using inaccurate or inappropriate edit summaries'
summary: 'Notice: Using inaccurate or inappropriate edit summaries'
}
},

Expand Down
9 changes: 7 additions & 2 deletions modules/twinklexfd-disabled.js
Original file line number Diff line number Diff line change
Expand Up @@ -965,8 +965,12 @@ Twinkle.xfd.callbacks = {
'nominate this page for speedy deletion under [[WP:CSD#U1|CSD U1]].' +
(Morebits.userIsSysop ? '\n\nThis log does not track XfD-related deletions made using Twinkle.' : '');

var editsummary = 'Logging [[' + params.discussionpage + '|' + utils.toTLACase(params.venue) + ' nomination]] of [[:' + Morebits.pageNameNorm + ']].';

var editsummary;
if (params.discussionpage) {
editsummary = 'Logging [[' + params.discussionpage + '|' + utils.toTLACase(params.venue) + ' nomination]] of [[:' + Morebits.pageNameNorm + ']].';
} else {
editsummary = 'Logging ' + utils.toTLACase(params.venue) + ' nomination of [[:' + Morebits.pageNameNorm + ']].';
}
// If a logged file is deleted but exists on commons, the wikilink will be blue, so provide a link to the log
var fileLogLink = mw.config.get('wgNamespaceNumber') === 6 ? ' ([{{fullurl:Special:Log|page=' + mw.util.wikiUrlencode(mw.config.get('wgPageName')) + '}} log])' : '';
// CFD/S and RM don't have canonical links
Expand Down Expand Up @@ -1796,6 +1800,7 @@ Twinkle.xfd.callbacks = {
var params = pageobj.getCallbackParameters();

params.tagText = '{{subst:cfr-speedy|1=' + params.cfdstarget.replace(/^:?Category:/, '') + '}}\n';
params.discussionpage = ''; // CFDS is just a bullet in a bulleted list. There's no section to link to, so we set this to blank. Blank will be recognized by both the generate userspace log code and the generate userspace log edit summary code as "don't wikilink to a section".
if (pageobj.canEdit()) {
pageobj.setPageText(params.tagText + text);
pageobj.setEditSummary('Listed for speedy renaming; see [[WP:CFDS|Categories for discussion/Speedy]].');
Expand Down
Loading

0 comments on commit 33b9387

Please sign in to comment.