BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
acc33668
Commit
acc33668
authored
Jan 17, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'configure-home-page' into 'master'
Allow to specify home page for non logged-in users See merge request !1404
parents
ada6c608
f2eb234c
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
39 additions
and
12 deletions
+39
-12
application_settings_controller.rb
app/controllers/admin/application_settings_controller.rb
+1
-0
application_controller.rb
app/controllers/application_controller.rb
+11
-0
application_helper.rb
app/helpers/application_helper.rb
+0
-5
application_setting.rb
app/models/application_setting.rb
+8
-0
_form.html.haml
app/views/admin/application_settings/_form.html.haml
+5
-0
devise.html.haml
app/views/layouts/devise.html.haml
+1
-2
20150116234544_add_home_page_url_for_application_settings.rb
...50116234544_add_home_page_url_for_application_settings.rb
+5
-0
schema.rb
db/schema.rb
+2
-1
settings.feature
features/admin/settings.feature
+2
-2
settings.rb
features/steps/admin/settings.rb
+4
-2
No files found.
app/controllers/admin/application_settings_controller.rb
View file @
acc33668
...
...
@@ -26,6 +26,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
:signin_enabled
,
:gravatar_enabled
,
:sign_in_text
,
:home_page_url
)
end
end
app/controllers/application_controller.rb
View file @
acc33668
...
...
@@ -48,6 +48,17 @@ class ApplicationController < ActionController::Base
end
end
def
authenticate_user!
(
*
args
)
# If user is not signe-in and tries to access root_path - redirect him to landing page
if
current_application_settings
.
home_page_url
.
present?
if
current_user
.
nil?
&&
controller_name
==
'dashboard'
&&
action_name
==
'show'
redirect_to
current_application_settings
.
home_page_url
and
return
end
end
super
(
*
args
)
end
def
log_exception
(
exception
)
application_trace
=
ActionDispatch
::
ExceptionWrapper
.
new
(
env
,
exception
).
application_trace
application_trace
.
map!
{
|
t
|
"
#{
t
}
\n
"
}
...
...
app/helpers/application_helper.rb
View file @
acc33668
...
...
@@ -292,9 +292,4 @@ module ApplicationHelper
profile_key_path
(
key
)
end
end
def
redirect_from_root?
request
.
env
[
'rack.session'
][
'user_return_to'
]
==
'/'
end
end
app/models/application_setting.rb
View file @
acc33668
class
ApplicationSetting
<
ActiveRecord
::
Base
validates
:home_page_url
,
allow_blank:
true
,
format:
{
with:
URI
::
regexp
(
%w(http https)
),
message:
"should be a valid url"
},
if: :home_page_url_column_exist
def
self
.
current
ApplicationSetting
.
last
end
...
...
@@ -12,4 +16,8 @@ class ApplicationSetting < ActiveRecord::Base
sign_in_text:
Settings
.
extra
[
'sign_in_text'
],
)
end
def
home_page_url_column_exist
ActiveRecord
::
Base
.
connection
.
column_exists?
(
:application_settings
,
:home_page_url
)
end
end
app/views/admin/application_settings/_form.html.haml
View file @
acc33668
...
...
@@ -26,6 +26,11 @@
.col-sm-10
=
f
.
number_field
:default_projects_limit
,
class:
'form-control'
.form-group
=
f
.
label
:home_page_url
,
class:
'control-label'
.col-sm-10
=
f
.
text_field
:home_page_url
,
class:
'form-control'
,
placeholder:
'http://company.example.com'
%span
.help-block
We will redirect non-logged in users to this page
.form-group
=
f
.
label
:sign_in_text
,
class:
'control-label'
.col-sm-10
=
f
.
text_area
:sign_in_text
,
class:
'form-control'
...
...
app/views/layouts/devise.html.haml
View file @
acc33668
...
...
@@ -6,8 +6,7 @@
=
render
"layouts/public_head_panel"
,
title:
''
.container.navless-container
.content
-
unless
redirect_from_root?
=
render
"layouts/flash"
=
render
"layouts/flash"
.row.prepend-top-20
.col-sm-5.pull-right
=
yield
...
...
db/migrate/20150116234544_add_home_page_url_for_application_settings.rb
0 → 100644
View file @
acc33668
class
AddHomePageUrlForApplicationSettings
<
ActiveRecord
::
Migration
def
change
add_column
:application_settings
,
:home_page_url
,
:string
end
end
db/schema.rb
View file @
acc33668
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201501
08073740
)
do
ActiveRecord
::
Schema
.
define
(
version:
201501
16234544
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -24,6 +24,7 @@ ActiveRecord::Schema.define(version: 20150108073740) do
t
.
text
"sign_in_text"
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
t
.
string
"home_page_url"
end
create_table
"broadcast_messages"
,
force:
true
do
|
t
|
...
...
features/admin/settings.feature
View file @
acc33668
...
...
@@ -5,5 +5,5 @@ Feature: Admin Settings
And
I visit admin settings page
Scenario
:
Change application settings
When
I
disable gravatar
s and save form
Then
I should
be see gravatar disabl
ed
When
I
modify setting
s and save form
Then
I should
see application settings sav
ed
features/steps/admin/settings.rb
View file @
acc33668
...
...
@@ -4,13 +4,15 @@ class Spinach::Features::AdminSettings < Spinach::FeatureSteps
include
SharedAdmin
include
Gitlab
::
CurrentSettings
step
'I
disable gravatar
s and save form'
do
step
'I
modify setting
s and save form'
do
uncheck
'Gravatar enabled'
fill_in
'Home page url'
,
with:
'https://about.gitlab.com/'
click_button
'Save'
end
step
'I should
be see gravatar disabl
ed'
do
step
'I should
see application settings sav
ed'
do
current_application_settings
.
gravatar_enabled
.
should
be_false
current_application_settings
.
home_page_url
.
should
==
'https://about.gitlab.com/'
page
.
should
have_content
'Application settings saved successfully'
end
end
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