summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/projects/pages_controller.rb54
-rw-r--r--app/controllers/projects/pages_domains_controller.rb49
-rw-r--r--app/views/projects/pages/_destroy.haml2
-rw-r--r--app/views/projects/pages/_list.html.haml4
-rw-r--r--app/views/projects/pages/index.html.haml26
-rw-r--r--app/views/projects/pages/show.html.haml44
-rw-r--r--app/views/projects/pages_domains/_form.html.haml (renamed from app/views/projects/pages/_form.html.haml)2
-rw-r--r--app/views/projects/pages_domains/new.html.haml (renamed from app/views/projects/pages/new.html.haml)0
-rw-r--r--app/views/projects/pages_domains/show.html.haml22
-rw-r--r--config/routes/project.rb6
-rw-r--r--features/steps/project/pages.rb2
11 files changed, 104 insertions, 107 deletions
diff --git a/app/controllers/projects/pages_controller.rb b/app/controllers/projects/pages_controller.rb
index 2268d2d8aa2..b73f998392d 100644
--- a/app/controllers/projects/pages_controller.rb
+++ b/app/controllers/projects/pages_controller.rb
@@ -1,49 +1,13 @@
class Projects::PagesController < Projects::ApplicationController
layout 'project_settings'
- before_action :authorize_update_pages!, except: [:show]
- before_action :authorize_remove_pages!, only: [:remove_pages]
- before_action :label, only: [:destroy]
- before_action :domain, only: [:show]
-
- helper_method :valid_certificate?, :valid_certificate_key?
- helper_method :valid_key_for_certificiate?, :valid_certificate_intermediates?
- helper_method :certificate, :certificate_key
-
- def index
- @domains = @project.pages_domains.order(:domain)
- end
+ before_action :authorize_update_pages!
def show
- end
-
- def new
- @domain = @project.pages_domains.new
- end
-
- def create
- @domain = @project.pages_domains.create(pages_domain_params)
-
- if @domain.valid?
- redirect_to namespace_project_pages_path(@project.namespace, @project)
- else
- render 'new'
- end
+ @domains = @project.pages_domains.order(:domain)
end
def destroy
- @domain.destroy
-
- respond_to do |format|
- format.html do
- redirect_to(namespace_project_pages_path(@project.namespace, @project),
- notice: 'Domain was removed')
- end
- format.js
- end
- end
-
- def remove_pages
project.remove_pages
project.pages_domains.destroy_all
@@ -54,18 +18,4 @@ class Projects::PagesController < Projects::ApplicationController
end
end
end
-
- private
-
- def pages_domain_params
- params.require(:pages_domain).permit(
- :certificate,
- :key,
- :domain
- )
- end
-
- def domain
- @domain ||= @project.pages_domains.find_by(domain: params[:id].to_s)
- end
end
diff --git a/app/controllers/projects/pages_domains_controller.rb b/app/controllers/projects/pages_domains_controller.rb
index e69de29bb2d..b8c253f6ae3 100644
--- a/app/controllers/projects/pages_domains_controller.rb
+++ b/app/controllers/projects/pages_domains_controller.rb
@@ -0,0 +1,49 @@
+class Projects::PagesDomainsController < Projects::ApplicationController
+ layout 'project_settings'
+
+ before_action :authorize_update_pages!, except: [:show]
+ before_action :domain, only: [:show, :destroy]
+
+ def show
+ end
+
+ def new
+ @domain = @project.pages_domains.new
+ end
+
+ def create
+ @domain = @project.pages_domains.create(pages_domain_params)
+
+ if @domain.valid?
+ redirect_to namespace_project_pages_path(@project.namespace, @project)
+ else
+ render 'new'
+ end
+ end
+
+ def destroy
+ @domain.destroy
+
+ respond_to do |format|
+ format.html do
+ redirect_to(namespace_project_pages_path(@project.namespace, @project),
+ notice: 'Domain was removed')
+ end
+ format.js
+ end
+ end
+
+ private
+
+ def pages_domain_params
+ params.require(:pages_domain).permit(
+ :certificate,
+ :key,
+ :domain
+ )
+ end
+
+ def domain
+ @domain ||= @project.pages_domains.find_by(domain: params[:id].to_s)
+ end
+end
diff --git a/app/views/projects/pages/_destroy.haml b/app/views/projects/pages/_destroy.haml
index c560aca5725..0cd25f82cd4 100644
--- a/app/views/projects/pages/_destroy.haml
+++ b/app/views/projects/pages/_destroy.haml
@@ -6,4 +6,4 @@
%p
Removing the pages will prevent from exposing them to outside world.
.form-actions
- = link_to 'Remove', remove_pages_namespace_project_pages_path(@project.namespace, @project), data: { confirm: 'Are you sure?'}, method: :delete, class: "btn btn-remove"
+ = link_to 'Remove pages', namespace_project_pages_path(@project.namespace, @project), data: { confirm: 'Are you sure?'}, method: :delete, class: "btn btn-remove"
diff --git a/app/views/projects/pages/_list.html.haml b/app/views/projects/pages/_list.html.haml
index e88a001d636..c1a6948a574 100644
--- a/app/views/projects/pages/_list.html.haml
+++ b/app/views/projects/pages/_list.html.haml
@@ -6,8 +6,8 @@
- @domains.each do |domain|
%li
.pull-right
- = link_to 'Details', namespace_project_page_path(@project.namespace, @project, domain), class: "btn btn-sm btn-grouped"
- = link_to 'Remove', namespace_project_page_path(@project.namespace, @project, domain), data: { confirm: 'Are you sure?'}, method: :delete, class: "btn btn-remove btn-sm btn-grouped"
+ = link_to 'Details', namespace_project_pages_domain_path(@project.namespace, @project, domain), class: "btn btn-sm btn-grouped"
+ = link_to 'Remove', namespace_project_pages_domain_path(@project.namespace, @project, domain), data: { confirm: 'Are you sure?'}, method: :delete, class: "btn btn-remove btn-sm btn-grouped"
.clearfix
%span= link_to domain.domain, domain.url
%p
diff --git a/app/views/projects/pages/index.html.haml b/app/views/projects/pages/index.html.haml
deleted file mode 100644
index 1a5dbb79830..00000000000
--- a/app/views/projects/pages/index.html.haml
+++ /dev/null
@@ -1,26 +0,0 @@
-- page_title "Pages"
-%h3.page_title
- Pages
-
- - if Gitlab.config.pages.external_http || Gitlab.config.pages.external_https
- = link_to new_namespace_project_page_path(@project.namespace, @project), class: "btn btn-new pull-right", title: "New Domain" do
- %i.fa.fa-plus
- New Domain
-
-%p.light
- With GitLab Pages you can host for free your static websites on GitLab.
- Combined with the power of GitLab CI and the help of GitLab Runner
- you can deploy static pages for your individual projects, your user or your group.
-
-%hr.clearfix
-
-- if Gitlab.config.pages.enabled
- = render 'access'
- = render 'use'
- - if Gitlab.config.pages.external_http || Gitlab.config.pages.external_https
- = render 'list'
- - else
- = render 'no_domains'
- = render 'destroy'
-- else
- = render 'disabled'
diff --git a/app/views/projects/pages/show.html.haml b/app/views/projects/pages/show.html.haml
index 8b7010b75b2..9be6f8678cf 100644
--- a/app/views/projects/pages/show.html.haml
+++ b/app/views/projects/pages/show.html.haml
@@ -1,22 +1,26 @@
-- page_title "#{@domain.domain}", "Pages Domain"
+- page_title "Pages"
+%h3.page_title
+ Pages
-%h3.page-title
- Pages Domain
+ - if Gitlab.config.pages.external_http || Gitlab.config.pages.external_https
+ = link_to new_namespace_project_pages_domain_path(@project.namespace, @project), class: "btn btn-new pull-right", title: "New Domain" do
+ %i.fa.fa-plus
+ New Domain
-.table-holder
- %table.table
- %tr
- %td
- Domain
- %td
- = link_to @domain.domain, @domain.url
- %tr
- %td
- Certificate
- %td
- - if @domain.certificate_text
- %pre
- = @domain.certificate_text
- - else
- .light
- missing
+%p.light
+ With GitLab Pages you can host for free your static websites on GitLab.
+ Combined with the power of GitLab CI and the help of GitLab Runner
+ you can deploy static pages for your individual projects, your user or your group.
+
+%hr.clearfix
+
+- if Gitlab.config.pages.enabled
+ = render 'access'
+ = render 'use'
+ - if Gitlab.config.pages.external_http || Gitlab.config.pages.external_https
+ = render 'list'
+ - else
+ = render 'no_domains'
+ = render 'destroy'
+- else
+ = render 'disabled'
diff --git a/app/views/projects/pages/_form.html.haml b/app/views/projects/pages_domains/_form.html.haml
index fd411462330..5458f9e7734 100644
--- a/app/views/projects/pages/_form.html.haml
+++ b/app/views/projects/pages_domains/_form.html.haml
@@ -1,4 +1,4 @@
-= form_for [@domain], url: namespace_project_pages_path(@project.namespace, @project), html: { class: 'form-horizontal fieldset-form' } do |f|
+= form_for [@project.namespace, @project, @domain], html: { class: 'form-horizontal fieldset-form' } do |f|
- if @domain.errors.any?
#error_explanation
.alert.alert-danger
diff --git a/app/views/projects/pages/new.html.haml b/app/views/projects/pages_domains/new.html.haml
index 2609df62aac..2609df62aac 100644
--- a/app/views/projects/pages/new.html.haml
+++ b/app/views/projects/pages_domains/new.html.haml
diff --git a/app/views/projects/pages_domains/show.html.haml b/app/views/projects/pages_domains/show.html.haml
new file mode 100644
index 00000000000..8b7010b75b2
--- /dev/null
+++ b/app/views/projects/pages_domains/show.html.haml
@@ -0,0 +1,22 @@
+- page_title "#{@domain.domain}", "Pages Domain"
+
+%h3.page-title
+ Pages Domain
+
+.table-holder
+ %table.table
+ %tr
+ %td
+ Domain
+ %td
+ = link_to @domain.domain, @domain.url
+ %tr
+ %td
+ Certificate
+ %td
+ - if @domain.certificate_text
+ %pre
+ = @domain.certificate_text
+ - else
+ .light
+ missing
diff --git a/config/routes/project.rb b/config/routes/project.rb
index 7a41cb81bfa..ea3bfdd45e6 100644
--- a/config/routes/project.rb
+++ b/config/routes/project.rb
@@ -39,10 +39,8 @@ constraints(ProjectUrlConstrainer.new) do
end
end
- resources :pages, except: [:edit, :update] do
- collection do
- delete :remove_pages
- end
+ resource :pages, only: [:show, :destroy] do
+ resources :domains, only: [:show, :new, :create, :destroy], controller: 'pages_domains'
end
resources :compare, only: [:index, :create] do
diff --git a/features/steps/project/pages.rb b/features/steps/project/pages.rb
index d484ae90bdc..a5cb81b0ef3 100644
--- a/features/steps/project/pages.rb
+++ b/features/steps/project/pages.rb
@@ -67,7 +67,7 @@ class Spinach::Features::ProjectPages < Spinach::FeatureSteps
end
step 'I visit add a new Pages Domain' do
- visit new_namespace_project_page_path(@project.namespace, @project)
+ visit new_namespace_project_pages_domain_path(@project.namespace, @project)
end
step 'I fill the domain' do