summaryrefslogtreecommitdiff
path: root/app/models/pages_domain.rb
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-02-10 12:07:46 +0100
committerJames Edwards-Jones <jedwardsjones@gitlab.com>2017-01-31 22:53:57 +0000
commit6e99226cca41f36d92c4ccb2cd398d2256091adc (patch)
treefc3cc5262537f33d46b2407970a6a7b6a5cef69d /app/models/pages_domain.rb
parentf034f6b3ec5dc8b72f43c954ddb34bae037be254 (diff)
downloadgitlab-ce-6e99226cca41f36d92c4ccb2cd398d2256091adc.tar.gz
Added PagesDomain
Diffstat (limited to 'app/models/pages_domain.rb')
-rw-r--r--app/models/pages_domain.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/app/models/pages_domain.rb b/app/models/pages_domain.rb
new file mode 100644
index 00000000000..eebdf7501de
--- /dev/null
+++ b/app/models/pages_domain.rb
@@ -0,0 +1,29 @@
+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