debian-mirror-gitlab/app/helpers/appearances_helper.rb

87 lines
2 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2014-09-02 18:07:02 +05:30
module AppearancesHelper
2019-07-07 11:18:12 +05:30
include MarkupHelper
2019-09-30 21:07:59 +05:30
include Gitlab::Utils::StrongMemoize
2019-07-07 11:18:12 +05:30
2014-09-02 18:07:02 +05:30
def brand_title
2019-02-15 15:39:39 +05:30
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-09-02 18:07:02 +05:30
end
def brand_image
2019-02-15 15:39:39 +05:30
image_tag(current_appearance.logo_path) if current_appearance&.logo?
2014-09-02 18:07:02 +05:30
end
def brand_text
2018-05-09 12:01:36 +05:30
markdown_field(current_appearance, :description)
2016-04-02 18:10:28 +05:30
end
2018-03-17 18:26:18 +05:30
def brand_new_project_guidelines
2018-05-09 12:01:36 +05:30
markdown_field(current_appearance, :new_project_guidelines)
2018-03-17 18:26:18 +05:30
end
2020-05-24 23:13:21 +05:30
def brand_profile_image_guidelines
markdown_field(current_appearance, :profile_image_guidelines)
end
2018-05-09 12:01:36 +05:30
def current_appearance
2019-09-30 21:07:59 +05:30
strong_memoize(:current_appearance) do
Appearance.current
end
2014-09-02 18:07:02 +05:30
end
2015-04-26 12:48:37 +05:30
def brand_header_logo
2018-05-09 12:01:36 +05:30
if current_appearance&.header_logo?
2019-07-07 11:18:12 +05:30
image_tag current_appearance.header_logo_path, class: 'brand-header-logo'
2016-04-02 18:10:28 +05:30
else
render 'shared/logo.svg'
end
2015-04-26 12:48:37 +05:30
end
2018-03-17 18:26:18 +05:30
# Skip the 'GitLab' type logo when custom brand logo is set
def brand_header_logo_type
2018-05-09 12:01:36 +05:30
unless current_appearance&.header_logo?
2018-03-17 18:26:18 +05:30
render 'shared/logo_type.svg'
end
end
2019-07-07 11:18:12 +05:30
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
def footer_message
return unless current_appearance&.show_footer?
render_message(:footer_message)
end
private
def render_message(field_sym, class_names: [], style: message_style)
class_names << field_sym.to_s.dasherize
content_tag :div, class: class_names, style: style do
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-09-02 18:07:02 +05:30
end
2019-12-04 20:38:33 +05:30
2021-06-08 01:23:25 +05:30
AppearancesHelper.prepend_mod