blob: e28d4c6766144887354f3c783598572d7fa5787c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
module Gitlab
class Favicon
class << self
def main
return custom_favicon_url(appearance_favicon.favicon_main.url) if appearance_favicon.exists?
return 'favicon-yellow.ico' if Gitlab::Utils.to_boolean(ENV['CANARY'])
return 'favicon-blue.ico' if Rails.env.development?
'favicon.ico'
end
def status_overlay(status_name)
path = File.join(
'ci_favicons',
'overlays',
"#{status_name}.png"
)
ActionController::Base.helpers.image_path(path)
end
def available_status_overlays
available_status_names.map do |status_name|
status_overlay(status_name)
end
end
def available_status_names
@available_status_names ||= begin
Dir.glob(Rails.root.join('app', 'assets', 'images', 'ci_favicons', 'overlays', "*.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
# 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
end
end
end
|