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
Boxiang Sun
gitlab-ce
Commits
6e99226c
Commit
6e99226c
authored
Feb 10, 2016
by
Kamil Trzcinski
Committed by
James Edwards-Jones
Jan 31, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added PagesDomain
parent
f034f6b3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
46 deletions
+45
-46
app/models/pages_domain.rb
app/models/pages_domain.rb
+29
-0
app/models/project.rb
app/models/project.rb
+2
-36
db/migrate/20160209125808_add_pages_custom_domain_to_projects.rb
...ate/20160209125808_add_pages_custom_domain_to_projects.rb
+0
-10
db/migrate/20160210105555_create_pages_domain.rb
db/migrate/20160210105555_create_pages_domain.rb
+14
-0
No files found.
app/models/pages_domain.rb
0 → 100644
View file @
6e99226c
class
PagesDomain
<
ActiveRecord
::
Base
belongs_to
:project
validates
:domain
,
hostname:
true
validates_uniqueness_of
:domain
,
allow_nil:
true
,
allow_blank:
true
validates
:certificate
,
certificate:
true
,
allow_nil:
true
,
allow_blank:
true
validates
:key
,
certificate_key:
true
,
allow_nil:
true
,
allow_blank:
true
attr_encrypted
:pages_custom_certificate_key
,
mode: :per_attribute_iv_and_salt
,
key:
Gitlab
::
Application
.
secrets
.
db_key_base
after_create
:update
after_save
:update
after_destroy
:update
def
url
return
unless
domain
return
unless
Dir
.
exist?
(
project
.
public_pages_path
)
if
certificate
return
"https://
#{
domain
}
"
else
return
"http://
#{
domain
}
"
end
end
def
update
UpdatePagesConfigurationService
.
new
(
project
).
execute
end
end
app/models/project.rb
View file @
6e99226c
...
...
@@ -150,6 +150,7 @@ class Project < ActiveRecord::Base
has_many
:lfs_objects
,
through: :lfs_objects_projects
has_many
:project_group_links
,
dependent: :destroy
has_many
:invited_groups
,
through: :project_group_links
,
source: :group
has_many
:pages_domains
,
dependent: :destroy
has_many
:todos
,
dependent: :destroy
has_many
:notification_settings
,
dependent: :destroy
,
as: :source
...
...
@@ -205,18 +206,11 @@ class Project < ActiveRecord::Base
presence:
true
,
inclusion:
{
in:
->
(
_object
)
{
Gitlab
.
config
.
repositories
.
storages
.
keys
}
}
validates
:pages_custom_domain
,
hostname:
true
,
allow_blank:
true
,
allow_nil:
true
validates_uniqueness_of
:pages_custom_domain
,
allow_nil:
true
,
allow_blank:
true
validates
:pages_custom_certificate
,
certificate:
true
,
allow_nil:
true
,
allow_blank:
true
validates
:pages_custom_certificate_key
,
certificate_key:
true
,
allow_nil:
true
,
allow_blank:
true
add_authentication_token_field
:runners_token
before_save
:ensure_runners_token
mount_uploader
:avatar
,
AvatarUploader
attr_encrypted
:pages_custom_certificate_key
,
mode: :per_attribute_iv_and_salt
,
key:
Gitlab
::
Application
.
secrets
.
db_key_base
# Scopes
default_scope
{
where
(
pending_delete:
false
)
}
...
...
@@ -1184,17 +1178,6 @@ class Project < ActiveRecord::Base
"
#{
url
}
/
#{
path
}
"
end
def
pages_custom_url
return
unless
pages_custom_domain
return
unless
Dir
.
exist?
(
public_pages_path
)
if
Gitlab
.
config
.
pages
.
https
return
"https://
#{
pages_custom_domain
}
"
else
return
"http://
#{
pages_custom_domain
}
"
end
end
def
pages_path
File
.
join
(
Settings
.
pages
.
path
,
path_with_namespace
)
end
...
...
@@ -1203,32 +1186,15 @@ class Project < ActiveRecord::Base
File
.
join
(
pages_path
,
'public'
)
end
def
remove_pages_certificate
update
(
pages_custom_certificate:
nil
,
pages_custom_certificate_key:
nil
)
UpdatePagesConfigurationService
.
new
(
self
).
execute
end
def
remove_pages
# 1. We rename pages to temporary directory
# 2. We wait 5 minutes, due to NFS caching
# 3. We asynchronously remove pages with force
temp_path
=
"
#{
path
}
.
#{
SecureRandom
.
hex
}
"
temp_path
=
"
#{
path
}
.
#{
SecureRandom
.
hex
}
.deleted
"
if
Gitlab
::
PagesTransfer
.
new
.
rename_project
(
path
,
temp_path
,
namespace
.
path
)
PagesWorker
.
perform_in
(
5
.
minutes
,
:remove
,
namespace
.
path
,
temp_path
)
end
update
(
pages_custom_certificate:
nil
,
pages_custom_certificate_key:
nil
,
pages_custom_domain:
nil
)
UpdatePagesConfigurationService
.
new
(
self
).
execute
end
def
wiki
...
...
db/migrate/20160209125808_add_pages_custom_domain_to_projects.rb
deleted
100644 → 0
View file @
f034f6b3
class
AddPagesCustomDomainToProjects
<
ActiveRecord
::
Migration
def
change
add_column
:projects
,
:pages_custom_certificate
,
:text
add_column
:projects
,
:encrypted_pages_custom_certificate_key
,
:text
add_column
:projects
,
:encrypted_pages_custom_certificate_key_iv
,
:string
add_column
:projects
,
:encrypted_pages_custom_certificate_key_salt
,
:string
add_column
:projects
,
:pages_custom_domain
,
:string
,
unique:
true
add_column
:projects
,
:pages_redirect_http
,
:boolean
,
default:
false
,
null:
false
end
end
db/migrate/20160210105555_create_pages_domain.rb
0 → 100644
View file @
6e99226c
class
CreatePagesDomain
<
ActiveRecord
::
Migration
def
change
create_table
:pages_domains
do
|
t
|
t
.
integer
:project_id
t
.
text
:certificate
t
.
text
:encrypted_key
t
.
string
:encrypted_key_iv
t
.
string
:encrypted_key_salt
t
.
string
:domain
end
add_index
:pages_domains
,
:domain
,
unique:
true
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