From af1e9778f0280cb60567260105cce37f216d8af9 Mon Sep 17 00:00:00 2001 From: Muratcan Yeldan Date: Fri, 18 Apr 2025 08:28:44 +0300 Subject: [PATCH] Add SHOW_SURVEY Environment variable to Docker, to disable survey in local Docker installation --- DeveloperGuide.md | 1 + .../docker-compose-latest-fat-endpoints-disabled.yml | 1 + .../docker-compose-latest-fat-security-postgres.yml | 1 + exampleYmlFiles/docker-compose-latest-fat-security.yml | 1 + exampleYmlFiles/docker-compose-latest-security-with-sso.yml | 1 + exampleYmlFiles/docker-compose-latest-security.yml | 1 + .../docker-compose-latest-ultra-lite-security.yml | 1 + exampleYmlFiles/docker-compose-latest-ultra-lite.yml | 1 + exampleYmlFiles/docker-compose-latest.yml | 1 + .../software/SPDF/controller/web/HomeWebController.java | 3 +++ src/main/resources/static/js/pages/home.js | 6 +++++- src/main/resources/templates/home.html | 2 ++ 12 files changed, 19 insertions(+), 1 deletion(-) diff --git a/DeveloperGuide.md b/DeveloperGuide.md index 8a4b53b6..bbf8b867 100644 --- a/DeveloperGuide.md +++ b/DeveloperGuide.md @@ -153,6 +153,7 @@ services: SYSTEM_MAXFILESIZE: "100" METRICS_ENABLED: "true" SYSTEM_GOOGLEVISIBILITY: "true" + SHOW_SURVEY: "true" restart: on-failure:5 ``` diff --git a/exampleYmlFiles/docker-compose-latest-fat-endpoints-disabled.yml b/exampleYmlFiles/docker-compose-latest-fat-endpoints-disabled.yml index 72968468..f36cd5bc 100644 --- a/exampleYmlFiles/docker-compose-latest-fat-endpoints-disabled.yml +++ b/exampleYmlFiles/docker-compose-latest-fat-endpoints-disabled.yml @@ -32,4 +32,5 @@ services: SYSTEM_MAXFILESIZE: "100" METRICS_ENABLED: "true" SYSTEM_GOOGLEVISIBILITY: "true" + SHOW_SURVEY: "true" restart: on-failure:5 diff --git a/exampleYmlFiles/docker-compose-latest-fat-security-postgres.yml b/exampleYmlFiles/docker-compose-latest-fat-security-postgres.yml index b79631b6..c04da191 100644 --- a/exampleYmlFiles/docker-compose-latest-fat-security-postgres.yml +++ b/exampleYmlFiles/docker-compose-latest-fat-security-postgres.yml @@ -36,6 +36,7 @@ services: SYSTEM_DATASOURCE_CUSTOMDATABASEURL: "jdbc:postgresql://db:5432/stirling_pdf" SYSTEM_DATASOURCE_USERNAME: "admin" SYSTEM_DATASOURCE_PASSWORD: "stirling" + SHOW_SURVEY: "true" restart: on-failure:5 db: diff --git a/exampleYmlFiles/docker-compose-latest-fat-security.yml b/exampleYmlFiles/docker-compose-latest-fat-security.yml index 5d01f33f..d9e4fa5a 100644 --- a/exampleYmlFiles/docker-compose-latest-fat-security.yml +++ b/exampleYmlFiles/docker-compose-latest-fat-security.yml @@ -30,4 +30,5 @@ services: SYSTEM_MAXFILESIZE: "100" METRICS_ENABLED: "true" SYSTEM_GOOGLEVISIBILITY: "true" + SHOW_SURVEY: "true" restart: on-failure:5 diff --git a/exampleYmlFiles/docker-compose-latest-security-with-sso.yml b/exampleYmlFiles/docker-compose-latest-security-with-sso.yml index 9b86d4cc..1514dd7d 100644 --- a/exampleYmlFiles/docker-compose-latest-security-with-sso.yml +++ b/exampleYmlFiles/docker-compose-latest-security-with-sso.yml @@ -38,4 +38,5 @@ services: SYSTEM_MAXFILESIZE: "100" METRICS_ENABLED: "true" SYSTEM_GOOGLEVISIBILITY: "true" + SHOW_SURVEY: "true" restart: on-failure:5 diff --git a/exampleYmlFiles/docker-compose-latest-security.yml b/exampleYmlFiles/docker-compose-latest-security.yml index b79ea801..ccd3a41c 100644 --- a/exampleYmlFiles/docker-compose-latest-security.yml +++ b/exampleYmlFiles/docker-compose-latest-security.yml @@ -30,4 +30,5 @@ services: SYSTEM_MAXFILESIZE: "100" METRICS_ENABLED: "true" SYSTEM_GOOGLEVISIBILITY: "true" + SHOW_SURVEY: "true" restart: on-failure:5 diff --git a/exampleYmlFiles/docker-compose-latest-ultra-lite-security.yml b/exampleYmlFiles/docker-compose-latest-ultra-lite-security.yml index 8f3932f7..c59713b7 100644 --- a/exampleYmlFiles/docker-compose-latest-ultra-lite-security.yml +++ b/exampleYmlFiles/docker-compose-latest-ultra-lite-security.yml @@ -27,4 +27,5 @@ services: SYSTEM_MAXFILESIZE: "100" METRICS_ENABLED: "true" SYSTEM_GOOGLEVISIBILITY: "true" + SHOW_SURVEY: "true" restart: on-failure:5 diff --git a/exampleYmlFiles/docker-compose-latest-ultra-lite.yml b/exampleYmlFiles/docker-compose-latest-ultra-lite.yml index d194be21..6148f725 100644 --- a/exampleYmlFiles/docker-compose-latest-ultra-lite.yml +++ b/exampleYmlFiles/docker-compose-latest-ultra-lite.yml @@ -26,4 +26,5 @@ services: SYSTEM_MAXFILESIZE: "100" METRICS_ENABLED: "true" SYSTEM_GOOGLEVISIBILITY: "true" + SHOW_SURVEY: "true" restart: on-failure:5 diff --git a/exampleYmlFiles/docker-compose-latest.yml b/exampleYmlFiles/docker-compose-latest.yml index 7dec8a95..51266ee8 100644 --- a/exampleYmlFiles/docker-compose-latest.yml +++ b/exampleYmlFiles/docker-compose-latest.yml @@ -28,4 +28,5 @@ services: SYSTEM_MAXFILESIZE: "100" METRICS_ENABLED: "true" SYSTEM_GOOGLEVISIBILITY: "true" + SHOW_SURVEY: "true" restart: on-failure:5 diff --git a/src/main/java/stirling/software/SPDF/controller/web/HomeWebController.java b/src/main/java/stirling/software/SPDF/controller/web/HomeWebController.java index 3341d005..0fdd8e9c 100644 --- a/src/main/java/stirling/software/SPDF/controller/web/HomeWebController.java +++ b/src/main/java/stirling/software/SPDF/controller/web/HomeWebController.java @@ -67,6 +67,9 @@ public class HomeWebController { @GetMapping("/") public String home(Model model) { model.addAttribute("currentPage", "home"); + String showSurvey = System.getenv("SHOW_SURVEY"); + boolean showSurveyValue = showSurvey == null || "true".equalsIgnoreCase(showSurvey); + model.addAttribute("showSurveyFromDocker", showSurveyValue); return "home"; } diff --git a/src/main/resources/static/js/pages/home.js b/src/main/resources/static/js/pages/home.js index 7872374e..6c48fe81 100644 --- a/src/main/resources/static/js/pages/home.js +++ b/src/main/resources/static/js/pages/home.js @@ -61,6 +61,10 @@ document.addEventListener('DOMContentLoaded', function () { localStorage.setItem('pageViews', pageViews.toString()); function shouldShowSurvey() { + if(!window.showSurvey) { + return false; + } + if (localStorage.getItem('dontShowSurvey') === 'true' || localStorage.getItem('surveyTaken') === 'true') { return false; } @@ -112,7 +116,7 @@ function setAsDefault(value) { function adjustVisibleElements() { const container = document.querySelector('.recent-features'); - if(!container) return; + if(!container) return; const subElements = Array.from(container.children); let totalWidth = 0; diff --git a/src/main/resources/templates/home.html b/src/main/resources/templates/home.html index 925aefe8..3842c1fe 100644 --- a/src/main/resources/templates/home.html +++ b/src/main/resources/templates/home.html @@ -218,6 +218,8 @@ /**/ + + window.showSurvey = /*[[${showSurveyFromDocker}]]*/ true