Commit 84df1bb4 authored by Drew Blessing's avatar Drew Blessing

Custom header logo

parent bdac5ddd
v 7.7.0
- Added custom header logo support (Drew Blessing)
v 7.6.2 v 7.6.2
- Fix failing migrations for MySQL, LDAP - Fix failing migrations for MySQL, LDAP
......
...@@ -2,3 +2,11 @@ ...@@ -2,3 +2,11 @@
max-width: 400px; max-width: 400px;
margin-bottom: 20px; margin-bottom: 20px;
} }
.appearance-dark-logo-preview {
background-color: #F1F1F1;
}
.appearance-light-logo-preview {
background-color: #373737;
}
...@@ -34,6 +34,16 @@ class Admin::AppearancesController < Admin::ApplicationController ...@@ -34,6 +34,16 @@ class Admin::AppearancesController < Admin::ApplicationController
redirect_to admin_appearances_path, notice: 'Logo was succesfully removed.' redirect_to admin_appearances_path, notice: 'Logo was succesfully removed.'
end end
def header_logos
appearance = Appearance.last
appearance.remove_light_logo!
appearance.remove_dark_logo!
appearance.save
redirect_to admin_appearances_path, notice: 'Header logos were succesfully removed.'
end
private private
# Use callbacks to share common setup or constraints between actions. # Use callbacks to share common setup or constraints between actions.
...@@ -43,6 +53,7 @@ class Admin::AppearancesController < Admin::ApplicationController ...@@ -43,6 +53,7 @@ class Admin::AppearancesController < Admin::ApplicationController
# Only allow a trusted parameter "white list" through. # Only allow a trusted parameter "white list" through.
def appearance_params def appearance_params
params.require(:appearance).permit(:title, :description, :logo, :updated_by) params.require(:appearance).permit(:title, :description, :logo,
:dark_logo, :light_logo, :updated_by)
end end
end end
...@@ -15,6 +15,21 @@ module AppearancesHelper ...@@ -15,6 +15,21 @@ module AppearancesHelper
end end
end end
def brand_header_logo
if brand_item.header_logos?
haml_tag(:style) do
# Dark theme/light logo
haml_concat ".dark_theme .app_logo a h1 {" \
"background: url('#{brand_item.light_logo}') " \
"no-repeat center center !important; }"
# Light theme/dark logo
haml_concat ".light_theme .app_logo a h1 {" \
"background: url('#{brand_item.dark_logo}') " \
"no-repeat center center !important; }"
end
end
end
def brand_text def brand_text
markdown(brand_item.description) markdown(brand_item.description)
end end
......
...@@ -2,6 +2,16 @@ class Appearance < ActiveRecord::Base ...@@ -2,6 +2,16 @@ class Appearance < ActiveRecord::Base
validates :title, presence: true validates :title, presence: true
validates :description, presence: true validates :description, presence: true
validates :logo, file_size: { maximum: 1000.kilobytes.to_i } validates :logo, file_size: { maximum: 1000.kilobytes.to_i }
validates :dark_logo, file_size: { maximum: 1000.kilobytes.to_i },
presence: true, if: :light_logo?
validates :light_logo, file_size: { maximum: 1000.kilobytes.to_i },
presence: true, if: :dark_logo?
mount_uploader :logo, AttachmentUploader mount_uploader :logo, AttachmentUploader
mount_uploader :dark_logo, AttachmentUploader
mount_uploader :light_logo, AttachmentUploader
def header_logos?
dark_logo? && light_logo?
end
end end
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
- @appearance.errors.full_messages.each do |msg| - @appearance.errors.full_messages.each do |msg|
%p= msg %p= msg
%fieldset.sign-in
%legend
Sign in/Sign up pages:
.form-group .form-group
= f.label :title, class: 'control-label' = f.label :title, class: 'control-label'
.col-sm-10 .col-sm-10
...@@ -25,6 +28,30 @@ ...@@ -25,6 +28,30 @@
= f.file_field :logo, class: "" = f.file_field :logo, class: ""
.hint .hint
Maximum logo size is 1MB, page optimized for logo size 640x360px Maximum logo size is 1MB, page optimized for logo size 640x360px
%fieldset.app_logo
%legend
Navigation bar:
.form-group
= f.label :dark_logo, class: 'control-label'
.col-sm-10
- if @appearance.dark_logo?
= image_tag @appearance.dark_logo, class: 'appearance-dark-logo-preview'
= f.file_field :dark_logo, class: ""
.hint
Maximum size is 1MB, page optimized for logo size 40x40px
= f.label :light_logo, class: 'control-label'
.col-sm-10
- if @appearance.light_logo?
= image_tag @appearance.light_logo, class: 'appearance-light-logo-preview'
= f.file_field :light_logo, class: ""
.hint
Maximum size is 1MB, page optimized for logo size 41x41px
-if @appearance.light_logo? || @appearance.dark_logo?
%br
= link_to 'Remove header logos', header_logos_admin_appearances_path, data: { confirm: "Header logos will be removed. Are you sure?"}, method: :delete, class: "btn btn-remove btn-small remove-logo"
.form-actions .form-actions
= f.submit 'Save', class: 'btn btn-save' = f.submit 'Save', class: 'btn btn-save'
= link_to 'Preview', preview_admin_appearances_path, class: 'btn', target: '_blank' = link_to 'Preview', preview_admin_appearances_path, class: 'btn', target: '_blank'
......
%h3.page-title %h3.page-title
Appearance settings Appearance settings
%p.light %p.light
You can modify look of sign-in and sign-up pages here You can modify the look and feel of GitLab here
%hr
= render 'form' = render 'form'
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
.navbar-inner .navbar-inner
.container .container
%div.app_logo %div.app_logo
- brand_header_logo if brand_item
= link_to root_path, class: "home has_bottom_tooltip", title: "Dashboard" do = link_to root_path, class: "home has_bottom_tooltip", title: "Dashboard" do
%h1 GITLAB %h1 GITLAB
%h1.title= title %h1.title= title
......
...@@ -114,6 +114,7 @@ Gitlab::Application.routes.draw do ...@@ -114,6 +114,7 @@ Gitlab::Application.routes.draw do
member do member do
get :preview get :preview
delete :logo delete :logo
delete :header_logos
end end
end end
......
class AddHeaderLogosToAppearances < ActiveRecord::Migration
def change
add_column :appearances, :dark_logo, :string
add_column :appearances, :light_logo, :string
end
end
...@@ -23,6 +23,8 @@ ActiveRecord::Schema.define(version: 20141217125223) do ...@@ -23,6 +23,8 @@ ActiveRecord::Schema.define(version: 20141217125223) do
t.integer "updated_by" t.integer "updated_by"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "dark_logo"
t.string "light_logo"
end end
create_table "audit_events", force: true do |t| create_table "audit_events", force: true do |t|
...@@ -369,8 +371,8 @@ ActiveRecord::Schema.define(version: 20141217125223) do ...@@ -369,8 +371,8 @@ ActiveRecord::Schema.define(version: 20141217125223) do
t.boolean "archived", default: false, null: false t.boolean "archived", default: false, null: false
t.string "import_status" t.string "import_status"
t.float "repository_size", default: 0.0 t.float "repository_size", default: 0.0
t.text "merge_requests_template"
t.integer "star_count", default: 0, null: false t.integer "star_count", default: 0, null: false
t.text "merge_requests_template"
t.boolean "merge_requests_rebase_enabled", default: false t.boolean "merge_requests_rebase_enabled", default: false
end end
......
...@@ -26,3 +26,12 @@ Feature: Admin Appearance ...@@ -26,3 +26,12 @@ Feature: Admin Appearance
Then I should see a logo Then I should see a logo
And I remove the logo And I remove the logo
Then I should see logo removed Then I should see logo removed
Scenario: Header logos
Given application has custom appearance
And I sign in as an admin
And I visit admin appearance page
When I attach header logos
Then I should see header logos
And I remove the header logos
Then I should see header logos removed
...@@ -37,18 +37,38 @@ class Spinach::Features::AdminAppearance < Spinach::FeatureSteps ...@@ -37,18 +37,38 @@ class Spinach::Features::AdminAppearance < Spinach::FeatureSteps
click_button 'Save' click_button 'Save'
end end
step 'I attach header logos' do
attach_file(:appearance_light_logo, File.join(Rails.root, 'public', 'header_logo_light.png'))
attach_file(:appearance_dark_logo, File.join(Rails.root, 'public', 'header_logo_dark.png'))
click_button 'Save'
end
step 'I should see a logo' do step 'I should see a logo' do
page.should have_xpath('//img[@src="/uploads/appearance/logo/1/gitlab_logo.png"]') page.should have_xpath('//img[@src="/uploads/appearance/logo/1/gitlab_logo.png"]')
end end
step 'I should see header logos' do
page.should have_xpath('//img[@src="/uploads/appearance/light_logo/1/header_logo_light.png"]')
page.should have_xpath('//img[@src="/uploads/appearance/dark_logo/1/header_logo_dark.png"]')
end
step 'I remove the logo' do step 'I remove the logo' do
click_link 'Remove logo' click_link 'Remove logo'
end end
step 'I remove the header logos' do
click_link 'Remove header logos'
end
step 'I should see logo removed' do step 'I should see logo removed' do
page.should_not have_xpath('//img[@src="/uploads/appearance/logo/1/gitlab_logo.png"]') page.should_not have_xpath('//img[@src="/uploads/appearance/logo/1/gitlab_logo.png"]')
end end
step 'I should see header logos removed' do
page.should_not have_xpath('//img[@src="/uploads/appearance/light_logo/1/header_logo_light.png"]')
page.should_not have_xpath('//img[@src="/uploads/appearance/dark_logo/1/header_logo_dark.png"]')
end
def appearance def appearance
Appearance.last Appearance.last
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment