From 791be12c074e5f5e77989f170e1a36c726e75f9a Mon Sep 17 00:00:00 2001 From: Lukas_Skywalker Date: Wed, 22 May 2024 10:01:35 +0200 Subject: [PATCH 1/4] WPC-1419: Fix search for multiple search terms When searching for multiple terms, the search should only match articles where all of the terms are present. This was changed in the frontend in https://hauptstadt.atlassian.net/browse/HA-176 and then later in the backend in https://wepublish.atlassian.net/browse/WPC-1419 by adding an ampersand. When both fixes are run, the search terms are broken and the search produces invalid SQL. This change removes the ampersand injection in the frontend. --- components/navigation/header/menu/MenuRubricEntries.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/navigation/header/menu/MenuRubricEntries.vue b/components/navigation/header/menu/MenuRubricEntries.vue index 253f02e..ae7dc0a 100644 --- a/components/navigation/header/menu/MenuRubricEntries.vue +++ b/components/navigation/header/menu/MenuRubricEntries.vue @@ -75,8 +75,7 @@ export default Vue.extend({ if (activeElement) { activeElement.blur() } - const preparedSearchQuery = this.searchQuery.replace(' ', ' & ') - const link = `/p/search?query=${preparedSearchQuery}` + const link = `/p/search?query=${this.searchQuery}` this.searchQuery = '' await this.$router.push(link) this.$store.commit('navigation/closeMenu') From cac3fdfa2cbdfdf955fe1130f5bfdb9aba728068 Mon Sep 17 00:00:00 2001 From: Lukas_Skywalker Date: Wed, 22 May 2024 11:05:34 +0200 Subject: [PATCH 2/4] HAS-16: Disable paywall even after navigation In commit 3767a3b4039ab4790c518474fe4946ca7ef55f01, a method to temporarily disable the paywall was added. When appending a secret key to the URL, the paywall was to be bypassed for 4 hours. The change correctly removed the 'articleId' parameter from the URL when visiting an article, but failed to take into account, that there was a second condition for hiding the paywall, namely that no navigation must have occurred before visiting the article. This change makes sure that the paywall is hidden, even when opening the home page and then navigating to the article. --- components/blocks/TeaserGridBlockView.vue | 4 +--- components/wepPublication/WepPublication.vue | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/blocks/TeaserGridBlockView.vue b/components/blocks/TeaserGridBlockView.vue index de56167..a1fe46a 100644 --- a/components/blocks/TeaserGridBlockView.vue +++ b/components/blocks/TeaserGridBlockView.vue @@ -199,7 +199,6 @@ import AuthorsLine from '~/components/author/AuthorsLine.vue' import ImgLoadingSlot from '~/sdk/wep/components/img/ImgLoadingSlot.vue' import PeerArticleTeaser from '~/sdk/wep/models/teaser/PeerArticleTeaser' import PeeringImgOverlay from '~/components/blocks/PeeringImgOverlay.vue' -import { LoginBypass } from '~/sdk/wep/utils' export default Vue.extend({ name: 'TeaserGridBlockView', @@ -265,8 +264,7 @@ export default Vue.extend({ // article id is for paywall purposes. see WepPublication.vue const baseUrl = `/a/${teaser?.wepPublication?.slug}` const hasAccess = this.$store.getters['auth/hasAccess'] - const loginBypass = (new LoginBypass(this.$cookies).check()) - return (hasAccess || loginBypass) ? baseUrl : `${baseUrl}?articleId=${teaser.wepPublication?.id}` + return hasAccess ? baseUrl : `${baseUrl}?articleId=${teaser.wepPublication?.id}` } else if (teaser.__typename === 'PageTeaser') { return `/p/${teaser?.wepPublication?.slug}` } diff --git a/components/wepPublication/WepPublication.vue b/components/wepPublication/WepPublication.vue index 154a97f..5ebb982 100644 --- a/components/wepPublication/WepPublication.vue +++ b/components/wepPublication/WepPublication.vue @@ -217,6 +217,7 @@ import PagePropertiesContent from '~/components/wepPublication/PagePropertiesCon import CrowdfundingBlock from '~/sdk/wep/models/block/CrowdfundingBlock' import UserInteractionOffline from '~/sdk/wep/components/helpers/UserInteractionOffline.vue' import TextZoom from '~/components/helpers/TextZoom.vue' +import { LoginBypass } from '~/sdk/wep/utils' export default Vue.extend({ name: 'WepPublication', @@ -384,7 +385,8 @@ export default Vue.extend({ startPath = currentPath } const paywallKey = this.$route.query.articleId - if (startPath !== currentPath || paywallKey) { + const loginBypass = (new LoginBypass(this.$cookies).check()) + if ((startPath !== currentPath || paywallKey) && !loginBypass) { // apply paywall blocks?.removeBlocks(3) this.showPaywall = true From 52639fce82c10a7398ffb3f23c24747e977d6e74 Mon Sep 17 00:00:00 2001 From: Lukas_Skywalker Date: Wed, 22 May 2024 12:00:19 +0200 Subject: [PATCH 3/4] SHARE-9: Add head.js and body.js scripts from the editor This change adds the head and body scripts hosted in the editor to the website. Since the WEP_API_URL_CLIENT environment voriable contains the trailing "/v1", it is removed when building the URL of the two scripts. --- nuxt.config.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nuxt.config.js b/nuxt.config.js index 8936427..dd98ac7 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -65,6 +65,10 @@ export default { {rel: 'icon', type: 'image/png', sizes: '16x16', href: '/favicon-16x16.png'}, {rel: 'manifest', href: '/site.webmanifest'}, {rel: 'mask-icon', href: '/safari-pinned-tab.svg', color: '#000000'} + ], + script: [ + { src: `${process.env.WEP_API_URL_CLIENT.replace('/v1', '')}/static/head.js` }, + { src: `${process.env.WEP_API_URL_CLIENT.replace('/v1', '')}/static/body.js`, body: true }, ] }, publicRuntimeConfig: { From c241e364fb9aaa4d0944e1af5c461226be341f11 Mon Sep 17 00:00:00 2001 From: Lukas_Skywalker Date: Wed, 22 May 2024 12:42:42 +0200 Subject: [PATCH 4/4] SHARE-9: Move script injection from nuxt config to layout Injecting the scripts inside the Nuxt config breaks the build of the application, because the environment variables are not availalble during build time. This change moves the configuration to the layout file, where the config is present. --- layouts/default.vue | 8 ++++++++ nuxt.config.js | 8 +++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/layouts/default.vue b/layouts/default.vue index 59d8af5..0dd40e3 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -69,6 +69,14 @@ export default Vue.extend({ overlay: false } }, + head() { + return { + script: [ + { src: `${this.$nuxt.context.$config.WEP_API_URL_CLIENT.replace('/v1', '')}/static/head.js` }, + { src: `${this.$nuxt.context.$config.WEP_API_URL_CLIENT.replace('/v1', '')}/static/body.js`, body: true }, + ] + } + }, computed: { redirectUrl (): string | undefined { return this.$nuxt.context.$config.REDIRECT_URL diff --git a/nuxt.config.js b/nuxt.config.js index dd98ac7..1a0aff2 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -65,10 +65,6 @@ export default { {rel: 'icon', type: 'image/png', sizes: '16x16', href: '/favicon-16x16.png'}, {rel: 'manifest', href: '/site.webmanifest'}, {rel: 'mask-icon', href: '/safari-pinned-tab.svg', color: '#000000'} - ], - script: [ - { src: `${process.env.WEP_API_URL_CLIENT.replace('/v1', '')}/static/head.js` }, - { src: `${process.env.WEP_API_URL_CLIENT.replace('/v1', '')}/static/body.js`, body: true }, ] }, publicRuntimeConfig: { @@ -97,7 +93,9 @@ export default { // HAS internal MEDIUM_SLUG: 'HAS' }, - privateRuntimeConfig: {}, + privateRuntimeConfig: { + WEP_API_URL_CLIENT: process.env.WEP_API_URL_CLIENT + }, // Global CSS: https://go.nuxtjs.dev/config-css css: [