GitLab steht wegen Wartungsarbeiten am Montag, den 10. Mai, zwischen 17:00 und 19:00 Uhr nicht zur Verfügung.

appearances_helper.rb 1.76 KB
Newer Older
1 2
# frozen_string_literal: true

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
3
module AppearancesHelper
4
  def brand_title
5 6 7 8 9 10
    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'
11 12 13
  end

  def brand_image
14
    image_tag(current_appearance.logo_path) if current_appearance&.logo?
15 16 17
  end

  def brand_text
18
    markdown_field(current_appearance, :description)
19 20
  end

21
  def brand_new_project_guidelines
22
    markdown_field(current_appearance, :new_project_guidelines)
23 24
  end

25
  def current_appearance
26
    @appearance ||= Appearance.current
27
  end
28 29

  def brand_header_logo
30
    if current_appearance&.header_logo?
31
      image_tag current_appearance.header_logo_path, class: 'brand-header-logo'
32 33 34
    else
      render 'shared/logo.svg'
    end
35
  end
36 37 38

  # Skip the 'GitLab' type logo when custom brand logo is set
  def brand_header_logo_type
39
    unless current_appearance&.header_logo?
40 41 42
      render 'shared/logo_type.svg'
    end
  end
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

  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)
  end

  def footer_message
    return unless current_appearance&.show_footer?

    render_message(:footer_message)
  end

  private

  def render_message(field_sym, class_names = [])
    class_names << field_sym.to_s.dasherize

    content_tag :div, class: class_names, style: message_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
75
end