Skip to content

Commit

Permalink
Merge branch 'wikimedia-gadgets:master' into sigcov-sports
Browse files Browse the repository at this point in the history
  • Loading branch information
earlt612 authored Sep 30, 2023
2 parents e7b2db6 + 19b092a commit 59b7e7a
Show file tree
Hide file tree
Showing 8 changed files with 643 additions and 377 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "monthly"
interval: "yearly"
32 changes: 32 additions & 0 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,38 @@ The `--base` flag operates as a *prefix*; note the presence of the trailing `/`.
[intadmin]: https://en.wikipedia.org/wiki/Wikipedia:Interface_administrators
[special_botpass]: https://en.wikipedia.org/wiki/Special:BotPasswords

#### Work instruction

If you are an interface admin on English Wikipedia and you want to deploy Twinkle's master branch, and you aren't interested in sync.pl's fancy options, here's a simple work instruction. Don't forget to change the username and password.

```
Microsoft Windows:
- download and install strawberry perl. https://strawberryperl.com/
- open powershell
- `cd` to your twinkle/scripts directory
- `cpanm install MediaWiki::API File::Slurper Config::General`
- `cpanm install Git::Repository --force`
- create a bot password at [[Special:BotPasswords]] with the following permissions: edit existing pages; edit the mediawiki namespace and sitewide/user json; edit sitewide and user css/js; create, edit and move pages
- create a file called .twinklerc in the root directory. populate it with the following data
username = yourUsernameHere (as provided by Special:BotPasswords, should have @ in it)
password = yourPasswordHere
mode = deploy
lang = en
family = wikipedia
url =
base = MediaWiki:Gadget-
- (local files are used for the deploy I think, so get everything up to date in the next 3 steps)
- `git checkout master`
- go to GitHub and sync your Twinkle fork
- `git pull`
- `perl sync.pl --mode=deploy --all`
- it'll ask yes/no. type y
- if it prompts you for any edit summaries, just hit enter to skip
- there will be lots of "Warning: unable to close filehandle" messages, and some other problems such as displaying ←[0m←[96m for line breaks. you can ignore these. shouldn't be a problem.
```

### 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).
Expand Down
7 changes: 5 additions & 2 deletions modules/friendlytag.js
Original file line number Diff line number Diff line change
Expand Up @@ -1439,14 +1439,17 @@ Twinkle.tag.callbacks = {
var lang = params.translationLanguage;
var reason = params.translationComments;

var templateText = '{{subst:needtrans|pg=' + Morebits.pageNameNorm + '|Language=' +
(lang || 'uncertain') + '|Comments=' + reason.trim() + '}} ~~~~';
var templateText;

var text, summary;
if (params.tags.indexOf('Rough translation') !== -1) {
templateText = '{{subst:duflu|pg=' + Morebits.pageNameNorm + '|Language=' +
(lang || 'uncertain') + '|Comments=' + reason.trim() + '}} ~~~~';
text = old_text + '\n\n' + templateText;
summary = 'Translation cleanup requested on ';
} else {
templateText = '{{subst:needtrans|pg=' + Morebits.pageNameNorm + '|Language=' +
(lang || 'uncertain') + '|Comments=' + reason.trim() + '}} ~~~~';
text = old_text.replace(/\n+(==\s?Translated pages that could still use some cleanup\s?==)/,
'\n\n' + templateText + '\n\n$1');
summary = 'Translation' + (lang ? ' from ' + lang : '') + ' requested on ';
Expand Down
14 changes: 14 additions & 0 deletions modules/twinklewarn.js
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,10 @@ Twinkle.warn.messages = {
label: 'Bad AIV report',
summary: 'Notice: Bad AIV report'
},
'uw-articletodraft': {
label: 'Article moved to draftspace',
summary: 'Notice: Article moved to draftspace'
},
'uw-autobiography': {
label: 'Creating autobiographies',
summary: 'Notice: Creating autobiographies'
Expand All @@ -960,6 +964,10 @@ Twinkle.warn.messages = {
summary: 'Notice: "Biting" newcomers',
suppressArticleInSummary: true // non-standard (user name, not article), and not necessary
},
'uw-blar': {
label: 'Article blanked and redirected',
summary: 'Notice: Article blanked and redirected'
},
'uw-coi': {
label: 'Conflict of interest',
summary: 'Notice: Conflict of interest',
Expand Down Expand Up @@ -1068,6 +1076,12 @@ Twinkle.warn.messages = {
label: 'Indiscriminate removal of redlinks',
summary: 'Notice: Be careful when removing redlinks'
},
'uw-refspam': {
label: 'Adding citations to research published by a small group of researchers',
summary: 'Notice: Adding citations to research published by a small group of researchers',
hideLinkedPage: true,
hideReason: true
},
'uw-selfrevert': {
label: 'Self-reverted editing tests',
summary: 'Notice: Self-reverted editing tests'
Expand Down
15 changes: 12 additions & 3 deletions modules/twinklexfd.js
Original file line number Diff line number Diff line change
Expand Up @@ -2022,8 +2022,8 @@ Twinkle.xfd.callbacks = {
var params = pageobj.getCallbackParameters();
var statelem = pageobj.getStatusElement();

var hiddenCommentRE = /==== ?Uncontroversial technical requests ?====(?:.|\n)*? -->/i;
var newtext = text.replace(hiddenCommentRE, '$&\n' + Twinkle.xfd.callbacks.getDiscussionWikitext('rm', params));
var discussionWikitext = Twinkle.xfd.callbacks.getDiscussionWikitext('rm', params);
var newtext = Twinkle.xfd.insertRMTR(text, discussionWikitext);
if (text === newtext) {
statelem.error('failed to find target spot for the entry');
return;
Expand All @@ -2040,7 +2040,16 @@ Twinkle.xfd.callbacks = {
}
};


/**
* Given the wikitext of the WP:RM/TR page and the wikitext to insert, insert it at the bottom of the ==== Uncontroversial technical requests ==== section.
* @param {String} pageWikitext
* @param {String} wikitextToInsert Will typically be `{{subst:RMassist|1=From|2=To|reason=Reason}}`, which expands out to `* {{RMassist/core | 1 = From | 2 = To | discuss = yes | reason = Reason | sig = Signature | requester = YourUserName}}`
* @return {String} pageWikitext
*/
Twinkle.xfd.insertRMTR = function(pageWikitext, wikitextToInsert) {
var placementRE = /\n{1,}(==== ?Requests to revert undiscussed moves ?====)/i;
return pageWikitext.replace(placementRE, '\n' + wikitextToInsert + '\n\n$1');
};

Twinkle.xfd.callback.evaluate = function(e) {
var form = e.target;
Expand Down
Loading

0 comments on commit 59b7e7a

Please sign in to comment.