@eeacms/volto-globalsearch 0.1.0

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.
Files changed (60) hide show
  1. package/.coverage.babel.config.js +9 -0
  2. package/.eslintignore +1 -0
  3. package/.project.eslintrc.js +46 -0
  4. package/.release-it.json +17 -0
  5. package/CHANGELOG.md +26 -0
  6. package/DEVELOP.md +52 -0
  7. package/LICENSE.md +9 -0
  8. package/README.md +106 -0
  9. package/RELEASE.md +74 -0
  10. package/babel.config.js +17 -0
  11. package/bootstrap +41 -0
  12. package/cypress.json +17 -0
  13. package/jest-addon.config.js +36 -0
  14. package/locales/volto.pot +0 -0
  15. package/package.json +47 -0
  16. package/src/components/LogoImage.jsx +16 -0
  17. package/src/components/MasonryLandingPage.jsx +277 -0
  18. package/src/components/WebsiteFilterListComponent.jsx +14 -0
  19. package/src/components/img/content-types-bg.png +0 -0
  20. package/src/components/img/countries-bg.png +0 -0
  21. package/src/components/img/organisations-bg.png +0 -0
  22. package/src/components/img/search-album-slideshow-bg.png +0 -0
  23. package/src/components/img/topics-bg.png +0 -0
  24. package/src/config/clusters.js +172 -0
  25. package/src/config/download.js +20 -0
  26. package/src/config/facets.js +298 -0
  27. package/src/config/filters.js +15 -0
  28. package/src/config/global-search-config.js +118 -0
  29. package/src/config/index.js +92 -0
  30. package/src/config/json/contentTypeNormalize.json +56 -0
  31. package/src/config/json/objectProvidesWhitelist.json +56 -0
  32. package/src/config/json/placesBlacklist.json +268 -0
  33. package/src/config/json/spatialWhitelist.json +264 -0
  34. package/src/config/json/topicsBlacklist.json +1 -0
  35. package/src/config/json/typesWhitelist.json +49 -0
  36. package/src/config/query.js +44 -0
  37. package/src/config/views.js +157 -0
  38. package/src/config/vocabulary.js +59 -0
  39. package/src/index.js +13 -0
  40. package/src/static/bise-logo.png +0 -0
  41. package/src/static/climate-adapt-logo.png +0 -0
  42. package/src/static/eea-logo.png +0 -0
  43. package/src/static/eionet-logo.png +0 -0
  44. package/src/static/energy-logo.png +0 -0
  45. package/src/static/etc-atni.png +0 -0
  46. package/src/static/etc-bd.jpg +0 -0
  47. package/src/static/etc-cca.jpeg +0 -0
  48. package/src/static/etc-cme.png +0 -0
  49. package/src/static/etc-icm.jpg +0 -0
  50. package/src/static/etc-uls.png +0 -0
  51. package/src/static/etc-wmge.png +0 -0
  52. package/src/static/forest-logo.png +0 -0
  53. package/src/static/ias-logo.png +0 -0
  54. package/src/static/industry-logo.png +0 -0
  55. package/src/static/water-logo.png +0 -0
  56. package/src/static/website-logo.png +0 -0
  57. package/src/static/wise-logo.png +0 -0
  58. package/src/styles/masonry-landing-page.less +145 -0
  59. package/src/styles/tiles-landing-page.less +0 -0
  60. package/src/utils.js +250 -0
