Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
b66a26b6
Commit
b66a26b6
authored
Mar 14, 2018
by
Tiago Botelho
Committed by
André Luís
Mar 30, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add system header and footer options to the application appearances
parent
9ae9d46c
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
110 additions
and
4 deletions
+110
-4
app/controllers/admin/appearances_controller.rb
app/controllers/admin/appearances_controller.rb
+14
-4
app/helpers/appearances_helper.rb
app/helpers/appearances_helper.rb
+40
-0
app/models/appearance.rb
app/models/appearance.rb
+7
-0
app/views/admin/appearances/_form.html.haml
app/views/admin/appearances/_form.html.haml
+23
-0
app/views/layouts/_footer_message.html.haml
app/views/layouts/_footer_message.html.haml
+1
-0
app/views/layouts/_header_message.html.haml
app/views/layouts/_header_message.html.haml
+1
-0
app/views/layouts/application.html.haml
app/views/layouts/application.html.haml
+2
-0
db/migrate/20180314145917_add_header_and_footer_banners_to_appearances_table.rb
...917_add_header_and_footer_banners_to_appearances_table.rb
+16
-0
db/schema.rb
db/schema.rb
+6
-0
No files found.
app/controllers/admin/appearances_controller.rb
View file @
b66a26b6
...
...
@@ -50,9 +50,19 @@ class Admin::AppearancesController < Admin::ApplicationController
# Only allow a trusted parameter "white list" through.
def
appearance_params
params
.
require
(
:appearance
).
permit
(
:title
,
:description
,
:logo
,
:logo_cache
,
:header_logo
,
:header_logo_cache
,
:new_project_guidelines
,
:updated_by
)
params
.
require
(
:appearance
).
permit
(
%i(
title
description
logo
logo_cache
header_logo
header_logo_cache
new_project_guidelines
updated_by
header_message
footer_message
background_color
font_color
)
)
end
end
app/helpers/appearances_helper.rb
View file @
b66a26b6
module
AppearancesHelper
def
header_message
(
appearance
)
return
unless
appearance
.
header_message
.
present?
appearance_message
(
appearance
,
:header_message
)
end
def
footer_message
(
appearance
)
return
unless
appearance
.
footer_message
.
present?
appearance_message
(
appearance
,
:footer_message
)
end
def
appearance_message
(
appearance
,
field_sym
)
class_names
=
[
field_sym
.
to_s
.
dasherize
]
class_names
<<
'with-performance-bar'
if
performance_bar_enabled?
content_tag
:div
,
class:
class_names
,
style:
message_style
(
appearance
)
do
icon
(
'bullhorn'
)
<<
' '
<<
render_message
(
appearance
,
field_sym
)
end
end
def
message_style
(
appearance
)
style
=
''
if
appearance
.
background_color
.
present?
style
<<
"background-color:
#{
appearance
.
background_color
}
"
style
<<
'; '
if
appearance
.
font_color
.
present?
end
if
appearance
.
font_color
.
present?
style
<<
"color:
#{
appearance
.
font_color
}
"
end
style
end
def
render_message
(
appearance
,
field
)
Banzai
.
render_field
(
appearance
,
field
).
html_safe
end
def
brand_title
brand_item
&
.
title
.
presence
||
'GitLab Enterprise Edition'
end
...
...
app/models/appearance.rb
View file @
b66a26b6
...
...
@@ -5,12 +5,19 @@ class Appearance < ActiveRecord::Base
cache_markdown_field
:description
cache_markdown_field
:new_project_guidelines
cache_markdown_field
:header_message
cache_markdown_field
:footer_message
validates
:background_color
,
allow_blank:
true
,
color:
true
validates
:font_color
,
allow_blank:
true
,
color:
true
validates
:logo
,
file_size:
{
maximum:
1
.
megabyte
}
validates
:header_logo
,
file_size:
{
maximum:
1
.
megabyte
}
validate
:single_appearance_row
,
on: :create
default_value_for
:background_color
,
'#E75E40'
default_value_for
:font_color
,
'#FFFFFF'
mount_uploader
:logo
,
AttachmentUploader
mount_uploader
:header_logo
,
AttachmentUploader
...
...
app/views/admin/appearances/_form.html.haml
View file @
b66a26b6
...
...
@@ -18,6 +18,29 @@
.hint
Maximum file size is 1MB. Pages are optimized for a 28px tall header logo
%fieldset
.system_header_footer
%legend
System header and footer:
.form-group
=
f
.
label
:header_message
,
'Header message'
,
class:
'control-label'
.col-sm-10
=
f
.
text_area
:header_message
,
placeholder:
'State your message to activate'
,
class:
"form-control js-autosize"
.form-group
=
f
.
label
:footer_message
,
'Footer message'
,
class:
'control-label'
.col-sm-10
=
f
.
text_area
:footer_message
,
placeholder:
'State your message to activate'
,
class:
"form-control js-autosize"
.form-group.js-toggle-colors-container
.col-sm-10.col-sm-offset-2
=
link_to
'Customize colors'
,
'#'
,
class:
'js-toggle-colors-link'
.form-group.js-toggle-colors-container.hide
=
f
.
label
:background_color
,
"Background Color"
,
class:
'control-label'
.col-sm-10
=
f
.
color_field
:background_color
,
class:
"form-control"
.form-group.js-toggle-colors-container.hide
=
f
.
label
:font_color
,
"Font Color"
,
class:
'control-label'
.col-sm-10
=
f
.
color_field
:font_color
,
class:
"form-control"
%fieldset
.sign-in
%legend
Sign in/Sign up pages:
...
...
app/views/layouts/_footer_message.html.haml
0 → 100644
View file @
b66a26b6
=
footer_message
(
Appearance
.
current
)
app/views/layouts/_header_message.html.haml
0 → 100644
View file @
b66a26b6
=
header_message
(
Appearance
.
current
)
app/views/layouts/application.html.haml
View file @
b66a26b6
...
...
@@ -4,7 +4,9 @@
%body
{
class:
"#{user_application_theme} #{@body_class}"
,
data:
{
page:
body_data_page
,
project:
"#{@project.path if @project}"
,
group:
"#{@group.path if @group}"
,
find_file:
find_file_path
}
}
=
render
"layouts/init_auto_complete"
if
@gfm_form
=
render
'peek/bar'
=
render
"layouts/header_message"
=
render
"layouts/header/default"
=
render
'layouts/page'
,
sidebar:
sidebar
,
nav:
nav
=
render
"layouts/footer_message"
=
yield
:scripts_body
db/migrate/20180314145917_add_header_and_footer_banners_to_appearances_table.rb
0 → 100644
View file @
b66a26b6
class
AddHeaderAndFooterBannersToAppearancesTable
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
change
add_column
:appearances
,
:header_message
,
:text
add_column
:appearances
,
:header_message_html
,
:text
add_column
:appearances
,
:footer_message
,
:text
add_column
:appearances
,
:footer_message_html
,
:text
add_column
:appearances
,
:background_color
,
:text
add_column
:appearances
,
:font_color
,
:text
end
end
db/schema.rb
View file @
b66a26b6
...
...
@@ -39,6 +39,12 @@ ActiveRecord::Schema.define(version: 20180327101207) do
t
.
integer
"cached_markdown_version"
t
.
text
"new_project_guidelines"
t
.
text
"new_project_guidelines_html"
t
.
text
"header_message"
t
.
text
"header_message_html"
t
.
text
"footer_message"
t
.
text
"footer_message_html"
t
.
text
"background_color"
t
.
text
"font_color"
end
create_table
"application_settings"
,
force: :cascade
do
|
t
|
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment