Class: Gitlab::Favicon

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/favicon.rb

Class Method Summary collapse

Class Method Details

.available_status_namesObject


36
37
38
39
40
41
42
# File 'lib/gitlab/favicon.rb', line 36

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

.development_faviconObject


21
22
23
24
25
# File 'lib/gitlab/favicon.rb', line 21

def development_favicon
  # This is a separate method so that EE can return a different favicon
  # for development environments.
  'favicon-blue.png'
end

.mainObject


6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/gitlab/favicon.rb', line 6

def main
  image_name =
    if appearance.favicon.exists?
      appearance.favicon_path
    elsif Gitlab.canary?
      'favicon-yellow.png'
    elsif Rails.env.development?
      development_favicon
    else
      'favicon.png'
    end

  ActionController::Base.helpers.image_path(image_name, host: host)
end

.status_overlay(status_name) ⇒ Object


27
28
29
30
31
32
33
34
# File 'lib/gitlab/favicon.rb', line 27

def status_overlay(status_name)
  path = File.join(
    'ci_favicons',
    "#{status_name}.png"
  )

  ActionController::Base.helpers.image_path(path, host: host)
end