@@ -0,0 +1,157 @@
1
+ import { clusterIcons } from './clusters';
2
+
3
+ export default {
4
+ resultViews: [
5
+ {
6
+ id: 'horizontalCard',
7
+ title: 'Horizontal cards',
8
+ icon: 'bars',
9
+ render: null,
10
+ isDefault: true,
11
+ factories: {
12
+ view: 'HorizontalCard.Group',
13
+ item: 'HorizontalCardItem',
14
+ },
15
+ },
16
+ {
17
+ id: 'card',
18
+ title: 'Cards',
19
+ icon: 'th',
20
+ render: null,
21
+ isDefault: false,
22
+ factories: {
23
+ view: 'Card.Group',
24
+ item: 'CardItem',
25
+ },
26
+ },
27
+ ],
28
+ cardViewParams: {
29
+ urlField: 'about',
30
+ titleField: 'title',
31
+ metatypeField: 'objectProvides',
32
+ descriptionField: 'description',
33
+ tagsField: 'topic',
34
+ issuedField: 'issued',
35
+ enabled: true,
36
+ getThumbnailUrl: 'getGlobalsearchThumbUrl',
37
+ getIconUrl: 'getGlobalsearchIconUrl',
38
+ clusterIcons,
39
+ },
40
+
41
+ horizontalCardViewParams: {
42
+ urlField: 'about',
43
+ titleField: 'title',
44
+ metatypeField: 'objectProvides',
45
+ descriptionField: 'description',
46
+ tagsField: 'topic',
47
+ issuedField: 'issued',
48
+ enabled: true,
49
+ getThumbnailUrl: 'getGlobalsearchThumbUrl',
50
+ getIconUrl: 'getGlobalsearchIconUrl',
51
+ clusterIcons,
52
+ },
53
+
54
+ initialView: {
55
+ factory: 'TilesLandingPage',
56
+ tilesLandingPageParams: {
57
+ maxPerSection: 30,
58
+ // clusterIcons,
59
+ sortField: 'issued.date',
60
+ sortDirection: 'desc',
61
+ sections: [
62
+ {
63
+ id: 'topics',
64
+ title: 'Topics',
65
+ facetField: 'topic',
66
+ sortOn: 'alpha',
67
+ },
68
+ {
69
+ id: 'countries',
70
+ title: 'Countries',
71
+ facetField: 'spatial',
72
+ filterType: 'any:exact',
73
+ sortOn: 'alpha',
74
+ icon: {
75
+ family: 'CountryFlags',
76
+ className: 'facet-option-icon',
77
+ },
78
+ },
79
+ {
80
+ id: 'types',
81
+ title: 'Types',
82
+ facetField: 'objectProvides',
83
+ sortOn: 'alpha',
84
+ icon: {
85
+ family: 'Content types',
86
+ },
87
+ },
88
+ {
89
+ id: 'language',
90
+ title: 'Languages',
91
+ facetField: 'language',
92
+ sortOn: 'custom',
93
+ sortOrder: 'asc',
94
+ },
95
+ {
96
+ id: 'website',
97
+ title: 'Sources',
98
+ facetField: 'cluster_name',
99
+ sortOn: 'count',
100
+ sortOrder: 'desc',
101
+ icon: {
102
+ family: 'Sources',
103
+ className: 'facet-option-icon',
104
+ },
105
+ },
106
+ ],
107
+ },
108
+ },
109
+
110
+ listingViewParams: {
111
+ enabled: false,
112
+ },
113
+
114
+ tableViewParams: {
115
+ titleField: 'title',
116
+ urlField: 'about',
117
+ enabled: false,
118
+ columns: [
119
+ {
120
+ title: 'Title',
121
+ field: 'title',
122
+ },
123
+ {
124
+ title: 'Description',
125
+ field: 'description',
126
+ },
127
+ {
128
+ title: 'Countries',
129
+ field: 'spatial',
130
+ },
131
+ {
132
+ title: 'Regions / Places / Cities / Seas...',
133
+ field: 'places',
134
+ },
135
+ {
136
+ title: 'Content types',
137
+ field: 'objectProvides',
138
+ },
139
+ {
140
+ title: 'Topics',
141
+ field: 'topic',
142
+ },
143
+ {
144
+ title: 'Issued',
145
+ field: 'issued',
146
+ },
147
+ {
148
+ title: 'Time coverage',
149
+ field: 'time_coverage',
150
+ },
151
+ {
152
+ title: 'Format',
153
+ field: 'format',
154
+ },
155
+ ],
156
+ },
157
+ };
@@ -0,0 +1,59 @@
1
+ const vocab = {
2
+ language: {
3
+ ar: 'العربية (ar)',
4
+ bg: 'Български (bg)',
5
+ bs: 'bosanski (bs)',
6
+ cs: 'čeština (cs)',
7
+ da: 'dansk (da)',
8
+ de: 'Deutsch (de)',
9
+ el: 'ελληνικά (el)',
10
+ en: 'English (en)',
11
+ es: 'Español (es)',
12
+ et: 'eesti (et)',
13
+ fi: 'Suomi (fi)',
14
+ fr: 'Français (fr)',
15
+ ga: 'Gaeilge (ga)',
16
+ hr: 'Hrvatski (hr)',
17
+ hu: 'magyar (hu)',
18
+ is: 'Íslenska (is)',
19
+ it: 'italiano (it)',
20
+ lt: 'lietuvių (lt)',
21
+ lv: 'Latviešu (lv)',
22
+ mk: 'македонски (mk)',
23
+ mt: 'Malti (mt)',
24
+ nl: 'Nederlands (nl)',
25
+ no: 'Norsk (no)',
26
+ pl: 'polski (pl)',
27
+ pt: 'Português (pt)',
28
+ ro: 'Română (ro)',
29
+ ru: 'русский (ru)',
30
+ sk: 'slovenčina (sk)',
31
+ sl: 'Slovenščina (sl)',
32
+ sq: 'Shqip (sq)',
33
+ sr: 'Српски (sr)',
34
+ sv: 'Svenska (sv)',
35
+ tr: 'Türkçe (tr)',
36
+ },
37
+ cluster_name: {
38
+ eea: 'European Environment Agency',
39
+ fise: 'Forest Information System for Europe',
40
+ bise: 'Biodiversity Information System for Europe',
41
+ industry: 'European Industrial Emissions Portal',
42
+ energy: 'Climate and Energy in the EU',
43
+ cca: 'Climate Adaptation Platform',
44
+ ias: 'Invasive Alien Species',
45
+ 'wise-freshwater': 'Freshwater Information System for Europe',
46
+ 'wise-marine': 'Marine Water Information System for Europe',
47
+ etc: 'European Environment Information and Observation Network (Eionet)',
48
+ 'etc-atni':
49
+ 'ETC on Air Pollution, Transport, Noise and Industrial Pollution',
50
+ 'etc-bd': 'ETC on Biological Diversity',
51
+ 'etc-cca': 'ETC on Climate Change Impacts, Vulnerability and Adaptation',
52
+ 'etc-cme': 'ETC on Climate Change Mitigation and Energy',
53
+ 'etc-icm': 'ETC on Inland, Coastal and Marine Waters',
54
+ 'etc-uls': 'ETC on Urban, Land and Soil Systems',
55
+ 'etc-wmge': 'ETC on Waste and Materials in Green Economy',
56
+ },
57
+ };
58
+
59
+ export default { vocab };
package/src/index.js ADDED
@@ -0,0 +1,13 @@
1
+ import installGlobalsearch from './config';
2
+
3
+ export default (config) => {
4
+ config.settings.searchlib = installGlobalsearch(config.settings.searchlib);
5
+
6
+ const { globalsearch } = config.settings.searchlib.searchui;
7
+
8
+ // Tweak the searchlib config to use the middleware instead of the index
9
+ globalsearch.elastic_index = '_es/globalsearch';
10
+ globalsearch.index_name = 'data_searchui';
11
+
12
+ return config;
13
+ };
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,145 @@
1
+ .ui.container.stackable.two.column.grid.body-content {
2
+ width: 100% !important;
3
+ margin: 0 !important;
4
+ }
5
+
6
+ .ui.container.one.column.grid {
7
+ width: 100% !important;
8
+ margin: 0 !important;
9
+ }
10
+
11
+ .ui.container.grid.body-footer {
12
+ width: 100% !important;
13
+ margin: 0 !important;
14
+ }
15
+
16
+ .tile {
17
+ padding: 18px;
18
+ margin: 0 12px 12px 0;
19
+ @media only screen and (min-width: 1536px) {
20
+ width: 23%;
21
+ }
22
+ @media only screen and (min-width: 900px) and (max-width: 1535px) {
23
+ width: 31%;
24
+ }
25
+ @media only screen and (min-width: 620px) and (max-width: 900px) {
26
+ width: 47%;
27
+ }
28
+ @media only screen and (max-width: 620px) {
29
+ width: 95%;
30
+ }
31
+
32
+ h2 {
33
+ border-bottom: 1px solid white;
34
+ margin: 0 0 1em 0;
35
+ margin-bottom: 0;
36
+ font-size: 200%;
37
+ font-weight: bold;
38
+ line-height: 1.3;
39
+ }
40
+
41
+ span {
42
+ font-size: 250%;
43
+ font-weight: bold;
44
+ }
45
+
46
+ &.available_content {
47
+ height: 434px;
48
+
49
+ h2 {
50
+ border-bottom: 1px solid #115c57;
51
+ color: #115c57;
52
+ font-size: 200%;
53
+ }
54
+
55
+ h3 {
56
+ color: #115c57;
57
+ }
58
+
59
+ span {
60
+ color: #1b928f;
61
+ }
62
+ }
63
+
64
+ &.countries {
65
+ height: 434px;
66
+ background: #1c65a4 url('./img/countries-bg.png') no-repeat center center;
67
+ background-position-y: 0;
68
+ color: white;
69
+
70
+ h2 {
71
+ padding-top: 180px;
72
+ }
73
+ }
74
+
75
+ &.content_types {
76
+ height: 300px;
77
+ background: #b3548d url('./img/content-types-bg.png') no-repeat 85% 55%;
78
+ color: white;
79
+ }
80
+
81
+ &.picture {
82
+ height: 434px;
83
+ background: #1b928f url('./img/search-album-slideshow-bg.png') no-repeat
84
+ center center;
85
+ color: white;
86
+ }
87
+
88
+ &.topics {
89
+ height: 300px;
90
+ background: #fbaf33 url('./img/topics-bg.png') no-repeat 85% 25%;
91
+ color: white;
92
+ }
93
+
94
+ &.time_coverage {
95
+ height: 300px;
96
+ background: #b0c649;
97
+ color: white;
98
+
99
+ p {
100
+ text-align: right;
101
+
102
+ span.label {
103
+ font-size: 150%;
104
+ font-weight: normal;
105
+ }
106
+ }
107
+ }
108
+
109
+ &.organisations {
110
+ height: 300px;
111
+ background: #babbdb url('./img/organisations-bg.png') no-repeat 85px 100px;
112
+ color: white;
113
+ }
114
+
115
+ &.latest {
116
+ height: 434px;
117
+
118
+ h2 {
119
+ border-bottom: 1px solid #1b928f;
120
+ color: #1b928f;
121
+ font-size: 250%;
122
+ }
123
+
124
+ ul {
125
+ padding-left: 0;
126
+ list-style-type: none;
127
+ }
128
+
129
+ li {
130
+ margin-bottom: 1em;
131
+
132
+ span {
133
+ font-size: 12px;
134
+ font-weight: normal;
135
+ }
136
+
137
+ a {
138
+ display: block;
139
+ color: #1b928f;
140
+ font-size: 12px;
141
+ font-weight: bold;
142
+ }
143
+ }
144
+ }
145
+ }
File without changes
package/src/utils.js ADDED
@@ -0,0 +1,250 @@
1
+ // export const get_icons = (settings) => {
2
+ // const icons = {};
3
+ // settings.clusters.forEach((cluster) => {
4
+ // icons[cluster.name] = cluster.icon;
5
+ // });
6
+ // return icons;
7
+ // };
8
+ //
9
+ export const build_runtime_mappings = (settings) => {
10
+ const clusters = settings.clusters
11
+ .map((cluster) => {
12
+ return (
13
+ '["name": "' +
14
+ cluster.name +
15
+ '", "values": ' +
16
+ JSON.stringify(cluster.values) +
17
+ ']'
18
+ );
19
+ })
20
+ .join(',');
21
+ const source =
22
+ 'emit("_all_"); def clusters_settings = [' +
23
+ clusters +
24
+ "]; def vals = doc['" +
25
+ settings.field +
26
+ "']; def clusters = ['All']; for (val in vals) { for (cs in clusters_settings) { if (cs.values.contains(val)) { emit(cs.name) } } }";
27
+
28
+ const mapping = {};
29
+ mapping[settings.name] = {
30
+ type: 'keyword',
31
+ script: { source: source },
32
+ };
33
+ return mapping;
34
+ };
35
+
36
+ export function getTodayWithTime() {
37
+ const d = new Date();
38
+ const month = d.getMonth() + 1;
39
+ const day = d.getDate();
40
+ const hour = d.getHours();
41
+ const minute = d.getMinutes();
42
+ const second = d.getSeconds();
43
+
44
+ const output = [
45
+ d.getFullYear(),
46
+ '-',
47
+ month < 10 ? '0' : '',
48
+ month,
49
+ '-',
50
+ day < 10 ? '0' : '',
51
+ day,
52
+ 'T',
53
+ hour < 10 ? '0' : '',
54
+ hour,
55
+ ':',
56
+ minute < 10 ? '0' : '',
57
+ minute,
58
+ ':',
59
+ second < 10 ? '0' : '',
60
+ second,
61
+ 'Z',
62
+ ].join('');
63
+ return output;
64
+ }
65
+ export const getGlobalsearchIconUrl = (contentTypeNormalize) => (
66
+ result,
67
+ config,
68
+ fallback,
69
+ ) => {
70
+ let image = fallback;
71
+ let has_img = false;
72
+ if (
73
+ result.about.raw.startsWith('http://www.eea.europa.eu/help/glossary/') ||
74
+ result.about.raw.startsWith('https://www.eea.europa.eu/help/glossary/')
75
+ ) {
76
+ image = 'https://www.eea.europa.eu/portal_depiction/term/image_thumb';
77
+ has_img = true;
78
+ }
79
+ if (
80
+ result.objectProvides &&
81
+ result.objectProvides.raw.indexOf('Country profile') !== -1
82
+ ) {
83
+ image =
84
+ 'https://www.eea.europa.eu/portal_depiction/country-profile/image_thumb';
85
+ has_img = true;
86
+ }
87
+ if (
88
+ result.about &&
89
+ result.about.raw.indexOf('://land.copernicus.eu') !== -1
90
+ ) {
91
+ image = 'https://www.eea.europa.eu/portal_depiction/data/image_thumb';
92
+ has_img = true;
93
+ } else {
94
+ if (!has_img) {
95
+ let contentTypes = contentTypeNormalize;
96
+ let _type;
97
+ let _typeClass;
98
+ let _contentType = 'generic';
99
+
100
+ if (!result.objectProvides) {
101
+ return image;
102
+ }
103
+
104
+ if (!Array.isArray(result.objectProvides?.raw)) {
105
+ result.objectProvides.raw = [result.objectProvides.raw];
106
+ }
107
+ if (result.objectProvides?.raw?.length > 0) {
108
+ var pos = result.objectProvides.raw.length - 1;
109
+ while (true) {
110
+ _type = result.objectProvides.raw[pos];
111
+ _typeClass = _type.toLowerCase().replace(/\s/g, '-');
112
+ if (contentTypes[_typeClass]) {
113
+ _contentType = contentTypes[_typeClass];
114
+ break;
115
+ }
116
+ pos--;
117
+ if (pos < 0) {
118
+ break;
119
+ }
120
+ }
121
+ }
122
+ image =
123
+ 'https://www.eea.europa.eu/portal_depiction/' +
124
+ _contentType +
125
+ '/image_thumb';
126
+ }
127
+ }
128
+
129
+ return image;
130
+ };
131
+
132
+ export const getGlobalsearchThumbUrl = (contentTypeNormalize) => (
133
+ result,
134
+ config,
135
+ fallback,
136
+ ) => {
137
+ let image = fallback;
138
+ let has_img = false;
139
+ if (result.site_id?.raw === 'sdi' && result['overview.url']) {
140
+ has_img = false;
141
+ /* if (!Array.isArray(result['overview.url']?.raw)) {
142
+ result['overview.url'].raw = [result['overview.url']?.raw];
143
+ }
144
+ if (result['overview.url']?.raw.length > 0) {
145
+ image = result['overview.url']?.raw[0];
146
+ }
147
+ has_img = true;*/
148
+ }
149
+ if (
150
+ result.about?.raw?.startsWith('http://www.eea.europa.eu/help/glossary/') ||
151
+ result.about?.raw?.startsWith('https://www.eea.europa.eu/help/glossary/')
152
+ ) {
153
+ image = 'https://www.eea.europa.eu/portal_depiction/term/image_preview';
154
+ has_img = true;
155
+ }
156
+ if (result.objectProvides?.raw?.indexOf('Country profile') !== -1) {
157
+ image =
158
+ 'https://www.eea.europa.eu/portal_depiction/country-profile/image_preview';
159
+ has_img = true;
160
+ }
161
+ if (result.about?.raw?.indexOf('://land.copernicus.eu') !== -1) {
162
+ image = result?.about?.raw + '/image_preview';
163
+ has_img = true;
164
+ }
165
+ if (
166
+ result.about?.raw?.indexOf('://biodiversity.europa.eu') !== -1 ||
167
+ result.about?.raw?.indexOf('://forest.eea.europa.eu') !== -1 ||
168
+ result.about?.raw?.indexOf('://climate-energy.eea.europa.eu') !== -1 ||
169
+ result.about?.raw?.indexOf('://industry.eea.europa.eu') !== -1
170
+ ) {
171
+ if (result.image_preview) {
172
+ image = result.image_preview.raw;
173
+ has_img = true;
174
+ }
175
+ }
176
+ if (
177
+ result.about?.raw?.startsWith('http://www.eea.europa.eu') ||
178
+ result.about?.raw?.startsWith('https://www.eea.europa.eu')
179
+ ) {
180
+ image = result.about.raw + '/image_preview';
181
+ has_img = true;
182
+ } else {
183
+ if (!has_img) {
184
+ let contentTypes = contentTypeNormalize;
185
+ let _type;
186
+ let _typeClass;
187
+ let _contentType = 'generic';
188
+ if (!Array.isArray(result.objectProvides?.raw)) {
189
+ result.objectProvides.raw = [result.objectProvides.raw];
190
+ }
191
+ if (result.objectProvides.raw.length > 0) {
192
+ var pos = result.objectProvides.raw.length - 1;
193
+ while (true) {
194
+ _type = result.objectProvides.raw[pos];
195
+ _typeClass = _type.toLowerCase().replace(/\s/g, '-');
196
+ if (contentTypes[_typeClass]) {
197
+ _contentType = contentTypes[_typeClass];
198
+ break;
199
+ }
200
+ pos--;
201
+ if (pos < 0) {
202
+ break;
203
+ }
204
+ }
205
+ }
206
+ image =
207
+ 'https://www.eea.europa.eu/portal_depiction/' +
208
+ _contentType +
209
+ '/image_preview';
210
+ }
211
+ }
212
+
213
+ return image;
214
+ };
215
+
216
+ export const get_cluster_icons = (settings) => {
217
+ const icons = {
218
+ fallback: {
219
+ name: 'file outline',
220
+ },
221
+ };
222
+ settings.clusters.forEach((cluster) => {
223
+ cluster.values.forEach((value) => {
224
+ icons[value] = {
225
+ cluster: cluster.name,
226
+ icon: cluster.icon,
227
+ };
228
+ });
229
+ });
230
+ return icons;
231
+ };
232
+
233
+ /**
234
+ * Returns a mapping of clusterName: {...icon...}. See registry/icons for more
235
+ * info
236
+ */
237
+ export const get_cluster_icons_dict = (settings) => {
238
+ return Object.assign(
239
+ {
240
+ fallback: { name: 'file outline' },
241
+ },
242
+ ...settings.clusters.map((cluster) =>
243
+ Object.assign(
244
+ {},
245
+ ...cluster.values.map((value) => ({ [value]: cluster.icon })),
246
+ { [cluster.name]: cluster.icon },
247
+ ),
248
+ ),
249
+ );
250
+ };