diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-06-07 16:54:41 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-06-07 16:54:41 +0000 |
commit | 290ca339adc952bcd939d1782af95f90d3b88716 (patch) | |
tree | 99d6b6bc75727949f1d3410bef321d31406668ca /lib | |
parent | 7b562c972713d19c2e537eb4df7cbe072ada8bbe (diff) | |
parent | 366e1331692900300df42e9c38fc17bd46b7ca1c (diff) | |
download | gitlab-ce-290ca339adc952bcd939d1782af95f90d3b88716.tar.gz |
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.rb | 47 | ||||
-rw-r--r-- | lib/gitlab/path_regex.rb | 2 |
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 |