gitlab-org--gitlab-foss/lib/gitlab/favicon.rb

48 lines
1.1 KiB
Ruby
Raw Normal View History

2017-09-26 15:04:37 +00:00
module Gitlab
class Favicon
class << self
def main
return appearance_favicon.url if appearance_favicon.exists?
2017-09-26 15:04:37 +00:00
2018-04-13 19:40:32 +00:00
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)
2017-09-26 15:04:37 +00:00
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
2017-09-26 15:04:37 +00:00
private
def appearance
2017-09-28 08:45:50 +00:00
RequestStore.store[:appearance] ||= (Appearance.current || Appearance.new)
2017-09-26 15:04:37 +00:00
end
def appearance_favicon
appearance.favicon
2017-09-26 15:04:37 +00:00
end
end
end
end