From f42d0905f41d5b5362fdd968255d15199699df1c Mon Sep 17 00:00:00 2001 From: Achilleas Pipinellis Date: Fri, 2 Jun 2023 10:24:56 +0000 Subject: Load the analytics only in the main site (14.10 backport) --- .gitlab-ci.yml | 124 ++++++++++++++++++++++----------------------- layouts/404.html | 8 ++- layouts/analytics.html | 2 + layouts/default.html | 6 +-- layouts/gtm.html | 2 +- layouts/head.html | 16 +++--- layouts/home.html | 4 +- layouts/instantsearch.html | 5 +- 8 files changed, 80 insertions(+), 87 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2433c848..5fe234c5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -417,72 +417,72 @@ test_unlinked_images: # # Deploy the Review App on a dev server # -review: - stage: deploy - extends: - - .retry - variables: - GIT_STRATEGY: none - needs: - - compile_dev - before_script: [] - cache: {} - script: - # Rsync to the Pages dir - - rsync -av --delete public /srv/nginx/pages/$CI_COMMIT_REF_SLUG$REVIEW_SLUG - # Remove public directory so that the next review app can run in a - # clean environment (limitation of the shell executor). - - rm -rf public - environment: - name: review/$CI_COMMIT_REF_SLUG$REVIEW_SLUG - url: http://$CI_COMMIT_REF_SLUG$REVIEW_SLUG.$APPS_DOMAIN - on_stop: review_stop - rules: - - if: '$CI_PROJECT_PATH == "gitlab-renovate-forks/gitlab-docs"' - when: manual - - if: '$CI_PROJECT_PATH !~ /^gitlab-org/' - when: never - - if: '$CI_MERGE_REQUEST_ID' - - if: '$CI_PIPELINE_SOURCE == "pipeline" || $CI_PIPELINE_SOURCE == "trigger"' - - if: '$CI_COMMIT_BRANCH =~ /docs-preview/' # TODO: Remove once no projects create such branch - tags: - - nginx - - review-apps +#review: +# stage: deploy +# extends: +# - .retry +# variables: +# GIT_STRATEGY: none +# needs: +# - compile_dev +# before_script: [] +# cache: {} +# script: +# # Rsync to the Pages dir +# - rsync -av --delete public /srv/nginx/pages/$CI_COMMIT_REF_SLUG$REVIEW_SLUG +# # Remove public directory so that the next review app can run in a +# # clean environment (limitation of the shell executor). +# - rm -rf public +# environment: +# name: review/$CI_COMMIT_REF_SLUG$REVIEW_SLUG +# url: http://$CI_COMMIT_REF_SLUG$REVIEW_SLUG.$APPS_DOMAIN +# on_stop: review_stop +# rules: +# - if: '$CI_PROJECT_PATH == "gitlab-renovate-forks/gitlab-docs"' +# when: manual +# - if: '$CI_PROJECT_PATH !~ /^gitlab-org/' +# when: never +# - if: '$CI_MERGE_REQUEST_ID' +# - if: '$CI_PIPELINE_SOURCE == "pipeline" || $CI_PIPELINE_SOURCE == "trigger"' +# - if: '$CI_COMMIT_BRANCH =~ /docs-preview/' # TODO: Remove once no projects create such branch +# tags: +# - nginx +# - review-apps # # Stop the Review App # -review_stop: - stage: deploy - extends: - - .retry - variables: - GIT_STRATEGY: none - needs: [] - artifacts: {} - before_script: [] - cache: {} - script: - - rm -rf public /srv/nginx/pages/$CI_COMMIT_REF_SLUG$REVIEW_SLUG - environment: - name: review/$CI_COMMIT_REF_SLUG$REVIEW_SLUG - action: stop - rules: - - if: '$CI_PROJECT_PATH == "gitlab-renovate-forks/gitlab-docs"' - allow_failure: true - when: manual - - if: '$CI_PROJECT_PATH !~ /^gitlab-org/' - when: never - - if: '$CI_MERGE_REQUEST_ID || $CI_PIPELINE_SOURCE == "pipeline"|| $CI_PIPELINE_SOURCE == "trigger"' - allow_failure: true - when: manual - # TODO: Remove once no projects create such branch - - if: '$CI_COMMIT_BRANCH =~ /docs-preview/' - allow_failure: true - when: manual - tags: - - nginx - - review-apps +#review_stop: +# stage: deploy +# extends: +# - .retry +# variables: +# GIT_STRATEGY: none +# needs: [] +# artifacts: {} +# before_script: [] +# cache: {} +# script: +# - rm -rf public /srv/nginx/pages/$CI_COMMIT_REF_SLUG$REVIEW_SLUG +# environment: +# name: review/$CI_COMMIT_REF_SLUG$REVIEW_SLUG +# action: stop +# rules: +# - if: '$CI_PROJECT_PATH == "gitlab-renovate-forks/gitlab-docs"' +# allow_failure: true +# when: manual +# - if: '$CI_PROJECT_PATH !~ /^gitlab-org/' +# when: never +# - if: '$CI_MERGE_REQUEST_ID || $CI_PIPELINE_SOURCE == "pipeline"|| $CI_PIPELINE_SOURCE == "trigger"' +# allow_failure: true +# when: manual +# # TODO: Remove once no projects create such branch +# - if: '$CI_COMMIT_BRANCH =~ /docs-preview/' +# allow_failure: true +# when: manual +# tags: +# - nginx +# - review-apps # # Clean up review apps and free disk space diff --git a/layouts/404.html b/layouts/404.html index 525641a4..65a37734 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -13,16 +13,14 @@
<%= yield %> <%= render '/footer.*' %> +
- - + <%= render '/docsearch.*' %> - <% if production? %> <%# Add analytics only in production %> - <%= render '/analytics.*' %> - <% end %> + <%= render '/analytics.*' %> diff --git a/layouts/analytics.html b/layouts/analytics.html index 3f8a9985..f18097f5 100644 --- a/layouts/analytics.html +++ b/layouts/analytics.html @@ -1,3 +1,4 @@ +<% if production_and_default_branch? %> +<% end %> diff --git a/layouts/default.html b/layouts/default.html index 49da148d..60c58c4e 100644 --- a/layouts/default.html +++ b/layouts/default.html @@ -101,10 +101,9 @@ <%= render '/docsearch.*' %> - <% if production? %> + <%# Add analytics only in production %> - <%= render '/analytics.*' %> - <% end %> + <%= render '/analytics.*' %> @@ -112,4 +111,3 @@ - diff --git a/layouts/gtm.html b/layouts/gtm.html index 87ebf4cb..bf124396 100644 --- a/layouts/gtm.html +++ b/layouts/gtm.html @@ -1,4 +1,4 @@ -<% if production? and ENV['CI_COMMIT_REF_NAME'] == ENV['CI_DEFAULT_BRANCH'] %> +<% if production_and_default_branch? %> <%# Adds GTM only in production // leave this immediately after the opening the body tag%>