Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAchilleas Pipinellis <axil@gitlab.com>2021-01-18 15:12:29 +0300
committerAchilleas Pipinellis <axil@gitlab.com>2021-01-18 15:53:28 +0300
commita968c6dbc843da7f1e7e5d05b9aef93f9686db68 (patch)
treef0de035c15e3b804f90b0fdf9c5ebd587cdeec80
parentf3f2bdf27d687ac9aacc9d44a0ede4769b8a8cc6 (diff)
Hide survey banner on stable branches
We don't want the banner to be shown on stable branches. This introduces a new function that checks if CI_COMMIT_REF_NAME is defined, and if not, it uses Git to find the current branch name. If show_banner is false and current_branch is not a stable branch, hide the banner.
-rw-r--r--content/index.erb6
-rw-r--r--layouts/banner.html30
-rw-r--r--layouts/default.html6
-rw-r--r--lib/helpers/generic.rb12
4 files changed, 31 insertions, 23 deletions
diff --git a/content/index.erb b/content/index.erb
index 08f26110..da24567a 100644
--- a/content/index.erb
+++ b/content/index.erb
@@ -24,11 +24,7 @@ title: GitLab Documentation
<main class="content">
<div class="row px-4 pt-4">
<div class="col-12">
- <% if @config[:show_banner] %>
- <div class="d-lg-block">
- <%= render '/banner.*' %>
- </div>
- <% end %>
+ <%= render '/banner.*' %>
<h1 class="landing-header-title border-bottom-0 font-weight-bold">Welcome to GitLab Docs</h1>
<p class="text-break">Here you can access the complete documentation for GitLab, the single application for the <span class="text-decoration-underline"><a href="https://docs.gitlab.com/ee/README.html#the-entire-devops-lifecycle">entire DevOps lifecycle</a></span>.</p>
</div>
diff --git a/layouts/banner.html b/layouts/banner.html
index eb88bb92..b71f3864 100644
--- a/layouts/banner.html
+++ b/layouts/banner.html
@@ -1,15 +1,19 @@
-<div class="admonition-wrapper note d-none" id="banner-close">
- <div class="admonition alert alert-banner alert-dismissible fade show text-center" role="alert">
- <i class="fa fa-gitlab fa-fw" style="color:rgb(225,67,41); font-size:.85em" aria-hidden="true"></i>
- Help us understand how you think about GitLab. Take
- <a href="https://gitlab.fra1.qualtrics.com/jfe/form/SV_a4PzZnp4XWVAEPs" target="_blank" rel="noopener noreferrer">
- this 5-question survey
- </a>
- !
- <i class="fa fa-gitlab fa-fw" style="color:rgb(225,67,41); font-size:.85em" aria-hidden="true"></i>
- <button type="button" class="close" data-dismiss="alert" aria-label="Close">
- <span aria-hidden="true">&times;</span>
- </button>
+<% if @config[:show_banner] and !stable_version?(current_branch) %>
+<div class="d-lg-block">
+ <div class="admonition-wrapper note d-none" id="banner-close">
+ <div class="admonition alert alert-banner alert-dismissible fade show text-center" role="alert">
+ <i class="fa fa-gitlab fa-fw" style="color:rgb(225,67,41); font-size:.85em" aria-hidden="true"></i>
+ Help us understand how you think about GitLab. Take
+ <a href="https://gitlab.fra1.qualtrics.com/jfe/form/SV_a4PzZnp4XWVAEPs" target="_blank" rel="noopener noreferrer">
+ this 5-question survey
+ </a>
+ !
+ <i class="fa fa-gitlab fa-fw" style="color:rgb(225,67,41); font-size:.85em" aria-hidden="true"></i>
+ <button type="button" class="close" data-dismiss="alert" aria-label="Close">
+ <span aria-hidden="true">&times;</span>
+ </button>
+ </div>
</div>
+ <script type="application/javascript" src="<%= @items['/assets/javascripts/banner.*'].path %>"></script>
</div>
-<script type="application/javascript" src="<%= @items['/assets/javascripts/banner.*'].path %>"></script>
+<% end %>
diff --git a/layouts/default.html b/layouts/default.html
index 5398b516..7179e7e4 100644
--- a/layouts/default.html
+++ b/layouts/default.html
@@ -29,11 +29,7 @@
</div>
<div class="row">
<div class="col">
- <% if @config[:show_banner] and production_and_default_branch? %>
- <div class="d-lg-block">
- <%= render '/banner.*' %>
- </div>
- <% end %>
+ <%= render '/banner.*' %>
</div>
</div>
<div class="row">
diff --git a/lib/helpers/generic.rb b/lib/helpers/generic.rb
index 6dfcaf96..264ba497 100644
--- a/lib/helpers/generic.rb
+++ b/lib/helpers/generic.rb
@@ -25,5 +25,17 @@ module Nanoc::Helpers
def omnibus?
ENV['NANOC_ENV'] == 'omnibus'
end
+
+ #
+ # Find the current branch. If CI_COMMIT_BRANCH is not defined, that means
+ # we're working locally, and Git is used to find the branch.
+ #
+ def current_branch
+ if ENV['CI_COMMIT_REF_NAME'].nil?
+ `git branch --show-current`.tr("\n", '')
+ else
+ ENV['CI_COMMIT_REF_NAME']
+ end
+ end
end
end