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

15 Commits

11 changed files with 5012 additions and 5414 deletions

10320
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "connector-mobilizon", "name": "connector-mobilizon",
"version": "1.2.0", "version": "1.4.0",
"description": "Display Mobilizon events in WordPress.", "description": "Display Mobilizon events in WordPress.",
"private": true, "private": true,
"type": "module", "type": "module",
@ -24,33 +24,33 @@
}, },
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"graphql": "16.9.0", "graphql": "16.11.0",
"luxon": "3.5.0" "luxon": "3.6.1"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "7.25.2", "@babel/core": "7.27.1",
"@babel/eslint-parser": "7.25.1", "@babel/eslint-parser": "7.27.1",
"@babel/preset-env": "7.25.3", "@babel/preset-env": "7.27.2",
"@babel/preset-react": "7.24.7", "@babel/preset-react": "7.27.1",
"@wordpress/eslint-plugin": "20.1.0", "@wordpress/eslint-plugin": "22.10.0",
"ava": "6.1.3", "ava": "6.3.0",
"babel-loader": "9.1.3", "babel-loader": "10.0.0",
"browser-env": "3.3.0", "c8": "10.1.3",
"c8": "10.1.2", "copy-webpack-plugin": "13.0.0",
"copy-webpack-plugin": "12.0.2", "eslint": "8.57.1",
"eslint": "8.57.0",
"eslint-plugin-ava": "14.0.0", "eslint-plugin-ava": "14.0.0",
"eslint-plugin-jsx": "0.1.0", "eslint-plugin-jsx": "0.1.0",
"eslint-plugin-react": "7.35.0", "eslint-plugin-react": "7.37.5",
"esm": "3.2.25", "esm": "3.2.25",
"gulp": "5.0.0", "gulp": "5.0.0",
"gulp-replace": "1.1.4", "gulp-replace": "1.1.4",
"husky": "9.1.4", "husky": "9.1.7",
"lint-staged": "15.2.8", "jsdom": "26.1.0",
"prettier": "3.3.3", "lint-staged": "15.5.2",
"prettier": "3.5.3",
"rimraf": "5.0.10", "rimraf": "5.0.10",
"webpack": "5.93.0", "webpack": "5.99.9",
"webpack-cli": "5.1.4" "webpack-cli": "6.0.1"
}, },
"ava": { "ava": {
"files": [ "files": [
@ -61,7 +61,7 @@
"niceName": "Connector for Mobilizon", "niceName": "Connector for Mobilizon",
"phpMinimumVersion": 7.4, "phpMinimumVersion": 7.4,
"wordpressMinimumVersion": 5.6, "wordpressMinimumVersion": 5.6,
"wordpressTestedUpToVersion": "6.6" "wordpressTestedUpToVersion": "6.8"
}, },
"lint-staged": { "lint-staged": {
"source/**/*.js": "eslint", "source/**/*.js": "eslint",

View File

@ -6,6 +6,23 @@
#### Fixed #### Fixed
#### Security #### Security
### [1.4.0]
#### Changed
- Update dependencies
- Confirm compatibility with WordPress 6.8
### [1.3.0]
#### Added
- Comment for translators what placeholder will contain
#### Changed
- Confirm compatibility with WordPress 6.7
- Load block script only in footer to reduce waiting time
- Update dependencies
#### Fixed
- Mark event-related data as non-translatable within plugin
- Add version number to script registration to break browser caching
- Handle location being null
### [1.2.0] ### [1.2.0]
#### Added #### Added
- Display event picture if available - Display event picture if available

View File

@ -1,5 +1,5 @@
import test from 'ava' import test from 'ava'
import browserEnv from 'browser-env' import { JSDOM } from 'jsdom'
import { import {
displayEvents, displayEvents,
@ -9,7 +9,9 @@ import {
} from './events-displayer.js' } from './events-displayer.js'
test.before(() => { test.before(() => {
browserEnv() const dom = new JSDOM()
global.document = dom.window.document
global.window = dom.window
window.MOBILIZON_CONNECTOR = { window.MOBILIZON_CONNECTOR = {
locale: 'en-GB', locale: 'en-GB',
timeZone: 'utc', timeZone: 'utc',

View File

@ -1,10 +1,11 @@
import test from 'ava' import test from 'ava'
import browserEnv from 'browser-env' import { JSDOM } from 'jsdom'
import { createAnchorElement } from './html-creator.js' import { createAnchorElement } from './html-creator.js'
test.beforeEach(() => { test.beforeEach(() => {
browserEnv() const dom = new JSDOM()
global.document = dom.window.document
}) })
test('#createAnchorElement usual parameters', (t) => { test('#createAnchorElement usual parameters', (t) => {

View File

@ -10,7 +10,7 @@ class EventsListBlock {
'wp-blocks', 'wp-blocks',
'wp-components', 'wp-components',
'wp-i18n' 'wp-i18n'
]); ], '<wordpress-version>', array('in_footer' => true));
register_block_type(NAME . '/events-list', [ register_block_type(NAME . '/events-list', [
'api_version' => 2, 'api_version' => 2,
'title' => __('Events List', 'connector-mobilizon'), 'title' => __('Events List', 'connector-mobilizon'),

View File

@ -26,7 +26,7 @@ final class Formatter
return $dateText; return $dateText;
} }
public static function format_location(string $description, string $locality): string { public static function format_location(string $description, ?string $locality): string {
$location = ''; $location = '';
if ($description && trim($description)) { if ($description && trim($description)) {
$location .= trim($description); $location .= trim($description);

View File

@ -43,6 +43,23 @@ You have to use their username, e.g. `@nosliensvivants`, and append the name of
## Changelog ## Changelog
### [1.4.0]
#### Changed
- Update dependencies
- Confirm compatibility with WordPress 6.8
### [1.3.0]
#### Added
- Comment for translators what placeholder will contain
#### Changed
- Confirm compatibility with WordPress 6.7
- Load block script only in footer to reduce waiting time
- Update dependencies
#### Fixed
- Mark event-related data as non-translatable within plugin
- Add version number to script registration to break browser caching
- Handle location being null
### [1.2.0] ### [1.2.0]
#### Added #### Added
- Display event picture if available - Display event picture if available

View File

@ -7,5 +7,8 @@ if (!defined('ABSPATH')) {
} }
?> ?>
<div class="<?php echo esc_attr($classNamePrefix); ?>_events-list"> <div class="<?php echo esc_attr($classNamePrefix); ?>_events-list">
<?php echo esc_html(sprintf(__('The group "%s" could not be found!', 'connector-mobilizon'), $groupName)); ?> <?php
/* translators: %s is replaced with the name of the group. */
echo esc_html(sprintf(__('The group "%s" could not be found!', 'connector-mobilizon'), $groupName));
?>
</div> </div>

View File

@ -13,12 +13,12 @@ if (!defined('ABSPATH')) {
<?php if (isset($event['picture'])) { ?> <?php if (isset($event['picture'])) { ?>
<img alt="<?php echo esc_attr($event['picture']['alt']); ?>" src="<?php echo esc_attr($event['picture']['base64']); ?>" style="display: block; max-width: 100%;"> <img alt="<?php echo esc_attr($event['picture']['alt']); ?>" src="<?php echo esc_attr($event['picture']['base64']); ?>" style="display: block; max-width: 100%;">
<?php } ?> <?php } ?>
<a href="<?php echo esc_attr($event['url']); ?>"><?php echo esc_html_e($event['title']); ?></a> <a href="<?php echo esc_attr($event['url']); ?>"><?php echo esc_html($event['title']); ?></a>
<br> <br>
<?php echo esc_html_e(Formatter::format_date($locale, $timeZone, $event['beginsOn'], $event['endsOn'], $isShortOffsetNameShown)); ?> <?php echo esc_html(Formatter::format_date($locale, $timeZone, $event['beginsOn'], $event['endsOn'], $isShortOffsetNameShown)); ?>
<?php if (isset($event['physicalAddress'])) { ?> <?php if (isset($event['physicalAddress'])) { ?>
<br> <br>
<?php echo esc_html_e(Formatter::format_location($event['physicalAddress']['description'], $event['physicalAddress']['locality'])) ?> <?php echo esc_html(Formatter::format_location($event['physicalAddress']['description'], $event['physicalAddress']['locality'])) ?>
<?php } ?> <?php } ?>
</li> </li>
<?php } ?> <?php } ?>

View File

@ -42,6 +42,10 @@ final class FormatterTest extends PHPUnit\Framework\TestCase
$this->assertSame('a', Formatter::format_location('a', '')); $this->assertSame('a', Formatter::format_location('a', ''));
} }
public function testLocationFormatDescriptionOnlyWithNull(): void {
$this->assertSame('a', Formatter::format_location('a', null));
}
public function testLocationFormatDescriptionWithSpaceOnly(): void { public function testLocationFormatDescriptionWithSpaceOnly(): void {
$this->assertSame('', Formatter::format_location(' ', '')); $this->assertSame('', Formatter::format_location(' ', ''));
} }