From 910824c91ef55e714a6b253bf1458a54f57078fc Mon Sep 17 00:00:00 2001 From: Roland Sadowski Date: Thu, 11 Jul 2024 16:58:44 +0100 Subject: [PATCH] add smartlook integration --- config/index.js | 3 +-- config/production.yaml | 6 +++++- package.json | 5 ++--- src/serverSetup/nunjucks.js | 5 +++++ src/views/layouts/main.html | 7 +++++++ 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/config/index.js b/config/index.js index fd4442d7..7afbc119 100644 --- a/config/index.js +++ b/config/index.js @@ -1,7 +1,6 @@ import HmpoConfig from 'hmpo-config' import yaml from 'js-yaml' import fs from 'fs' -import _ from 'lodash' const readConfig = (config) => { return yaml.load(fs.readFileSync(`./config/${config}.yaml`, 'utf8')) @@ -16,7 +15,7 @@ const getConfig = () => { const customConfig = readConfig(environment) - const combinedConfig = _.merge({}, defaultConfig, customConfig) + const combinedConfig = Object.assign({}, defaultConfig, customConfig) const config = new HmpoConfig() config.addConfig(combinedConfig) diff --git a/config/production.yaml b/config/production.yaml index 43f1dd15..231112b3 100644 --- a/config/production.yaml +++ b/config/production.yaml @@ -10,4 +10,8 @@ redis: { host: 'production-pub-async-redis-eihmmv.serverless.euw2.cache.amazonaws.com', port: '6379' } -url: 'https://publish.digital-land.info/' \ No newline at end of file +url: 'https://publish.digital-land.info/' +smartlook: { + key: '6383ab27d6f6a02f043a518bea629cd232dc0131', + region: 'eu' +} \ No newline at end of file diff --git a/package.json b/package.json index a7861dd7..b1a49bdf 100644 --- a/package.json +++ b/package.json @@ -27,8 +27,8 @@ "test:acceptance": "NODE_ENV=development playwright test --config ./test/acceptance/playwright.config.js", "test:acceptance:ci": "NODE_ENV=ci playwright test --config ./test/acceptance/playwright.config.js", "playwright-codegen": "playwright codegen http://localhost:5000", - "lint": "standard", - "lint:fix": "standard --fix" + "lint": "standard --ignore=src/views/common/smartlook.js", + "lint:fix": "standard --fix --ignore=src/views/common/smartlook.js" }, "engines": { "node": ">=18.0.0 <20.0.0" @@ -73,7 +73,6 @@ "hmpo-form-wizard": "^13.0.0", "hmpo-i18n": "^6.0.1", "js-yaml": "^4.1.0", - "lodash": "^4.17.21", "maplibre-gl": "^4.1.0", "multer": "^1.4.5-lts.1", "notifications-node-client": "^8.2.0", diff --git a/src/serverSetup/nunjucks.js b/src/serverSetup/nunjucks.js index 5a7a20e8..e273dbc8 100644 --- a/src/serverSetup/nunjucks.js +++ b/src/serverSetup/nunjucks.js @@ -25,6 +25,11 @@ export function setupNunjucks ({ app, dataSubjects }) { feedbackLink: config.feedbackLink } + if ('smartlook' in config) { + globalValues.smartlookKey = config.smartlook.key + globalValues.smartlookRegion = config.smartlook.region + } + Object.keys(globalValues).forEach((key) => { nunjucksEnv.addGlobal(key, globalValues[key]) }) diff --git a/src/views/layouts/main.html b/src/views/layouts/main.html index 291d8488..07557602 100644 --- a/src/views/layouts/main.html +++ b/src/views/layouts/main.html @@ -19,6 +19,13 @@ {% block head %} + {% if smartlookKey %} + {% block smartlook %} + + {% endblock %} + {% endif %} {% endblock %} {% block header %}