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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2018-06-07 19:54:41 +0300
committerDouwe Maan <douwe@gitlab.com>2018-06-07 19:54:41 +0300
commit290ca339adc952bcd939d1782af95f90d3b88716 (patch)
tree99d6b6bc75727949f1d3410bef321d31406668ca /lib
parent7b562c972713d19c2e537eb4df7cbe072ada8bbe (diff)
parent366e1331692900300df42e9c38fc17bd46b7ca1c (diff)
Merge branch 'feature/customizable-favicon' into 'master'
Customizable favicon Closes #15661 See merge request gitlab-org/gitlab-ce!14497
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/favicon.rb47
-rw-r--r--lib/gitlab/path_regex.rb2
2 files changed, 48 insertions, 1 deletions
diff --git a/lib/gitlab/favicon.rb b/lib/gitlab/favicon.rb
new file mode 100644
index 00000000000..451c9daf761
--- /dev/null
+++ b/lib/gitlab/favicon.rb
@@ -0,0 +1,47 @@
+module Gitlab
+ class Favicon
+ class << self
+ def main
+ return appearance_favicon.favicon_main.url if appearance_favicon.exists?
+
+ image_name =
+ if Gitlab::Utils.to_boolean(ENV['CANARY'])
+ 'favicon-yellow.png'
+ elsif Rails.env.development?
+ 'favicon-blue.png'
+ else
+ 'favicon.png'
+ end
+
+ ActionController::Base.helpers.image_path(image_name)
+ end
+
+ def status_overlay(status_name)
+ path = File.join(
+ 'ci_favicons',
+ "#{status_name}.png"
+ )
+
+ ActionController::Base.helpers.image_path(path)
+ end
+
+ def available_status_names
+ @available_status_names ||= begin
+ Dir.glob(Rails.root.join('app', 'assets', 'images', 'ci_favicons', '*.png'))
+ .map { |file| File.basename(file, '.png') }
+ .sort
+ end
+ end
+
+ private
+
+ def appearance
+ RequestStore.store[:appearance] ||= (Appearance.current || Appearance.new)
+ end
+
+ def appearance_favicon
+ appearance.favicon
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/path_regex.rb b/lib/gitlab/path_regex.rb
index 4dc38aae61e..e5191f5c7f9 100644
--- a/lib/gitlab/path_regex.rb
+++ b/lib/gitlab/path_regex.rb
@@ -30,7 +30,7 @@ module Gitlab
dashboard
deploy.html
explore
- favicon.ico
+ favicon.png
files
groups
health_check