@eeacms/volto-flourish 0.1.0 → 0.1.2
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 +59 -3
- package/README.md +20 -18
- package/package.json +10 -4
- package/src/blocks/EmbedFlourish/Edit.js +36 -0
- package/src/blocks/EmbedFlourish/View.js +99 -0
- package/src/blocks/EmbedFlourish/View.test.jsx +39 -0
- package/src/blocks/EmbedFlourish/index.js +27 -0
- package/src/blocks/EmbedFlourish/schema.js +102 -0
- package/src/blocks/index.js +19 -0
- package/src/index.js +18 -1
- package/src/middleware.js +27 -0
- package/src/widgets/FlourishViewWidget.jsx +18 -0
- package/src/widgets/index.js +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,61 @@
|
|
|
1
|
-
|
|
1
|
+
### Changelog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
All notable changes to this project will be documented in this file. Dates are displayed in UTC.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
|
+
|
|
7
|
+
### [0.1.2](https://github.com/eea/volto-flourish/compare/0.1.1...0.1.2) - 16 September 2024
|
|
8
|
+
|
|
9
|
+
#### :house: Internal changes
|
|
10
|
+
|
|
11
|
+
- style: Automated code fix [eea-jenkins - [`71fbb9b`](https://github.com/eea/volto-flourish/commit/71fbb9b4e6521de530d7abdd1c4fe20ba6afd092)]
|
|
12
|
+
- style: Automated code fix [eea-jenkins - [`d90efae`](https://github.com/eea/volto-flourish/commit/d90efaeddab695ebdb356032eadeeb535650ad97)]
|
|
13
|
+
|
|
14
|
+
#### :hammer_and_wrench: Others
|
|
15
|
+
|
|
16
|
+
- set default value [Tripon Eugen - [`fceac76`](https://github.com/eea/volto-flourish/commit/fceac761126034e78494a0876ca751532a449767)]
|
|
17
|
+
- add test params [Tripon Eugen - [`72e582e`](https://github.com/eea/volto-flourish/commit/72e582ecc219836f6615249d5716b9438e7692e2)]
|
|
18
|
+
- add toolbar [Tripon Eugen - [`e786558`](https://github.com/eea/volto-flourish/commit/e786558bea8a8951b663f1b924b7c8198741163d)]
|
|
19
|
+
- wip [Tripon Eugen - [`162ae1f`](https://github.com/eea/volto-flourish/commit/162ae1fecb3cc68ffc3cf0890e4b86099a395146)]
|
|
20
|
+
- update test and default values [Tripon Eugen - [`4ae23a8`](https://github.com/eea/volto-flourish/commit/4ae23a8e62fa135d228ed9ed552b55273ad31fdf)]
|
|
21
|
+
- add test data [Tripon Eugen - [`2089c05`](https://github.com/eea/volto-flourish/commit/2089c054e21dd1eacd4870109add6ba4c1ed72f3)]
|
|
22
|
+
- add test data [Tripon Eugen - [`9ba6954`](https://github.com/eea/volto-flourish/commit/9ba6954de4dacdf3da9aa9a7a7b46bb326aec2d4)]
|
|
23
|
+
- add test [Tripon Eugen - [`5cd1f8d`](https://github.com/eea/volto-flourish/commit/5cd1f8d472bd3f78a887b88a784e2859c7e752fd)]
|
|
24
|
+
- Update Jenkinsfile: don't run volto 16 tests [Krisztina Elekes - [`4fe41ed`](https://github.com/eea/volto-flourish/commit/4fe41ed2364fb7c138b521651c2281c97f93d156)]
|
|
25
|
+
- eslint [Tripon Eugen - [`04eda9a`](https://github.com/eea/volto-flourish/commit/04eda9a5097471e0222a36a97aee6821673b30f3)]
|
|
26
|
+
- add volto-embed dependencies [Tripon Eugen - [`6147417`](https://github.com/eea/volto-flourish/commit/614741750ebf1403b0b33aea10957b60fa511b72)]
|
|
27
|
+
- add dependecies volto-embed [Tripon Eugen - [`76f1651`](https://github.com/eea/volto-flourish/commit/76f165140cc79d8ef0ab944f36f12e4a88be9c50)]
|
|
28
|
+
- show sources [Tripon Eugen - [`2410686`](https://github.com/eea/volto-flourish/commit/241068652f53ba9ec70454fd4d1428f04bd40076)]
|
|
29
|
+
- show sources [Tripon Eugen - [`246d415`](https://github.com/eea/volto-flourish/commit/246d415376f2c71987fb45a9be56cd57939c9b9d)]
|
|
30
|
+
### [0.1.1](https://github.com/eea/volto-flourish/compare/0.1.0...0.1.1) - 20 August 2024
|
|
31
|
+
|
|
32
|
+
#### :bug: Bug Fixes
|
|
33
|
+
|
|
34
|
+
- fix: cypress on Volto 16 [alin - [`4d75c3f`](https://github.com/eea/volto-flourish/commit/4d75c3f72fb06897c0424d1422f0ff97a9aad1e4)]
|
|
35
|
+
|
|
36
|
+
#### :hammer_and_wrench: Others
|
|
37
|
+
|
|
38
|
+
- screenshot update [Tripon Eugen - [`8706a47`](https://github.com/eea/volto-flourish/commit/8706a4749867ae024d449cd245ff7922a101d000)]
|
|
39
|
+
- screenshot update [Tripon Eugen - [`5162fdf`](https://github.com/eea/volto-flourish/commit/5162fdf2a310516d27f4eebc4d55abd21397ea82)]
|
|
40
|
+
- screenshot and message [Tripon Eugen - [`7341b36`](https://github.com/eea/volto-flourish/commit/7341b36d3e3ffb905c25ddec08066220ef030ec4)]
|
|
41
|
+
- cleanup [Tripon Eugen - [`2996b94`](https://github.com/eea/volto-flourish/commit/2996b94d648ef913394aeadf7c7a264497c90639)]
|
|
42
|
+
- iframe height default value [Tripon Eugen - [`6064b38`](https://github.com/eea/volto-flourish/commit/6064b385f951c8cf5b449abc421508e595947e76)]
|
|
43
|
+
- iframe height [Tripon Eugen - [`b7778e1`](https://github.com/eea/volto-flourish/commit/b7778e109775fb13eb9a94b6a7ce064c194f2ab7)]
|
|
44
|
+
- iframe use height defined [Tripon Eugen - [`0894e6f`](https://github.com/eea/volto-flourish/commit/0894e6fed948ba2e9f8cade45baea61c017a5b14)]
|
|
45
|
+
- iframe set height and border [Tripon Eugen - [`8270d81`](https://github.com/eea/volto-flourish/commit/8270d81cba8f83e2e7adec4a81b524c2f9d034f9)]
|
|
46
|
+
- Widget View check flourish download check empty [Tripon Eugen - [`d3ae5ab`](https://github.com/eea/volto-flourish/commit/d3ae5ab5e3031ef1d8bfd6809fbddcb256dcf0c9)]
|
|
47
|
+
- Widget View check flourish download [Tripon Eugen - [`9f967b3`](https://github.com/eea/volto-flourish/commit/9f967b365e81ca1d5613148e10813011144fafed)]
|
|
48
|
+
- iframe title [Tripon Eugen - [`be9fde6`](https://github.com/eea/volto-flourish/commit/be9fde6bf2a8bcb9ab450d364c6f43b2ca2ad13f)]
|
|
49
|
+
- embed flourish edit mode (empty item) [Tripon Eugen - [`37864ed`](https://github.com/eea/volto-flourish/commit/37864ed905556b53827f9b7385495744094863dd)]
|
|
50
|
+
- display iframe only when url is set [Tripon Eugen - [`89caf41`](https://github.com/eea/volto-flourish/commit/89caf4112ac53dd1a0ba904e32536d96fafc723c)]
|
|
51
|
+
- eslint [Tripon Eugen - [`56d2b21`](https://github.com/eea/volto-flourish/commit/56d2b214a2f574bbf8b00cc41871f33a25713a5c)]
|
|
52
|
+
- Flourish widget and embeded block [Tripon Eugen - [`c6b6fed`](https://github.com/eea/volto-flourish/commit/c6b6fed75367fb2f5de13aea71c543b9018f40af)]
|
|
53
|
+
- WIP [Tiberiu Ichim - [`b4d4484`](https://github.com/eea/volto-flourish/commit/b4d448427c8dfc71327b8ba1b471dd6d4d30883f)]
|
|
54
|
+
- test middleware [Tripon Eugen - [`2f64fb4`](https://github.com/eea/volto-flourish/commit/2f64fb4900b8f69019b659b6560fe55f4e46c023)]
|
|
55
|
+
- Readme [Tiberiu Ichim - [`8ea6019`](https://github.com/eea/volto-flourish/commit/8ea6019dd75ac679db3f9a557e5e3be1da5b5bf8)]
|
|
56
|
+
### 0.1.0 - 2 August 2024
|
|
57
|
+
|
|
58
|
+
#### :hammer_and_wrench: Others
|
|
59
|
+
|
|
60
|
+
- Bootstrap [Tiberiu Ichim - [`154115b`](https://github.com/eea/volto-flourish/commit/154115b9197720809e8dfe66315c48ce363c4478)]
|
|
61
|
+
- Initial commit [Tiberiu Ichim - [`9549a6a`](https://github.com/eea/volto-flourish/commit/9549a6a2d506f03a7901bd5b8667a63a135bb750)]
|
package/README.md
CHANGED
|
@@ -14,12 +14,14 @@
|
|
|
14
14
|
[](https://sonarqube.eea.europa.eu/dashboard?id=volto-flourish-develop)
|
|
15
15
|
[](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
|
-
|
|
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
|
+

|
|
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
|
-
|
|
47
|
+
- If you already have a volto project, just update `package.json`:
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
```JSON
|
|
50
|
+
"addons": [
|
|
51
|
+
"@eeacms/volto-flourish"
|
|
52
|
+
],
|
|
51
53
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@eeacms/volto-flourish": "*"
|
|
56
|
+
}
|
|
57
|
+
```
|
|
56
58
|
|
|
57
|
-
|
|
59
|
+
- If not, create one:
|
|
58
60
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "0.1.2",
|
|
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,15 @@
|
|
|
16
16
|
"type": "git",
|
|
17
17
|
"url": "git@github.com:eea/volto-flourish.git"
|
|
18
18
|
},
|
|
19
|
-
"
|
|
19
|
+
"addons": [
|
|
20
|
+
"@eeacms/volto-embed"
|
|
21
|
+
],
|
|
20
22
|
"devDependencies": {
|
|
21
|
-
"@plone/scripts": "*",
|
|
22
23
|
"@cypress/code-coverage": "^3.10.0",
|
|
23
|
-
"
|
|
24
|
+
"@plone/scripts": "*",
|
|
24
25
|
"babel-plugin-transform-class-properties": "^6.24.1",
|
|
26
|
+
"cypress": "13.1.0",
|
|
27
|
+
"cypress-fail-fast": "^5.0.1",
|
|
25
28
|
"husky": "^8.0.3",
|
|
26
29
|
"lint-staged": "^14.0.1",
|
|
27
30
|
"md5": "^2.3.0"
|
|
@@ -66,5 +69,8 @@
|
|
|
66
69
|
"i18n": "make i18n",
|
|
67
70
|
"cypress:run": "make cypress-run",
|
|
68
71
|
"cypress:open": "make cypress-open"
|
|
72
|
+
},
|
|
73
|
+
"dependencies": {
|
|
74
|
+
"@eeacms/volto-embed": "*"
|
|
69
75
|
}
|
|
70
76
|
}
|
|
@@ -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,99 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useSelector, useDispatch } from 'react-redux';
|
|
3
|
+
import { getContent } from '@plone/volto/actions';
|
|
4
|
+
import { flattenToAppURL } from '@plone/volto/helpers';
|
|
5
|
+
// import { Sources } from '@eeacms/volto-embed/Toolbar';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
FigureNote,
|
|
9
|
+
Sources,
|
|
10
|
+
MoreInfo,
|
|
11
|
+
Share,
|
|
12
|
+
Enlarge,
|
|
13
|
+
} from '@eeacms/volto-embed/Toolbar';
|
|
14
|
+
|
|
15
|
+
export default function View(props) {
|
|
16
|
+
const { id, data } = props;
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
with_sources,
|
|
20
|
+
// with_download,
|
|
21
|
+
with_notes,
|
|
22
|
+
with_share,
|
|
23
|
+
with_enlarge,
|
|
24
|
+
with_more_info,
|
|
25
|
+
flourish_item_url,
|
|
26
|
+
flourish_iframe_height = '600px',
|
|
27
|
+
} = data;
|
|
28
|
+
|
|
29
|
+
const flourish_url = flourish_item_url + '/@@flourish/index.html';
|
|
30
|
+
const vis_url = flattenToAppURL(flourish_item_url || '');
|
|
31
|
+
const dispatch = useDispatch();
|
|
32
|
+
|
|
33
|
+
const flourishItemContent = useSelector(
|
|
34
|
+
(state) => state.content?.subrequests?.[id]?.data,
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (vis_url) {
|
|
39
|
+
const action = getContent(vis_url, null, id);
|
|
40
|
+
dispatch(action);
|
|
41
|
+
}
|
|
42
|
+
}, [dispatch, vis_url, id]);
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<div className="embed-flourish">
|
|
46
|
+
{flourish_item_url ? (
|
|
47
|
+
<div>
|
|
48
|
+
<iframe
|
|
49
|
+
src={flourish_url}
|
|
50
|
+
width="100%"
|
|
51
|
+
title={flourishItemContent?.title}
|
|
52
|
+
style={{
|
|
53
|
+
border: '0px',
|
|
54
|
+
height: flourish_iframe_height,
|
|
55
|
+
}}
|
|
56
|
+
></iframe>
|
|
57
|
+
{flourishItemContent && (
|
|
58
|
+
<div className="visualization-toolbar">
|
|
59
|
+
<div className="left-col">
|
|
60
|
+
{with_notes && (
|
|
61
|
+
<FigureNote notes={flourishItemContent?.figure_note || []} />
|
|
62
|
+
)}
|
|
63
|
+
{flourishItemContent && with_sources && (
|
|
64
|
+
<Sources
|
|
65
|
+
sources={flourishItemContent?.data_provenance?.data || []}
|
|
66
|
+
/>
|
|
67
|
+
)}
|
|
68
|
+
{with_more_info && (
|
|
69
|
+
<MoreInfo href={flourishItemContent['@id']} />
|
|
70
|
+
)}
|
|
71
|
+
</div>
|
|
72
|
+
<div className="right-col">
|
|
73
|
+
{with_share && <Share href={flourishItemContent['@id']} />}
|
|
74
|
+
{with_enlarge && (
|
|
75
|
+
<Enlarge>
|
|
76
|
+
<View
|
|
77
|
+
{...props}
|
|
78
|
+
data={{
|
|
79
|
+
...props.data,
|
|
80
|
+
with_notes: false,
|
|
81
|
+
with_sources: false,
|
|
82
|
+
with_more_info: false,
|
|
83
|
+
with_enlarge: false,
|
|
84
|
+
with_share: false,
|
|
85
|
+
with_download: false,
|
|
86
|
+
}}
|
|
87
|
+
/>
|
|
88
|
+
</Enlarge>
|
|
89
|
+
)}
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
)}
|
|
93
|
+
</div>
|
|
94
|
+
) : props.mode ? (
|
|
95
|
+
<div>Embed flourish</div>
|
|
96
|
+
) : null}
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
3
|
+
import configureStore from 'redux-mock-store';
|
|
4
|
+
import { render } from '@testing-library/react';
|
|
5
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
6
|
+
import { Provider } from 'react-intl-redux';
|
|
7
|
+
import View from './View';
|
|
8
|
+
|
|
9
|
+
const mockStore = configureStore();
|
|
10
|
+
|
|
11
|
+
describe('View', () => {
|
|
12
|
+
it('should render the component', () => {
|
|
13
|
+
const data = {
|
|
14
|
+
with_sources: false,
|
|
15
|
+
with_notes: false,
|
|
16
|
+
with_share: false,
|
|
17
|
+
with_enlarge: false,
|
|
18
|
+
with_more_info: false,
|
|
19
|
+
flourish_item_url: undefined,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const store = mockStore({
|
|
23
|
+
userSession: { token: '1234' },
|
|
24
|
+
intl: {
|
|
25
|
+
locale: 'en',
|
|
26
|
+
messages: {},
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const { container } = render(
|
|
31
|
+
<Provider store={store}>
|
|
32
|
+
<MemoryRouter>
|
|
33
|
+
<View data={data} />
|
|
34
|
+
</MemoryRouter>
|
|
35
|
+
</Provider>,
|
|
36
|
+
);
|
|
37
|
+
expect(container.querySelector('.embed-flourish')).toBeInTheDocument();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -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,102 @@
|
|
|
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: [
|
|
22
|
+
'flourish_test_url',
|
|
23
|
+
'flourish_item_url',
|
|
24
|
+
'flourish_iframe_height',
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: 'toolbar',
|
|
29
|
+
title: 'Toolbar',
|
|
30
|
+
fields: [
|
|
31
|
+
'with_sources',
|
|
32
|
+
'with_notes',
|
|
33
|
+
'with_more_info',
|
|
34
|
+
// 'with_download',
|
|
35
|
+
'with_share',
|
|
36
|
+
'with_enlarge',
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
properties: {
|
|
41
|
+
flourish_item_url: {
|
|
42
|
+
title: 'Fourish item',
|
|
43
|
+
widget: 'internal_url',
|
|
44
|
+
description: (
|
|
45
|
+
<div>
|
|
46
|
+
<p>An item that has loaded a Flourish visualization.</p>
|
|
47
|
+
</div>
|
|
48
|
+
),
|
|
49
|
+
},
|
|
50
|
+
flourish_iframe_height: {
|
|
51
|
+
title: (
|
|
52
|
+
<a
|
|
53
|
+
rel="noopener noreferrer"
|
|
54
|
+
target="_blank"
|
|
55
|
+
href="https://developer.mozilla.org/en-US/docs/Web/CSS/height"
|
|
56
|
+
>
|
|
57
|
+
{props.intl.formatMessage(messages.CSSHeight)}
|
|
58
|
+
</a>
|
|
59
|
+
),
|
|
60
|
+
default: '600px',
|
|
61
|
+
description: props.intl.formatMessage(
|
|
62
|
+
messages.CSSFlourishHeightDescription,
|
|
63
|
+
),
|
|
64
|
+
},
|
|
65
|
+
with_notes: {
|
|
66
|
+
title: 'Show note',
|
|
67
|
+
type: 'boolean',
|
|
68
|
+
default: true,
|
|
69
|
+
},
|
|
70
|
+
with_sources: {
|
|
71
|
+
title: 'Show sources',
|
|
72
|
+
description: 'Will show sources set in this page Data provenance',
|
|
73
|
+
type: 'boolean',
|
|
74
|
+
default: true,
|
|
75
|
+
},
|
|
76
|
+
with_more_info: {
|
|
77
|
+
title: 'Show more info',
|
|
78
|
+
type: 'boolean',
|
|
79
|
+
default: true,
|
|
80
|
+
},
|
|
81
|
+
with_enlarge: {
|
|
82
|
+
title: 'Show enlarge button',
|
|
83
|
+
type: 'boolean',
|
|
84
|
+
default: true,
|
|
85
|
+
},
|
|
86
|
+
// with_download: {
|
|
87
|
+
// title: 'Show download button',
|
|
88
|
+
// type: 'boolean',
|
|
89
|
+
// default: true,
|
|
90
|
+
// },
|
|
91
|
+
with_share: {
|
|
92
|
+
title: 'Show share button',
|
|
93
|
+
type: 'boolean',
|
|
94
|
+
default: true,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
required: ['flourish_item_url'],
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
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
|
-
|
|
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;
|