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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
492627c9
Commit
492627c9
authored
Feb 19, 2016
by
Kamil Trzcinski
Committed by
James Edwards-Jones
Jan 31, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the URL of group pages
parent
c089f103
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
3 deletions
+48
-3
app/models/project.rb
app/models/project.rb
+7
-3
doc/pages/README.md
doc/pages/README.md
+8
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+33
-0
No files found.
app/models/project.rb
View file @
492627c9
...
...
@@ -1167,12 +1167,16 @@ class Project < ActiveRecord::Base
def
pages_url
return
unless
Dir
.
exist?
(
public_pages_path
)
host
=
"
#{
namespace
.
path
}
.
#{
Settings
.
pages
.
host
}
"
# The hostname always needs to be in downcased
# All web servers convert hostname to lowercase
host
=
"
#{
namespace
.
path
}
.
#{
Settings
.
pages
.
host
}
"
.
downcase
# The host in URL always needs to be downcased
url
=
Gitlab
.
config
.
pages
.
url
.
sub
(
/^https?:\/\//
)
do
|
prefix
|
"
#{
prefix
}#{
namespace
.
path
}
."
end
end
.
downcase
# If the project path is the same as host,
leave the short version
# If the project path is the same as host,
we serve it as group page
return
url
if
host
==
path
"
#{
url
}
/
#{
path
}
"
...
...
doc/pages/README.md
View file @
492627c9
...
...
@@ -45,6 +45,14 @@ URL it will be accessible.
| Specific project under a user's page |
`walter/area51`
|
`https://walter.gitlab.io/area51`
|
| Specific project under a group's page |
`therug/welovecats`
|
`https://therug.gitlab.io/welovecats`
|
## Group pages
You can create a group page in context of your group.
The project for group page must be written in lower.
If you have a group
`TheRug`
and pages are hosted under
`Example.com`
in order to create a group page
create a new project named
`therug.example.com`
.
## Enable the pages feature in your project
The GitLab Pages feature needs to be explicitly enabled for each project
...
...
spec/models/project_spec.rb
View file @
492627c9
...
...
@@ -1845,4 +1845,37 @@ describe Project, models: true do
def
enable_lfs
allow
(
Gitlab
.
config
.
lfs
).
to
receive
(
:enabled
).
and_return
(
true
)
end
describe
:pages_url
do
let
(
:group
)
{
create
:group
,
name:
group_name
}
let
(
:project
)
{
create
:empty_project
,
namespace:
group
,
name:
project_name
}
let
(
:domain
)
{
'Example.com'
}
subject
{
project
.
pages_url
}
before
do
FileUtils
.
mkdir_p
(
project
.
public_pages_path
)
allow
(
Settings
.
pages
).
to
receive
(
:host
).
and_return
(
domain
)
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:url
).
and_return
(
'http://example.com'
)
end
after
do
FileUtils
.
rmdir
(
project
.
public_pages_path
)
end
context
'group page'
do
let
(
:group_name
)
{
'Group'
}
let
(
:project_name
)
{
'group.example.com'
}
it
{
is_expected
.
to
eq
(
"http://group.example.com"
)
}
end
context
'project page'
do
let
(
:group_name
)
{
'Group'
}
let
(
:project_name
)
{
'Project'
}
it
{
is_expected
.
to
eq
(
"http://group.example.com/project"
)
}
end
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