From 921105301ce51aaab18a0693a9087468d33b57db Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Tue, 25 Sep 2018 14:31:43 +0100 Subject: [PATCH] Move angular-templates route and controller into Web engine The route and controller were in the main app and the views in the engine, with this commit they stay all inside the engine This is done to keep it simple and remove the unnecessary dependency between main app and engine If we use this mechanism in the future for other things in the main app or other engines, we can find a way to extract/abstract this --- app/controllers/angular_templates_controller.rb | 5 ----- config/routes.rb | 2 -- .../app/controllers/web/angular_templates_controller.rb | 9 +++++++++ .../angular_templates/_cookies_policy_entry.html.haml | 0 .../{ => web}/angular_templates/cookies_banner.html.haml | 0 .../{ => web}/angular_templates/cookies_policy.html.haml | 0 engines/web/config/routes.rb | 2 ++ 7 files changed, 11 insertions(+), 7 deletions(-) delete mode 100644 app/controllers/angular_templates_controller.rb create mode 100644 engines/web/app/controllers/web/angular_templates_controller.rb rename engines/web/app/views/{ => web}/angular_templates/_cookies_policy_entry.html.haml (100%) rename engines/web/app/views/{ => web}/angular_templates/cookies_banner.html.haml (100%) rename engines/web/app/views/{ => web}/angular_templates/cookies_policy.html.haml (100%) diff --git a/app/controllers/angular_templates_controller.rb b/app/controllers/angular_templates_controller.rb deleted file mode 100644 index 44d870cc58e..00000000000 --- a/app/controllers/angular_templates_controller.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AngularTemplatesController < ApplicationController - def show - render params[:id].to_s, layout: nil - end -end diff --git a/config/routes.rb b/config/routes.rb index 21d23469335..bc3fc303f0f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -88,8 +88,6 @@ get '/:id/shop', to: 'enterprises#shop', as: 'enterprise_shop' get "/enterprises/:permalink", to: redirect("/") # Legacy enterprise URL - get "/angular-templates/:id", to: "angular_templates#show", constraints: { name: %r{[\/\w\.]+} } - namespace :api do resources :enterprises do post :update_image, on: :member diff --git a/engines/web/app/controllers/web/angular_templates_controller.rb b/engines/web/app/controllers/web/angular_templates_controller.rb new file mode 100644 index 00000000000..d8670a46643 --- /dev/null +++ b/engines/web/app/controllers/web/angular_templates_controller.rb @@ -0,0 +1,9 @@ +module Web + class AngularTemplatesController < ApplicationController + helper Web::Engine.helpers + + def show + render params[:id].to_s, layout: nil + end + end +end diff --git a/engines/web/app/views/angular_templates/_cookies_policy_entry.html.haml b/engines/web/app/views/web/angular_templates/_cookies_policy_entry.html.haml similarity index 100% rename from engines/web/app/views/angular_templates/_cookies_policy_entry.html.haml rename to engines/web/app/views/web/angular_templates/_cookies_policy_entry.html.haml diff --git a/engines/web/app/views/angular_templates/cookies_banner.html.haml b/engines/web/app/views/web/angular_templates/cookies_banner.html.haml similarity index 100% rename from engines/web/app/views/angular_templates/cookies_banner.html.haml rename to engines/web/app/views/web/angular_templates/cookies_banner.html.haml diff --git a/engines/web/app/views/angular_templates/cookies_policy.html.haml b/engines/web/app/views/web/angular_templates/cookies_policy.html.haml similarity index 100% rename from engines/web/app/views/angular_templates/cookies_policy.html.haml rename to engines/web/app/views/web/angular_templates/cookies_policy.html.haml diff --git a/engines/web/config/routes.rb b/engines/web/config/routes.rb index e9143b1c7df..121f3bdd9a0 100644 --- a/engines/web/config/routes.rb +++ b/engines/web/config/routes.rb @@ -4,4 +4,6 @@ resource :consent, only: [:show, :create, :destroy], controller: "cookies_consent" end end + + get "/angular-templates/:id", to: "angular_templates#show", constraints: { name: %r{[\/\w\.]+} } end