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

Merge branch 'main' into block

This commit is contained in:
Daniel Waxweiler
2022-06-03 23:32:23 +02:00
20 changed files with 4894 additions and 8730 deletions

View File

@@ -1,16 +1,46 @@
### [Unreleased]
#### Added
- Add specific error message for the case the group is not found
- Add code formatter prettier
#### Changed
- Set minimum PHP version to oldest officially supported 7.4
- Update dependencies
- Simplify build process
#### Deprecated
#### Removed
#### Fixed
#### Security
### [0.9.1] - 2020-05-19
#### Fixed
- Fix WordPress compatibility version number
### [0.9.0] - 2020-05-19
#### Added
- Improve explanation of group name filter
#### Changed
- Update dependencies
- Confirm compatibility with WordPress 6.0
#### Fixed
- Fix displaying error message for the case the group is not found
### [0.8.0] - 2022-01-09
#### Added
- Add support for older browsers using babel
#### Changed
- Confirm compatibility with WordPress 5.9
- Update dependencies
#### Fixed
- Use ES modules correctly
- Trim events' location
### [0.7.0] - 2021-12-23
#### Added
- Add specific error message for the case the group is not found
- Add code formatter prettier
#### Changed
- Update dependencies
- Simplify build process
#### Fixed
- Fix Invalid DateTime on event end time being null
#### Security
- Set minimum PHP version to oldest stable 7.4
### [0.6.2] - 2021-08-24
#### Changed
- Update dependencies

View File

