1
0
mirror of https://github.com/dwaxweiler/connector-mobilizon synced 2025-06-05 21:59:25 +02:00

1 Commits

Author SHA1 Message Date
db59e26e65 release version 0.4.0 2021-04-20 21:32:47 +02:00
24 changed files with 246 additions and 408 deletions

View File

@ -14,9 +14,6 @@
"plugins": [ "plugins": [
"ava" "ava"
], ],
"ignorePatterns": [
"gulpfile.js"
],
"rules": { "rules": {
"indent": [ "indent": [
"error", "error",

View File

@ -1,71 +0,0 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
schedule:
- cron: '39 19 * * 4'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
steps:
- name: Checkout repository
uses: actions/checkout@v2
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

View File

@ -1,29 +0,0 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Node.js CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build-prod

View File

@ -18,15 +18,14 @@ More details can be found in the [WordPress Plugin Directory](https://wordpress.
### Release procedure ### Release procedure
1. Make sure `changelog.txt` is up-to-date. Use a new version number and copy over the new section into `readme.txt`. 1. Make sure `changelog.txt` is up-to-date. Use a new version number and copy over the new section into `readme.txt`.
2. Update `package.json` with the same version number. 2. Update `package.json` with the same version number.
3. Update the `package-lock.json`: `npm i --package-lock-only` 3. Build: `npm run build-prod`
4. Build: `npm run build-prod` 4. Determine minimum PHP version for code and update package.json if needed: `./vendor/bin/phpcompatinfo analyser:run ./source`
5. Determine minimum PHP version for code and update package.json if needed: `./vendor/bin/phpcompatinfo analyser:run ./source` 5. Make sure screenshots are up-to-date.
6. Make sure screenshots are up-to-date. 6. Copy the built plugin into `/trunk` of SVN.
7. Copy the built plugin into `/trunk` of SVN. 7. Create a new tag of the new version: `svn cp trunk tags/<version>`
8. Create a new tag of the new version: `svn cp trunk tags/<version>` 8. Check the version number occurences in both folders.
9. Check the version number occurences in both folders. 9. Commit everything together: `svn ci -m "release version <version>"`
10. Commit everything together to the release SVN: `svn ci -m "release version <version>"` 10. Tag the new version in `git` too.
11. Commit and tag the new version in `git` too.
### Other commands ### Other commands
- Run ESLint: `npm run eslint` - Run ESLint: `npm run eslint`

246
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "connector-mobilizon", "name": "connector-mobilizon",
"version": "0.5.0", "version": "0.4.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "connector-mobilizon", "name": "connector-mobilizon",
"version": "0.5.0", "version": "0.4.0",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"graphql": "^15.5.0", "graphql": "^15.5.0",
@ -16,15 +16,15 @@
}, },
"devDependencies": { "devDependencies": {
"ava": "^3.15.0", "ava": "^3.15.0",
"c8": "^7.7.2", "c8": "^7.7.1",
"del": "^6.0.0", "del": "^6.0.0",
"eslint": "^7.25.0", "eslint": "^7.24.0",
"eslint-plugin-ava": "^12.0.0", "eslint-plugin-ava": "^12.0.0",
"esm": "^3.2.25", "esm": "^3.2.25",
"gulp": "^4.0.2", "gulp": "^4.0.2",
"gulp-replace": "^1.1.2", "gulp-replace": "^1.0.0",
"jsdom": "^16.5.3", "jsdom": "^16.5.3",
"webpack": "^5.36.2", "webpack": "^5.34.0",
"webpack-cli": "^4.6.0", "webpack-cli": "^4.6.0",
"webpack-stream": "^6.1.2" "webpack-stream": "^6.1.2"
}, },
@ -251,10 +251,10 @@
"integrity": "sha512-c5ciR06jK8u9BstrmJyO97m+klJrrhCf9u3rLu3DEAJBirxRqSCvDQoYKmxuYwQI5SZChAWu+tq9oVlGRuzPAg==", "integrity": "sha512-c5ciR06jK8u9BstrmJyO97m+klJrrhCf9u3rLu3DEAJBirxRqSCvDQoYKmxuYwQI5SZChAWu+tq9oVlGRuzPAg==",
"dev": true "dev": true
}, },
"node_modules/@types/expect": { "node_modules/@types/is-windows": {
"version": "1.20.4", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/@types/expect/-/expect-1.20.4.tgz", "resolved": "https://registry.npmjs.org/@types/is-windows/-/is-windows-1.0.0.tgz",
"integrity": "sha512-Q5Vn3yjTDyCMV50TB6VRIbQNxSE4OmZR86VSbGaNpfUolm0iePBB4KdEEHmxoY5sT2+2DIvXW0rvMDP2nHZ4Mg==", "integrity": "sha512-tJ1rq04tGKuIJoWIH0Gyuwv4RQ3+tIu7wQrC0MV47raQ44kIzXSSFKfrxFUOWVRvesoF7mrTqigXmqoZJsXwTg==",
"dev": true "dev": true
}, },
"node_modules/@types/istanbul-lib-coverage": { "node_modules/@types/istanbul-lib-coverage": {
@ -270,9 +270,9 @@
"dev": true "dev": true
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "14.14.43", "version": "14.14.37",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.43.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.37.tgz",
"integrity": "sha512-3pwDJjp1PWacPTpH0LcfhgjvurQvrZFBrC6xxjaUEZ7ifUtT32jtjPxEMMblpqd2Mvx+k8haqQJLQxolyGN/cQ==", "integrity": "sha512-XYmBiy+ohOR4Lh5jE379fV2IU+6Jn4g5qASinhitfyO71b/sCo6MKsMLF5tc7Zf2CE8hViVQyYSobJNke8OvUw==",
"dev": true "dev": true
}, },
"node_modules/@types/normalize-package-data": { "node_modules/@types/normalize-package-data": {
@ -281,16 +281,6 @@
"integrity": "sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==", "integrity": "sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==",
"dev": true "dev": true
}, },
"node_modules/@types/vinyl": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/@types/vinyl/-/vinyl-2.0.4.tgz",
"integrity": "sha512-2o6a2ixaVI2EbwBPg1QYLGQoHK56p/8X/sGfKbFC8N6sY9lfjsMf/GprtkQkSya0D4uRiutRZ2BWj7k3JvLsAQ==",
"dev": true,
"dependencies": {
"@types/expect": "^1.20.4",
"@types/node": "*"
}
},
"node_modules/@webassemblyjs/ast": { "node_modules/@webassemblyjs/ast": {
"version": "1.11.0", "version": "1.11.0",
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.0.tgz", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.0.tgz",
@ -589,9 +579,9 @@
"dev": true "dev": true
}, },
"node_modules/acorn": { "node_modules/acorn": {
"version": "8.2.2", "version": "8.0.4",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.2.2.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.0.4.tgz",
"integrity": "sha512-VrMS8kxT0e7J1EX0p6rI/E0FbfOVcvBpbIqHThFv+f8YrZIlMfVotYcXKVPmTvPW8sW5miJzfUFrrvthUZg8VQ==", "integrity": "sha512-XNP0PqF1XD19ZlLKvB7cMmnZswW4C/03pRHgirB30uSJTaS3A3V1/P4sS3HPvFmjoriPCJQs+JDSbm4bL1TxGQ==",
"dev": true, "dev": true,
"bin": { "bin": {
"acorn": "bin/acorn" "acorn": "bin/acorn"
@ -1422,9 +1412,6 @@
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=0.8" "node": ">=0.8"
},
"funding": {
"url": "https://bevry.me/fund"
} }
}, },
"node_modules/bl": { "node_modules/bl": {
@ -1739,15 +1726,16 @@
"dev": true "dev": true
}, },
"node_modules/c8": { "node_modules/c8": {
"version": "7.7.2", "version": "7.7.1",
"resolved": "https://registry.npmjs.org/c8/-/c8-7.7.2.tgz", "resolved": "https://registry.npmjs.org/c8/-/c8-7.7.1.tgz",
"integrity": "sha512-8AqNnUMxB3hsgYCYso2GJjlwnaNPlrEEbYbCQb7N76V1nrOgCKXiTcE3gXU18rIj0FeduPywROrIBMC7XAKApg==", "integrity": "sha512-OO9KpDGv1iTd/MBNUForJH7vPKt9XnRPWSBKeRJGma4xfTaKBObA0zWAplFpFRuf/qRmATFqGFrzxqDk51LXsw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@bcoe/v8-coverage": "^0.2.3", "@bcoe/v8-coverage": "^0.2.3",
"@istanbuljs/schema": "^0.1.2", "@istanbuljs/schema": "^0.1.2",
"find-up": "^5.0.0", "find-up": "^5.0.0",
"foreground-child": "^2.0.0", "foreground-child": "^2.0.0",
"furi": "^2.0.0",
"istanbul-lib-coverage": "^3.0.0", "istanbul-lib-coverage": "^3.0.0",
"istanbul-lib-report": "^3.0.0", "istanbul-lib-report": "^3.0.0",
"istanbul-reports": "^3.0.2", "istanbul-reports": "^3.0.2",
@ -3061,6 +3049,15 @@
"safer-buffer": "^2.1.0" "safer-buffer": "^2.1.0"
} }
}, },
"node_modules/editions": {
"version": "1.3.4",
"resolved": "https://registry.npmjs.org/editions/-/editions-1.3.4.tgz",
"integrity": "sha512-gzao+mxnYDzIysXKMQi/+M1mjy/rjestjg6OPoYTtI+3Izp23oiGZitsl9lPDPiTGXbcSIk1iJWhliSaglxnUg==",
"dev": true,
"engines": {
"node": ">=0.8"
}
},
"node_modules/electron-to-chromium": { "node_modules/electron-to-chromium": {
"version": "1.3.701", "version": "1.3.701",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.701.tgz", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.701.tgz",
@ -3307,9 +3304,9 @@
} }
}, },
"node_modules/eslint": { "node_modules/eslint": {
"version": "7.25.0", "version": "7.24.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-7.25.0.tgz", "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.24.0.tgz",
"integrity": "sha512-TVpSovpvCNpLURIScDRB6g5CYu/ZFq9GfX2hLNIV4dSBKxIWojeDODvYl3t0k0VtMxYeR8OXPCFE5+oHMlGfhw==", "integrity": "sha512-k9gaHeHiFmGCDQ2rEfvULlSLruz6tgfA8DEn+rY9/oYPFFTlz55mM/Q/Rij1b2Y42jwZiK3lXvNTw6w6TXzcKQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@babel/code-frame": "7.12.11", "@babel/code-frame": "7.12.11",
@ -4501,6 +4498,16 @@
"integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=",
"dev": true "dev": true
}, },
"node_modules/furi": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/furi/-/furi-2.0.0.tgz",
"integrity": "sha512-uKuNsaU0WVaK/vmvj23wW1bicOFfyqSsAIH71bRZx8kA4Xj+YCHin7CJKJJjkIsmxYaPFLk9ljmjEyB7xF7WvQ==",
"dev": true,
"dependencies": {
"@types/is-windows": "^1.0.0",
"is-windows": "^1.0.2"
}
},
"node_modules/get-caller-file": { "node_modules/get-caller-file": {
"version": "2.0.5", "version": "2.0.5",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
@ -5070,19 +5077,17 @@
} }
}, },
"node_modules/gulp-replace": { "node_modules/gulp-replace": {
"version": "1.1.2", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/gulp-replace/-/gulp-replace-1.1.2.tgz", "resolved": "https://registry.npmjs.org/gulp-replace/-/gulp-replace-1.0.0.tgz",
"integrity": "sha512-rsZs3IbCCJNB0h+oVYbhzz07MjaaawCuGkMDQgRzbZ71Wh+pU+8RyZaw1N0ji3i40uefacrLIKHhVk88BWeoYQ==", "integrity": "sha512-lgdmrFSI1SdhNMXZQbrC75MOl1UjYWlOWNbNRnz+F/KHmgxt3l6XstBoAYIdadwETFyG/6i+vWUSCawdC3pqOw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@types/node": "^14.14.41", "istextorbinary": "2.2.1",
"@types/vinyl": "^2.0.4", "readable-stream": "^2.0.1",
"istextorbinary": "^3.0.0", "replacestream": "^4.0.0"
"replacestream": "^4.0.3",
"yargs-parser": ">=5.0.0-security.0"
}, },
"engines": { "engines": {
"node": ">=10" "node": ">=0.10"
} }
}, },
"node_modules/gulp/node_modules/ansi-colors": { "node_modules/gulp/node_modules/ansi-colors": {
@ -6208,19 +6213,17 @@
} }
}, },
"node_modules/istextorbinary": { "node_modules/istextorbinary": {
"version": "3.3.0", "version": "2.2.1",
"resolved": "https://registry.npmjs.org/istextorbinary/-/istextorbinary-3.3.0.tgz", "resolved": "https://registry.npmjs.org/istextorbinary/-/istextorbinary-2.2.1.tgz",
"integrity": "sha512-Tvq1W6NAcZeJ8op+Hq7tdZ434rqnMx4CCZ7H0ff83uEloDvVbqAwaMTZcafKGJT0VHkYzuXUiCY4hlXQg6WfoQ==", "integrity": "sha512-TS+hoFl8Z5FAFMK38nhBkdLt44CclNRgDHWeMgsV8ko3nDlr/9UI2Sf839sW7enijf8oKsZYXRvM8g0it9Zmcw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"binaryextensions": "^2.2.0", "binaryextensions": "2",
"textextensions": "^3.2.0" "editions": "^1.3.3",
"textextensions": "2"
}, },
"engines": { "engines": {
"node": ">=8" "node": ">=0.12"
},
"funding": {
"url": "https://bevry.me/fund"
} }
}, },
"node_modules/jest-worker": { "node_modules/jest-worker": {
@ -6316,6 +6319,18 @@
} }
} }
}, },
"node_modules/jsdom/node_modules/acorn": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.1.0.tgz",
"integrity": "sha512-LWCF/Wn0nfHOmJ9rzQApGnxnvgfROzGilS8936rqN/lfcYkY9MYZzdMqN+2NJ4SlTc+m5HiSa+kNfDtI64dwUA==",
"dev": true,
"bin": {
"acorn": "bin/acorn"
},
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/json-buffer": { "node_modules/json-buffer": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.0.tgz", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.0.tgz",
@ -9996,15 +10011,12 @@
"dev": true "dev": true
}, },
"node_modules/textextensions": { "node_modules/textextensions": {
"version": "3.3.0", "version": "2.6.0",
"resolved": "https://registry.npmjs.org/textextensions/-/textextensions-3.3.0.tgz", "resolved": "https://registry.npmjs.org/textextensions/-/textextensions-2.6.0.tgz",
"integrity": "sha512-mk82dS8eRABNbeVJrEiN5/UMSCliINAuz8mkUwH4SwslkNP//gbEzlWNS5au0z5Dpx40SQxzqZevZkn+WYJ9Dw==", "integrity": "sha512-49WtAWS+tcsy93dRt6P0P3AMD2m5PvXRhuEA0kaXos5ZLlujtYmpmFsB+QvWUSxE1ZsstmYXfQ7L40+EcQgpAQ==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=8" "node": ">=0.8"
},
"funding": {
"url": "https://bevry.me/fund"
} }
}, },
"node_modules/through": { "node_modules/through": {
@ -11055,9 +11067,9 @@
} }
}, },
"node_modules/webpack": { "node_modules/webpack": {
"version": "5.36.2", "version": "5.34.0",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.36.2.tgz", "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.34.0.tgz",
"integrity": "sha512-XJumVnnGoH2dV+Pk1VwgY4YT6AiMKpVoudUFCNOXMIVrEKPUgEwdIfWPjIuGLESAiS8EdIHX5+TiJz/5JccmRg==", "integrity": "sha512-+WiFMgaZqhu7zKN64LQ7z0Ml4WWI+9RwG6zmS0wJDQXiCeg3hpN8fYFNJ+6WlosDT55yVxTfK7XHUAOVR4rLyA==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@types/eslint-scope": "^3.7.0", "@types/eslint-scope": "^3.7.0",
@ -11065,7 +11077,7 @@
"@webassemblyjs/ast": "1.11.0", "@webassemblyjs/ast": "1.11.0",
"@webassemblyjs/wasm-edit": "1.11.0", "@webassemblyjs/wasm-edit": "1.11.0",
"@webassemblyjs/wasm-parser": "1.11.0", "@webassemblyjs/wasm-parser": "1.11.0",
"acorn": "^8.2.1", "acorn": "^8.0.4",
"browserslist": "^4.14.5", "browserslist": "^4.14.5",
"chrome-trace-event": "^1.0.2", "chrome-trace-event": "^1.0.2",
"enhanced-resolve": "^5.8.0", "enhanced-resolve": "^5.8.0",
@ -12046,10 +12058,10 @@
"integrity": "sha512-c5ciR06jK8u9BstrmJyO97m+klJrrhCf9u3rLu3DEAJBirxRqSCvDQoYKmxuYwQI5SZChAWu+tq9oVlGRuzPAg==", "integrity": "sha512-c5ciR06jK8u9BstrmJyO97m+klJrrhCf9u3rLu3DEAJBirxRqSCvDQoYKmxuYwQI5SZChAWu+tq9oVlGRuzPAg==",
"dev": true "dev": true
}, },
"@types/expect": { "@types/is-windows": {
"version": "1.20.4", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/@types/expect/-/expect-1.20.4.tgz", "resolved": "https://registry.npmjs.org/@types/is-windows/-/is-windows-1.0.0.tgz",
"integrity": "sha512-Q5Vn3yjTDyCMV50TB6VRIbQNxSE4OmZR86VSbGaNpfUolm0iePBB4KdEEHmxoY5sT2+2DIvXW0rvMDP2nHZ4Mg==", "integrity": "sha512-tJ1rq04tGKuIJoWIH0Gyuwv4RQ3+tIu7wQrC0MV47raQ44kIzXSSFKfrxFUOWVRvesoF7mrTqigXmqoZJsXwTg==",
"dev": true "dev": true
}, },
"@types/istanbul-lib-coverage": { "@types/istanbul-lib-coverage": {
@ -12065,9 +12077,9 @@
"dev": true "dev": true
}, },
"@types/node": { "@types/node": {
"version": "14.14.43", "version": "14.14.37",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.43.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.37.tgz",
"integrity": "sha512-3pwDJjp1PWacPTpH0LcfhgjvurQvrZFBrC6xxjaUEZ7ifUtT32jtjPxEMMblpqd2Mvx+k8haqQJLQxolyGN/cQ==", "integrity": "sha512-XYmBiy+ohOR4Lh5jE379fV2IU+6Jn4g5qASinhitfyO71b/sCo6MKsMLF5tc7Zf2CE8hViVQyYSobJNke8OvUw==",
"dev": true "dev": true
}, },
"@types/normalize-package-data": { "@types/normalize-package-data": {
@ -12076,16 +12088,6 @@
"integrity": "sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==", "integrity": "sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==",
"dev": true "dev": true
}, },
"@types/vinyl": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/@types/vinyl/-/vinyl-2.0.4.tgz",
"integrity": "sha512-2o6a2ixaVI2EbwBPg1QYLGQoHK56p/8X/sGfKbFC8N6sY9lfjsMf/GprtkQkSya0D4uRiutRZ2BWj7k3JvLsAQ==",
"dev": true,
"requires": {
"@types/expect": "^1.20.4",
"@types/node": "*"
}
},
"@webassemblyjs/ast": { "@webassemblyjs/ast": {
"version": "1.11.0", "version": "1.11.0",
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.0.tgz", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.0.tgz",
@ -12390,9 +12392,9 @@
"dev": true "dev": true
}, },
"acorn": { "acorn": {
"version": "8.2.2", "version": "8.0.4",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.2.2.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.0.4.tgz",
"integrity": "sha512-VrMS8kxT0e7J1EX0p6rI/E0FbfOVcvBpbIqHThFv+f8YrZIlMfVotYcXKVPmTvPW8sW5miJzfUFrrvthUZg8VQ==", "integrity": "sha512-XNP0PqF1XD19ZlLKvB7cMmnZswW4C/03pRHgirB30uSJTaS3A3V1/P4sS3HPvFmjoriPCJQs+JDSbm4bL1TxGQ==",
"dev": true "dev": true
}, },
"acorn-globals": { "acorn-globals": {
@ -13348,15 +13350,16 @@
"dev": true "dev": true
}, },
"c8": { "c8": {
"version": "7.7.2", "version": "7.7.1",
"resolved": "https://registry.npmjs.org/c8/-/c8-7.7.2.tgz", "resolved": "https://registry.npmjs.org/c8/-/c8-7.7.1.tgz",
"integrity": "sha512-8AqNnUMxB3hsgYCYso2GJjlwnaNPlrEEbYbCQb7N76V1nrOgCKXiTcE3gXU18rIj0FeduPywROrIBMC7XAKApg==", "integrity": "sha512-OO9KpDGv1iTd/MBNUForJH7vPKt9XnRPWSBKeRJGma4xfTaKBObA0zWAplFpFRuf/qRmATFqGFrzxqDk51LXsw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@bcoe/v8-coverage": "^0.2.3", "@bcoe/v8-coverage": "^0.2.3",
"@istanbuljs/schema": "^0.1.2", "@istanbuljs/schema": "^0.1.2",
"find-up": "^5.0.0", "find-up": "^5.0.0",
"foreground-child": "^2.0.0", "foreground-child": "^2.0.0",
"furi": "^2.0.0",
"istanbul-lib-coverage": "^3.0.0", "istanbul-lib-coverage": "^3.0.0",
"istanbul-lib-report": "^3.0.0", "istanbul-lib-report": "^3.0.0",
"istanbul-reports": "^3.0.2", "istanbul-reports": "^3.0.2",
@ -14470,6 +14473,12 @@
"safer-buffer": "^2.1.0" "safer-buffer": "^2.1.0"
} }
}, },
"editions": {
"version": "1.3.4",
"resolved": "https://registry.npmjs.org/editions/-/editions-1.3.4.tgz",
"integrity": "sha512-gzao+mxnYDzIysXKMQi/+M1mjy/rjestjg6OPoYTtI+3Izp23oiGZitsl9lPDPiTGXbcSIk1iJWhliSaglxnUg==",
"dev": true
},
"electron-to-chromium": { "electron-to-chromium": {
"version": "1.3.701", "version": "1.3.701",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.701.tgz", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.701.tgz",
@ -14674,9 +14683,9 @@
} }
}, },
"eslint": { "eslint": {
"version": "7.25.0", "version": "7.24.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-7.25.0.tgz", "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.24.0.tgz",
"integrity": "sha512-TVpSovpvCNpLURIScDRB6g5CYu/ZFq9GfX2hLNIV4dSBKxIWojeDODvYl3t0k0VtMxYeR8OXPCFE5+oHMlGfhw==", "integrity": "sha512-k9gaHeHiFmGCDQ2rEfvULlSLruz6tgfA8DEn+rY9/oYPFFTlz55mM/Q/Rij1b2Y42jwZiK3lXvNTw6w6TXzcKQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/code-frame": "7.12.11", "@babel/code-frame": "7.12.11",
@ -15628,6 +15637,16 @@
"integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=",
"dev": true "dev": true
}, },
"furi": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/furi/-/furi-2.0.0.tgz",
"integrity": "sha512-uKuNsaU0WVaK/vmvj23wW1bicOFfyqSsAIH71bRZx8kA4Xj+YCHin7CJKJJjkIsmxYaPFLk9ljmjEyB7xF7WvQ==",
"dev": true,
"requires": {
"@types/is-windows": "^1.0.0",
"is-windows": "^1.0.2"
}
},
"get-caller-file": { "get-caller-file": {
"version": "2.0.5", "version": "2.0.5",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
@ -16248,16 +16267,14 @@
} }
}, },
"gulp-replace": { "gulp-replace": {
"version": "1.1.2", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/gulp-replace/-/gulp-replace-1.1.2.tgz", "resolved": "https://registry.npmjs.org/gulp-replace/-/gulp-replace-1.0.0.tgz",
"integrity": "sha512-rsZs3IbCCJNB0h+oVYbhzz07MjaaawCuGkMDQgRzbZ71Wh+pU+8RyZaw1N0ji3i40uefacrLIKHhVk88BWeoYQ==", "integrity": "sha512-lgdmrFSI1SdhNMXZQbrC75MOl1UjYWlOWNbNRnz+F/KHmgxt3l6XstBoAYIdadwETFyG/6i+vWUSCawdC3pqOw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/node": "^14.14.41", "istextorbinary": "2.2.1",
"@types/vinyl": "^2.0.4", "readable-stream": "^2.0.1",
"istextorbinary": "^3.0.0", "replacestream": "^4.0.0"
"replacestream": "^4.0.3",
"yargs-parser": ">=5.0.0-security.0"
} }
}, },
"gulplog": { "gulplog": {
@ -16991,13 +17008,14 @@
} }
}, },
"istextorbinary": { "istextorbinary": {
"version": "3.3.0", "version": "2.2.1",
"resolved": "https://registry.npmjs.org/istextorbinary/-/istextorbinary-3.3.0.tgz", "resolved": "https://registry.npmjs.org/istextorbinary/-/istextorbinary-2.2.1.tgz",
"integrity": "sha512-Tvq1W6NAcZeJ8op+Hq7tdZ434rqnMx4CCZ7H0ff83uEloDvVbqAwaMTZcafKGJT0VHkYzuXUiCY4hlXQg6WfoQ==", "integrity": "sha512-TS+hoFl8Z5FAFMK38nhBkdLt44CclNRgDHWeMgsV8ko3nDlr/9UI2Sf839sW7enijf8oKsZYXRvM8g0it9Zmcw==",
"dev": true, "dev": true,
"requires": { "requires": {
"binaryextensions": "^2.2.0", "binaryextensions": "2",
"textextensions": "^3.2.0" "editions": "^1.3.3",
"textextensions": "2"
} }
}, },
"jest-worker": { "jest-worker": {
@ -17071,6 +17089,14 @@
"whatwg-url": "^8.5.0", "whatwg-url": "^8.5.0",
"ws": "^7.4.4", "ws": "^7.4.4",
"xml-name-validator": "^3.0.0" "xml-name-validator": "^3.0.0"
},
"dependencies": {
"acorn": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.1.0.tgz",
"integrity": "sha512-LWCF/Wn0nfHOmJ9rzQApGnxnvgfROzGilS8936rqN/lfcYkY9MYZzdMqN+2NJ4SlTc+m5HiSa+kNfDtI64dwUA==",
"dev": true
}
} }
}, },
"json-buffer": { "json-buffer": {
@ -20085,9 +20111,9 @@
"dev": true "dev": true
}, },
"textextensions": { "textextensions": {
"version": "3.3.0", "version": "2.6.0",
"resolved": "https://registry.npmjs.org/textextensions/-/textextensions-3.3.0.tgz", "resolved": "https://registry.npmjs.org/textextensions/-/textextensions-2.6.0.tgz",
"integrity": "sha512-mk82dS8eRABNbeVJrEiN5/UMSCliINAuz8mkUwH4SwslkNP//gbEzlWNS5au0z5Dpx40SQxzqZevZkn+WYJ9Dw==", "integrity": "sha512-49WtAWS+tcsy93dRt6P0P3AMD2m5PvXRhuEA0kaXos5ZLlujtYmpmFsB+QvWUSxE1ZsstmYXfQ7L40+EcQgpAQ==",
"dev": true "dev": true
}, },
"through": { "through": {
@ -20982,9 +21008,9 @@
"dev": true "dev": true
}, },
"webpack": { "webpack": {
"version": "5.36.2", "version": "5.34.0",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.36.2.tgz", "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.34.0.tgz",
"integrity": "sha512-XJumVnnGoH2dV+Pk1VwgY4YT6AiMKpVoudUFCNOXMIVrEKPUgEwdIfWPjIuGLESAiS8EdIHX5+TiJz/5JccmRg==", "integrity": "sha512-+WiFMgaZqhu7zKN64LQ7z0Ml4WWI+9RwG6zmS0wJDQXiCeg3hpN8fYFNJ+6WlosDT55yVxTfK7XHUAOVR4rLyA==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/eslint-scope": "^3.7.0", "@types/eslint-scope": "^3.7.0",
@ -20992,7 +21018,7 @@
"@webassemblyjs/ast": "1.11.0", "@webassemblyjs/ast": "1.11.0",
"@webassemblyjs/wasm-edit": "1.11.0", "@webassemblyjs/wasm-edit": "1.11.0",
"@webassemblyjs/wasm-parser": "1.11.0", "@webassemblyjs/wasm-parser": "1.11.0",
"acorn": "^8.2.1", "acorn": "^8.0.4",
"browserslist": "^4.14.5", "browserslist": "^4.14.5",
"chrome-trace-event": "^1.0.2", "chrome-trace-event": "^1.0.2",
"enhanced-resolve": "^5.8.0", "enhanced-resolve": "^5.8.0",

View File

@ -1,6 +1,6 @@
{ {
"name": "connector-mobilizon", "name": "connector-mobilizon",
"version": "0.5.0", "version": "0.4.0",
"description": "Display mobilizon events in WordPress.", "description": "Display mobilizon events in WordPress.",
"private": true, "private": true,
"scripts": { "scripts": {
@ -27,15 +27,15 @@
}, },
"devDependencies": { "devDependencies": {
"ava": "^3.15.0", "ava": "^3.15.0",
"c8": "^7.7.2", "c8": "^7.7.1",
"del": "^6.0.0", "del": "^6.0.0",
"eslint": "^7.25.0", "eslint": "^7.24.0",
"eslint-plugin-ava": "^12.0.0", "eslint-plugin-ava": "^12.0.0",
"esm": "^3.2.25", "esm": "^3.2.25",
"gulp": "^4.0.2", "gulp": "^4.0.2",
"gulp-replace": "^1.1.2", "gulp-replace": "^1.0.0",
"jsdom": "^16.5.3", "jsdom": "^16.5.3",
"webpack": "^5.36.2", "webpack": "^5.34.0",
"webpack-cli": "^4.6.0", "webpack-cli": "^4.6.0",
"webpack-stream": "^6.1.2" "webpack-stream": "^6.1.2"
}, },

View File

@ -1,20 +1,14 @@
### [Unreleased] ### [Unreleased]
#### Added #### Added
- Show events' location if set: `description` and `locality` fields
- Plugin icon
#### Changed #### Changed
- Update dev dependencies eslint, jsdom, webpack
#### Deprecated #### Deprecated
#### Removed #### Removed
#### Fixed #### Fixed
#### Security #### Security
### [0.5.0] - 2021-05-06
#### Added
- Localise dates based on the WordPress locale and time zone
#### Changed
- Clearly list features in `readme.txt` description
- Update dev dependencies c8, eslint, gulp-replace, webpack
#### Fixed
- Improve translatability
### [0.4.0] - 2021-04-20 ### [0.4.0] - 2021-04-20
#### Added #### Added
- Show events' location if set: `description` and `locality` fields - Show events' location if set: `description` and `locality` fields

View File

@ -2,42 +2,42 @@ import test from 'ava'
import DateTimeWrapper from './date-time-wrapper' import DateTimeWrapper from './date-time-wrapper'
test('#getShortDate usual date', t => { test('#getShortDate usual date', t => {
const d = new DateTimeWrapper({ text: '2020-12-24T16:45:00Z' }) const d = new DateTimeWrapper('2020-12-24T16:45:00Z')
t.is(d.getShortDate(), '24/12/2020') t.is(d.getShortDate(), '24/12/2020')
}) })
test('#get24Time usual time', t => { test('#get24Time usual time', t => {
const d = new DateTimeWrapper({ text: '2020-12-24T16:45:00Z' }) const d = new DateTimeWrapper('2020-12-24T16:45:00Z')
t.is(d.get24Time(), '16:45') t.is(d.get24Time(), '17:45')
}) })
test('#equalsDate same date, different time', t => { test('#equalsDate same date, different time', t => {
const d = new DateTimeWrapper({ text: '2020-12-24T16:45:00Z' }) const d = new DateTimeWrapper('2020-12-24T16:45:00Z')
const e = new DateTimeWrapper({ text: '2020-12-24T17:46:01Z' }) const e = new DateTimeWrapper('2020-12-24T17:46:01Z')
t.true(d.equalsDate(e)) t.true(d.equalsDate(e))
}) })
test('#equalsDate different date, different time', t => { test('#equalsDate different date, different time', t => {
const d = new DateTimeWrapper({ text: '2020-12-24T16:45:00Z' }) const d = new DateTimeWrapper('2020-12-24T16:45:00Z')
const e = new DateTimeWrapper({ text: '2021-11-25T17:46:01Z' }) const e = new DateTimeWrapper('2021-11-25T17:46:01Z')
t.false(d.equalsDate(e)) t.false(d.equalsDate(e))
}) })
test('#equalsDate different day, different time', t => { test('#equalsDate different day, different time', t => {
const d = new DateTimeWrapper({ text: '2020-12-24T16:45:00Z' }) const d = new DateTimeWrapper('2020-12-24T16:45:00Z')
const e = new DateTimeWrapper({ text: '2020-12-25T17:46:01Z' }) const e = new DateTimeWrapper('2020-12-25T17:46:01Z')
t.false(d.equalsDate(e)) t.false(d.equalsDate(e))
}) })
test('#equalsDate different month, different time', t => { test('#equalsDate different month, different time', t => {
const d = new DateTimeWrapper({ text: '2020-12-24T16:45:00Z' }) const d = new DateTimeWrapper('2020-12-24T16:45:00Z')
const e = new DateTimeWrapper({ text: '2020-11-24T17:46:01Z' }) const e = new DateTimeWrapper('2020-11-24T17:46:01Z')
t.false(d.equalsDate(e)) t.false(d.equalsDate(e))
}) })
test('#equalsDate different year, different time', t => { test('#equalsDate different year, different time', t => {
const d = new DateTimeWrapper({ text: '2020-12-24T16:45:00Z' }) const d = new DateTimeWrapper('2020-12-24T16:45:00Z')
const e = new DateTimeWrapper({ text: '2021-12-24T17:46:01Z' }) const e = new DateTimeWrapper('2021-12-24T17:46:01Z')
t.false(d.equalsDate(e)) t.false(d.equalsDate(e))
}) })

View File

@ -2,8 +2,8 @@ import { DateTime } from 'luxon'
export default class DateTimeWrapper { export default class DateTimeWrapper {
constructor({ locale = 'en-GB', text, timeZone = 'utc' } = {}) { constructor(text) {
this.dateTime = DateTime.fromISO(text, { locale, zone: timeZone }) this.dateTime = DateTime.fromISO(text)
} }
getShortDate() { getShortDate() {
@ -23,6 +23,6 @@ export default class DateTimeWrapper {
} }
static getCurrentDatetimeAsString() { static getCurrentDatetimeAsString() {
return DateTime.now().toString() return DateTime.local().toString()
} }
} }

View File

@ -1,61 +0,0 @@
import test from 'ava'
import { JSDOM } from 'jsdom'
import { displayEvents, displayErrorMessage } from './events-displayer'
let document
test.before(() => {
document = new JSDOM().window.document
})
test.beforeEach(t => {
t.context.list = document.createElement('ul')
t.context.list.setAttribute('data-locale', 'en-GB')
t.context.list.setAttribute('data-maximum', '2')
t.context.list.setAttribute('data-time-zone', 'utc')
const listElement = document.createElement('li')
listElement.setAttribute('style', 'display: none;')
t.context.list.appendChild(listElement)
})
test('#displayEvents one event', t => {
const list = t.context.list
const data = {
events: {
elements: [
{
title: 'a',
url: 'b',
beginsOn: '2021-04-15T10:30:00Z',
endsOn: '2021-04-15T15:30:00Z',
physicalAddress: {
description: 'c',
locality: 'd'
}
}
]
}
}
displayEvents({ data, document, list })
t.is(list.children.length, 2)
t.is(list.children[1].childNodes[0].tagName, 'A')
t.is(list.children[1].childNodes[0].getAttribute('href'), 'b')
t.is(list.children[1].childNodes[0].childNodes[0].nodeValue, 'a')
t.is(list.children[1].childNodes[1].tagName, 'BR')
t.is(list.children[1].childNodes[2].nodeValue, '15/04/2021 10:30 - 15:30')
t.is(list.children[1].childNodes[3].tagName, 'BR')
t.is(list.children[1].childNodes[4].nodeValue, 'c, d')
})
test('#displayErrorMessage no children added', t => {
const list = t.context.list
displayErrorMessage({ data: '', list })
t.is(list.children.length, 1)
})
test('#displayErrorMessage error message display', t => {
const list = t.context.list
displayErrorMessage({ data: '', list })
t.is(list.children[0].style.display, 'block')
})

View File

@ -1,44 +0,0 @@
import Formatter from './formatter'
import { createAnchorElement } from './html-creator'
export function displayEvents({ data, document, list }) {
const locale = list.getAttribute('data-locale')
const maxEventsCount = list.getAttribute('data-maximum')
const timeZone = list.getAttribute('data-time-zone')
const events = data.events ? data.events.elements : data.group.organizedEvents.elements
const eventsCount = Math.min(maxEventsCount, events.length)
for (let i = 0; i < eventsCount; i++) {
const li = document.createElement('li')
const a = createAnchorElement({ document, text: events[i].title, url: events[i].url })
li.appendChild(a)
const br = document.createElement('br')
li.appendChild(br)
const date = Formatter.formatDate({ locale, start: events[i].beginsOn, end: events[i].endsOn, timeZone })
const textnode = document.createTextNode(date)
li.appendChild(textnode)
if (events[i].physicalAddress) {
const location = Formatter.formatLocation({
description: events[i].physicalAddress.description,
locality: events[i].physicalAddress.locality
})
if (location) {
const brBeforeLocation = document.createElement('br')
li.appendChild(brBeforeLocation)
const textnodeLocation = document.createTextNode(location)
li.appendChild(textnodeLocation)
}
}
list.appendChild(li)
}
}
export function displayErrorMessage({ data, list }) {
console.error(data)
list.children[0].style.display = 'block'
}

View File

@ -1,8 +1,51 @@
import { displayEvents, displayErrorMessage } from './events-displayer' import Formatter from './formatter'
import * as GraphqlWrapper from './graphql-wrapper' import * as GraphqlWrapper from './graphql-wrapper'
import { createAnchorElement } from './html-creator'
const NAME = '<wordpress-name>' const NAME = '<wordpress-name>'
function displayEvents(data, list) {
const maxEventsCount = list.getAttribute('data-maximum')
const events = data.events ? data.events.elements : data.group.organizedEvents.elements
const eventsCount = Math.min(maxEventsCount, events.length)
for (let i = 0; i < eventsCount; i++) {
const li = document.createElement('li')
const a = createAnchorElement({ text: events[i].title, url: events[i].url })
li.appendChild(a)
const br = document.createElement('br')
li.appendChild(br)
const date = Formatter.formatDate({ start: events[i].beginsOn, end: events[i].endsOn })
const textnode = document.createTextNode(date)
li.appendChild(textnode)
if (events[i].physicalAddress) {
const location = Formatter.formatLocation({
description: events[i].physicalAddress.description,
locality: events[i].physicalAddress.locality
})
if (location) {
const brBeforeLocation = document.createElement('br')
li.appendChild(brBeforeLocation)
const textnodeLocation = document.createTextNode(location)
li.appendChild(textnodeLocation)
}
}
list.appendChild(li)
}
}
function displayErrorMessage(data, list) {
console.error(data)
for (let i = 0; i < list.children.length; i++) {
list.children[i].style.display = 'block'
}
}
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
const eventLists = document.getElementsByClassName(NAME + '_events-list') const eventLists = document.getElementsByClassName(NAME + '_events-list')
for (let list of eventLists) { for (let list of eventLists) {
@ -11,12 +54,12 @@ document.addEventListener('DOMContentLoaded', () => {
const groupName = list.getAttribute('data-group-name') const groupName = list.getAttribute('data-group-name')
if (groupName) { if (groupName) {
GraphqlWrapper.getUpcomingEventsByGroupName({ url, limit, groupName }) GraphqlWrapper.getUpcomingEventsByGroupName({ url, limit, groupName })
.then((data) => displayEvents({ data, document, list })) .then((data) => displayEvents(data, list))
.catch((data) => displayErrorMessage({ data, list })) .catch((data) => displayErrorMessage(data, list))
} else { } else {
GraphqlWrapper.getUpcomingEvents({ url, limit }) GraphqlWrapper.getUpcomingEvents({ url, limit })
.then((data) => displayEvents({ data, document, list })) .then((data) => displayEvents(data, list))
.catch((data) => displayErrorMessage({ data, list })) .catch((data) => displayErrorMessage(data, list))
} }
} }
}) })

View File

@ -3,12 +3,12 @@ import Formatter from './formatter'
test('#formatDate one date', t => { test('#formatDate one date', t => {
const date = Formatter.formatDate({ start: '2021-04-15T10:30:00Z', end: '2021-04-15T15:30:00Z' }) const date = Formatter.formatDate({ start: '2021-04-15T10:30:00Z', end: '2021-04-15T15:30:00Z' })
t.is(date, '15/04/2021 10:30 - 15:30') t.is(date, '15/04/2021 12:30 - 17:30')
}) })
test('#formatDate two dates', t => { test('#formatDate two dates', t => {
const date = Formatter.formatDate({ start: '2021-04-15T10:30:00Z', end: '2021-04-16T15:30:00Z' }) const date = Formatter.formatDate({ start: '2021-04-15T10:30:00Z', end: '2021-04-16T15:30:00Z' })
t.is(date, '15/04/2021 10:30 - 16/04/2021 15:30') t.is(date, '15/04/2021 12:30 - 16/04/2021 17:30')
}) })
test('#formatLocation both parameters', t => { test('#formatLocation both parameters', t => {

View File

@ -2,9 +2,9 @@ import DateTimeWrapper from './date-time-wrapper'
export default class Formatter { export default class Formatter {
static formatDate({ locale, timeZone, start, end }) { static formatDate({ start, end }) {
const startDateTime = new DateTimeWrapper({ locale, text: start, timeZone }) const startDateTime = new DateTimeWrapper(start)
const endDateTime = new DateTimeWrapper({ locale, text: end, timeZone }) const endDateTime = new DateTimeWrapper(end)
let dateText = startDateTime.getShortDate() let dateText = startDateTime.getShortDate()
dateText += ' ' + startDateTime.get24Time() dateText += ' ' + startDateTime.get24Time()
dateText += ' - ' dateText += ' - '

View File

@ -1,16 +1,14 @@
import test from 'ava' import test from 'ava'
import { JSDOM } from 'jsdom' import { JSDOM } from 'jsdom'
import { createAnchorElement } from './html-creator' import * as HtmlCreator from './html-creator'
let document
test.beforeEach(() => { test.beforeEach(() => {
document = new JSDOM().window.document global.document = new JSDOM().window.document
}) })
test('#createAnchorElement usual parameters', t => { test('#createAnchorElement usual parameters', t => {
const a = createAnchorElement({ document, text: 'a', url: 'b' }) const a = HtmlCreator.createAnchorElement({ text: 'a', url: 'b' })
t.is(a.tagName, 'A') t.is(a.tagName, 'A')
t.is(a.innerHTML, 'a') t.is(a.innerHTML, 'a')
t.is(a.getAttribute('href'), 'b') t.is(a.getAttribute('href'), 'b')

View File

@ -1,4 +1,4 @@
export function createAnchorElement({ document, text, url }) { export function createAnchorElement({ text, url }) {
const a = document.createElement('a') const a = document.createElement('a')
a.setAttribute('href', url) a.setAttribute('href', url)
a.setAttribute('target', '_blank') a.setAttribute('target', '_blank')

View File

@ -9,3 +9,4 @@ if (!defined('ABSPATH')) {
const DEFAULT_EVENTS_COUNT = 5; const DEFAULT_EVENTS_COUNT = 5;
const NAME = '<wordpress-name>'; const NAME = '<wordpress-name>';
const NICE_NAME = '<wordpress-nice-name>'; const NICE_NAME = '<wordpress-nice-name>';
const TEXT_DOMAIN = '<wordpress-name>';

View File

@ -26,10 +26,9 @@ class EventsListShortcut {
$classNamePrefix = NAME; $classNamePrefix = NAME;
$eventsCount = $atts_with_overriden_defaults['events-count']; $eventsCount = $atts_with_overriden_defaults['events-count'];
$locale = str_replace('_', '-', get_locale());
$groupName = $atts_with_overriden_defaults['group-name']; $groupName = $atts_with_overriden_defaults['group-name'];
$url = Settings::getUrl(); $url = Settings::getUrl();
$timeZone = get_option('timezone_string'); $textDomain = TEXT_DOMAIN;
ob_start(); ob_start();
require dirname(__DIR__) . '/view/events-list.php'; require dirname(__DIR__) . '/view/events-list.php';

View File

@ -11,9 +11,9 @@ class EventsListWidget extends \WP_Widget {
public function __construct() { public function __construct() {
parent::__construct( parent::__construct(
NAME . '-events-list', NAME . '-events-list',
NICE_NAME . ' ' . __('Events List', 'connector-mobilizon'), NICE_NAME . ' ' . esc_html__('Events List', TEXT_DOMAIN),
array( array(
'description' => __('A list of the upcoming events of the connected Mobilizon instance.', 'connector-mobilizon'), 'description' => __('A list of the upcoming events of the connected Mobilizon instance.', TEXT_DOMAIN),
), ),
); );
} }
@ -27,10 +27,9 @@ class EventsListWidget extends \WP_Widget {
$classNamePrefix = NAME; $classNamePrefix = NAME;
$eventsCount = $options['eventsCount']; $eventsCount = $options['eventsCount'];
$locale = str_replace('_', '-', get_locale());
$groupName = isset($options['groupName']) ? $options['groupName'] : ''; $groupName = isset($options['groupName']) ? $options['groupName'] : '';
$url = Settings::getUrl(); $url = Settings::getUrl();
$timeZone = get_option('timezone_string'); $textDomain = TEXT_DOMAIN;
require dirname(__DIR__) . '/view/events-list.php'; require dirname(__DIR__) . '/view/events-list.php';
@ -38,9 +37,10 @@ class EventsListWidget extends \WP_Widget {
} }
public function form($options) { public function form($options) {
$title = !empty($options['title']) ? $options['title'] : __('Events', 'connector-mobilizon'); $title = !empty($options['title']) ? $options['title'] : esc_html__('Events', TEXT_DOMAIN);
$eventsCount = !empty($options['eventsCount']) ? $options['eventsCount'] : DEFAULT_EVENTS_COUNT; $eventsCount = !empty($options['eventsCount']) ? $options['eventsCount'] : DEFAULT_EVENTS_COUNT;
$groupName = !empty($options['groupName']) ? $options['groupName'] : ''; $groupName = !empty($options['groupName']) ? $options['groupName'] : '';
$textDomain = TEXT_DOMAIN;
require dirname(__DIR__) . '/view/events-list-widget/form.php'; require dirname(__DIR__) . '/view/events-list-widget/form.php';
} }

View File

@ -29,14 +29,14 @@ class Settings {
add_settings_section( add_settings_section(
self::$SETTINGS_SECTION_NAME, self::$SETTINGS_SECTION_NAME,
__('General Settings', 'connector-mobilizon'), __('General Settings', TEXT_DOMAIN),
'', '',
self::$PAGE_NAME self::$PAGE_NAME
); );
add_settings_field( add_settings_field(
self::$SETTING_FIELD_NAME_URL, self::$SETTING_FIELD_NAME_URL,
__('URL', 'connector-mobilizon'), __('URL', TEXT_DOMAIN),
'MobilizonConnector\Settings::output_field_url', 'MobilizonConnector\Settings::output_field_url',
self::$PAGE_NAME, self::$PAGE_NAME,
self::$SETTINGS_SECTION_NAME, self::$SETTINGS_SECTION_NAME,
@ -47,6 +47,7 @@ class Settings {
} }
public static function output_field_url($args) { public static function output_field_url($args) {
$textDomain = TEXT_DOMAIN;
$url = self::getUrl(); $url = self::getUrl();
require dirname(__DIR__) . '/view/settings/url-field.php'; require dirname(__DIR__) . '/view/settings/url-field.php';
} }
@ -57,7 +58,7 @@ class Settings {
add_settings_error( add_settings_error(
self::$OPTION_NAME_URL, self::$OPTION_NAME_URL,
'wordpress_mobilizon_field_url_error', 'wordpress_mobilizon_field_url_error',
__('The URL is invalid.', 'connector-mobilizon'), __('The URL is invalid.', TEXT_DOMAIN),
'error' 'error'
); );
} }
@ -69,7 +70,7 @@ class Settings {
public static function register_settings_page() { public static function register_settings_page() {
add_options_page( add_options_page(
NICE_NAME . ' ' . __('Settings', 'connector-mobilizon'), NICE_NAME . ' ' . __('Settings', TEXT_DOMAIN),
NICE_NAME, NICE_NAME,
'manage_options', 'manage_options',
NAME . '-settings', NAME . '-settings',

View File

@ -14,17 +14,13 @@ License: <wordpress-license>
<wordpress-nice-name> allows you to display the upcoming events of [Mobilizon](https://joinmobilizon.org/), which is a federated event listing platform, on your WordPress website. <wordpress-nice-name> allows you to display the upcoming events of [Mobilizon](https://joinmobilizon.org/), which is a federated event listing platform, on your WordPress website.
Features You can display the upcoming events using a widget and everywhere else using a shortcut.
- Display events as widget and as shortcut
- Display events' title, date and location if available
- Configure number of events to show per widget and per shortcut
- Optionally filter events by a specific group per widget and per shortcut
- Set the URL of the Mobilizon instance globally in the settings
- Cache requests' responses for 2 minutes in the browser's `sessionStorage`
Shortcut format with limiting the number of events to show to 3 for example: `[<wordpress-name>-events-list events-count=3]` Shortcut format with limiting the number of events to show to 3 for example: `[<wordpress-name>-events-list events-count=3]`
Optionally, you can only show the events of a specific group by indicatings its name: `[<wordpress-name>-events-list events-count=3 group-name="mygroup"]` Optionally, you can only show the events of a specific group by indicatings its name: `[<wordpress-name>-events-list events-count=3 group-name="mygroup"]`
The requests' responses are cached for 2 minutes in the browser's `sessionStorage`.
The source code is available on [Github](https://github.com/dwaxweiler/connector-mobilizon). The source code is available on [Github](https://github.com/dwaxweiler/connector-mobilizon).
## Screenshots ## Screenshots
@ -35,15 +31,6 @@ The source code is available on [Github](https://github.com/dwaxweiler/connector
## Changelog ## Changelog
### [0.5.0] - 2021-05-06
#### Added
- Localise dates based on the WordPress locale and time zone
#### Changed
- Clearly list features in `readme.txt` description
- Update dev dependencies c8, eslint, gulp-replace, webpack
#### Fixed
- Improve translatability
### [0.4.0] - 2021-04-20 ### [0.4.0] - 2021-04-20
#### Added #### Added
- Show events' location if set: `description` and `locality` fields - Show events' location if set: `description` and `locality` fields

View File

@ -5,14 +5,14 @@ if (!defined('ABSPATH')) {
} }
?> ?>
<p> <p>
<label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php esc_html_e('Title', 'connector-mobilizon'); ?>:</label> <label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php esc_attr_e('Title', $textDomain); ?>:</label>
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text" value="<?php echo esc_attr($title); ?>"> <input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text" value="<?php echo esc_attr($title); ?>">
</p> </p>
<p> <p>
<label for="<?php echo esc_attr($this->get_field_id('eventsCount')); ?>"><?php esc_html_e('Number of events to show', 'connector-mobilizon'); ?>:</label> <label for="<?php echo esc_attr($this->get_field_id('eventsCount')); ?>"><?php esc_attr_e('Number of events to show', $textDomain); ?>:</label>
<input class="tiny-text" id="<?php echo esc_attr($this->get_field_id('eventsCount')); ?>" name="<?php echo esc_attr($this->get_field_name('eventsCount')); ?>" type="number" value="<?php echo esc_attr($eventsCount); ?>" min="1"> <input class="tiny-text" id="<?php echo esc_attr($this->get_field_id('eventsCount')); ?>" name="<?php echo esc_attr($this->get_field_name('eventsCount')); ?>" type="number" value="<?php echo esc_attr($eventsCount); ?>" min="1">
</p> </p>
<p> <p>
<label for="<?php echo esc_attr($this->get_field_id('groupName')); ?>"><?php esc_html_e('Group name (optional)', 'connector-mobilizon'); ?>:</label> <label for="<?php echo esc_attr($this->get_field_id('groupName')); ?>"><?php esc_attr_e('Group name (optional)', $textDomain); ?>:</label>
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('groupName')); ?>" name="<?php echo esc_attr($this->get_field_name('groupName')); ?>" type="text" value="<?php echo esc_attr($groupName); ?>"> <input class="widefat" id="<?php echo esc_attr($this->get_field_id('groupName')); ?>" name="<?php echo esc_attr($this->get_field_name('groupName')); ?>" type="text" value="<?php echo esc_attr($groupName); ?>">
</p> </p>

View File

@ -6,9 +6,7 @@ if (!defined('ABSPATH')) {
?> ?>
<ul class="<?php echo esc_attr($classNamePrefix); ?>_events-list" <ul class="<?php echo esc_attr($classNamePrefix); ?>_events-list"
data-url="<?php echo esc_attr($url); ?>" data-url="<?php echo esc_attr($url); ?>"
data-locale="<?php echo esc_attr($locale); ?>"
data-maximum="<?php echo esc_attr($eventsCount); ?>" data-maximum="<?php echo esc_attr($eventsCount); ?>"
data-group-name="<?php echo esc_attr($groupName); ?>" data-group-name="<?php echo esc_attr($groupName); ?>">
data-time-zone="<?php echo esc_attr($timeZone); ?>"> <li style="display: none;"><?php echo esc_html_e('The events could not be loaded!', $textDomain); ?></li>
<li style="display: none;"><?php esc_html_e('The events could not be loaded!', 'connector-mobilizon'); ?></li>
</ul> </ul>

View File

@ -10,5 +10,5 @@ if (!defined('ABSPATH')) {
type="url" type="url"
value="<?php echo esc_attr($url); ?>"> value="<?php echo esc_attr($url); ?>">
<p class="description"> <p class="description">
<?php esc_html_e('The URL of the Mobilizon instance whose events you want to list, e.g. https://example.net', 'connector-mobilizon'); ?> <?php esc_html_e('The URL of the Mobilizon instance whose events you want to list, e.g. https://example.net', $textDomain); ?>
</p> </p>