2015-05-01 04:39:11 -04:00
|
|
|
module PageLayoutHelper
|
|
|
|
def page_title(*titles)
|
|
|
|
@page_title ||= []
|
|
|
|
|
|
|
|
@page_title.push(*titles.compact) if titles.any?
|
|
|
|
|
2015-12-02 08:57:51 -05:00
|
|
|
# Segments are seperated by middot
|
|
|
|
@page_title.join(" \u00b7 ")
|
2015-05-01 04:39:11 -04:00
|
|
|
end
|
|
|
|
|
2015-12-23 16:56:27 -05:00
|
|
|
# Define or get a description for the current page
|
|
|
|
#
|
|
|
|
# description - String (default: nil)
|
|
|
|
#
|
|
|
|
# If this helper is called multiple times with an argument, only the last
|
|
|
|
# description will be returned when called without an argument. Descriptions
|
|
|
|
# have newlines replaced with spaces and all HTML tags are sanitized.
|
|
|
|
#
|
|
|
|
# Examples:
|
|
|
|
#
|
|
|
|
# page_description # => "GitLab Community Edition"
|
|
|
|
# page_description("Foo")
|
|
|
|
# page_description # => "Foo"
|
|
|
|
#
|
|
|
|
# page_description("<b>Bar</b>\nBaz")
|
|
|
|
# page_description # => "Bar Baz"
|
|
|
|
#
|
|
|
|
# Returns an HTML-safe String.
|
|
|
|
def page_description(description = nil)
|
|
|
|
@page_description ||= page_description_default
|
|
|
|
|
|
|
|
if description.present?
|
|
|
|
@page_description = description
|
|
|
|
else
|
|
|
|
sanitize(@page_description.squish, tags: [])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Default value for page_description when one hasn't been defined manually by
|
|
|
|
# a view
|
|
|
|
def page_description_default
|
|
|
|
if @project
|
|
|
|
@project.description
|
|
|
|
else
|
|
|
|
brand_title
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def page_image
|
|
|
|
default = image_url('gitlab_logo.png')
|
|
|
|
|
|
|
|
if @project
|
|
|
|
@project.avatar_url || default
|
|
|
|
elsif @user
|
|
|
|
avatar_icon(@user)
|
|
|
|
else
|
|
|
|
default
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-05-01 04:39:11 -04:00
|
|
|
def header_title(title = nil, title_url = nil)
|
|
|
|
if title
|
|
|
|
@header_title = title
|
|
|
|
@header_title_url = title_url
|
|
|
|
else
|
|
|
|
@header_title_url ? link_to(@header_title, @header_title_url) : @header_title
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def sidebar(name = nil)
|
|
|
|
if name
|
|
|
|
@sidebar = name
|
|
|
|
else
|
|
|
|
@sidebar
|
|
|
|
end
|
|
|
|
end
|
2015-08-26 05:51:28 -04:00
|
|
|
|
|
|
|
def fluid_layout(enabled = false)
|
|
|
|
if @fluid_layout.nil?
|
2015-10-05 12:09:05 -04:00
|
|
|
@fluid_layout = (current_user && current_user.layout == "fluid") || enabled
|
2015-08-26 05:51:28 -04:00
|
|
|
else
|
|
|
|
@fluid_layout
|
|
|
|
end
|
|
|
|
end
|
2015-09-09 17:29:19 -04:00
|
|
|
|
|
|
|
def blank_container(enabled = false)
|
|
|
|
if @blank_container.nil?
|
|
|
|
@blank_container = enabled
|
|
|
|
else
|
|
|
|
@blank_container
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def container_class
|
|
|
|
css_class = "container-fluid"
|
|
|
|
|
2015-09-10 03:51:37 -04:00
|
|
|
unless fluid_layout
|
2015-09-09 17:29:19 -04:00
|
|
|
css_class += " container-limited"
|
|
|
|
end
|
|
|
|
|
|
|
|
if blank_container
|
|
|
|
css_class += " container-blank"
|
|
|
|
end
|
|
|
|
|
|
|
|
css_class
|
|
|
|
end
|
2015-05-01 04:39:11 -04:00
|
|
|
end
|