Module: AppearancesHelper

Includes:
Gitlab::Utils::StrongMemoize, MarkupHelper
Included in:
EmailsHelper
Defined in:
app/helpers/appearances_helper.rb

Instance Method Summary collapse

Methods included from MarkupHelper

#cross_project_reference, #first_line_in_markdown, #link_to_html, #link_to_markdown, #link_to_markdown_field, #markdown, #markdown_field, #markup, #render_wiki_content

Instance Method Details

#appearance_apple_touch_iconObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/helpers/appearances_helper.rb', line 25

def appearance_apple_touch_icon
  link_tags = favicon_link_tag('apple-touch-icon.png', rel: 'apple-touch-icon')

  return link_tags unless current_appearance&.pwa_icon.present?

  link_tags = favicon_link_tag(
    appearance_pwa_icon_path_scaled(Appearance::ALLOWED_PWA_ICON_SCALER_WIDTHS.first),
    rel: 'apple-touch-icon'
  )

  Appearance::ALLOWED_PWA_ICON_SCALER_WIDTHS.each do |width|
    link_tags += "\n"
    link_tags += favicon_link_tag(appearance_pwa_icon_path_scaled(width),
      sizes: "#{width}x#{width}", rel: 'apple-touch-icon')
  end

  link_tags
end

#appearance_maskable_logoObject



13
14
15
# File 'app/helpers/appearances_helper.rb', line 13

def 
  append_root_path('/-/pwa-icons/maskable-logo.png')
end

#appearance_pwa_descriptionObject



52
53
54
55
56
57
58
# File 'app/helpers/appearances_helper.rb', line 52

def appearance_pwa_description
  current_appearance&.pwa_description.presence ||
    _("The complete DevOps platform. " \
      "One application with endless possibilities. " \
      "Organizations rely on GitLab’s source code management, " \
      "CI/CD, security, and more to deliver software rapidly.")
end

#appearance_pwa_icon_path_scaled(width) ⇒ Object



7
8
9
10
11
# File 'app/helpers/appearances_helper.rb', line 7

def appearance_pwa_icon_path_scaled(width)
  return unless Appearance::ALLOWED_PWA_ICON_SCALER_WIDTHS.include?(width)

  append_root_path((current_appearance&.pwa_icon_path_scaled(width) || "/-/pwa-icons/logo-#{width}.png"))
end

#appearance_pwa_nameObject



44
45
46
# File 'app/helpers/appearances_helper.rb', line 44

def appearance_pwa_name
  current_appearance&.pwa_name.presence || _('GitLab')
end

#appearance_pwa_short_nameObject



48
49
50
# File 'app/helpers/appearances_helper.rb', line 48

def appearance_pwa_short_name
  current_appearance&.pwa_short_name.presence || _('GitLab')
end

#append_root_path(path) ⇒ Object



17
18
19
# File 'app/helpers/appearances_helper.rb', line 17

def append_root_path(path)
  Gitlab::Utils.append_path(Gitlab.config.gitlab.relative_url_root, path)
end

#brand_header_logo(options = {}) ⇒ Object



97
98
99
100
101
102
103
104
105
106
107
# File 'app/helpers/appearances_helper.rb', line 97

def (options = {})
  add_gitlab_logo_text = options[:add_gitlab_logo_text] || false

  if current_appearance&.header_logo?
    image_tag current_appearance.header_logo_path, class: 'brand-header-logo', alt: ''
  elsif add_gitlab_logo_text
    render partial: 'shared/logo_with_text', formats: :svg
  else
    render partial: 'shared/logo', formats: :svg
  end
end

#brand_imageObject



65
66
67
# File 'app/helpers/appearances_helper.rb', line 65

def brand_image
  image_tag(brand_image_path, alt: brand_title, class: 'gl-invisible gl-h-10 js-portrait-logo-detection')
end

#brand_image_pathObject



69
70
71
72
73
# File 'app/helpers/appearances_helper.rb', line 69

def brand_image_path
  return current_appearance.logo_path if current_appearance&.logo?

  image_path('logo.svg')
end

#brand_member_guidelinesObject



79
80
81
# File 'app/helpers/appearances_helper.rb', line 79

def brand_member_guidelines
  markdown_field(current_appearance, :member_guidelines)
end

#brand_new_project_guidelinesObject



83
84
85
# File 'app/helpers/appearances_helper.rb', line 83

def brand_new_project_guidelines
  markdown_field(current_appearance, :new_project_guidelines)
end

#brand_profile_image_guidelinesObject



87
88
89
# File 'app/helpers/appearances_helper.rb', line 87

def brand_profile_image_guidelines
  markdown_field(current_appearance, :profile_image_guidelines)
end

#brand_titleObject



21
22
23
# File 'app/helpers/appearances_helper.rb', line 21

def brand_title
  current_appearance&.title.presence || default_brand_title
end

#current_appearanceObject



91
92
93
94
95
# File 'app/helpers/appearances_helper.rb', line 91

def current_appearance
  strong_memoize(:current_appearance) do
    Appearance.current
  end
end

#custom_sign_in_descriptionObject



75
76
77
# File 'app/helpers/appearances_helper.rb', line 75

def 
  markdown_field(current_appearance, :description)
end

#default_brand_titleObject



60
61
62
63
# File 'app/helpers/appearances_helper.rb', line 60

def default_brand_title
  # This resides in a separate method so that EE can easily redefine it.
  _('GitLab Community Edition')
end


118
119
120
121
122
# File 'app/helpers/appearances_helper.rb', line 118

def footer_message
  return unless current_appearance&.show_footer?

  render_message(:footer_message)
end

#header_messageObject



109
110
111
112
113
114
115
116
# File 'app/helpers/appearances_helper.rb', line 109

def header_message
  return unless current_appearance&.show_header?

  class_names = []
  class_names << 'with-performance-bar' if performance_bar_enabled?

  render_message(:header_message, class_names: class_names)
end