mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-22 19:16:39 +10:00
Merge branch 'brand-sign-in' into 'master'
Brand sign in Allows customise of login screen for admin users. Fixes #66.
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
v 6.8.0
|
||||
- Customise sign-in page with custom text and logo
|
||||
|
||||
v 6.7.1
|
||||
- Handle LDAP errors in Adapter#dn_matches_filter?
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 62 KiB |
@@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
||||
@@ -72,6 +72,7 @@
|
||||
@import "sections/dashboard.scss";
|
||||
@import "sections/stat_graph.scss";
|
||||
@import "sections/groups.scss";
|
||||
@import "sections/appearances.scss";
|
||||
|
||||
/**
|
||||
* Code highlight
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
.appearance-logo-preview {
|
||||
max-width: 400px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
@@ -5,12 +5,19 @@
|
||||
font-weight: 200;
|
||||
}
|
||||
|
||||
.login-box{
|
||||
max-width: 304px;
|
||||
.login-box {
|
||||
position: relative;
|
||||
@include border-radius(5px);
|
||||
margin: auto;
|
||||
background: white;
|
||||
padding: 20px;
|
||||
background: #f5f5f5;
|
||||
border: 1px solid #EEE;
|
||||
}
|
||||
|
||||
.brand-image {
|
||||
margin-bottom: 20px;
|
||||
img {
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.login-logo{
|
||||
@@ -19,7 +26,7 @@
|
||||
}
|
||||
|
||||
.form-control {
|
||||
background-color: #f1f1f1;
|
||||
background-color: #FFF;
|
||||
font-size: 16px;
|
||||
padding: 14px 10px;
|
||||
width: 100%;
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
class Admin::AppearancesController < Admin::ApplicationController
|
||||
before_filter :set_appearance, except: :create
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def preview
|
||||
end
|
||||
|
||||
def create
|
||||
@appearance = Appearance.new(appearance_params)
|
||||
|
||||
if @appearance.save
|
||||
redirect_to admin_appearances_path, notice: 'Appearance was successfully created.'
|
||||
else
|
||||
render action: 'show'
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if @appearance.update(appearance_params)
|
||||
redirect_to admin_appearances_path, notice: 'Appearance was successfully updated.'
|
||||
else
|
||||
render action: 'show'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_appearance
|
||||
@appearance = Appearance.last || Appearance.new
|
||||
end
|
||||
|
||||
# Only allow a trusted parameter "white list" through.
|
||||
def appearance_params
|
||||
params.require(:appearance).permit(:title, :description, :logo, :updated_by)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,45 @@
|
||||
module AppearancesHelper
|
||||
def brand_title
|
||||
if brand_item
|
||||
brand_item.title
|
||||
else
|
||||
'GitLab Enterprise Edition'
|
||||
end
|
||||
end
|
||||
|
||||
def brand_image
|
||||
logo = if brand_item
|
||||
brand_item.logo
|
||||
else
|
||||
'brand_logo.png'
|
||||
end
|
||||
|
||||
image_tag logo
|
||||
end
|
||||
|
||||
def brand_text
|
||||
default_text =<<eos
|
||||
### GitLab is open source software to collaborate on code.
|
||||
|
||||
Manage git repositories with fine grained access controls that keep your code secure.
|
||||
Perform code reviews and enhance collaboration with merge requests.
|
||||
Each project can also have an issue tracker and a wiki.
|
||||
|
||||
Used by more than 50,000 organizations, GitLab is the most popular solution to manage git repositories on-premises.
|
||||
Read more about GitLab at #{link_to "www.gitlab.com", "https://www.gitlab.com/", target: "_blank"}.
|
||||
eos
|
||||
|
||||
|
||||
text = if brand_item
|
||||
brand_item.description
|
||||
else
|
||||
default_text
|
||||
end
|
||||
|
||||
markdown text
|
||||
end
|
||||
|
||||
def brand_item
|
||||
@appearance ||= Appearance.first
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
class Appearance < ActiveRecord::Base
|
||||
attr_accessible :title, :description, :logo
|
||||
|
||||
validates :title, presence: true
|
||||
validates :description, presence: true
|
||||
validates :logo, file_size: { maximum: 1000.kilobytes.to_i }
|
||||
|
||||
mount_uploader :logo, AttachmentUploader
|
||||
end
|
||||
@@ -0,0 +1,31 @@
|
||||
= form_for @appearance, url: admin_appearances_path, html: { class: 'form-horizontal'} do |f|
|
||||
- if @appearance.errors.any?
|
||||
.alert.alert-danger
|
||||
- @appearance.errors.full_messages.each do |msg|
|
||||
%p= msg
|
||||
|
||||
.form-group
|
||||
= f.label :title, class: 'control-label'
|
||||
.col-sm-10
|
||||
= f.text_field :title, class: "form-control"
|
||||
.form-group
|
||||
= f.label :description, class: 'control-label'
|
||||
.col-sm-10
|
||||
= f.text_area :description, class: "form-control", rows: 10
|
||||
.hint
|
||||
Description parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}.
|
||||
.form-group
|
||||
= f.label :logo, class: 'control-label'
|
||||
.col-sm-10
|
||||
- if @appearance.logo
|
||||
= image_tag @appearance.logo, class: 'appearance-logo-preview'
|
||||
= f.file_field :logo, class: ""
|
||||
.hint
|
||||
Maximum logo size is 1MB, page optimized for logo size 640x360px
|
||||
.form-actions
|
||||
= f.submit 'Save', class: 'btn btn-save'
|
||||
= link_to 'Preview', preview_admin_appearances_path, class: 'btn', target: '_blank'
|
||||
|
||||
- if @appearance.updated_at
|
||||
%span.pull-right
|
||||
Last edit #{time_ago_with_tooltip(@appearance.updated_at)}
|
||||
@@ -0,0 +1,28 @@
|
||||
%h3.page-title
|
||||
Appearance settings - Preview
|
||||
%hr
|
||||
|
||||
.ui-box
|
||||
.title
|
||||
Sign-in page
|
||||
%div
|
||||
.login-page
|
||||
.container
|
||||
.content
|
||||
.login-title
|
||||
%h1= brand_title
|
||||
%hr
|
||||
.container
|
||||
.content
|
||||
.row
|
||||
.col-sm-7
|
||||
.brand-image
|
||||
= brand_image
|
||||
.brand_text
|
||||
= brand_text
|
||||
.col-sm-4
|
||||
.login-box
|
||||
%h3.page-title Sign in
|
||||
= text_field_tag :login, nil, class: "form-control top", placeholder: "Username or Email"
|
||||
= password_field_tag :password, nil, class: "form-control bottom", placeholder: "Password"
|
||||
= button_tag "Sign in", class: "btn-create btn"
|
||||
@@ -0,0 +1,8 @@
|
||||
%h3.page-title
|
||||
Appearance settings
|
||||
%p.light
|
||||
You can modify look of sign-in and sign-up pages here
|
||||
|
||||
%hr
|
||||
|
||||
= render 'form'
|
||||
@@ -5,15 +5,16 @@
|
||||
= render "layouts/flash"
|
||||
.container
|
||||
.content
|
||||
%center
|
||||
%h1 GitLab
|
||||
%p.light
|
||||
GitLab is open source software to collaborate on code.
|
||||
%br
|
||||
#{link_to "Sign in", new_user_session_path} or browse for #{link_to "public projects", public_projects_path}.
|
||||
.login-title
|
||||
%h1= brand_title
|
||||
%hr
|
||||
.container
|
||||
.content
|
||||
= yield
|
||||
%center.prepend-top-20
|
||||
%h6 Enterprise Edition
|
||||
.row
|
||||
.col-sm-7
|
||||
.brand-image
|
||||
= brand_image
|
||||
.brand_text
|
||||
= brand_text
|
||||
.col-sm-5
|
||||
= yield
|
||||
|
||||
@@ -16,4 +16,5 @@
|
||||
= link_to "Hooks", admin_hooks_path
|
||||
= nav_link(controller: :background_jobs) do
|
||||
= link_to "Background Jobs", admin_background_jobs_path
|
||||
|
||||
= nav_link(controller: :appearances) do
|
||||
= link_to "Appearance", admin_appearances_path
|
||||
|
||||
@@ -100,6 +100,12 @@ Gitlab::Application.routes.draw do
|
||||
end
|
||||
end
|
||||
|
||||
resource :appearances do
|
||||
member do
|
||||
get :preview
|
||||
end
|
||||
end
|
||||
|
||||
root to: "dashboard#index"
|
||||
end
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
class CreateAppearances < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :appearances do |t|
|
||||
t.string :title
|
||||
t.text :description
|
||||
t.string :logo
|
||||
t.integer :updated_by
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
+10
-1
@@ -11,11 +11,20 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20140407135544) do
|
||||
ActiveRecord::Schema.define(version: 20140414093351) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
create_table "appearances", force: true do |t|
|
||||
t.string "title"
|
||||
t.text "description"
|
||||
t.string "logo"
|
||||
t.integer "updated_by"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "broadcast_messages", force: true do |t|
|
||||
t.text "message", null: false
|
||||
t.datetime "starts_at"
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
Feature: Admin Appearance
|
||||
Scenario: Create new appearance
|
||||
Given I sign in as an admin
|
||||
And I visit admin appearance page
|
||||
When submit form with new appearance
|
||||
Then I should be redirected to admin appearance page
|
||||
And I should see newly created appearance
|
||||
|
||||
Scenario: Preview appearance
|
||||
Given application has custom appearance
|
||||
And I sign in as an admin
|
||||
When I visit admin appearance page
|
||||
And I click preview button
|
||||
Then I should see a customized appearance
|
||||
|
||||
Scenario: Custom sign-in page
|
||||
Given application has custom appearance
|
||||
When I visit login page
|
||||
Then I should see a customized appearance
|
||||
@@ -0,0 +1,38 @@
|
||||
class Spinach::Features::AdminAppearance < Spinach::FeatureSteps
|
||||
include SharedAuthentication
|
||||
include SharedPaths
|
||||
|
||||
step 'submit form with new appearance' do
|
||||
fill_in 'appearance_title', with: 'MyCompany'
|
||||
fill_in 'appearance_description', with: 'dev server'
|
||||
click_button 'Save'
|
||||
end
|
||||
|
||||
step 'I should be redirected to admin appearance page' do
|
||||
current_path.should == admin_appearances_path
|
||||
page.should have_content 'Appearance settings'
|
||||
end
|
||||
|
||||
step 'I should see newly created appearance' do
|
||||
page.should have_field('appearance_title', with: 'MyCompany')
|
||||
page.should have_field('appearance_description', with: 'dev server')
|
||||
page.should have_content 'Last edit'
|
||||
end
|
||||
|
||||
step 'I click preview button' do
|
||||
click_link "Preview"
|
||||
end
|
||||
|
||||
step 'application has custom appearance' do
|
||||
create(:appearance)
|
||||
end
|
||||
|
||||
step 'I should see a customized appearance' do
|
||||
page.should have_content appearance.title
|
||||
page.should have_content appearance.description
|
||||
end
|
||||
|
||||
def appearance
|
||||
Appearance.last
|
||||
end
|
||||
end
|
||||
@@ -5,6 +5,10 @@ module SharedPaths
|
||||
visit new_project_path
|
||||
end
|
||||
|
||||
step 'I visit login page' do
|
||||
visit new_user_session_path
|
||||
end
|
||||
|
||||
# ----------------------------------------
|
||||
# User
|
||||
# ----------------------------------------
|
||||
@@ -157,6 +161,10 @@ module SharedPaths
|
||||
visit admin_groups_path
|
||||
end
|
||||
|
||||
step 'I visit admin appearance page' do
|
||||
visit admin_appearances_path
|
||||
end
|
||||
|
||||
step 'I visit admin teams page' do
|
||||
visit admin_teams_path
|
||||
end
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||
|
||||
FactoryGirl.define do
|
||||
factory :appearance do
|
||||
title "GitLab Enterprise Edition"
|
||||
description "Open source software to collaborate on code"
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Appearance do
|
||||
subject { create(:appearance) }
|
||||
|
||||
it { should be_valid }
|
||||
end
|
||||
Reference in New Issue
Block a user