Skip to content

Commit

Permalink
Merge branch 'master' into linter-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
NovemLinguae authored Jun 2, 2024
2 parents 4b65a05 + ca049a8 commit bc9f5df
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 24 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Linter

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm ci
- run: npm run lint
15 changes: 15 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Unit Tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm ci
- run: npm test
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This is the source code for version 4 of the Wikipedia gadget [XFDcloser](https://en.wikipedia.org/wiki/Wikipedia:XFDcloser).

## Installation instructions and user guide
Will be available at [https://en.wikipedia.org/wiki/Wikipedia:XFDcloser](https://en.wikipedia.org/wiki/Wikipedia:XFDcloser). Currently, that page is for version 3.
Is available at [https://en.wikipedia.org/wiki/Wikipedia:XFDcloser](https://en.wikipedia.org/wiki/Wikipedia:XFDcloser).

## Repository structure
- `bin\` contains scripts to run with node. To run, type `node bin\FILENAME` in the terminal (`.js` extensions are optional)
Expand Down Expand Up @@ -48,6 +48,7 @@ Will be available at [https://en.wikipedia.org/wiki/Wikipedia:XFDcloser](https:/
## On-wiki testing
On-wiki testing is conducted at the [Test Wikipedia](https://test.wikipedia.org/wiki/Main_Page) (testwiki).
- Note that the `extendedconfirmed` permission does not exist there, so the gadget definition lines need to be adjusted accordingly when testing non-admin accounts.

### Testing development version
1. Ensure the XFDcloser gadget is *not* enabled in your preferences.
2. Add code like the following to [your common.js](https://test.wikipedia.org/wiki/Special:MyPage/common.js):
Expand All @@ -62,10 +63,13 @@ On-wiki testing is conducted at the [Test Wikipedia](https://test.wikipedia.org/
```

3. Set up mock XFD discussions. A development version of Twinkle is available as a gadget, and can be used to nominate pages for deletion.
4. Run `node bin/server` in a terminal (in the directory where your local repistory is located)
5. Now when you visit the XFD log/discussion pages, the most recently built version of the script will be loaded.
4. First time only: create the /dist/ folder so the build script doesn't throw an error.
5. Run `npm run build:dev`.
6. Run `node bin/server` in a terminal (in the directory where your local repistory is located).
7. Now when you visit the XFD log/discussion pages, the most recently built version of the script will be loaded.

### Testing deployment
1. Comment out or remove the code that load the development version from [your common.js](https://test.wikipedia.org/wiki/Special:MyPage/common.js)
1. Comment out or remove the code that loads the development version from [your common.js](https://test.wikipedia.org/wiki/Special:MyPage/common.js)
2. Ensure the XFDcloser gadget is enabled in your preferences.
3. Deploy to testwiki (see "Repository structure" section above for what goes where)
4. Set up mock XFD discussions. A development version of Twinkle is available as a gadget, and can be used to nominate pages for deletion.
Expand All @@ -74,9 +78,9 @@ On-wiki testing is conducted at the [Test Wikipedia](https://test.wikipedia.org/
## Deployment
As XFDcloser is a gadget, you must have interface-admin rights to deploy to the wiki.
1. Ensure:
- changes are committed and merged to master branch on GitHub rep
- changes are committed and merged to master branch of the GitHub repo
- you are currently on the master branch, and synced with GitHub repo
2. Bump the version number. See the comments in the `bin\version.js` file for how to do this from the terminal.
2. Bump the version number. See the comments in the `bin\version.js` file for how to do this from the terminal.
3. Commit the version change, and push/sync to GitHub repo
4. Run a full build: run `npm run build` in terminal
5. You are now ready to deploy: see the comments in the `bin\deploy.js` file for how to do this from the terminal.
Expand All @@ -87,6 +91,7 @@ A general overview of planned features:
- [ ] Preferences, similar to Rater
- [ ] Rename option for CfD, and possibly some other feature requests on WT:XFDC
- [ ] Possibly add handling for closing requested moves

### Roadmap
- [ ] Complete the v4 rewrite
- [ ] Get beta testers to try out the new version. Fix/adjust things as they get reported.
Expand Down
2 changes: 1 addition & 1 deletion bin/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* - bug fixes and very small changes increment the patch number
* - new features and other changes increment the minor number and reset the
* patch number to 0
* - significant changes, such as shifting coding paradyms or completely
* - significant changes, such as shifting coding paradigms or completely
* redesigning the UI, increment the major number and reset both the minor
* and patch numbers to 0
*
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xfdcloser",
"version": "4.0.13",
"version": "4.0.14",
"description": "Wikipedia userscript that helps assess pages for WikiProjects",
"homepage": "https://github.com/wikimedia-gadgets/xfdcloser",
"browser": "index.js",
Expand All @@ -10,11 +10,15 @@
"test:delay": "mocha --delay --require @babel/register --reporter list",
"lint:es5": "jshint \"dist/loader-dev.js\" \"dist/loader-gadget.js\"",
"lint:es5:dev": "jshint \"dist/loader-dev.js\"",
"lint:css": "stylelint \"styles-src/**/*.css\" --fix",
"lint:es6": "eslint \"xfdcloser-src/**/*.js\" \"test/*\" --fix",
"lint:bin": "eslint \"bin/*.js\" --fix --env node",
"lint:css": "stylelint \"styles-src/**/*.css\"",
"lint:es6": "eslint \"xfdcloser-src/**/*.js\" \"test/*\"",
"lint:bin": "eslint \"bin/*.js\" --env node",
"lint": "npm run lint:es6 && npm run lint:es5 && npm run lint:css",
"lint:dev": "npm run lint:es6 && npm run lint:es5:dev && npm run lint:css",
"lint:css:fix": "stylelint \"styles-src/**/*.css\" --fix",
"lint:es6:fix": "eslint \"xfdcloser-src/**/*.js\" \"test/*\" --fix",
"lint:bin:fix": "eslint \"bin/*.js\" --fix --env node",
"lint:fix": "npm run lint:es6:fix && npm run lint:bin:fix && npm run lint:css:fix",
"globals:node": "concat-cli -f \"globals-src/comment.js\" \"globals-src/node.js\" -o \"globals.js\"",
"globals:window": "concat-cli -f \"globals-src/comment.js\" \"globals-src/window.js\" -o \"globals.js\"",
"build:loader:dev": "concat-cli -f \"loader-src/loader-dev-top.js.txt\" \"loader-src/loader-core.js.txt\" \"loader-src/loader-dev-bottom.js.txt\" -o dist/loader-dev.js",
Expand All @@ -25,7 +29,7 @@
"build:concat": "concat-cli -f \"core-comment-top.js\" dist/core.min.js \"core-comment-bottom.js\" -o dist/core-gadget.js",
"build:css": "node bin/concatCss",
"build": "npm run globals:window && npm run build:loader && npm run lint && npm run test:all && npm run build:css && npm run build:bundle && npm run build:minify && npm run build:concat",
"build:dev": "npm run globals:window && npm run build:loader:dev && npm run lint:dev && npm run test:all && npm run build:bundle ",
"build:dev": "npm run globals:window && npm run build:loader:dev && npm run build:css && npm run build:bundle",
"build:quickdev": "npm run globals:window && npm run build:loader:dev && npm run build:bundle "
},
"author": {
Expand Down
1 change: 0 additions & 1 deletion styles-src/discussion.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
.skin-minerva .xfdc-status {
font-size: 0.98rem;
display: block;
margin: -1rem 0 1rem;
}

.xfdc-action {
Expand Down
9 changes: 7 additions & 2 deletions xfdcloser-src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,16 @@ import DiscussionView from "./Views/DiscussionView";
});
});
} else {
let heading = config.xfd.html.headlineinner.oldskin;
if ( [ "vector", "vector-2022", "minerva" ].includes ( mw.config.get( "skin" ) ) ) {
heading = config.xfd.html.headlineinner.newskin;
}

// Initialise show/hide closed discussions tag, unless there is only one discussion on the page
const showHide = $("#mw-content-text " + config.xfd.html.head).length > 1 && ShowHideTag.initialiseNewTag();
const showHide = $("#mw-content-text " + heading).length > 1 && ShowHideTag.initialiseNewTag();

// Set up discussion object for each discussion
$(config.xfd.html.head + " > span.mw-headline")
$( heading )
.not(".XFDcloser-ignore")
.each(function(index) {
try {
Expand Down
54 changes: 48 additions & 6 deletions xfdcloser-src/Venue.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,14 @@ Venue.Mfd = () => new Venue("mfd", {
hasIndividualSubpages: true,
ns_number: null,
html: {
head: "h4",
headlineouter: {
newskin: "h4",
oldskin: ".mw-heading.mw-heading4"
},
headlineinner: {
newskin: "h4 > .mw-headline",
oldskin: "h4"
},
list: "dl",
listitem: "dd"
},
Expand All @@ -80,7 +87,14 @@ Venue.Cfd = () => {
path: "Wikipedia:Categories for discussion/Log/",
ns_number: [14],
html: {
head: "h4",
headlineouter: {
newskin: "h4",
oldskin: ".mw-heading.mw-heading4"
},
headlineinner: {
newskin: "h4 > .mw-headline",
oldskin: "h4"
},
list: "ul",
listitem: "li",
nthSpan: "2"
Expand Down Expand Up @@ -130,7 +144,14 @@ Venue.Ffd = () => new Venue("ffd", {
ns_number: [6],
ns_unlink: ["0", "10", "100", "118"], // main, Template, Portal, Draft
html: {
head: "h4",
headlineouter: {
newskin: "h4",
oldskin: ".mw-heading.mw-heading4"
},
headlineinner: {
newskin: "h4 > .mw-headline",
oldskin: "h4"
},
list: "dl",
listitem: "dd",
nthSpan: "1"
Expand Down Expand Up @@ -158,7 +179,14 @@ Venue.Tfd = () => {
subpagePath: "Wikipedia:Templates for discussion/",
ns_number: [10, 828],
html: {
head: "h4",
headlineouter: {
newskin: "h4",
oldskin: ".mw-heading.mw-heading4"
},
headlineinner: {
newskin: "h4 > .mw-headline",
oldskin: "h4"
},
list: "ul",
listitem: "li",
nthSpan: "1"
Expand Down Expand Up @@ -235,7 +263,14 @@ Venue.Rfd = () => {
path: "Wikipedia:Redirects for discussion/Log/",
ns_number: null,
html: {
head: "h4",
headlineouter: {
newskin: "h4",
oldskin: ".mw-heading.mw-heading4"
},
headlineinner: {
newskin: "h4 > .mw-headline",
oldskin: "h4"
},
list: "ul",
listitem: "li"
},
Expand Down Expand Up @@ -274,7 +309,14 @@ Venue.Afd = transcludedOnly => new Venue("afd", {
ns_logpages: 4, // Wikipedia
ns_unlink: ["0", "10", "100", "118"], // main, Template, Portal, Draft
html: {
head: "h3",
headlineouter: {
newskin: "h3",
oldskin: ".mw-heading.mw-heading3"
},
headlineinner: {
newskin: "h3 > .mw-headline",
oldskin: "h3"
},
list: "dl",
listitem: "dd",
nthSpan: "2"
Expand Down
8 changes: 6 additions & 2 deletions xfdcloser-src/Views/DiscussionView.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,14 @@ DiscussionView.newFromHeadline = function({headingIndex, context, venue, current

// Find all nodes that are part of this discussion (i.e. excluding subsequent closed discussions)
$("table.mw-collapsible").has("div.xfd-closed").addClass("xfd-closed"); // Fix for closed discussion within a collapsed table (e.g. MfD)
const $discussionNodes = $heading.nextUntil(venue.html.head + ", div.xfd-closed, table.xfd-closed");
let headlineouter = venue.html.headlineouter.oldskin;
if ( [ "vector", "vector-2022", "minerva" ].includes ( mw.config.get( "skin" ) ) ) {
headlineouter = venue.html.headlineouter.newskin;
}
const $discussionNodes = $heading.nextUntil(headlineouter + ", div.xfd-closed, table.xfd-closed");
$discussionNodes.addClass(`${id}-discussion-node`);

// Get list of nominated pages. Also the proposed action for CfD.
// Get list of nominated pages. Also the proposed action for CfD.
let pages = [];
let action = "";
if (venue.type === "cfd") {
Expand Down

0 comments on commit bc9f5df

Please sign in to comment.