@@ -1,5 +1,5 @@
import test from 'ava'
import DateTimeWrapper from './date-time-wrapper'
import DateTimeWrapper from './date-time-wrapper.js'
test('#getShortDate usual date', (t) => {
const d = new DateTimeWrapper({ text: '2020-12-24T16:45:00Z' })

View File

@@ -1,7 +1,7 @@
import test from 'ava'
import { JSDOM } from 'jsdom'
import { displayEvents, displayErrorMessage } from './events-displayer'
import { displayEvents, displayErrorMessage } from './events-displayer.js'
let document

View File

@@ -1,5 +1,5 @@
import Formatter from './formatter'
import { createAnchorElement } from './html-creator'
import Formatter from './formatter.js'
import { createAnchorElement } from './html-creator.js'
export function displayEvents({ data, document, list }) {
const locale = list.getAttribute('data-locale')

View File

@@ -1,5 +1,5 @@
import { displayEvents, displayErrorMessage } from './events-displayer'
import * as GraphqlWrapper from './graphql-wrapper'
import { displayEvents, displayErrorMessage } from './events-displayer.js'
import * as GraphqlWrapper from './graphql-wrapper.js'
const NAME = '<wordpress-name>'

View File

@@ -1,5 +1,5 @@
import test from 'ava'
import Formatter from './formatter'
import Formatter from './formatter.js'
test('#formatDate one date', (t) => {
const date = Formatter.formatDate({
@@ -32,20 +32,42 @@ test('#formatDate two dates with short offset name', (t) => {
end: '2021-04-16T15:30:00Z',
isShortOffsetNameShown: true,
})
t.is(date, '15/04/2021 10:30 (UTC) - 16/04/2021 15:30 (UTC)')
t.is(date, '15/04/2021 10:30 - 16/04/2021 15:30 (UTC)')
})
test('#formatDate second date is null', (t) => {
const date = Formatter.formatDate({
start: '2021-04-15T10:30:00Z',
end: null,
})
t.is(date, '15/04/2021 10:30')
})
test('#formatDate second date is null with short offset name', (t) => {
const date = Formatter.formatDate({
start: '2021-04-15T10:30:00Z',
end: null,
isShortOffsetNameShown: true,
})
t.is(date, '15/04/2021 10:30 (UTC)')
})
test('#formatLocation both parameters', (t) => {
const date = Formatter.formatLocation({ description: 'a', locality: 'b' })
t.is(date, 'a, b')
const location = Formatter.formatLocation({ description: 'a', locality: 'b' })
t.is(location, 'a, b')
})
test('#formatLocation description only', (t) => {
const date = Formatter.formatLocation({ description: 'a' })
t.is(date, 'a')
const location = Formatter.formatLocation({ description: 'a' })
t.is(location, 'a')
})
test('#formatLocation description with space only', (t) => {
const location = Formatter.formatLocation({ description: ' ' })
t.is(location, '')
})
test('#formatLocation locality only', (t) => {
const date = Formatter.formatLocation({ locality: 'a' })
t.is(date, 'a')
const location = Formatter.formatLocation({ locality: 'a' })
t.is(location, 'a')
})

View File

@@ -1,4 +1,4 @@
import DateTimeWrapper from './date-time-wrapper'
import DateTimeWrapper from './date-time-wrapper.js'
export default class Formatter {
static formatDate({ locale, timeZone, start, end, isShortOffsetNameShown }) {
@@ -7,29 +7,32 @@ export default class Formatter {
text: start,
timeZone,
})
const endDateTime = new DateTimeWrapper({ locale, text: end, timeZone })
let dateText = startDateTime.getShortDate()
dateText += ' ' + startDateTime.get24Time()
if (!startDateTime.equalsDate(endDateTime)) {
if (isShortOffsetNameShown) {
dateText += ' (' + startDateTime.getShortOffsetName() + ')'
}
dateText += ' - '
dateText += endDateTime.getShortDate() + ' '
} else {
dateText += ' - '
if (!end && isShortOffsetNameShown) {
dateText += ' (' + startDateTime.getShortOffsetName() + ')'
}
dateText += endDateTime.get24Time()
if (isShortOffsetNameShown) {
dateText += ' (' + endDateTime.getShortOffsetName() + ')'
if (end) {
const endDateTime = new DateTimeWrapper({ locale, text: end, timeZone })
if (!startDateTime.equalsDate(endDateTime)) {
dateText += ' - '
dateText += endDateTime.getShortDate() + ' '
} else {
dateText += ' - '
}
dateText += endDateTime.get24Time()
if (isShortOffsetNameShown) {
dateText += ' (' + endDateTime.getShortOffsetName() + ')'
}
}
return dateText
}
static formatLocation({ description, locality }) {
let location = ''
if (description) {
location += description
if (description && description.trim()) {
location += description.trim()
}
if (location && locality) {
location += ', '

View File

@@ -1,6 +1,6 @@
import SessionCache from './session-cache'
import SessionCache from './session-cache.js'
import { request } from 'graphql-request'
import DateTimeWrapper from './date-time-wrapper'
import DateTimeWrapper from './date-time-wrapper.js'
export function getUpcomingEvents({ url, limit }) {
const query = `
@@ -37,7 +37,7 @@ export function getUpcomingEvents({ url, limit }) {
export function getUpcomingEventsByGroupName({ url, limit, groupName }) {
const query = `
query ($afterDatetime: DateTime, $groupName: String, $limit: Int) {
query ($afterDatetime: DateTime, $groupName: String!, $limit: Int) {
group(preferredUsername: $groupName) {
organizedEvents(afterDatetime: $afterDatetime, limit: $limit) {
elements {

View File

@@ -1,7 +1,7 @@
import test from 'ava'
import { JSDOM } from 'jsdom'
import { createAnchorElement } from './html-creator'
import { createAnchorElement } from './html-creator.js'
let document

View File

@@ -1,5 +1,5 @@
import test from 'ava'
import hash from './object-hash-wrapper'
import hash from './object-hash-wrapper.js'
test('#hash object', (t) => {
t.is(hash({ foo: 'bar' }), 'a75c05bdca7d704bdfcd761913e5a4e4636e956b')

View File

@@ -1,5 +1,5 @@
import test from 'ava'
import SessionCache from './session-cache'
import SessionCache from './session-cache.js'
const fakeStorage = {
elements: {},

View File

@@ -1,4 +1,4 @@
import hash from './object-hash-wrapper'
import hash from './object-hash-wrapper.js'
const MAX_AGE_IN_MS = 120000

View File

@@ -24,7 +24,9 @@ Features
- Toggle adding named offset in brackets after the time in the settings
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"]`
You have to use their username, e.g. `@nosliensvivants`, and append the name of their instance if they use a different one, e.g. `@yaam_berlin@mobilize.berlin`.
The source code is available on [Github](https://github.com/dwaxweiler/connector-mobilizon).
@@ -36,6 +38,41 @@ The source code is available on [Github](https://github.com/dwaxweiler/connector
## Changelog
### [0.9.1] - 2020-05-19
#### Fixed
- Fix WordPress compatibility version number
### [0.9.0] - 2020-05-19
#### Added
- Improve explanation of group name filter
#### Changed
- Update dependencies
- Confirm compatibility with WordPress 6.0
#### Fixed
- Fix displaying error message for the case the group is not found
### [0.8.0] - 2022-01-09
#### Added
- Add support for older browsers using babel
#### Changed
- Confirm compatibility with WordPress 5.9
- Update dependencies
#### Fixed
- Use ES modules correctly
- Trim events' location
### [0.7.0] - 2021-12-23
#### Added
- Add specific error message for the case the group is not found
- Add code formatter prettier
#### Changed
- Update dependencies
- Simplify build process
#### Fixed
- Fix Invalid DateTime on event end time being null
#### Security
- Set minimum PHP version to oldest stable 7.4
### [0.6.2] - 2021-08-24
#### Changed
- Update dependencies