2017-09-26 15:04:37 +00:00
|
|
|
module Gitlab
|
|
|
|
class Favicon
|
|
|
|
class << self
|
2017-09-28 11:57:08 +00:00
|
|
|
def main
|
2018-04-13 19:40:32 +00:00
|
|
|
image_name =
|
2018-06-20 14:00:13 +00:00
|
|
|
if appearance_favicon.exists?
|
|
|
|
appearance_favicon.url
|
|
|
|
elsif Gitlab::Utils.to_boolean(ENV['CANARY'])
|
2018-04-13 19:40:32 +00:00
|
|
|
'favicon-yellow.png'
|
|
|
|
elsif Rails.env.development?
|
|
|
|
'favicon-blue.png'
|
|
|
|
else
|
|
|
|
'favicon.png'
|
|
|
|
end
|
|
|
|
|
2018-06-20 14:00:13 +00:00
|
|
|
ActionController::Base.helpers.image_path(image_name, host: host)
|
2017-09-26 15:04:37 +00:00
|
|
|
end
|
|
|
|
|
2017-12-06 20:04:53 +00:00
|
|
|
def status_overlay(status_name)
|
|
|
|
path = File.join(
|
|
|
|
'ci_favicons',
|
|
|
|
"#{status_name}.png"
|
|
|
|
)
|
|
|
|
|
2018-06-20 14:00:13 +00:00
|
|
|
ActionController::Base.helpers.image_path(path, host: host)
|
2017-12-06 20:04:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def available_status_names
|
|
|
|
@available_status_names ||= begin
|
2017-12-07 12:15:49 +00:00
|
|
|
Dir.glob(Rails.root.join('app', 'assets', 'images', 'ci_favicons', '*.png'))
|
2017-12-06 20:04:53 +00:00
|
|
|
.map { |file| File.basename(file, '.png') }
|
|
|
|
.sort
|
2017-09-27 11:18:49 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-09-26 15:04:37 +00:00
|
|
|
private
|
|
|
|
|
2018-06-20 14:00:13 +00:00
|
|
|
# we only want to create full urls when there's a different asset_host
|
|
|
|
# configured.
|
|
|
|
def host
|
|
|
|
if Gitlab::Application.config.asset_host.nil? || Gitlab::Application.config.asset_host == Gitlab.config.gitlab.base_url
|
|
|
|
nil
|
|
|
|
else
|
|
|
|
Gitlab.config.gitlab.base_url
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-09-26 15:04:37 +00:00
|
|
|
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
|
2017-09-27 11:18:49 +00:00
|
|
|
appearance.favicon
|
2017-09-26 15:04:37 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|