2017-09-26 15:04:37 +00:00
|
|
|
module Gitlab
|
|
|
|
class Favicon
|
|
|
|
class << self
|
|
|
|
def default
|
2017-09-27 11:23:05 +00:00
|
|
|
return custom_favicon_url(appearance_favicon.default.url) if appearance_favicon.exists?
|
2017-09-26 15:04:37 +00:00
|
|
|
return 'favicon-yellow.ico' if Gitlab::Utils.to_boolean(ENV['CANARY'])
|
|
|
|
return 'favicon-blue.ico' if Rails.env.development?
|
|
|
|
|
|
|
|
'favicon.ico'
|
|
|
|
end
|
|
|
|
|
2017-09-27 11:18:49 +00:00
|
|
|
def status(status_name)
|
|
|
|
if appearance_favicon.exists?
|
2017-09-27 11:23:05 +00:00
|
|
|
custom_favicon_url(appearance_favicon.public_send("status_#{status_name}").url) # rubocop:disable GitlabSecurity/PublicSend
|
2017-09-27 11:18:49 +00:00
|
|
|
else
|
|
|
|
dir = 'ci_favicons'
|
|
|
|
dir = File.join(dir, 'dev') if Rails.env.development?
|
|
|
|
dir = File.join(dir, 'canary') if Gitlab::Utils.to_boolean(ENV['CANARY'])
|
|
|
|
|
|
|
|
File.join(dir, "favicon_status_#{status_name}.ico")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-09-26 15:04:37 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
def appearance
|
2017-09-27 11:18:49 +00:00
|
|
|
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
|
2017-09-27 11:23:05 +00:00
|
|
|
|
|
|
|
# Without the '?' at the end of the favicon url the custom favicon (i.e.
|
|
|
|
# the favicons that are served through `UploadController`) are not shown
|
|
|
|
# in the browser.
|
|
|
|
def custom_favicon_url(url)
|
|
|
|
"#{url}?"
|
|
|
|
end
|
2017-09-26 15:04:37 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|