@eeacms/volto-datahub 1.0.17 → 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 +8 -5
- package/package.json +1 -1
- package/src/express-middleware.js +89 -0
- package/src/index.js +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,14 @@ 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)]
|
|
7
15
|
### [1.0.17](https://github.com/eea/volto-datahub/compare/1.0.16...1.0.17) - 10 March 2023
|
|
8
16
|
|
|
9
17
|
#### :hammer_and_wrench: Others
|
|
@@ -18,7 +26,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
18
26
|
- added utils.js [Zoltan Szabo - [`fdb33c3`](https://github.com/eea/volto-datahub/commit/fdb33c37e1af2fe071dbe8f4f5dcd2b82932edc8)]
|
|
19
27
|
- Show 'Obsolete' info in the metadata section in the banner [Zoltan Szabo - [`fddfd2a`](https://github.com/eea/volto-datahub/commit/fddfd2aea63d1a1d1567c163ab29dd7119781117)]
|
|
20
28
|
- Show 'More information' section only if it's not empty [Zoltan Szabo - [`612f035`](https://github.com/eea/volto-datahub/commit/612f03509c6adf143631ae6dee5ca2bd48a501c3)]
|
|
21
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`b9100f6`](https://github.com/eea/volto-datahub/commit/b9100f6b2b2e9e9a26b9c11708c8fda94137cecc)]
|
|
22
29
|
### [1.0.15](https://github.com/eea/volto-datahub/compare/1.0.14...1.0.15) - 1 March 2023
|
|
23
30
|
|
|
24
31
|
### [1.0.14](https://github.com/eea/volto-datahub/compare/1.0.13...1.0.14) - 1 March 2023
|
|
@@ -111,11 +118,9 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
111
118
|
#### :hammer_and_wrench: Others
|
|
112
119
|
|
|
113
120
|
- Fix eslintrc: add @eeacms/search [kreafox - [`465816f`](https://github.com/eea/volto-datahub/commit/465816feb8f58095ab4b5b3168cd29ebede3a10c)]
|
|
114
|
-
- Use latest Volto before yarn 3 [Tiberiu Ichim - [`69f5859`](https://github.com/eea/volto-datahub/commit/69f585980fd9a38ff99d0c7875704671857720f7)]
|
|
115
121
|
- Reorder sections on landing page [kreafox - [`46fac8d`](https://github.com/eea/volto-datahub/commit/46fac8d821cf93fe1b2c380380719de130c3f1cb)]
|
|
116
122
|
- Fix project eslintrc [kreafox - [`5baa150`](https://github.com/eea/volto-datahub/commit/5baa1505ec38ed313269f5608c186c6a6a8bbfc4)]
|
|
117
123
|
- Open dataset links in new tab [kreafox - [`bbed914`](https://github.com/eea/volto-datahub/commit/bbed914dc2edf6c749d1d73d93a423bc642e680c)]
|
|
118
|
-
- Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`380a2a9`](https://github.com/eea/volto-datahub/commit/380a2a9625c6f799df7a7c343fad3f3b3d959f96)]
|
|
119
124
|
## [1.0.0](https://github.com/eea/volto-datahub/compare/0.1.12...1.0.0) - 28 October 2022
|
|
120
125
|
|
|
121
126
|
#### :nail_care: Enhancements
|
|
@@ -140,7 +145,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
140
145
|
#### :hammer_and_wrench: Others
|
|
141
146
|
|
|
142
147
|
- fixed query for related items [Zoltan Szabo - [`b66faee`](https://github.com/eea/volto-datahub/commit/b66faee1f8a1922cd22b3a36eccc9c7b92e377d4)]
|
|
143
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`158fe1a`](https://github.com/eea/volto-datahub/commit/158fe1a0b1767452e2e51a3e2ef97169589a50e8)]
|
|
144
148
|
### [0.1.10](https://github.com/eea/volto-datahub/compare/0.1.9...0.1.10) - 21 September 2022
|
|
145
149
|
|
|
146
150
|
#### :hammer_and_wrench: Others
|
|
@@ -229,7 +233,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
229
233
|
#### :hammer_and_wrench: Others
|
|
230
234
|
|
|
231
235
|
- Hide questions & fix landing page [kreafox - [`a1ef303`](https://github.com/eea/volto-datahub/commit/a1ef3033df0e84f3a72dd0f984c8717dff2a771c)]
|
|
232
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`910688e`](https://github.com/eea/volto-datahub/commit/910688e3ddf2f8cda4f941595ae9a6ee0ec0ea3b)]
|
|
233
236
|
### [0.1.1](https://github.com/eea/volto-datahub/compare/0.1.0...0.1.1) - 10 June 2022
|
|
234
237
|
|
|
235
238
|
### [0.1.0](https://github.com/eea/volto-datahub/compare/0.0.1...0.1.0) - 9 June 2022
|
package/package.json
CHANGED
|
@@ -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
|
|