@eeacms/volto-flourish 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
- # Changelog
1
+ ### Changelog
2
2
 
3
- ## 0.1.0
3
+ All notable changes to this project will be documented in this file. Dates are displayed in UTC.
4
4
 
5
- - Initial release
5
+ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
+
7
+ ### [0.1.1](https://github.com/eea/volto-flourish/compare/0.1.0...0.1.1) - 20 August 2024
8
+
9
+ #### :bug: Bug Fixes
10
+
11
+ - fix: cypress on Volto 16 [alin - [`4d75c3f`](https://github.com/eea/volto-flourish/commit/4d75c3f72fb06897c0424d1422f0ff97a9aad1e4)]
12
+
13
+ #### :hammer_and_wrench: Others
14
+
15
+ - screenshot update [Tripon Eugen - [`8706a47`](https://github.com/eea/volto-flourish/commit/8706a4749867ae024d449cd245ff7922a101d000)]
16
+ - screenshot update [Tripon Eugen - [`5162fdf`](https://github.com/eea/volto-flourish/commit/5162fdf2a310516d27f4eebc4d55abd21397ea82)]
17
+ - screenshot and message [Tripon Eugen - [`7341b36`](https://github.com/eea/volto-flourish/commit/7341b36d3e3ffb905c25ddec08066220ef030ec4)]
18
+ - cleanup [Tripon Eugen - [`2996b94`](https://github.com/eea/volto-flourish/commit/2996b94d648ef913394aeadf7c7a264497c90639)]
19
+ - iframe height default value [Tripon Eugen - [`6064b38`](https://github.com/eea/volto-flourish/commit/6064b385f951c8cf5b449abc421508e595947e76)]
20
+ - iframe height [Tripon Eugen - [`b7778e1`](https://github.com/eea/volto-flourish/commit/b7778e109775fb13eb9a94b6a7ce064c194f2ab7)]
21
+ - iframe use height defined [Tripon Eugen - [`0894e6f`](https://github.com/eea/volto-flourish/commit/0894e6fed948ba2e9f8cade45baea61c017a5b14)]
22
+ - iframe set height and border [Tripon Eugen - [`8270d81`](https://github.com/eea/volto-flourish/commit/8270d81cba8f83e2e7adec4a81b524c2f9d034f9)]
23
+ - Widget View check flourish download check empty [Tripon Eugen - [`d3ae5ab`](https://github.com/eea/volto-flourish/commit/d3ae5ab5e3031ef1d8bfd6809fbddcb256dcf0c9)]
24
+ - Widget View check flourish download [Tripon Eugen - [`9f967b3`](https://github.com/eea/volto-flourish/commit/9f967b365e81ca1d5613148e10813011144fafed)]
25
+ - iframe title [Tripon Eugen - [`be9fde6`](https://github.com/eea/volto-flourish/commit/be9fde6bf2a8bcb9ab450d364c6f43b2ca2ad13f)]
26
+ - embed flourish edit mode (empty item) [Tripon Eugen - [`37864ed`](https://github.com/eea/volto-flourish/commit/37864ed905556b53827f9b7385495744094863dd)]
27
+ - display iframe only when url is set [Tripon Eugen - [`89caf41`](https://github.com/eea/volto-flourish/commit/89caf4112ac53dd1a0ba904e32536d96fafc723c)]
28
+ - eslint [Tripon Eugen - [`56d2b21`](https://github.com/eea/volto-flourish/commit/56d2b214a2f574bbf8b00cc41871f33a25713a5c)]
29
+ - Flourish widget and embeded block [Tripon Eugen - [`c6b6fed`](https://github.com/eea/volto-flourish/commit/c6b6fed75367fb2f5de13aea71c543b9018f40af)]
30
+ - WIP [Tiberiu Ichim - [`b4d4484`](https://github.com/eea/volto-flourish/commit/b4d448427c8dfc71327b8ba1b471dd6d4d30883f)]
31
+ - test middleware [Tripon Eugen - [`2f64fb4`](https://github.com/eea/volto-flourish/commit/2f64fb4900b8f69019b659b6560fe55f4e46c023)]
32
+ - Readme [Tiberiu Ichim - [`8ea6019`](https://github.com/eea/volto-flourish/commit/8ea6019dd75ac679db3f9a557e5e3be1da5b5bf8)]
33
+ ### 0.1.0 - 2 August 2024
34
+
35
+ #### :hammer_and_wrench: Others
36
+
37
+ - Bootstrap [Tiberiu Ichim - [`154115b`](https://github.com/eea/volto-flourish/commit/154115b9197720809e8dfe66315c48ce363c4478)]
38
+ - Initial commit [Tiberiu Ichim - [`9549a6a`](https://github.com/eea/volto-flourish/commit/9549a6a2d506f03a7901bd5b8667a63a135bb750)]
package/README.md CHANGED
@@ -14,12 +14,14 @@
14
14
  [![Bugs](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-flourish-develop&metric=bugs)](https://sonarqube.eea.europa.eu/dashboard?id=volto-flourish-develop)
15
15
  [![Duplicated Lines (%)](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-flourish-develop&metric=duplicated_lines_density)](https://sonarqube.eea.europa.eu/dashboard?id=volto-flourish-develop)
16
16
 
17
-
18
17
  [Volto](https://github.com/plone/volto) add-on
19
18
 
20
19
  ## Features
21
20
 
22
- Demo GIF
21
+ Flourish integration
22
+
23
+ #### IMPORTANT! In order to load a Flourish visualization, the eea.api.dataconnector addon needs to be active on the Plone side.
24
+ ![Flourish Block](./docs/preview.png "Flourish Block")
23
25
 
24
26
  ## Getting started
25
27
 
@@ -42,25 +44,25 @@ Go to http://localhost:3000
42
44
 
43
45
  1. Start Volto frontend
44
46
 
45
- * If you already have a volto project, just update `package.json`:
47
+ - If you already have a volto project, just update `package.json`:
46
48
 
47
- ```JSON
48
- "addons": [
49
- "@eeacms/volto-flourish"
50
- ],
49
+ ```JSON
50
+ "addons": [
51
+ "@eeacms/volto-flourish"
52
+ ],
51
53
 
52
- "dependencies": {
53
- "@eeacms/volto-flourish": "*"
54
- }
55
- ```
54
+ "dependencies": {
55
+ "@eeacms/volto-flourish": "*"
56
+ }
57
+ ```
56
58
 
57
- * If not, create one:
59
+ - If not, create one:
58
60
 
59
- ```
60
- npm install -g yo @plone/generator-volto
61
- yo @plone/volto my-volto-project --canary --addon @eeacms/volto-flourish
62
- cd my-volto-project
63
- ```
61
+ ```
62
+ npm install -g yo @plone/generator-volto
63
+ yo @plone/volto my-volto-project --canary --addon @eeacms/volto-flourish
64
+ cd my-volto-project
65
+ ```
64
66
 
65
67
  1. Install new add-ons and restart Volto:
66
68
 
@@ -91,7 +93,7 @@ See [LICENSE.md](https://github.com/eea/volto-flourish/blob/master/LICENSE.md) f
91
93
  ## Funding
92
94
 
93
95
  [European Environment Agency (EU)](http://eea.europa.eu)
94
- (EEA).
96
+ (EEA).
95
97
  All Rights Reserved.
96
98
 
97
99
  See [LICENSE.md](https://github.com/eea/volto-addon-template/blob/master/LICENSE.md) for details.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-flourish",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "@eeacms/volto-flourish: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -16,12 +16,12 @@
16
16
  "type": "git",
17
17
  "url": "git@github.com:eea/volto-flourish.git"
18
18
  },
19
- "dependencies": {},
20
19
  "devDependencies": {
21
- "@plone/scripts": "*",
22
20
  "@cypress/code-coverage": "^3.10.0",
23
- "cypress-fail-fast": "^5.0.1",
21
+ "@plone/scripts": "*",
24
22
  "babel-plugin-transform-class-properties": "^6.24.1",
23
+ "cypress": "13.1.0",
24
+ "cypress-fail-fast": "^5.0.1",
25
25
  "husky": "^8.0.3",
26
26
  "lint-staged": "^14.0.1",
27
27
  "md5": "^2.3.0"
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import { compose } from 'redux';
3
+ import { injectIntl } from 'react-intl';
4
+ import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';
5
+ import { SidebarPortal } from '@plone/volto/components';
6
+ import getSchema from './schema';
7
+
8
+ import View from './View';
9
+
10
+ const Edit = (props) => {
11
+ const { block, data, selected, onChangeBlock } = props;
12
+ const schema = React.useMemo(() => getSchema(props), [props]);
13
+
14
+ return (
15
+ <React.Fragment>
16
+ <View mode="edit" {...props} />
17
+ <SidebarPortal selected={selected}>
18
+ <BlockDataForm
19
+ block={block}
20
+ schema={schema}
21
+ title={schema.title}
22
+ onChangeBlock={onChangeBlock}
23
+ onChangeField={(id, value) => {
24
+ onChangeBlock(block, {
25
+ ...data,
26
+ [id]: value,
27
+ });
28
+ }}
29
+ formData={data}
30
+ />
31
+ </SidebarPortal>
32
+ </React.Fragment>
33
+ );
34
+ };
35
+
36
+ export default compose(injectIntl)(Edit);
@@ -0,0 +1,24 @@
1
+ const View = (props) => {
2
+ const flourish_url = props.data.flourish_item_url + '/@@flourish/index.html';
3
+ const { flourish_iframe_height = '600px' } = props.data;
4
+ return (
5
+ <div className="embed-flourish">
6
+ {props.data.flourish_item_url ? (
7
+ <iframe
8
+ src={flourish_url}
9
+ width="100%"
10
+ // height={props.data.flourish_iframe_height}
11
+ title="FlourishEmbed"
12
+ style={{
13
+ border: '0px',
14
+ height: flourish_iframe_height,
15
+ }}
16
+ ></iframe>
17
+ ) : props.mode ? (
18
+ <div>Embed flourish</div>
19
+ ) : null}
20
+ </div>
21
+ );
22
+ };
23
+
24
+ export default View;
@@ -0,0 +1,27 @@
1
+ import EmbedFlourishVisualizatonEdit from './Edit';
2
+ import EmbedFlourishVisualizatonView from './View';
3
+
4
+ import sliderSVG from '@plone/volto/icons/slider.svg';
5
+
6
+ const config = (config) => {
7
+ config.blocks.blocksConfig.embed_flourish_visualization = {
8
+ id: 'embed_flourish_visualization',
9
+ title: 'Embed Flourish',
10
+ icon: sliderSVG,
11
+ group: 'data_visualizations',
12
+ edit: EmbedFlourishVisualizatonEdit,
13
+ view: EmbedFlourishVisualizatonView,
14
+ restricted: false,
15
+ mostUsed: false,
16
+ sidebarTab: 1,
17
+ blocks: {},
18
+ security: {
19
+ addPermission: [],
20
+ view: [],
21
+ },
22
+ };
23
+
24
+ return config;
25
+ };
26
+
27
+ export default config;
@@ -0,0 +1,55 @@
1
+ import { defineMessages } from 'react-intl';
2
+
3
+ const messages = defineMessages({
4
+ CSSHeight: {
5
+ id: 'CSS height',
6
+ defaultMessage: 'CSS height',
7
+ },
8
+ CSSFlourishHeightDescription: {
9
+ id: 'Iframe height',
10
+ defaultMessage: 'Flourish iframe height',
11
+ },
12
+ });
13
+
14
+ const schema = (props) => {
15
+ return {
16
+ title: 'Embed Flourish',
17
+ fieldsets: [
18
+ {
19
+ id: 'default',
20
+ title: 'Default',
21
+ fields: ['flourish_item_url', 'flourish_iframe_height'],
22
+ },
23
+ ],
24
+ properties: {
25
+ flourish_item_url: {
26
+ title: 'Fourish item',
27
+ widget: 'internal_url',
28
+ description: (
29
+ <div>
30
+ <p>An item that has loaded a Flourish visualization.</p>
31
+ </div>
32
+ ),
33
+ },
34
+ flourish_iframe_height: {
35
+ title: (
36
+ <a
37
+ rel="noopener noreferrer"
38
+ target="_blank"
39
+ href="https://developer.mozilla.org/en-US/docs/Web/CSS/height"
40
+ >
41
+ {props.intl.formatMessage(messages.CSSHeight)}
42
+ </a>
43
+ ),
44
+ default: '600px',
45
+ description: props.intl.formatMessage(
46
+ messages.CSSFlourishHeightDescription,
47
+ ),
48
+ },
49
+ },
50
+
51
+ required: ['flourish_item_url'],
52
+ };
53
+ };
54
+
55
+ export default schema;
@@ -0,0 +1,19 @@
1
+ import { uniqBy } from 'lodash';
2
+ import installEmbedFlourishVisualization from './EmbedFlourish';
3
+
4
+ const config = (config) => {
5
+ config.blocks.groupBlocksOrder = uniqBy(
6
+ [
7
+ ...config.blocks.groupBlocksOrder,
8
+ { id: 'flourish_visualizations', title: 'Flourish Visualizations' },
9
+ ],
10
+ 'id',
11
+ );
12
+
13
+ return [installEmbedFlourishVisualization].reduce(
14
+ (acc, apply) => apply(acc),
15
+ config,
16
+ );
17
+ };
18
+
19
+ export default config;
package/src/index.js CHANGED
@@ -1,5 +1,22 @@
1
+ import installBlocks from './blocks';
2
+ import { FlourishViewWidget } from './widgets';
3
+
1
4
  const applyConfig = (config) => {
2
- return config;
5
+ if (__SERVER__) {
6
+ const express = require('express');
7
+ const flourishApiHandler = require('./middleware').default;
8
+
9
+ const middleware = express.Router();
10
+ middleware.all('**/@@flourish/**', flourishApiHandler);
11
+ middleware.id = 'flourish';
12
+
13
+ config.settings.expressMiddleware = [
14
+ ...config.settings.expressMiddleware,
15
+ middleware,
16
+ ];
17
+ }
18
+ config.widgets.views.id.flourish_zip = FlourishViewWidget;
19
+ return [installBlocks].reduce((acc, apply) => apply(acc), config);
3
20
  };
4
21
 
5
22
  export default applyConfig;
@@ -0,0 +1,27 @@
1
+ import { getAPIResourceWithAuth } from '@plone/volto/helpers';
2
+
3
+ const HEADERS = [
4
+ 'accept-ranges',
5
+ 'cache-control',
6
+ 'content-disposition',
7
+ 'content-range',
8
+ 'content-type',
9
+ 'x-sendfile',
10
+ 'x-accel-redirect',
11
+ 'x-robots-tag',
12
+ ];
13
+
14
+ export default function flourishMiddleware(req, res, next) {
15
+ getAPIResourceWithAuth(req)
16
+ .then((resource) => {
17
+ // Just forward the headers that we need
18
+ HEADERS.forEach((header) => {
19
+ if (resource.headers[header]) {
20
+ res.set(header, resource.get(header));
21
+ }
22
+ });
23
+ res.status(resource.statusCode);
24
+ res.send(resource.body);
25
+ })
26
+ .catch(next);
27
+ }
@@ -0,0 +1,18 @@
1
+ const FlourishViewWidget = (props) => {
2
+ const flourish_url = props.value?.download?.replace(
3
+ '/@@download/flourish_zip',
4
+ '/@@flourish/index.html',
5
+ );
6
+ return props.value ? (
7
+ <div className="flourish-view-widget">
8
+ <iframe
9
+ src={flourish_url}
10
+ height="100%"
11
+ width="100%"
12
+ title="Flourish Widget"
13
+ ></iframe>
14
+ </div>
15
+ ) : null;
16
+ };
17
+
18
+ export default FlourishViewWidget;
@@ -0,0 +1,3 @@
1
+ import FlourishViewWidget from './FlourishViewWidget';
2
+
3
+ export { FlourishViewWidget };