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_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



33
34
35
36
37
38
39
# File 'app/helpers/appearances_helper.rb', line 33

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



25
26
27
# File 'app/helpers/appearances_helper.rb', line 25

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

#appearance_pwa_short_nameObject



29
30
31
# File 'app/helpers/appearances_helper.rb', line 29

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



78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'app/helpers/appearances_helper.rb', line 78

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

  if current_appearance&.header_logo?
    image_tag current_appearance.header_logo_path, class: 'brand-header-logo'
  elsif add_gitlab_white_text
    render partial: 'shared/logo_with_white_text', formats: :svg
  elsif add_gitlab_black_text
    render partial: 'shared/logo_with_black_text', formats: :svg
  else
    render partial: 'shared/logo', formats: :svg
  end
end

#brand_imageObject



46
47
48
# File 'app/helpers/appearances_helper.rb', line 46

def brand_image
  image_tag(brand_image_path, alt: brand_title, class: 'gl-w-10')
end

#brand_image_pathObject



50
51
52
53
54
# File 'app/helpers/appearances_helper.rb', line 50

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

  image_path('logo.svg')
end

#brand_new_project_guidelinesObject



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

def brand_new_project_guidelines
  markdown_field(current_appearance, :new_project_guidelines)
end

#brand_profile_image_guidelinesObject



68
69
70
# File 'app/helpers/appearances_helper.rb', line 68

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



72
73
74
75
76
# File 'app/helpers/appearances_helper.rb', line 72

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

#custom_sign_in_descriptionObject



56
57
58
59
60
61
62
# File 'app/helpers/appearances_helper.rb', line 56

def 
  [
    markdown_field(current_appearance, :description),
    markdown_field(Gitlab::CurrentSettings.current_application_settings, :sign_in_text),
    markdown(Gitlab::CurrentSettings.help_text)
  ].compact_blank.join("<br>").html_safe
end

#default_brand_titleObject



41
42
43
44
# File 'app/helpers/appearances_helper.rb', line 41

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


102
103
104
105
106
# File 'app/helpers/appearances_helper.rb', line 102

def footer_message
  return unless current_appearance&.show_footer?

  render_message(:footer_message)
end

#header_messageObject



93
94
95
96
97
98
99
100
# File 'app/helpers/appearances_helper.rb', line 93

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