@eeacms/volto-datahub 1.0.16 → 1.0.18
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 +15 -5
- package/package.json +1 -1
- package/src/components/Result/DatahubCardItem.jsx +10 -3
- package/src/config/facets.js +57 -0
- package/src/express-middleware.js +89 -0
- package/src/index.js +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,21 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
### [1.0.18](https://github.com/eea/volto-datahub/compare/1.0.17...1.0.18) - 13 March 2023
|
|
8
|
+
|
|
9
|
+
#### :hammer_and_wrench: Others
|
|
10
|
+
|
|
11
|
+
- lint [Zoltan Szabo - [`3d9c842`](https://github.com/eea/volto-datahub/commit/3d9c8428fac3aa66cba164639926745b81434b52)]
|
|
12
|
+
- Remove console.logs [Zoltan Szabo - [`09e19bf`](https://github.com/eea/volto-datahub/commit/09e19bf7656b3a11c5f967b0ff45d05ca8b3bcd5)]
|
|
13
|
+
- set lastmod in sitemap [Zoltan Szabo - [`bb2819c`](https://github.com/eea/volto-datahub/commit/bb2819c41eed63a23532cba01eeedd7c3f8b7217)]
|
|
14
|
+
- Refs #250008; add datahub sitemap [Tiberiu Ichim - [`c9f9996`](https://github.com/eea/volto-datahub/commit/c9f9996ba71b49932a52b21aeb6b7cfcb80a60d2)]
|
|
15
|
+
### [1.0.17](https://github.com/eea/volto-datahub/compare/1.0.16...1.0.17) - 10 March 2023
|
|
16
|
+
|
|
17
|
+
#### :hammer_and_wrench: Others
|
|
18
|
+
|
|
19
|
+
- test(Jenkinsfile): Use latest stable volto for testing [Zoltan Szabo - [`7aed7a1`](https://github.com/eea/volto-datahub/commit/7aed7a124289f3b39b479fda1bbedd72de88d95b)]
|
|
20
|
+
- Move labels inside <a> [kreafox - [`4273ece`](https://github.com/eea/volto-datahub/commit/4273ece5870b6661b1a66da91f6678923649a3cb)]
|
|
21
|
+
- updates on archived items [Zoltan Szabo - [`627225d`](https://github.com/eea/volto-datahub/commit/627225d726ef48cfbcebddbf574abbe46c2c844d)]
|
|
7
22
|
### [1.0.16](https://github.com/eea/volto-datahub/compare/1.0.15...1.0.16) - 6 March 2023
|
|
8
23
|
|
|
9
24
|
#### :hammer_and_wrench: Others
|
|
@@ -11,7 +26,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
11
26
|
- added utils.js [Zoltan Szabo - [`fdb33c3`](https://github.com/eea/volto-datahub/commit/fdb33c37e1af2fe071dbe8f4f5dcd2b82932edc8)]
|
|
12
27
|
- Show 'Obsolete' info in the metadata section in the banner [Zoltan Szabo - [`fddfd2a`](https://github.com/eea/volto-datahub/commit/fddfd2aea63d1a1d1567c163ab29dd7119781117)]
|
|
13
28
|
- Show 'More information' section only if it's not empty [Zoltan Szabo - [`612f035`](https://github.com/eea/volto-datahub/commit/612f03509c6adf143631ae6dee5ca2bd48a501c3)]
|
|
14
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`b9100f6`](https://github.com/eea/volto-datahub/commit/b9100f6b2b2e9e9a26b9c11708c8fda94137cecc)]
|
|
15
29
|
### [1.0.15](https://github.com/eea/volto-datahub/compare/1.0.14...1.0.15) - 1 March 2023
|
|
16
30
|
|
|
17
31
|
### [1.0.14](https://github.com/eea/volto-datahub/compare/1.0.13...1.0.14) - 1 March 2023
|
|
@@ -104,11 +118,9 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
104
118
|
#### :hammer_and_wrench: Others
|
|
105
119
|
|
|
106
120
|
- Fix eslintrc: add @eeacms/search [kreafox - [`465816f`](https://github.com/eea/volto-datahub/commit/465816feb8f58095ab4b5b3168cd29ebede3a10c)]
|
|
107
|
-
- Use latest Volto before yarn 3 [Tiberiu Ichim - [`69f5859`](https://github.com/eea/volto-datahub/commit/69f585980fd9a38ff99d0c7875704671857720f7)]
|
|
108
121
|
- Reorder sections on landing page [kreafox - [`46fac8d`](https://github.com/eea/volto-datahub/commit/46fac8d821cf93fe1b2c380380719de130c3f1cb)]
|
|
109
122
|
- Fix project eslintrc [kreafox - [`5baa150`](https://github.com/eea/volto-datahub/commit/5baa1505ec38ed313269f5608c186c6a6a8bbfc4)]
|
|
110
123
|
- Open dataset links in new tab [kreafox - [`bbed914`](https://github.com/eea/volto-datahub/commit/bbed914dc2edf6c749d1d73d93a423bc642e680c)]
|
|
111
|
-
- Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`380a2a9`](https://github.com/eea/volto-datahub/commit/380a2a9625c6f799df7a7c343fad3f3b3d959f96)]
|
|
112
124
|
## [1.0.0](https://github.com/eea/volto-datahub/compare/0.1.12...1.0.0) - 28 October 2022
|
|
113
125
|
|
|
114
126
|
#### :nail_care: Enhancements
|
|
@@ -133,7 +145,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
133
145
|
#### :hammer_and_wrench: Others
|
|
134
146
|
|
|
135
147
|
- fixed query for related items [Zoltan Szabo - [`b66faee`](https://github.com/eea/volto-datahub/commit/b66faee1f8a1922cd22b3a36eccc9c7b92e377d4)]
|
|
136
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`158fe1a`](https://github.com/eea/volto-datahub/commit/158fe1a0b1767452e2e51a3e2ef97169589a50e8)]
|
|
137
148
|
### [0.1.10](https://github.com/eea/volto-datahub/compare/0.1.9...0.1.10) - 21 September 2022
|
|
138
149
|
|
|
139
150
|
#### :hammer_and_wrench: Others
|
|
@@ -222,7 +233,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
222
233
|
#### :hammer_and_wrench: Others
|
|
223
234
|
|
|
224
235
|
- Hide questions & fix landing page [kreafox - [`a1ef303`](https://github.com/eea/volto-datahub/commit/a1ef3033df0e84f3a72dd0f984c8717dff2a771c)]
|
|
225
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`910688e`](https://github.com/eea/volto-datahub/commit/910688e3ddf2f8cda4f941595ae9a6ee0ec0ea3b)]
|
|
226
236
|
### [0.1.1](https://github.com/eea/volto-datahub/compare/0.1.0...0.1.1) - 10 June 2022
|
|
227
237
|
|
|
228
238
|
### [0.1.0](https://github.com/eea/volto-datahub/compare/0.0.1...0.1.0) - 9 June 2022
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
+
import { Label } from 'semantic-ui-react';
|
|
3
4
|
import { DateTime, StringList } from '@eeacms/search';
|
|
4
5
|
import { ResultContext } from '@eeacms/search';
|
|
5
6
|
import { Link } from 'react-router-dom';
|
|
@@ -16,9 +17,15 @@ const DatahubCardItem = (props) => {
|
|
|
16
17
|
|
|
17
18
|
const item = {
|
|
18
19
|
title: (
|
|
19
|
-
|
|
20
|
-
{result.title}
|
|
21
|
-
|
|
20
|
+
<>
|
|
21
|
+
<Link to={result.href} title={result.title}>
|
|
22
|
+
{result.title}
|
|
23
|
+
{result.isNew && <Label className="new-item">New</Label>}
|
|
24
|
+
{result.isExpired && (
|
|
25
|
+
<Label className="archived-item">Archived</Label>
|
|
26
|
+
)}
|
|
27
|
+
</Link>
|
|
28
|
+
</>
|
|
22
29
|
),
|
|
23
30
|
description: <ResultContext {...props} />,
|
|
24
31
|
preview_image_url: result.hasImage ? result.thumbUrl : undefined,
|
package/src/config/facets.js
CHANGED
|
@@ -3,10 +3,67 @@ import {
|
|
|
3
3
|
fixedRangeFacet,
|
|
4
4
|
histogramFacet,
|
|
5
5
|
makeRange,
|
|
6
|
+
booleanFacet,
|
|
6
7
|
} from '@eeacms/search';
|
|
7
8
|
import { dateRangeFacet } from '@eeacms/search';
|
|
8
9
|
|
|
10
|
+
export function getTodayWithTime() {
|
|
11
|
+
const d = new Date();
|
|
12
|
+
const month = d.getMonth() + 1;
|
|
13
|
+
const day = d.getDate();
|
|
14
|
+
const hour = d.getHours();
|
|
15
|
+
const minute = d.getMinutes();
|
|
16
|
+
const second = d.getSeconds();
|
|
17
|
+
|
|
18
|
+
const output = [
|
|
19
|
+
d.getFullYear(),
|
|
20
|
+
'-',
|
|
21
|
+
month < 10 ? '0' : '',
|
|
22
|
+
month,
|
|
23
|
+
'-',
|
|
24
|
+
day < 10 ? '0' : '',
|
|
25
|
+
day,
|
|
26
|
+
'T',
|
|
27
|
+
hour < 10 ? '0' : '',
|
|
28
|
+
hour,
|
|
29
|
+
':',
|
|
30
|
+
minute < 10 ? '0' : '',
|
|
31
|
+
minute,
|
|
32
|
+
':',
|
|
33
|
+
second < 10 ? '0' : '',
|
|
34
|
+
second,
|
|
35
|
+
'Z',
|
|
36
|
+
].join('');
|
|
37
|
+
return output;
|
|
38
|
+
}
|
|
39
|
+
|
|
9
40
|
const facets = [
|
|
41
|
+
booleanFacet(() => ({
|
|
42
|
+
field: 'IncludeArchived',
|
|
43
|
+
label: 'Include archived content',
|
|
44
|
+
id: 'archived-facet',
|
|
45
|
+
showInFacetsList: false,
|
|
46
|
+
showInSecondaryFacetsList: true,
|
|
47
|
+
isFilter: true, // filters don't need facet options to show up
|
|
48
|
+
|
|
49
|
+
// we want this to be applied by default
|
|
50
|
+
// when the facet is checked, then apply the `on` key:
|
|
51
|
+
off: {
|
|
52
|
+
constant_score: {
|
|
53
|
+
filter: {
|
|
54
|
+
bool: {
|
|
55
|
+
should: [
|
|
56
|
+
{ bool: { must_not: { exists: { field: 'expires' } } } },
|
|
57
|
+
// Functions should be supported in the buildFilters
|
|
58
|
+
{ range: { expires: { gte: getTodayWithTime() } } },
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
on: null,
|
|
65
|
+
})),
|
|
66
|
+
|
|
10
67
|
multiTermFacet({
|
|
11
68
|
field: 'instrument',
|
|
12
69
|
isFilterable: true,
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { registry } from '@eeacms/search';
|
|
2
|
+
import express from 'express';
|
|
3
|
+
import buildRequest from '@eeacms/search/lib/search/query';
|
|
4
|
+
import superagent from 'superagent';
|
|
5
|
+
// import zlib from 'zlib';
|
|
6
|
+
|
|
7
|
+
const getUrlES = (appName) => {
|
|
8
|
+
return (
|
|
9
|
+
process.env[`RAZZLE_PROXY_ES_DSN_${appName}`] ||
|
|
10
|
+
process.env.RAZZLE_PROXY_ES_DSN ||
|
|
11
|
+
'http://localhost:9200/_all'
|
|
12
|
+
);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
function handleSearchRequest(body, params) {
|
|
16
|
+
const { urlES } = params;
|
|
17
|
+
const url = `${urlES}/_search`;
|
|
18
|
+
if (body?.params?.config) {
|
|
19
|
+
delete body.params.config;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
superagent
|
|
24
|
+
.post(url)
|
|
25
|
+
.send(body)
|
|
26
|
+
.set('accept', 'application/json')
|
|
27
|
+
.end((err, resp) => {
|
|
28
|
+
if (resp && resp.body) {
|
|
29
|
+
return resolve(resp.body);
|
|
30
|
+
}
|
|
31
|
+
return reject({ error: 'Error' });
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function toPublicURL(id) {
|
|
37
|
+
return `https://www.eea.europa.eu/en/datahub/datahubitem-view/${id}`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function generateSitemap(appConfig) {
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
42
|
+
const body = buildRequest({ filters: [] }, appConfig);
|
|
43
|
+
delete body['source'];
|
|
44
|
+
delete body['params'];
|
|
45
|
+
delete body['runtime_mappings'];
|
|
46
|
+
delete body['index'];
|
|
47
|
+
body._source = { include: ['about', 'last_modified'] };
|
|
48
|
+
body.size = 10000;
|
|
49
|
+
const urlES = getUrlES('datahub');
|
|
50
|
+
handleSearchRequest(body, { urlES }).then((body) => {
|
|
51
|
+
const items = body?.hits?.hits || [];
|
|
52
|
+
|
|
53
|
+
const urls = items.map(
|
|
54
|
+
(item) => ` <url>\n <loc>${toPublicURL(item._id)}</loc>\n
|
|
55
|
+
<lastmod>${item._source.last_modified}</lastmod>\n </url>`,
|
|
56
|
+
);
|
|
57
|
+
const result = `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">\n${urls.join(
|
|
58
|
+
'\n',
|
|
59
|
+
)}\n</urlset>`;
|
|
60
|
+
|
|
61
|
+
// zlib.gzip(Buffer.from(result, 'utf8'), (_err, buffer) => {
|
|
62
|
+
// resolve(buffer);
|
|
63
|
+
// });
|
|
64
|
+
|
|
65
|
+
resolve(result);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function sitemap(req, res, next) {
|
|
71
|
+
const appConfig = registry.searchui['datahub'];
|
|
72
|
+
|
|
73
|
+
generateSitemap(appConfig)
|
|
74
|
+
.then((body) => res.send(body))
|
|
75
|
+
.catch((body) => {
|
|
76
|
+
res.send({ error: body });
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export default function makeMiddlewares(config) {
|
|
81
|
+
const middleware = express.Router();
|
|
82
|
+
// middleware.use(express.json({ limit: config.settings.maxResponseSize }));
|
|
83
|
+
middleware.use(express.urlencoded({ extended: true }));
|
|
84
|
+
|
|
85
|
+
middleware.all('**/datahub/sitemap-data.xml', sitemap);
|
|
86
|
+
middleware.id = 'datahub-sitemap';
|
|
87
|
+
|
|
88
|
+
return middleware;
|
|
89
|
+
}
|
package/src/index.js
CHANGED
|
@@ -45,6 +45,16 @@ const applyConfig = (config) => {
|
|
|
45
45
|
...(config.addonRoutes || []),
|
|
46
46
|
];
|
|
47
47
|
config.addonReducers.datahub_results = datahub_results;
|
|
48
|
+
|
|
49
|
+
if (__SERVER__) {
|
|
50
|
+
const makeMiddlewares = require('./express-middleware').default;
|
|
51
|
+
|
|
52
|
+
config.settings.expressMiddleware = [
|
|
53
|
+
...config.settings.expressMiddleware,
|
|
54
|
+
makeMiddlewares(config),
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
|
|
48
58
|
return config;
|
|
49
59
|
};
|
|
50
60
|
|