mirror of
https://github.com/dwaxweiler/connector-mobilizon
synced 2025-06-05 21:59:25 +02:00
Compare commits
52 Commits
Author | SHA1 | Date | |
---|---|---|---|
8f54398b43 | |||
c131076f1a | |||
2d2b1b9293 | |||
a3a980d6db | |||
60870eae3c | |||
8f345ba4e4 | |||
6ce3f49e52 | |||
c8a999d028 | |||
05d6f78c0c | |||
105c6e1240 | |||
ec63b4ec9e | |||
2dc823505b | |||
6bf4cb95b1 | |||
054e313a4d | |||
89145fe9ed | |||
22c0b22b8e | |||
bc86f8e7c9 | |||
a8584096d8 | |||
65b42ba1e7 | |||
eae2d422e0 | |||
e30eaa47d2 | |||
dd0f4a7965 | |||
4c0de97ff2 | |||
74522103a2 | |||
bfa6c00e45 | |||
a5605d4d13 | |||
9c553b7dda | |||
f5a7e1ed04 | |||
f181743ecf | |||
72f2c12343 | |||
cf49fb47d6 | |||
748649bde3 | |||
3fd69fc7f6 | |||
540731e28a | |||
233cdbf8fa | |||
56d501464e | |||
f36e2a6e6a | |||
b8ffbdb835 | |||
710103bb10 | |||
c9b04cb2f8 | |||
12e6adacbf | |||
08cad477d1 | |||
0ee1d8cc18 | |||
1e4d0c0a09 | |||
28245574d8 | |||
214fc50d6d | |||
f580b4fb69 | |||
aa8012c8e8 | |||
8b6e312645 | |||
c28d5ec50e | |||
8e9445b60a | |||
4dd1084a3f |
34
.eslintrc.json
Normal file
34
.eslintrc.json
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"es2020": true
|
||||||
|
},
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:ava/recommended"
|
||||||
|
],
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 11,
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
"ava"
|
||||||
|
],
|
||||||
|
"ignorePatterns": [
|
||||||
|
"gulpfile.js"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"indent": [
|
||||||
|
"error",
|
||||||
|
2
|
||||||
|
],
|
||||||
|
"quotes": [
|
||||||
|
"error",
|
||||||
|
"single"
|
||||||
|
],
|
||||||
|
"semi": [
|
||||||
|
"error",
|
||||||
|
"never"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
71
.github/workflows/codeql-analysis.yml
vendored
Normal file
71
.github/workflows/codeql-analysis.yml
vendored
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
# 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
|
29
.github/workflows/test.yml
vendored
Normal file
29
.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# 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
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
build/
|
build/
|
||||||
|
coverage/
|
||||||
node_modules/
|
node_modules/
|
||||||
vendor/
|
vendor/
|
||||||
|
19
README.md
19
README.md
@ -1,5 +1,9 @@
|
|||||||
# Connector for Mobilizon
|
# Connector for Mobilizon
|
||||||
|
|
||||||
|
Connector for Mobilizon allows you to display the upcoming events of [Mobilizon](https://joinmobilizon.org/), which is a federated event listing platform, on your WordPress website.
|
||||||
|
|
||||||
|
More details can be found in the [WordPress Plugin Directory](https://wordpress.org/plugins/connector-mobilizon/).
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
### Setup
|
### Setup
|
||||||
@ -14,11 +18,18 @@
|
|||||||
### 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. Build: `npm run build-prod`
|
3. Update the `package-lock.json`: `npm i --package-lock-only`
|
||||||
4. Determine minimum PHP version for code and update package.json if needed: `./vendor/bin/phpcompatinfo analyser:run ./source`
|
4. Build: `npm run build-prod`
|
||||||
5. Make sure screenshots are up-to-date.
|
5. Determine minimum PHP version for code and update package.json if needed: `./vendor/bin/phpcompatinfo analyser:run ./source`
|
||||||
6. Copy the built plugin into `/trunk` of SVN. Also creatte a new tag of the new version. Check the version number occurences in both folders. Commit everything together.
|
6. Make sure screenshots are up-to-date.
|
||||||
|
7. Copy the built plugin into `/trunk` of SVN.
|
||||||
|
8. Create a new tag of the new version: `svn cp trunk tags/<version>`
|
||||||
|
9. Check the version number occurences in both folders.
|
||||||
|
10. Commit everything together to the release SVN: `svn ci -m "release version <version>"`
|
||||||
|
11. Commit and tag the new version in `git` too.
|
||||||
|
|
||||||
### Other commands
|
### Other commands
|
||||||
|
- Run ESLint: `npm run eslint`
|
||||||
|
- Run JavaScript code coverage with tests: `npm run coverage`
|
||||||
- Run tests: `npm test`
|
- Run tests: `npm test`
|
||||||
- Delete build folder: `gulp clean`
|
- Delete build folder: `gulp clean`
|
||||||
|
BIN
assets/icon-128x128.png
Normal file
BIN
assets/icon-128x128.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.8 KiB |
BIN
assets/icon-256x256.png
Normal file
BIN
assets/icon-256x256.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.1 KiB |
16
assets/icon.svg
Normal file
16
assets/icon.svg
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
|
<svg width="100%" height="100%" viewBox="0 0 256 256" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
||||||
|
<g transform="matrix(3.1904,0,0,3.1904,-120.199,-271.206)">
|
||||||
|
<circle cx="37.675" cy="125.127" r="29.385" style="fill:rgb(71,68,103);"/>
|
||||||
|
</g>
|
||||||
|
<g transform="matrix(1.26548,0,0,2.29215,-58.5821,-124.97)">
|
||||||
|
<path d="M120.375,110.363L201.527,106.002L201.527,101.64L221.522,110.363L201.527,119.087L201.527,114.725L120.375,110.363Z" style="fill:rgb(255,213,153);"/>
|
||||||
|
</g>
|
||||||
|
<g transform="matrix(1.18916,0.432821,-0.783962,2.15392,28.3042,-121.978)">
|
||||||
|
<path d="M120.375,110.363L201.527,106.002L201.527,101.64L221.522,110.363L201.527,119.087L201.527,114.725L120.375,110.363Z" style="fill:rgb(255,213,153);"/>
|
||||||
|
</g>
|
||||||
|
<g transform="matrix(1.18916,-0.432821,0.783962,2.15392,-144.737,-97.4496)">
|
||||||
|
<path d="M120.375,110.363L201.527,106.002L201.527,101.64L221.522,110.363L201.527,119.087L201.527,114.725L120.375,110.363Z" style="fill:rgb(255,213,153);"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.3 KiB |
@ -32,7 +32,7 @@ function bundleFrontend() {
|
|||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
.pipe(dest(FOLDER_BUILD));
|
.pipe(dest(FOLDER_BUILD));
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyBackend() {
|
function copyBackend() {
|
||||||
return src([
|
return src([
|
||||||
@ -52,6 +52,7 @@ function injectMetadata() {
|
|||||||
.pipe(replace('<wordpress-author-name>', PACKAGE.author.name))
|
.pipe(replace('<wordpress-author-name>', PACKAGE.author.name))
|
||||||
.pipe(replace('<wordpress-author-url>', PACKAGE.author.url))
|
.pipe(replace('<wordpress-author-url>', PACKAGE.author.url))
|
||||||
.pipe(replace('<wordpress-description>', PACKAGE.description))
|
.pipe(replace('<wordpress-description>', PACKAGE.description))
|
||||||
|
.pipe(replace('<wordpress-donation-link>', PACKAGE.funding.url))
|
||||||
.pipe(replace('<wordpress-license>', PACKAGE.license))
|
.pipe(replace('<wordpress-license>', PACKAGE.license))
|
||||||
.pipe(replace('<wordpress-minimum-version>', PACKAGE.additionalDetails.wordpressMinimumVersion))
|
.pipe(replace('<wordpress-minimum-version>', PACKAGE.additionalDetails.wordpressMinimumVersion))
|
||||||
.pipe(replace('<wordpress-name>', PACKAGE.name))
|
.pipe(replace('<wordpress-name>', PACKAGE.name))
|
||||||
|
BIN
icon.afdesign
Normal file
BIN
icon.afdesign
Normal file
Binary file not shown.
12840
package-lock.json
generated
12840
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
22
package.json
22
package.json
@ -1,32 +1,42 @@
|
|||||||
{
|
{
|
||||||
"name": "connector-mobilizon",
|
"name": "connector-mobilizon",
|
||||||
"version": "0.2.2",
|
"version": "0.5.0",
|
||||||
"description": "Display mobilizon events in WordPress.",
|
"description": "Display mobilizon events in WordPress.",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build-dev": "gulp dev",
|
"build-dev": "gulp dev",
|
||||||
"build-prod": "ava && gulp prod",
|
"build-prod": "ava && gulp prod",
|
||||||
|
"coverage": "c8 --all --reporter=html --reporter=text --include=source/**/*.js ava",
|
||||||
|
"eslint": "npx eslint source/**/*.js",
|
||||||
"test": "ava"
|
"test": "ava"
|
||||||
},
|
},
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Daniel Waxweiler",
|
"name": "Daniel Waxweiler",
|
||||||
"url": "https://www.danielwaxweiler.net/"
|
"url": "https://www.danielwaxweiler.net/"
|
||||||
},
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "individual",
|
||||||
|
"url": "https://paypal.me/dwaxweiler"
|
||||||
|
},
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"graphql": "^15.5.0",
|
"graphql": "^15.5.0",
|
||||||
"graphql-request": "^3.4.0",
|
"graphql-request": "^3.4.0",
|
||||||
"luxon": "^1.25.0"
|
"luxon": "^1.26.0",
|
||||||
|
"object-hash": "^2.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"ava": "^3.15.0",
|
"ava": "^3.15.0",
|
||||||
|
"c8": "^7.7.2",
|
||||||
"del": "^6.0.0",
|
"del": "^6.0.0",
|
||||||
|
"eslint": "^7.25.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.0.0",
|
"gulp-replace": "^1.1.2",
|
||||||
"jsdom": "^16.5.0",
|
"jsdom": "^16.5.3",
|
||||||
"webpack": "^5.24.4",
|
"webpack": "^5.36.2",
|
||||||
"webpack-cli": "^4.5.0",
|
"webpack-cli": "^4.6.0",
|
||||||
"webpack-stream": "^6.1.2"
|
"webpack-stream": "^6.1.2"
|
||||||
},
|
},
|
||||||
"ava": {
|
"ava": {
|
||||||
|
@ -6,6 +6,31 @@
|
|||||||
#### 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
|
||||||
|
#### Added
|
||||||
|
- Show events' location if set: `description` and `locality` fields
|
||||||
|
- Plugin icon
|
||||||
|
#### Changed
|
||||||
|
- Update dev dependencies eslint, jsdom, webpack
|
||||||
|
|
||||||
|
### [0.3.0] - 2021-04-05
|
||||||
|
#### Added
|
||||||
|
- Donation link to WordPress Plugin Directory sidebar and to `package.json`
|
||||||
|
- Cache requests for 2 minutes
|
||||||
|
- Set up ESLint static code analysis
|
||||||
|
#### Changed
|
||||||
|
- Update luxon dependency
|
||||||
|
- Update dev dependencies jsdom, webpack, webpack-cli
|
||||||
|
|
||||||
### [0.2.2] - 2021-03-10
|
### [0.2.2] - 2021-03-10
|
||||||
#### Changed
|
#### Changed
|
||||||
- Confirm compatibility with WordPress 5.7
|
- Confirm compatibility with WordPress 5.7
|
||||||
|
@ -1,43 +1,43 @@
|
|||||||
import test from 'ava';
|
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('2020-12-24T16:45:00Z')
|
const d = new DateTimeWrapper({ text: '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('2020-12-24T16:45:00Z')
|
const d = new DateTimeWrapper({ text: '2020-12-24T16:45:00Z' })
|
||||||
t.is(d.get24Time(), '17:45')
|
t.is(d.get24Time(), '16:45')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('#equalsDate same date, different time', t => {
|
test('#equalsDate same date, different time', t => {
|
||||||
const d = new DateTimeWrapper('2020-12-24T16:45:00Z')
|
const d = new DateTimeWrapper({ text: '2020-12-24T16:45:00Z' })
|
||||||
const e = new DateTimeWrapper('2020-12-24T17:46:01Z')
|
const e = new DateTimeWrapper({ text: '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('2020-12-24T16:45:00Z')
|
const d = new DateTimeWrapper({ text: '2020-12-24T16:45:00Z' })
|
||||||
const e = new DateTimeWrapper('2021-11-25T17:46:01Z')
|
const e = new DateTimeWrapper({ text: '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('2020-12-24T16:45:00Z')
|
const d = new DateTimeWrapper({ text: '2020-12-24T16:45:00Z' })
|
||||||
const e = new DateTimeWrapper('2020-12-25T17:46:01Z')
|
const e = new DateTimeWrapper({ text: '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('2020-12-24T16:45:00Z')
|
const d = new DateTimeWrapper({ text: '2020-12-24T16:45:00Z' })
|
||||||
const e = new DateTimeWrapper('2020-11-24T17:46:01Z')
|
const e = new DateTimeWrapper({ text: '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('2020-12-24T16:45:00Z')
|
const d = new DateTimeWrapper({ text: '2020-12-24T16:45:00Z' })
|
||||||
const e = new DateTimeWrapper('2021-12-24T17:46:01Z')
|
const e = new DateTimeWrapper({ text: '2021-12-24T17:46:01Z' })
|
||||||
t.false(d.equalsDate(e))
|
t.false(d.equalsDate(e))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon'
|
||||||
|
|
||||||
export class DateTimeWrapper {
|
export default class DateTimeWrapper {
|
||||||
|
|
||||||
constructor(text) {
|
constructor({ locale = 'en-GB', text, timeZone = 'utc' } = {}) {
|
||||||
this.dateTime = DateTime.fromISO(text)
|
this.dateTime = DateTime.fromISO(text, { locale, zone: timeZone })
|
||||||
}
|
}
|
||||||
|
|
||||||
getShortDate() {
|
getShortDate() {
|
||||||
@ -23,6 +23,6 @@ export class DateTimeWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static getCurrentDatetimeAsString() {
|
static getCurrentDatetimeAsString() {
|
||||||
return DateTime.local().toString();
|
return DateTime.now().toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
61
source/connector-mobilizon/front/events-displayer-test.js
Normal file
61
source/connector-mobilizon/front/events-displayer-test.js
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
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')
|
||||||
|
})
|
44
source/connector-mobilizon/front/events-displayer.js
Normal file
44
source/connector-mobilizon/front/events-displayer.js
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
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'
|
||||||
|
}
|
@ -1,59 +1,22 @@
|
|||||||
import { DateTimeWrapper } from './date-time-wrapper';
|
import { displayEvents, displayErrorMessage } from './events-displayer'
|
||||||
import * as GraphqlWrapper from './graphql-wrapper'
|
import * as GraphqlWrapper from './graphql-wrapper'
|
||||||
import * as HtmlCreator 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 = HtmlCreator.createAnchorElement({ text: events[i].title, url: events[i].url });
|
|
||||||
li.appendChild(a)
|
|
||||||
|
|
||||||
const br = document.createElement('br')
|
|
||||||
li.appendChild(br)
|
|
||||||
|
|
||||||
const beginsOn = new DateTimeWrapper(events[i].beginsOn)
|
|
||||||
const endsOn = new DateTimeWrapper(events[i].endsOn)
|
|
||||||
let dateText = beginsOn.getShortDate()
|
|
||||||
dateText += ' ' + beginsOn.get24Time()
|
|
||||||
dateText += ' - '
|
|
||||||
if (!beginsOn.equalsDate(endsOn)) {
|
|
||||||
dateText += endsOn.getShortDate() + ' '
|
|
||||||
}
|
|
||||||
dateText += endsOn.get24Time()
|
|
||||||
const textnode = document.createTextNode(dateText);
|
|
||||||
li.appendChild(textnode)
|
|
||||||
|
|
||||||
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) {
|
||||||
const url = list.getAttribute('data-url') + '/api'
|
const url = list.getAttribute('data-url') + '/api'
|
||||||
const limit = list.getAttribute('data-maximum')
|
const limit = parseInt(list.getAttribute('data-maximum'))
|
||||||
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, list))
|
.then((data) => displayEvents({ data, document, 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, list))
|
.then((data) => displayEvents({ data, document, list }))
|
||||||
.catch((data) => displayErrorMessage(data, list))
|
.catch((data) => displayErrorMessage({ data, list }))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
27
source/connector-mobilizon/front/formatter-test.js
Normal file
27
source/connector-mobilizon/front/formatter-test.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import test from 'ava'
|
||||||
|
import Formatter from './formatter'
|
||||||
|
|
||||||
|
test('#formatDate one date', t => {
|
||||||
|
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')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('#formatDate two dates', t => {
|
||||||
|
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')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('#formatLocation both parameters', t => {
|
||||||
|
const date = Formatter.formatLocation({ description: 'a', locality: 'b' })
|
||||||
|
t.is(date, 'a, b')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('#formatLocation description only', t => {
|
||||||
|
const date = Formatter.formatLocation({ description: 'a' })
|
||||||
|
t.is(date, 'a')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('#formatLocation locality only', t => {
|
||||||
|
const date = Formatter.formatLocation({ locality: 'a' })
|
||||||
|
t.is(date, 'a')
|
||||||
|
})
|
31
source/connector-mobilizon/front/formatter.js
Normal file
31
source/connector-mobilizon/front/formatter.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import DateTimeWrapper from './date-time-wrapper'
|
||||||
|
|
||||||
|
export default class Formatter {
|
||||||
|
|
||||||
|
static formatDate({ locale, timeZone, start, end }) {
|
||||||
|
const startDateTime = new DateTimeWrapper({ locale, text: start, timeZone })
|
||||||
|
const endDateTime = new DateTimeWrapper({ locale, text: end, timeZone })
|
||||||
|
let dateText = startDateTime.getShortDate()
|
||||||
|
dateText += ' ' + startDateTime.get24Time()
|
||||||
|
dateText += ' - '
|
||||||
|
if (!startDateTime.equalsDate(endDateTime)) {
|
||||||
|
dateText += endDateTime.getShortDate() + ' '
|
||||||
|
}
|
||||||
|
dateText += endDateTime.get24Time()
|
||||||
|
return dateText
|
||||||
|
}
|
||||||
|
|
||||||
|
static formatLocation({ description, locality }) {
|
||||||
|
let location = ''
|
||||||
|
if (description) {
|
||||||
|
location += description
|
||||||
|
}
|
||||||
|
if (location && locality) {
|
||||||
|
location += ', '
|
||||||
|
}
|
||||||
|
if (locality) {
|
||||||
|
location += locality
|
||||||
|
}
|
||||||
|
return location
|
||||||
|
}
|
||||||
|
}
|
@ -1,41 +1,64 @@
|
|||||||
import { request, gql } from 'graphql-request'
|
import SessionCache from './session-cache'
|
||||||
import { DateTimeWrapper } from './date-time-wrapper'
|
import { request } from 'graphql-request'
|
||||||
|
import DateTimeWrapper from './date-time-wrapper'
|
||||||
|
|
||||||
export function getUpcomingEvents({ url, limit }) {
|
export function getUpcomingEvents({ url, limit }) {
|
||||||
const query = gql`
|
const query = `
|
||||||
query {
|
query ($limit: Int) {
|
||||||
events(limit:${limit}) {
|
events(limit: $limit) {
|
||||||
elements {
|
|
||||||
id,
|
|
||||||
title,
|
|
||||||
url,
|
|
||||||
beginsOn,
|
|
||||||
endsOn
|
|
||||||
},
|
|
||||||
total
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
return request(url, query)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getUpcomingEventsByGroupName({ url, limit, groupName }) {
|
|
||||||
const afterDatetime = DateTimeWrapper.getCurrentDatetimeAsString();
|
|
||||||
const query = gql`
|
|
||||||
query {
|
|
||||||
group(preferredUsername:"${groupName}") {
|
|
||||||
organizedEvents(afterDatetime:"${afterDatetime}", limit:${limit}) {
|
|
||||||
elements {
|
elements {
|
||||||
id,
|
id,
|
||||||
title,
|
title,
|
||||||
url,
|
url,
|
||||||
beginsOn,
|
beginsOn,
|
||||||
endsOn
|
endsOn,
|
||||||
|
physicalAddress {
|
||||||
|
description,
|
||||||
|
locality
|
||||||
|
}
|
||||||
},
|
},
|
||||||
total
|
total
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
`
|
`
|
||||||
return request(url, query)
|
const dataInCache = SessionCache.get(sessionStorage, { url, query, variables: { limit }})
|
||||||
|
if (dataInCache !== null)
|
||||||
|
return Promise.resolve(dataInCache)
|
||||||
|
return request(url, query, { limit })
|
||||||
|
.then((data) => {
|
||||||
|
SessionCache.add(sessionStorage, { url, query, variables: { limit }}, data)
|
||||||
|
return Promise.resolve(data)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getUpcomingEventsByGroupName({ url, limit, groupName }) {
|
||||||
|
const query = `
|
||||||
|
query ($afterDatetime: DateTime, $groupName: String, $limit: Int) {
|
||||||
|
group(preferredUsername: $groupName) {
|
||||||
|
organizedEvents(afterDatetime: $afterDatetime, limit: $limit) {
|
||||||
|
elements {
|
||||||
|
id,
|
||||||
|
title,
|
||||||
|
url,
|
||||||
|
beginsOn,
|
||||||
|
endsOn,
|
||||||
|
physicalAddress {
|
||||||
|
description,
|
||||||
|
locality
|
||||||
|
}
|
||||||
|
},
|
||||||
|
total
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
|
const afterDatetime = DateTimeWrapper.getCurrentDatetimeAsString()
|
||||||
|
const dataInCache = SessionCache.get(sessionStorage, { url, query, variables: { afterDatetime, groupName, limit }})
|
||||||
|
if (dataInCache !== null)
|
||||||
|
return Promise.resolve(dataInCache)
|
||||||
|
return request(url, query, { afterDatetime, groupName, limit })
|
||||||
|
.then((data) => {
|
||||||
|
SessionCache.add(sessionStorage, { url, query, variables: { afterDatetime, groupName, limit }}, data)
|
||||||
|
return Promise.resolve(data)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
import test from 'ava';
|
import test from 'ava'
|
||||||
import { JSDOM } from 'jsdom';
|
import { JSDOM } from 'jsdom'
|
||||||
|
|
||||||
import * as HtmlCreator from './html-creator';
|
import { createAnchorElement } from './html-creator'
|
||||||
|
|
||||||
|
let document
|
||||||
|
|
||||||
test.beforeEach(() => {
|
test.beforeEach(() => {
|
||||||
global.document = new JSDOM().window.document
|
document = new JSDOM().window.document
|
||||||
})
|
})
|
||||||
|
|
||||||
test('createAnchorElement() usual parameters', t => {
|
test('#createAnchorElement usual parameters', t => {
|
||||||
const a = HtmlCreator.createAnchorElement({ text: 'a', url: 'b' })
|
const a = createAnchorElement({ document, 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')
|
||||||
})
|
})
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
export function createAnchorElement({ text, url }) {
|
export function createAnchorElement({ document, 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')
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
import test from 'ava'
|
||||||
|
import hash from './object-hash-wrapper'
|
||||||
|
|
||||||
|
test('#hash object', t => {
|
||||||
|
t.is(hash({foo: 'bar'}), 'a75c05bdca7d704bdfcd761913e5a4e4636e956b')
|
||||||
|
})
|
5
source/connector-mobilizon/front/object-hash-wrapper.js
Normal file
5
source/connector-mobilizon/front/object-hash-wrapper.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import objectHash from 'object-hash'
|
||||||
|
|
||||||
|
export default function hash(object) {
|
||||||
|
return objectHash(object)
|
||||||
|
}
|
34
source/connector-mobilizon/front/session-cache-test.js
Normal file
34
source/connector-mobilizon/front/session-cache-test.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import test from 'ava'
|
||||||
|
import SessionCache from './session-cache'
|
||||||
|
|
||||||
|
const fakeStorage = {
|
||||||
|
|
||||||
|
elements: {},
|
||||||
|
|
||||||
|
clear() {
|
||||||
|
this.elements = {}
|
||||||
|
},
|
||||||
|
|
||||||
|
getItem(key) {
|
||||||
|
const value = this.elements[key]
|
||||||
|
if (value === undefined) return null
|
||||||
|
return value
|
||||||
|
},
|
||||||
|
|
||||||
|
setItem(key, value) {
|
||||||
|
this.elements[key] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
test.afterEach(() => {
|
||||||
|
fakeStorage.clear()
|
||||||
|
})
|
||||||
|
|
||||||
|
test('#add & #get', t => {
|
||||||
|
SessionCache.add(fakeStorage, { a: 'b' }, { c: 'd' })
|
||||||
|
t.deepEqual(SessionCache.get(fakeStorage, { a: 'b' }), { c: 'd' })
|
||||||
|
})
|
||||||
|
|
||||||
|
test('#get no entry', t => {
|
||||||
|
t.is(SessionCache.get(fakeStorage, { a: 'bb' }), null)
|
||||||
|
})
|
24
source/connector-mobilizon/front/session-cache.js
Normal file
24
source/connector-mobilizon/front/session-cache.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import hash from './object-hash-wrapper'
|
||||||
|
|
||||||
|
const MAX_AGE_IN_MS = 120000
|
||||||
|
|
||||||
|
export default class SessionCache {
|
||||||
|
|
||||||
|
static add(storage, parameters, data) {
|
||||||
|
const key = hash(parameters)
|
||||||
|
const timestamp = Date.now()
|
||||||
|
const value = {
|
||||||
|
data,
|
||||||
|
timestamp,
|
||||||
|
}
|
||||||
|
storage.setItem(key, JSON.stringify(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
static get(storage, parameters) {
|
||||||
|
const key = hash(parameters)
|
||||||
|
const value = JSON.parse(storage.getItem(key))
|
||||||
|
if (value && value.timestamp && value.timestamp > Date.now() - MAX_AGE_IN_MS)
|
||||||
|
return value.data
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
@ -9,4 +9,3 @@ 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>';
|
|
||||||
|
@ -26,9 +26,10 @@ 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();
|
||||||
$textDomain = TEXT_DOMAIN;
|
$timeZone = get_option('timezone_string');
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
require dirname(__DIR__) . '/view/events-list.php';
|
require dirname(__DIR__) . '/view/events-list.php';
|
||||||
|
@ -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 . ' ' . esc_html__('Events List', TEXT_DOMAIN),
|
NICE_NAME . ' ' . __('Events List', 'connector-mobilizon'),
|
||||||
array(
|
array(
|
||||||
'description' => __('A list of the upcoming events of the connected Mobilizon instance.', TEXT_DOMAIN),
|
'description' => __('A list of the upcoming events of the connected Mobilizon instance.', 'connector-mobilizon'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -27,9 +27,10 @@ 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();
|
||||||
$textDomain = TEXT_DOMAIN;
|
$timeZone = get_option('timezone_string');
|
||||||
|
|
||||||
require dirname(__DIR__) . '/view/events-list.php';
|
require dirname(__DIR__) . '/view/events-list.php';
|
||||||
|
|
||||||
@ -37,10 +38,9 @@ class EventsListWidget extends \WP_Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function form($options) {
|
public function form($options) {
|
||||||
$title = !empty($options['title']) ? $options['title'] : esc_html__('Events', TEXT_DOMAIN);
|
$title = !empty($options['title']) ? $options['title'] : __('Events', 'connector-mobilizon');
|
||||||
$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';
|
||||||
}
|
}
|
||||||
|
@ -29,14 +29,14 @@ class Settings {
|
|||||||
|
|
||||||
add_settings_section(
|
add_settings_section(
|
||||||
self::$SETTINGS_SECTION_NAME,
|
self::$SETTINGS_SECTION_NAME,
|
||||||
__('General Settings', TEXT_DOMAIN),
|
__('General Settings', 'connector-mobilizon'),
|
||||||
'',
|
'',
|
||||||
self::$PAGE_NAME
|
self::$PAGE_NAME
|
||||||
);
|
);
|
||||||
|
|
||||||
add_settings_field(
|
add_settings_field(
|
||||||
self::$SETTING_FIELD_NAME_URL,
|
self::$SETTING_FIELD_NAME_URL,
|
||||||
__('URL', TEXT_DOMAIN),
|
__('URL', 'connector-mobilizon'),
|
||||||
'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,7 +47,6 @@ 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';
|
||||||
}
|
}
|
||||||
@ -58,7 +57,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.', TEXT_DOMAIN),
|
__('The URL is invalid.', 'connector-mobilizon'),
|
||||||
'error'
|
'error'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -70,7 +69,7 @@ class Settings {
|
|||||||
|
|
||||||
public static function register_settings_page() {
|
public static function register_settings_page() {
|
||||||
add_options_page(
|
add_options_page(
|
||||||
NICE_NAME . ' ' . __('Settings', TEXT_DOMAIN),
|
NICE_NAME . ' ' . __('Settings', 'connector-mobilizon'),
|
||||||
NICE_NAME,
|
NICE_NAME,
|
||||||
'manage_options',
|
'manage_options',
|
||||||
NAME . '-settings',
|
NAME . '-settings',
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# <wordpress-nice-name>
|
# <wordpress-nice-name>
|
||||||
Contributors: dwaxweiler
|
Contributors: dwaxweiler
|
||||||
|
Donate link: <wordpress-donation-link>
|
||||||
Tags: mobilizon, events
|
Tags: mobilizon, events
|
||||||
Stable tag: <wordpress-version>
|
Stable tag: <wordpress-version>
|
||||||
Requires at least: <wordpress-minimum-version>
|
Requires at least: <wordpress-minimum-version>
|
||||||
@ -11,9 +12,15 @@ License: <wordpress-license>
|
|||||||
|
|
||||||
## Description
|
## Description
|
||||||
|
|
||||||
<wordpress-nice-name> allows you to display the upcoming events of [Mobilizon](https://joinmobilizon.org/), which is a federated event listing platform.
|
<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.
|
||||||
|
|
||||||
You can display the upcoming events using a widget and everywhere else using a shortcut.
|
Features
|
||||||
|
- 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"]`
|
||||||
@ -28,6 +35,31 @@ 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
|
||||||
|
#### Added
|
||||||
|
- Show events' location if set: `description` and `locality` fields
|
||||||
|
- Plugin icon
|
||||||
|
#### Changed
|
||||||
|
- Update dev dependencies eslint, jsdom, webpack
|
||||||
|
|
||||||
|
### [0.3.0] - 2021-04-05
|
||||||
|
#### Added
|
||||||
|
- Donation link to WordPress Plugin Directory sidebar and to `package.json`
|
||||||
|
- Cache requests for 2 minutes
|
||||||
|
- Set up ESLint static code analysis
|
||||||
|
#### Changed
|
||||||
|
- Update luxon dependency
|
||||||
|
- Update dev dependencies jsdom, webpack, webpack-cli
|
||||||
|
|
||||||
### [0.2.2] - 2021-03-10
|
### [0.2.2] - 2021-03-10
|
||||||
#### Changed
|
#### Changed
|
||||||
- Confirm compatibility with WordPress 5.7
|
- Confirm compatibility with WordPress 5.7
|
||||||
|
@ -5,14 +5,14 @@ if (!defined('ABSPATH')) {
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<p>
|
<p>
|
||||||
<label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php esc_attr_e('Title', $textDomain); ?>:</label>
|
<label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php esc_html_e('Title', 'connector-mobilizon'); ?>:</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_attr_e('Number of events to show', $textDomain); ?>:</label>
|
<label for="<?php echo esc_attr($this->get_field_id('eventsCount')); ?>"><?php esc_html_e('Number of events to show', 'connector-mobilizon'); ?>:</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_attr_e('Group name (optional)', $textDomain); ?>:</label>
|
<label for="<?php echo esc_attr($this->get_field_id('groupName')); ?>"><?php esc_html_e('Group name (optional)', 'connector-mobilizon'); ?>:</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>
|
||||||
|
@ -6,7 +6,9 @@ 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); ?>"
|
||||||
<li style="display: none;"><?php echo esc_html_e('The events could not be loaded!', $textDomain); ?></li>
|
data-time-zone="<?php echo esc_attr($timeZone); ?>">
|
||||||
|
<li style="display: none;"><?php esc_html_e('The events could not be loaded!', 'connector-mobilizon'); ?></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -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', $textDomain); ?>
|
<?php esc_html_e('The URL of the Mobilizon instance whose events you want to list, e.g. https://example.net', 'connector-mobilizon'); ?>
|
||||||
</p>
|
</p>
|
||||||
|
Reference in New Issue
Block a user