2018-08-18 07:19:57 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-07-11 10:16:44 -04:00
|
|
|
module AppearancesHelper
|
2019-02-20 10:18:15 -05:00
|
|
|
include MarkupHelper
|
2019-06-23 17:34:49 -04:00
|
|
|
include Gitlab::Utils::StrongMemoize
|
2019-02-20 10:18:15 -05:00
|
|
|
|
2014-07-11 08:05:40 -04:00
|
|
|
def brand_title
|
2018-12-06 11:14:12 -05:00
|
|
|
current_appearance&.title.presence || default_brand_title
|
|
|
|
end
|
|
|
|
|
|
|
|
def default_brand_title
|
|
|
|
# This resides in a separate method so that EE can easily redefine it.
|
|
|
|
'GitLab Community Edition'
|
2014-07-11 08:05:40 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def brand_image
|
2022-10-05 23:08:18 -04:00
|
|
|
image_tag(brand_image_path, alt: brand_title, class: 'gl-w-10')
|
|
|
|
end
|
|
|
|
|
|
|
|
def brand_image_path
|
|
|
|
return current_appearance.logo_path if current_appearance&.logo?
|
|
|
|
|
|
|
|
image_path('logo.svg')
|
2014-07-11 08:05:40 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def brand_text
|
2018-04-02 10:27:12 -04:00
|
|
|
markdown_field(current_appearance, :description)
|
2016-02-22 14:49:16 -05:00
|
|
|
end
|
|
|
|
|
2017-11-22 08:48:38 -05:00
|
|
|
def brand_new_project_guidelines
|
2018-04-02 10:27:12 -04:00
|
|
|
markdown_field(current_appearance, :new_project_guidelines)
|
2017-11-22 08:48:38 -05:00
|
|
|
end
|
|
|
|
|
2020-04-28 11:09:29 -04:00
|
|
|
def brand_profile_image_guidelines
|
|
|
|
markdown_field(current_appearance, :profile_image_guidelines)
|
|
|
|
end
|
|
|
|
|
2018-04-02 10:27:12 -04:00
|
|
|
def current_appearance
|
2019-06-23 17:34:49 -04:00
|
|
|
strong_memoize(:current_appearance) do
|
|
|
|
Appearance.current
|
|
|
|
end
|
2014-07-11 08:05:40 -04:00
|
|
|
end
|
2015-02-25 01:58:47 -05:00
|
|
|
|
2022-04-27 11:10:01 -04:00
|
|
|
def brand_header_logo(options = {})
|
|
|
|
add_gitlab_white_text = options[:add_gitlab_white_text] || false
|
|
|
|
add_gitlab_black_text = options[:add_gitlab_black_text] || false
|
|
|
|
|
2018-04-02 10:27:12 -04:00
|
|
|
if current_appearance&.header_logo?
|
2019-02-12 12:42:08 -05:00
|
|
|
image_tag current_appearance.header_logo_path, class: 'brand-header-logo'
|
2022-04-27 11:10:01 -04:00
|
|
|
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
|
2016-02-22 14:49:16 -05:00
|
|
|
else
|
2021-10-26 14:09:19 -04:00
|
|
|
render partial: 'shared/logo', formats: :svg
|
2016-02-22 14:49:16 -05:00
|
|
|
end
|
2015-02-25 01:58:47 -05:00
|
|
|
end
|
2017-11-15 16:31:17 -05:00
|
|
|
|
2018-04-02 10:26:59 -04:00
|
|
|
def header_message
|
|
|
|
return unless current_appearance&.show_header?
|
|
|
|
|
|
|
|
class_names = []
|
|
|
|
class_names << 'with-performance-bar' if performance_bar_enabled?
|
|
|
|
|
2019-02-20 10:18:15 -05:00
|
|
|
render_message(:header_message, class_names: class_names)
|
2018-04-02 10:26:59 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def footer_message
|
|
|
|
return unless current_appearance&.show_footer?
|
|
|
|
|
|
|
|
render_message(:footer_message)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2019-02-20 10:18:15 -05:00
|
|
|
def render_message(field_sym, class_names: [], style: message_style)
|
2018-04-02 10:26:59 -04:00
|
|
|
class_names << field_sym.to_s.dasherize
|
|
|
|
|
2019-02-20 10:18:15 -05:00
|
|
|
content_tag :div, class: class_names, style: style do
|
2018-04-02 10:26:59 -04:00
|
|
|
markdown_field(current_appearance, field_sym)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def message_style
|
|
|
|
style = []
|
|
|
|
style << "background-color: #{current_appearance.message_background_color};"
|
|
|
|
style << "color: #{current_appearance.message_font_color}"
|
|
|
|
style.join
|
|
|
|
end
|
2014-07-11 08:05:40 -04:00
|
|
|
end
|
2019-09-13 09:26:31 -04:00
|
|
|
|
2021-05-05 08:10:33 -04:00
|
|
|
AppearancesHelper.prepend_mod
|