@eeacms/volto-globalsearch 1.0.22 → 2.0.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.
package/.eslintrc.js ADDED
@@ -0,0 +1,65 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const projectRootPath = fs.realpathSync(__dirname + '/../../../');
4
+
5
+ let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto');
6
+ let configFile;
7
+ if (fs.existsSync(`${projectRootPath}/tsconfig.json`))
8
+ configFile = `${projectRootPath}/tsconfig.json`;
9
+ else if (fs.existsSync(`${projectRootPath}/jsconfig.json`))
10
+ configFile = `${projectRootPath}/jsconfig.json`;
11
+
12
+ if (configFile) {
13
+ const jsConfig = require(configFile).compilerOptions;
14
+ const pathsConfig = jsConfig.paths;
15
+ if (pathsConfig['@plone/volto'])
16
+ voltoPath = `./${jsConfig.baseUrl}/${pathsConfig['@plone/volto'][0]}`;
17
+ }
18
+
19
+ const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`);
20
+ const reg = new AddonConfigurationRegistry(projectRootPath);
21
+
22
+ // Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
23
+ const addonAliases = Object.keys(reg.packages).map((o) => [
24
+ o,
25
+ reg.packages[o].modulePath,
26
+ ]);
27
+
28
+ const addonExtenders = reg.getEslintExtenders().map((m) => require(m));
29
+
30
+ const defaultConfig = {
31
+ extends: `${voltoPath}/.eslintrc`,
32
+ settings: {
33
+ 'import/resolver': {
34
+ alias: {
35
+ map: [
36
+ ['@plone/volto', '@plone/volto/src'],
37
+ ['@plone/volto-slate', '@plone/volto/packages/volto-slate/src'],
38
+ ...addonAliases,
39
+ ['@package', `${__dirname}/src`],
40
+ ['@root', `${__dirname}/src`],
41
+ ['~', `${__dirname}/src`],
42
+ ],
43
+ extensions: ['.js', '.jsx', '.json'],
44
+ },
45
+ 'babel-plugin-root-import': {
46
+ rootPathSuffix: 'src',
47
+ },
48
+ },
49
+ },
50
+ rules: {
51
+ 'react/jsx-no-target-blank': [
52
+ 'error',
53
+ {
54
+ allowReferrer: true,
55
+ },
56
+ ],
57
+ }
58
+ };
59
+
60
+ const config = addonExtenders.reduce(
61
+ (acc, extender) => extender.modify(acc),
62
+ defaultConfig,
63
+ );
64
+
65
+ module.exports = config;
package/CHANGELOG.md CHANGED
@@ -4,6 +4,24 @@ 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
+ ### [2.0.0](https://github.com/eea/volto-globalsearch/compare/1.1.0...2.0.0) - 22 April 2024
8
+
9
+ #### :rocket: New Features
10
+
11
+ - feat: Release 2.0.0 - Volto 17 support [alin - [`3b0dfda`](https://github.com/eea/volto-globalsearch/commit/3b0dfda9e0801c52509f81c285f2e531ef0787d1)]
12
+ - feat: Volto 17 support - refs #264527 [EEA Jenkins - [`ebfe19f`](https://github.com/eea/volto-globalsearch/commit/ebfe19fb45f303647810c850891165182d5e64be)]
13
+
14
+ #### :hammer_and_wrench: Others
15
+
16
+ ### [1.1.0](https://github.com/eea/volto-globalsearch/compare/1.0.22...1.1.0) - 16 January 2024
17
+
18
+ #### :hammer_and_wrench: Others
19
+
20
+ - Release 1.1.0 [Alin Voinea - [`822ac10`](https://github.com/eea/volto-globalsearch/commit/822ac1049228c132637fd019f233ae7bc63ff9a8)]
21
+ - updated facets [Zoltan Szabo - [`7206aed`](https://github.com/eea/volto-globalsearch/commit/7206aed30bf3a178c4660a4a280821bee5e4a19b)]
22
+ - added facet for publisher [Zoltan Szabo - [`68dc66a`](https://github.com/eea/volto-globalsearch/commit/68dc66a612286a7767bbed289e1743aac23adc4e)]
23
+ - updated default facets config [Zoltan Szabo - [`adbd434`](https://github.com/eea/volto-globalsearch/commit/adbd434c6baedaf98cd3145e75e368c92101758d)]
24
+ - added new facets [Zoltan Szabo - [`acc6ba8`](https://github.com/eea/volto-globalsearch/commit/acc6ba8e4ee8c911343ac129f4ae3fcc99355ff7)]
7
25
  ### [1.0.22](https://github.com/eea/volto-globalsearch/compare/1.0.21...1.0.22) - 12 December 2023
8
26
 
9
27
  #### :house: Internal changes
package/README.md CHANGED
@@ -76,6 +76,43 @@ Go to http://localhost:3000
76
76
 
77
77
  1. Happy editing!
78
78
 
79
+ # Customizing the volto-searchblock
80
+
81
+ ## Modifying Clusters
82
+
83
+ To customize the behavior of the `volto-searchblock` in your volto theme addon, you can modify clusters by following these steps:
84
+
85
+ 1. Find or create `index.js` in the `src/config`
86
+
87
+ In your theme addon, create the `src/config/index.js` file. You can refer to the [example file](https://github.com/eea/volto-marine-theme/blob/eea-design/src/config/index.js) in the `volto-marine-theme` repository.
88
+
89
+ 2. Locate and Modify Clusters
90
+
91
+ Clusters are found in `config.searchui.<name_of_search>.runtime_mappings`. For example, in the case of the `volto-marine-theme`, the `<name_of_search>` was `marinemeasure`, and clusters are located in `config.searchui.marinemeasure.runtime_mappings`.
92
+
93
+ 3. Use `build_runtime_mappings`
94
+
95
+ You have to pass the clusters transformed by build_runtime_mappings function. Import the `build_runtime_mappings` as follows:
96
+
97
+ ```javascript
98
+ import { build_runtime_mappings } from '@eeacms/volto-globalsearch/utils';
99
+ ```
100
+ 5. Default Clusters
101
+
102
+ Default clusters are defined [here](https://github.com/eea/volto-globalsearch/blob/master/src/config/clusters.js). Decide whether you want to override all clusters or modify specific ones.
103
+ If you decided to modify them, you can import them in your addon as follows:
104
+ ```javascript
105
+ import { clusters } from '@eeacms/volto-globalsearch/config/clusters';
106
+ ```
107
+
108
+ 6. Example Modification
109
+
110
+ Here's an example of how the Publications cluster was modified in the CountryFactsheet by keeping the rest as default: https://github.com/eea/volto-marine-theme/pull/43/files.
111
+
112
+ 7. Cluster Structure
113
+
114
+ Be aware that a cluster contains the `values` key that holds the `content types` on which the cluster will act.
115
+
79
116
  ## Release
80
117
 
81
118
  See [RELEASE.md](https://github.com/eea/volto-globalsearch/blob/master/RELEASE.md).
@@ -1,3 +1,5 @@
1
+ require('dotenv').config({ path: __dirname + '/.env' });
2
+
1
3
  module.exports = {
2
4
  testMatch: ['**/src/addons/**/?(*.)+(spec|test).[jt]s?(x)'],
3
5
  collectCoverageFrom: [
@@ -9,20 +11,27 @@ module.exports = {
9
11
  '@plone/volto/cypress': '<rootDir>/node_modules/@plone/volto/cypress',
10
12
  '@plone/volto/babel': '<rootDir>/node_modules/@plone/volto/babel',
11
13
  '@plone/volto/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
12
- '@package/(.*)$': '<rootDir>/src/$1',
13
- '@root/(.*)$': '<rootDir>/src/$1',
14
+ '@package/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
15
+ '@root/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
14
16
  '@plone/volto-quanta/(.*)$': '<rootDir>/src/addons/volto-quanta/src/$1',
17
+ '@eeacms/search/(.*)$':
18
+ '<rootDir>/node_modules/@eeacms/volto-searchlib/src/$1',
15
19
  '@eeacms/search': '<rootDir>/node_modules/@eeacms/volto-searchlib/src',
16
20
  '@eeacms/(.*?)/(.*)$': '<rootDir>/node_modules/@eeacms/$1/src/$2',
17
- '@plone/volto-slate':
21
+ '@plone/volto-slate$':
18
22
  '<rootDir>/node_modules/@plone/volto/packages/volto-slate/src',
23
+ '@plone/volto-slate/(.*)$':
24
+ '<rootDir>/node_modules/@plone/volto/packages/volto-slate/src/$1',
19
25
  '~/(.*)$': '<rootDir>/src/$1',
20
26
  'load-volto-addons':
21
27
  '<rootDir>/node_modules/@plone/volto/jest-addons-loader.js',
22
28
  },
23
- transformIgnorePatterns: ['node_modules/(?!@eeacms)/volto-listing-block'],
29
+ transformIgnorePatterns: [
30
+ '/node_modules/(?!(@plone|@root|@package|@eeacms)/).*/',
31
+ ],
24
32
  transform: {
25
33
  '^.+\\.js(x)?$': 'babel-jest',
34
+ '^.+\\.ts(x)?$': 'babel-jest',
26
35
  '^.+\\.(png)$': 'jest-file',
27
36
  '^.+\\.(jpg)$': 'jest-file',
28
37
  '^.+\\.(svg)$': './node_modules/@plone/volto/jest-svgsystem-transform.js',
@@ -35,4 +44,9 @@ module.exports = {
35
44
  statements: 5,
36
45
  },
37
46
  },
47
+ ...(process.env.JEST_USE_SETUP === 'ON' && {
48
+ setupFilesAfterEnv: [
49
+ '<rootDir>/node_modules/@eeacms/volto-globalsearch/jest.setup.js',
50
+ ],
51
+ }),
38
52
  };
package/jest.setup.js ADDED
@@ -0,0 +1,65 @@
1
+ import { jest } from '@jest/globals';
2
+ import configureStore from 'redux-mock-store';
3
+ import thunk from 'redux-thunk';
4
+ import { blocksConfig } from '@plone/volto/config/Blocks';
5
+ import installSlate from '@plone/volto-slate/index';
6
+
7
+ var mockSemanticComponents = jest.requireActual('semantic-ui-react');
8
+ var mockComponents = jest.requireActual('@plone/volto/components');
9
+ var config = jest.requireActual('@plone/volto/registry').default;
10
+
11
+ config.blocks.blocksConfig = {
12
+ ...blocksConfig,
13
+ ...config.blocks.blocksConfig,
14
+ };
15
+
16
+ jest.doMock('semantic-ui-react', () => ({
17
+ __esModule: true,
18
+ ...mockSemanticComponents,
19
+ Popup: ({ content, trigger }) => {
20
+ return (
21
+ <div className="popup">
22
+ <div className="trigger">{trigger}</div>
23
+ <div className="content">{content}</div>
24
+ </div>
25
+ );
26
+ },
27
+ }));
28
+
29
+ jest.doMock('@plone/volto/components', () => {
30
+ return {
31
+ __esModule: true,
32
+ ...mockComponents,
33
+ SidebarPortal: ({ children }) => <div id="sidebar">{children}</div>,
34
+ };
35
+ });
36
+
37
+ jest.doMock('@plone/volto/registry', () =>
38
+ [installSlate].reduce((acc, apply) => apply(acc), config),
39
+ );
40
+
41
+ const mockStore = configureStore([thunk]);
42
+
43
+ global.fetch = jest.fn(() =>
44
+ Promise.resolve({
45
+ json: () => Promise.resolve({}),
46
+ }),
47
+ );
48
+
49
+ global.store = mockStore({
50
+ intl: {
51
+ locale: 'en',
52
+ messages: {},
53
+ formatMessage: jest.fn(),
54
+ },
55
+ content: {
56
+ create: {},
57
+ subrequests: [],
58
+ },
59
+ connected_data_parameters: {},
60
+ screen: {
61
+ page: {
62
+ width: 768,
63
+ },
64
+ },
65
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-globalsearch",
3
- "version": "1.0.22",
3
+ "version": "2.0.0",
4
4
  "description": "@eeacms/volto-globalsearch: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -28,6 +28,7 @@
28
28
  "@cypress/code-coverage": "^3.10.0",
29
29
  "@plone/scripts": "*",
30
30
  "babel-plugin-transform-class-properties": "^6.24.1",
31
+ "dotenv": "^16.3.2",
31
32
  "husky": "^8.0.3",
32
33
  "lint-staged": "^14.0.1",
33
34
  "md5": "^2.3.0"
@@ -200,9 +200,10 @@ const LandingPage = (props) => {
200
200
  landingDataAggs.aggregations.organisations.buckets.length;
201
201
  const topics = landingDataAggs.aggregations.topics.buckets.length;
202
202
  const languages = landingDataAggs.aggregations.languages.buckets.length;
203
- const content_types = landingDataAggs.aggregations.content_types.buckets.filter(
204
- (bucket) => objectProvidesWhitelist.indexOf(bucket.key) !== -1,
205
- ).length;
203
+ const content_types =
204
+ landingDataAggs.aggregations.content_types.buckets.filter(
205
+ (bucket) => objectProvidesWhitelist.indexOf(bucket.key) !== -1,
206
+ ).length;
206
207
  const countries = landingDataAggs.aggregations.countries.buckets.filter(
207
208
  (bucket) => spatialWhitelist.indexOf(bucket.key) !== -1,
208
209
  ).length;
@@ -70,7 +70,7 @@ export const clusters = {
70
70
 
71
71
  export const clusterIcons = get_cluster_icons(clusters);
72
72
 
73
- export default {
73
+ const config = {
74
74
  icons: {
75
75
  'Content types': get_cluster_icons_dict(clusters),
76
76
  Sources: {
@@ -168,6 +168,8 @@ export default {
168
168
  },
169
169
  };
170
170
 
171
+ export default config;
172
+
171
173
  export function typesForClustersOptionsFilter(options, filters) {
172
174
  // Only display content types that belong to the currently selected cluster
173
175
  const clusterMap = Object.assign(
@@ -1,4 +1,4 @@
1
- export default {
1
+ const download = {
2
2
  download_fields: [
3
3
  {
4
4
  field: 'about',
@@ -18,3 +18,5 @@ export default {
18
18
  },
19
19
  ],
20
20
  };
21
+
22
+ export default download;
@@ -12,6 +12,7 @@ import topicsBlacklist from './json/topicsBlacklist.json';
12
12
  import { getTodayWithTime } from '../utils';
13
13
 
14
14
  const languageCodes = [
15
+ 'en',
15
16
  'ar',
16
17
  'sr',
17
18
  'sq',
@@ -22,7 +23,6 @@ const languageCodes = [
22
23
  'da',
23
24
  'nl',
24
25
  'el',
25
- 'en',
26
26
  'et',
27
27
  'fi',
28
28
  'fr',
@@ -273,13 +273,67 @@ const facets = [
273
273
  facetValues: languageCodes,
274
274
  sortOn: 'custom',
275
275
  sortOnCustomLabel: 'Alphabetical',
276
+ sortOrder: 'ascending',
277
+ }),
278
+ multiTermFacet({
279
+ field: 'dpsir.keyword',
280
+ isFilterable: false,
281
+ isMulti: true,
282
+ label: 'DPSIR',
283
+ }),
284
+ multiTermFacet({
285
+ field: 'typology.keyword',
286
+ isFilterable: false,
287
+ isMulti: true,
288
+ label: 'Typology',
289
+ }),
290
+ multiTermFacet({
291
+ field: 'un_sdgs.keyword',
292
+ isFilterable: false,
293
+ isMulti: true,
294
+ label: 'UN SDGs',
295
+ }),
296
+ multiTermFacet({
297
+ field: 'data_provenances_organisations.keyword',
298
+ isFilterable: true,
299
+ isMulti: true,
300
+ label: 'Data sources',
301
+ }),
302
+ multiTermFacet({
303
+ field: 'creators.keyword',
304
+ isFilterable: true,
305
+ isMulti: true,
306
+ label: 'Creators',
307
+ authOnly: true,
308
+ }),
309
+ multiTermFacet({
310
+ field: 'contributors.keyword',
311
+ isFilterable: true,
312
+ isMulti: true,
313
+ label: 'Contributors',
314
+ }),
315
+ multiTermFacet({
316
+ field: 'subject.keyword_lc',
317
+ isFilterable: true,
318
+ isMulti: true,
319
+ label: 'Tags',
320
+ sortOn: 'value',
321
+ sortOrder: 'ascending',
322
+ }),
323
+ multiTermFacet({
324
+ field: 'publishers.keyword',
325
+ isFilterable: false,
326
+ isMulti: true,
327
+ label: 'Publishers',
276
328
  }),
277
329
  ];
278
330
 
279
- export default {
331
+ const facetsWrapper = {
280
332
  facets,
281
333
  };
282
334
 
335
+ export default facetsWrapper;
336
+
283
337
  // default filter values
284
338
  // TODO: this needs to be removed and the configuration plugged into each of
285
339
  // the facets
@@ -25,10 +25,12 @@ function constantScore() {
25
25
  }
26
26
  constantScore.id = 'constantScore';
27
27
 
28
- export default {
28
+ const filters = {
29
29
  // filter values that are always added to the ES requests
30
30
  permanentFilters: [
31
31
  { term: { hasWorkflowState: 'published' } },
32
32
  constantScore,
33
33
  ],
34
34
  };
35
+
36
+ export default filters;
@@ -112,12 +112,10 @@ export default function install(config) {
112
112
 
113
113
  config.resolve.getGlobalSearchHealthcheck = healthcheck;
114
114
 
115
- config.resolve.getGlobalsearchIconUrl = getGlobalsearchIconUrl(
116
- contentTypeNormalize,
117
- );
118
- config.resolve.getGlobalsearchThumbUrl = getGlobalsearchThumbUrl(
119
- contentTypeNormalize,
120
- );
115
+ config.resolve.getGlobalsearchIconUrl =
116
+ getGlobalsearchIconUrl(contentTypeNormalize);
117
+ config.resolve.getGlobalsearchThumbUrl =
118
+ getGlobalsearchThumbUrl(contentTypeNormalize);
121
119
 
122
120
  config.resolve.typesForClustersOptionsFilter = typesForClustersOptionsFilter;
123
121
 
@@ -1,4 +1,4 @@
1
- export default {
1
+ const query = {
2
2
  debugQuery: false,
3
3
  extraQueryParams: {
4
4
  text_fields: [
@@ -42,3 +42,5 @@ export default {
42
42
  // ],
43
43
  // },
44
44
  };
45
+
46
+ export default query;
@@ -1,6 +1,6 @@
1
1
  import { clusterIcons } from './clusters';
2
2
 
3
- export default {
3
+ const views = {
4
4
  resultViews: [
5
5
  {
6
6
  id: 'horizontalCard',
@@ -274,3 +274,5 @@ export default {
274
274
  ],
275
275
  },
276
276
  };
277
+
278
+ export default views;
@@ -60,4 +60,6 @@ const vocab = {
60
60
  },
61
61
  };
62
62
 
63
- export default { vocab };
63
+ const vocabWrapper = { vocab };
64
+
65
+ export default vocabWrapper;
package/src/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import installGlobalsearch from './config';
2
2
 
3
- export default (config) => {
3
+ const config = (config) => {
4
4
  config.settings.searchlib = installGlobalsearch(config.settings.searchlib);
5
5
 
6
6
  const { globalsearch, globalsearchbase } = config.settings.searchlib.searchui;
@@ -14,3 +14,5 @@ export default (config) => {
14
14
 
15
15
  return config;
16
16
  };
17
+
18
+ export default config;
package/src/utils.js CHANGED
@@ -63,158 +63,154 @@ export function getTodayWithTime() {
63
63
  return output;
64
64
  }
65
65
 
66
- export const getGlobalsearchIconUrl = (contentTypeNormalize) => (
67
- result,
68
- config,
69
- fallback,
70
- ) => {
71
- let image = fallback;
72
- let has_img = false;
73
- if (
74
- result.about.raw.startsWith('http://www.eea.europa.eu/help/glossary/') ||
75
- result.about.raw.startsWith('https://www.eea.europa.eu/help/glossary/')
76
- ) {
77
- image = 'https://www.eea.europa.eu/portal_depiction/term/image_thumb';
78
- has_img = true;
79
- }
80
- if (
81
- result.objectProvides &&
82
- result.objectProvides.raw.indexOf('Country profile') !== -1
83
- ) {
84
- image =
85
- 'https://www.eea.europa.eu/portal_depiction/country-profile/image_thumb';
86
- has_img = true;
87
- }
88
- if (
89
- result.about &&
90
- result.about.raw.indexOf('://land.copernicus.eu') !== -1
91
- ) {
92
- image = 'https://www.eea.europa.eu/portal_depiction/data/image_thumb';
93
- has_img = true;
94
- } else {
95
- if (!has_img) {
96
- let contentTypes = contentTypeNormalize;
97
- let _type;
98
- let _typeClass;
99
- let _contentType = 'generic';
66
+ export const getGlobalsearchIconUrl =
67
+ (contentTypeNormalize) => (result, config, fallback) => {
68
+ let image = fallback;
69
+ let has_img = false;
70
+ if (
71
+ result.about.raw.startsWith('http://www.eea.europa.eu/help/glossary/') ||
72
+ result.about.raw.startsWith('https://www.eea.europa.eu/help/glossary/')
73
+ ) {
74
+ image = 'https://www.eea.europa.eu/portal_depiction/term/image_thumb';
75
+ has_img = true;
76
+ }
77
+ if (
78
+ result.objectProvides &&
79
+ result.objectProvides.raw.indexOf('Country profile') !== -1
80
+ ) {
81
+ image =
82
+ 'https://www.eea.europa.eu/portal_depiction/country-profile/image_thumb';
83
+ has_img = true;
84
+ }
85
+ if (
86
+ result.about &&
87
+ result.about.raw.indexOf('://land.copernicus.eu') !== -1
88
+ ) {
89
+ image = 'https://www.eea.europa.eu/portal_depiction/data/image_thumb';
90
+ has_img = true;
91
+ } else {
92
+ if (!has_img) {
93
+ let contentTypes = contentTypeNormalize;
94
+ let _type;
95
+ let _typeClass;
96
+ let _contentType = 'generic';
100
97
 
101
- if (!result.objectProvides) {
102
- return image;
103
- }
98
+ if (!result.objectProvides) {
99
+ return image;
100
+ }
104
101
 
105
- if (!Array.isArray(result.objectProvides?.raw)) {
106
- result.objectProvides.raw = [result.objectProvides.raw];
107
- }
108
- if (result.objectProvides?.raw?.length > 0) {
109
- var pos = result.objectProvides.raw.length - 1;
110
- while (true) {
111
- _type = result.objectProvides.raw[pos];
112
- _typeClass = _type.toLowerCase().replace(/\s/g, '-');
113
- if (contentTypes[_typeClass]) {
114
- _contentType = contentTypes[_typeClass];
115
- break;
116
- }
117
- pos--;
118
- if (pos < 0) {
119
- break;
102
+ if (!Array.isArray(result.objectProvides?.raw)) {
103
+ result.objectProvides.raw = [result.objectProvides.raw];
104
+ }
105
+ if (result.objectProvides?.raw?.length > 0) {
106
+ var pos = result.objectProvides.raw.length - 1;
107
+ while (true) {
108
+ _type = result.objectProvides.raw[pos];
109
+ _typeClass = _type.toLowerCase().replace(/\s/g, '-');
110
+ if (contentTypes[_typeClass]) {
111
+ _contentType = contentTypes[_typeClass];
112
+ break;
113
+ }
114
+ pos--;
115
+ if (pos < 0) {
116
+ break;
117
+ }
120
118
  }
121
119
  }
120
+ image =
121
+ 'https://www.eea.europa.eu/portal_depiction/' +
122
+ _contentType +
123
+ '/image_thumb';
122
124
  }
123
- image =
124
- 'https://www.eea.europa.eu/portal_depiction/' +
125
- _contentType +
126
- '/image_thumb';
127
125
  }
128
- }
129
126
 
130
- return image;
131
- };
127
+ return image;
128
+ };
132
129
 
133
- export const getGlobalsearchThumbUrl = (contentTypeNormalize) => (
134
- result,
135
- config,
136
- fallback,
137
- ) => {
138
- let image = fallback;
139
- let has_img = false;
140
- if (result.site_id?.raw === 'sdi' && result['overview.url']) {
141
- has_img = false;
142
- /* if (!Array.isArray(result['overview.url']?.raw)) {
130
+ export const getGlobalsearchThumbUrl =
131
+ (contentTypeNormalize) => (result, config, fallback) => {
132
+ let image = fallback;
133
+ let has_img = false;
134
+ if (result.site_id?.raw === 'sdi' && result['overview.url']) {
135
+ has_img = false;
136
+ /* if (!Array.isArray(result['overview.url']?.raw)) {
143
137
  result['overview.url'].raw = [result['overview.url']?.raw];
144
138
  }
145
139
  if (result['overview.url']?.raw.length > 0) {
146
140
  image = result['overview.url']?.raw[0];
147
141
  }
148
142
  has_img = true;*/
149
- }
150
- if (
151
- result.about?.raw?.startsWith('http://www.eea.europa.eu/help/glossary/') ||
152
- result.about?.raw?.startsWith('https://www.eea.europa.eu/help/glossary/')
153
- ) {
154
- image = 'https://www.eea.europa.eu/portal_depiction/term/image_preview';
155
- has_img = true;
156
- }
157
- if (result.objectProvides?.raw?.indexOf('Country profile') !== -1) {
158
- image =
159
- 'https://www.eea.europa.eu/portal_depiction/country-profile/image_preview';
160
- has_img = true;
161
- }
162
- if (result.about?.raw?.indexOf('://land.copernicus.eu') !== -1) {
163
- image = result?.about?.raw + '/image_preview';
164
- has_img = true;
165
- }
166
- if (
167
- result.about?.raw?.indexOf('://biodiversity.europa.eu') !== -1 ||
168
- result.about?.raw?.indexOf('://forest.eea.europa.eu') !== -1 ||
169
- result.about?.raw?.indexOf('://climate-energy.eea.europa.eu') !== -1 ||
170
- result.about?.raw?.indexOf('://industry.eea.europa.eu') !== -1 ||
171
- result.about?.raw?.indexOf('://www.eea.europa.eu/en/') !== -1
172
- ) {
173
- if (result.image_preview) {
174
- image = result.image_preview.raw;
143
+ }
144
+ if (
145
+ result.about?.raw?.startsWith(
146
+ 'http://www.eea.europa.eu/help/glossary/',
147
+ ) ||
148
+ result.about?.raw?.startsWith('https://www.eea.europa.eu/help/glossary/')
149
+ ) {
150
+ image = 'https://www.eea.europa.eu/portal_depiction/term/image_preview';
151
+ has_img = true;
152
+ }
153
+ if (result.objectProvides?.raw?.indexOf('Country profile') !== -1) {
154
+ image =
155
+ 'https://www.eea.europa.eu/portal_depiction/country-profile/image_preview';
175
156
  has_img = true;
176
157
  }
177
- }
178
- if (
179
- (result.about?.raw?.startsWith('http://www.eea.europa.eu') ||
180
- result.about?.raw?.startsWith('https://www.eea.europa.eu')) &&
181
- result.about?.raw?.indexOf('://www.eea.europa.eu/en/') === -1
182
- ) {
183
- image = result.about.raw + '/image_preview';
184
- has_img = true;
185
- } else {
186
- if (!has_img) {
187
- let contentTypes = contentTypeNormalize;
188
- let _type;
189
- let _typeClass;
190
- let _contentType = 'generic';
191
- if (!Array.isArray(result.objectProvides?.raw)) {
192
- result.objectProvides.raw = [result.objectProvides.raw];
158
+ if (result.about?.raw?.indexOf('://land.copernicus.eu') !== -1) {
159
+ image = result?.about?.raw + '/image_preview';
160
+ has_img = true;
161
+ }
162
+ if (
163
+ result.about?.raw?.indexOf('://biodiversity.europa.eu') !== -1 ||
164
+ result.about?.raw?.indexOf('://forest.eea.europa.eu') !== -1 ||
165
+ result.about?.raw?.indexOf('://climate-energy.eea.europa.eu') !== -1 ||
166
+ result.about?.raw?.indexOf('://industry.eea.europa.eu') !== -1 ||
167
+ result.about?.raw?.indexOf('://www.eea.europa.eu/en/') !== -1
168
+ ) {
169
+ if (result.image_preview) {
170
+ image = result.image_preview.raw;
171
+ has_img = true;
193
172
  }
194
- if (result.objectProvides.raw.length > 0) {
195
- var pos = result.objectProvides.raw.length - 1;
196
- while (true) {
197
- _type = result.objectProvides.raw[pos];
198
- _typeClass = _type.toLowerCase().replace(/\s/g, '-');
199
- if (contentTypes[_typeClass]) {
200
- _contentType = contentTypes[_typeClass];
201
- break;
202
- }
203
- pos--;
204
- if (pos < 0) {
205
- break;
173
+ }
174
+ if (
175
+ (result.about?.raw?.startsWith('http://www.eea.europa.eu') ||
176
+ result.about?.raw?.startsWith('https://www.eea.europa.eu')) &&
177
+ result.about?.raw?.indexOf('://www.eea.europa.eu/en/') === -1
178
+ ) {
179
+ image = result.about.raw + '/image_preview';
180
+ has_img = true;
181
+ } else {
182
+ if (!has_img) {
183
+ let contentTypes = contentTypeNormalize;
184
+ let _type;
185
+ let _typeClass;
186
+ let _contentType = 'generic';
187
+ if (!Array.isArray(result.objectProvides?.raw)) {
188
+ result.objectProvides.raw = [result.objectProvides.raw];
189
+ }
190
+ if (result.objectProvides.raw.length > 0) {
191
+ var pos = result.objectProvides.raw.length - 1;
192
+ while (true) {
193
+ _type = result.objectProvides.raw[pos];
194
+ _typeClass = _type.toLowerCase().replace(/\s/g, '-');
195
+ if (contentTypes[_typeClass]) {
196
+ _contentType = contentTypes[_typeClass];
197
+ break;
198
+ }
199
+ pos--;
200
+ if (pos < 0) {
201
+ break;
202
+ }
206
203
  }
207
204
  }
205
+ image =
206
+ 'https://www.eea.europa.eu/portal_depiction/' +
207
+ _contentType +
208
+ '/image_preview';
208
209
  }
209
- image =
210
- 'https://www.eea.europa.eu/portal_depiction/' +
211
- _contentType +
212
- '/image_preview';
213
210
  }
214
- }
215
211
 
216
- return image;
217
- };
212
+ return image;
213
+ };
218
214
 
219
215
  export const get_cluster_icons = (settings) => {
220
216
  const icons = {
@@ -1,53 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
-
4
- const projectRootPath = fs.existsSync('./project')
5
- ? fs.realpathSync('./project')
6
- : fs.realpathSync('./../../../');
7
- const packageJson = require(path.join(projectRootPath, 'package.json'));
8
- const jsConfig = require(path.join(projectRootPath, 'jsconfig.json'))
9
- .compilerOptions;
10
-
11
- const pathsConfig = jsConfig.paths;
12
-
13
- let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto');
14
-
15
- Object.keys(pathsConfig).forEach((pkg) => {
16
- if (pkg === '@plone/volto') {
17
- voltoPath = `./${jsConfig.baseUrl}/${pathsConfig[pkg][0]}`;
18
- }
19
- });
20
- const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`);
21
- const reg = new AddonConfigurationRegistry(projectRootPath);
22
-
23
- // Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
24
- const addonAliases = Object.keys(reg.packages).map((o) => [
25
- o,
26
- reg.packages[o].modulePath,
27
- ]);
28
-
29
- const voltoSearchlibPath = path.dirname(
30
- reg.packages['@eeacms/volto-searchlib'].modulePath,
31
- );
32
- const searchlibPath = path.resolve(`${voltoSearchlibPath}/searchlib`);
33
-
34
- module.exports = {
35
- extends: `${projectRootPath}/node_modules/@plone/volto/.eslintrc`,
36
- settings: {
37
- 'import/resolver': {
38
- alias: {
39
- map: [
40
- ['@plone/volto', '@plone/volto/src'],
41
- ...addonAliases,
42
- ['@eeacms/search', searchlibPath],
43
- ['@package', `${__dirname}/src`],
44
- ['~', `${__dirname}/src`],
45
- ],
46
- extensions: ['.js', '.jsx', '.json'],
47
- },
48
- 'babel-plugin-root-import': {
49
- rootPathSuffix: 'src',
50
- },
51
- },
52
- },
53
- };