Skip to content

Commit

Permalink
Merge pull request #431 from InfoAmazonia/release/2.10.0
Browse files Browse the repository at this point in the history
Release 2.10.0
  • Loading branch information
leopiccionia authored Aug 26, 2024
2 parents 93e9cb8 + c80fea5 commit b5703d3
Show file tree
Hide file tree
Showing 15 changed files with 430 additions and 305 deletions.
501 changes: 302 additions & 199 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
"react-mapbox-gl": "^4.8.6",
"react-movable": "^2.5.0",
"scrollama": "^2.2.2",
"styled-components": "^5.2.0",
"use-debounce": "^3.4.2"
"styled-components": "^6.1.12",
"use-debounce": "^10.0.3"
},
"devDependencies": {
"@wordpress/scripts": "^28.5.0",
"@wordpress/scripts": "^27.9.0",
"css-loader": "^7.1.2",
"mapbox-gl": "^1.13.1",
"postcss": "^8.4.41",
Expand Down
7 changes: 5 additions & 2 deletions src/README.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
=== JEO ===
Contributors: earthjournalism
Tested up to: 6.6.1
Stable tag: 2.9.3
Stable tag: 2.10.0
Requires PHP: 7.2
Requires at least: 5.8
License: GPL-2.0+
License URI: http://www.gnu.org/licenses/gpl-2.0.txt
Version: 2.9.3
Version: 2.10.0

The JEO plugin acts as a geojournalism platform that allows news organizations, bloggers and NGOs to publish news stories as layers of information on digital maps.

Expand Down Expand Up @@ -49,6 +49,9 @@ After activating the plugin, a new item will appear on the WordPress dashboard:

== Changelog ==

= 2.10.0 =
* Update dependencies

= 2.9.3 =
* Add support for more syntax in EJS templates, via [eta](https://eta.js.org/docs/intro/template-syntax)
* bugfix: Fix a regression that made popup template compilation fail
Expand Down
13 changes: 11 additions & 2 deletions src/includes/class-jeo.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public function register_assets() {

$deps = array_merge( array( 'lodash' ), $asset_file['dependencies'] );

wp_register_style( 'jeo-js', JEO_BASEURL . '/js/build/postsSidebar.css' );
wp_register_script(
'jeo-js',
JEO_BASEURL . '/js/build/postsSidebar.js',
Expand Down Expand Up @@ -181,6 +182,7 @@ public function register_assets() {

$map_blocks_assets = include JEO_BASEPATH . '/js/build/mapBlocks.asset.php';

wp_register_style( 'jeo-map-blocks', JEO_BASEURL . '/js/build/mapBlocks.css' );
wp_register_script(
'jeo-map-blocks',
JEO_BASEURL . '/js/build/mapBlocks.js',
Expand All @@ -206,14 +208,19 @@ public function register_block_category( $categories ) {
}

public function register_block_types() {
register_block_type( 'jeo/map-blocks', array( 'editor_script' => 'jeo-map-blocks' ) );
register_block_type( 'jeo/map-blocks', array(
'editor_script' => 'jeo-map-blocks',
'editor_style' => 'jeo-map-blocks',
) );
register_block_type( 'jeo/storymap', array(
'render_callback' => [$this, 'story_map_dynamic_render_callback'],
'editor_script' => 'jeo-map-blocks',
'editor_style' => 'jeo-map-blocks',
) );
register_block_type( 'jeo/embedded-storymap', array(
'render_callback' => [$this, 'embedded_story_map_dynamic_render_callback'],
'editor_script' => 'jeo-map-blocks',
'editor_style' => 'jeo-map-blocks',
) );
}

Expand Down Expand Up @@ -340,12 +347,14 @@ public function enqueue_scripts() {
wp_enqueue_style( 'mapboxgl', 'https://api.mapbox.com/mapbox-gl-js/v1.13.1/mapbox-gl.css', time() );
wp_enqueue_script( 'mapboxgl-loader' );
wp_enqueue_script( 'mapboxgl-spiderifier' );
wp_enqueue_style( 'jeo-map', JEO_BASEURL . '/js/build/jeoMap.css' );
wp_enqueue_script( 'jeo-map', JEO_BASEURL . '/js/build/jeoMap.js', array( 'mapboxgl-loader', 'mapboxgl-spiderifier', 'jquery', 'wp-element' ), false, true );

wp_set_script_translations('jeo-map', 'jeo', plugin_dir_path( __DIR__ ) . 'languages');


$discovery_assets = include JEO_BASEPATH . '/js/build/discovery.asset.php';
wp_enqueue_style( 'discovery-map', JEO_BASEURL . '/js/build/discovery.css' );
wp_enqueue_script( 'discovery-map', JEO_BASEURL . '/js/build/discovery.js', array_merge( $discovery_assets['dependencies'], array( 'wp-element', 'mapboxgl-loader', 'jquery', 'jeo-map' ) ), false, true);

wp_set_script_translations('discovery-map', 'jeo', plugin_dir_path( __DIR__ ) . 'languages');
Expand All @@ -370,7 +379,7 @@ public function enqueue_scripts() {
]
));

wp_enqueue_style( 'jeo-map', JEO_BASEURL . '/css/jeo-map.css', time() );
wp_enqueue_style( 'jeo-map-css', JEO_BASEURL . '/css/jeo-map.css', time() );
wp_localize_script(
'jeo-map',
'jeoMapVars',
Expand Down
2 changes: 2 additions & 0 deletions src/includes/sidebars/class-sidebars.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function rest_post_query($args, $request) {
public function load_assets() {
$asset_file = include JEO_BASEPATH . '/js/build/postsSidebar.asset.php';

wp_enqueue_style( 'jeo-layers-sidebar', JEO_BASEURL . '/js/build/layersSidebar.css' );
wp_enqueue_script(
'jeo-layers-sidebar',
JEO_BASEURL . '/js/build/layersSidebar.js',
Expand Down Expand Up @@ -49,6 +50,7 @@ public function load_assets() {
)
);

wp_enqueue_style( 'jeo-maps-sidebar', JEO_BASEURL . '/js/build/mapsSidebar.css' );
wp_enqueue_script(
'jeo-maps-sidebar',
JEO_BASEURL . '/js/build/mapsSidebar.js',
Expand Down
4 changes: 2 additions & 2 deletions src/jeo.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @wordpress-plugin
* Plugin Name: JEO WP
* Description: Interactive Map blocks for Wordpress Gutenberg
* Version: 2.9.3
* Version: 2.10.0
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: jeo
Expand All @@ -22,7 +22,7 @@
* Start at version 1.0.0 and use SemVer - https://semver.org
* Rename this for your plugin and update it as you release new versions.
*/
define( 'JEO_VERSION', '2.9.3' );
define( 'JEO_VERSION', '2.10.0' );

define( 'JEO_BASEPATH', plugin_dir_path( __FILE__ ) );
define( 'JEO_BASEURL', plugins_url('', __FILE__) );
Expand Down
5 changes: 1 addition & 4 deletions src/js/src/discovery/blocks/lazy-image.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import {
useRef,
} from '@wordpress/element';
import { useRef } from '@wordpress/element';
import styled, { keyframes } from 'styled-components';
import PropTypes from 'prop-types';

const loadingAnimation = keyframes`
0%{
Expand Down
16 changes: 6 additions & 10 deletions src/js/src/discovery/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component } from '@wordpress/element';
import { Component, createRoot } from '@wordpress/element';
import Sidebar from './blocks/sidebar';
import './style/discovery.scss';
import { __ } from '@wordpress/i18n';
Expand Down Expand Up @@ -444,14 +444,10 @@ class Discovery extends Component {

if ( document.querySelector( '.discovery-embed' ) ) {
document.querySelectorAll( '.discovery-embed' ).forEach( ( element ) => {
wp.element.render(
<Discovery embed={ true } useStories={ false } />,
element
);
const root = createRoot( element );
root.render( <Discovery embed={ true } useStories={ false } /> );
} );
} else if ( document.getElementById( 'discovery' ) ) {
wp.element.render(
<Discovery useStories={ true } />,
document.getElementById( 'discovery' )
);
} else if ( document.querySelector( '#discovery' ) ) {
const root = createRoot( document.querySelector( '#discovery' ) );
root.render( <Discovery useStories={ true } /> );
}
53 changes: 26 additions & 27 deletions src/js/src/layers-sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,32 @@ import domReady from '@wordpress/dom-ready';
import { registerPlugin } from '@wordpress/plugins';

import LayersSidebar from './layers-sidebar';
import { waitUntil } from '../shared/wait';

domReady( () => {
registerPlugin( 'jeo-layers-sidebar', {
icon: null,
render: () => {
const currentPostType = useSelect( ( select ) => {
return select( 'core/editor' ).getCurrentPostType()
}, [] );
domReady(() => {
waitUntil(
() => document.querySelector( '.editor-post-title' ),
( postTitleElement ) => {
registerPlugin( 'jeo-layers-sidebar', {
icon: null,
render: () => {
const currentPostType = useSelect( ( select ) => {
return select( 'core/editor' ).getCurrentPostType()
}, [] );

const postTitleElement = document.querySelector('.editor-post-title');
if (currentPostType === "map-layer") {
const preview = document.createElement('div');
preview.setAttribute('id', 'layer-preview');
postTitleElement.parentNode.appendChild(preview);
}

if(!postTitleElement) {
return null;
}

if(currentPostType === "map-layer") {
const preview = document.createElement('div');
preview.setAttribute('id', 'layer-preview');
postTitleElement.parentNode.appendChild(preview);
}

return (
<AsyncModeProvider value={ true }>
{ currentPostType === "map-layer"? <LayersSidebar /> : null };
</AsyncModeProvider>
)

},
} );
} );
return (
<AsyncModeProvider value={ true }>
{ currentPostType === "map-layer"? <LayersSidebar /> : null };
</AsyncModeProvider>
);
},
} );
}
);
});
5 changes: 3 additions & 2 deletions src/js/src/map-blocks/storymap-display.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, createRoot } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import classNames from 'classnames';
import mapboxgl from 'mapbox-gl';
import React, { Component } from 'react';
import scrollama from 'scrollama';

import { renderLayer } from './map-preview-layer';
Expand Down Expand Up @@ -537,8 +537,9 @@ function decodeHtml( html ) {
}

document.querySelectorAll( '.story-map-container' ).forEach( ( storyMapElement ) => {
const root = createRoot( storyMapElement );
const storyMapProps = JSON.parse( decodeHtml( storyMapElement.dataset.properties ) );
wp.element.render( <StoryMapDisplay { ...storyMapProps } />, storyMapElement );
root.render( <StoryMapDisplay { ...storyMapProps } /> );

// `overflow` avoids `position:sticky`
let parent = storyMapElement.parentElement;
Expand Down
2 changes: 1 addition & 1 deletion src/js/src/map-blocks/storymap-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ const applyWithSelect = withSelect( ( select, { attributes } ) => ( {
'map',
attributes.map_id,
] ),
loadedLayers: select( 'core' ).getEntityRecords( 'postType', 'map-layer', { per_page: -1, order: 'asc', orderby: 'menu_order', ID: 122820 } ),
loadedLayers: select( 'core' ).getEntityRecords( 'postType', 'map-layer', { per_page: -1, order: 'asc', orderby: 'menu_order' } ),
loadingLayers: select( 'core/data' ).isResolving(
'core',
'getEntityRecords',
Expand Down
69 changes: 31 additions & 38 deletions src/js/src/maps-sidebar/index.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,36 @@
// import { select } from '@wordpress/data';
import domReady from '@wordpress/dom-ready';
import { useSelect, AsyncModeProvider } from '@wordpress/data';
import domReady from '@wordpress/dom-ready';
import { registerPlugin } from '@wordpress/plugins';

import MapsSidebar from './maps-sidebar';

import StoryMapSidebar from './storymap-sidebar';

domReady( () => {
registerPlugin( 'jeo-maps-sidebar', {
icon: null,
render: () => {
const currentPostType = useSelect( ( select ) => {
return select( 'core/editor' ).getCurrentPostType()
}, [] );

const postTitleElement = document.querySelector('.editor-post-title');

if(!postTitleElement) {
return null;
}

if(currentPostType === "map") {
const preview = document.createElement('div');
preview.setAttribute('id', 'map-preview');
postTitleElement.parentNode.appendChild(preview);
}

return (
<AsyncModeProvider value={ true }>
{ currentPostType === "map"? <MapsSidebar /> : null };
{ currentPostType === "storymap"? <StoryMapSidebar /> : null };
</AsyncModeProvider>
)

},
} );

// }


} );
import { waitUntil } from '../shared/wait';

domReady(() => {
waitUntil(
() => document.querySelector( '.editor-post-title' ),
( postTitleElement ) => {
registerPlugin( 'jeo-maps-sidebar', {
icon: null,
render: () => {
const currentPostType = useSelect( ( select ) => {
return select( 'core/editor' ).getCurrentPostType();
}, [] );

if (currentPostType === "map") {
const preview = document.createElement('div');
preview.setAttribute('id', 'map-preview');
postTitleElement.parentNode.appendChild(preview);
}

return (
<AsyncModeProvider value={ true }>
{ currentPostType === "map"? <MapsSidebar /> : null };
{ currentPostType === "storymap"? <StoryMapSidebar /> : null };
</AsyncModeProvider>
);
},
} );
}
);
});
25 changes: 12 additions & 13 deletions src/js/src/posts-sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,18 @@ const JeoGeocodePanel = class JeoGeocodePanel extends Component {
registerPlugin( 'jeo-posts-sidebar', {
icon: null,
render: () => {
const currentPostType = useSelect( ( select ) => {
return select( 'core/editor' ).getCurrentPostType();
}, [] );

const currentPostType = useSelect( ( select ) => {
return select( 'core/editor' ).getCurrentPostType()
}, [] );

return (
<div>
{ currentPostType ?
<PluginDocumentSettingPanel title={ __( 'Geolocation', 'jeo' ) }>
<JeoGeocodePanel />
</PluginDocumentSettingPanel>
: null };
</div>
)
return (
<div>
{ currentPostType ?
<PluginDocumentSettingPanel title={ __( 'Geolocation', 'jeo' ) }>
<JeoGeocodePanel />
</PluginDocumentSettingPanel>
: null };
</div>
);
},
} );
20 changes: 20 additions & 0 deletions src/js/src/shared/wait.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export function waitUntil ( condition, callback, intervalMs = 50, timeoutMs = 30_000 ) {
const initialValue = condition();
if ( initialValue ) {
return callback( initialValue );
}

let elapsed = 0;
let interval = window.setInterval( () => {
const value = condition();
if ( value ) {
callback( value );
return window.clearInterval( interval );
}

elapsed += intervalMs;
if ( elapsed >= timeoutMs ) {
window.clearInterval( interval );
}
}, intervalMs );
}
Loading

0 comments on commit b5703d3

Please sign in to comment.