Redirect all /editor paths to /builder

pull/7746/head
Javier Torres 8 years ago
parent 824a7182c9
commit b5762f94e3

@ -28,15 +28,22 @@ module CartoDB
# @param params Hash Parameters to send to the url (Optional)
# @param user ::User (Optional) If not sent will use subdomain or /user/xxx from controller request
def self.url(context, path, params={}, user = nil)
# Must clean user_domain or else polymorphic_path will use it and generate again /u/xxx/user/xxx
CartoDB.base_url_from_request(context.request, user) + context.polymorphic_path(path, params.merge({user_domain:nil}))
end
# Helper method to encapsulate Rails base URL generation compatible with our subdomainless mode
# @param request A request to extract subdomain and parameters from
# @param user ::User (Optional) If not sent will use subdomain or /user/xxx from controller request
def self.base_url_from_request(request, user = nil)
if user.nil?
subdomain = self.extract_subdomain(context.request)
subdomain = self.extract_subdomain(request)
org_username = nil
else
subdomain = user.subdomain
org_username = user.organization_username
end
# Must clean user_domain or else polymorphic_path will use it and generate again /u/xxx/user/xxx
CartoDB.base_url(subdomain, org_username) + context.polymorphic_path(path, params.merge({user_domain:nil}))
CartoDB.base_url(subdomain, org_username)
end
# Helper method to encapsulate Rails URL path generation compatible with our subdomainless mode

@ -47,7 +47,7 @@ CartoDB::Application.routes.draw do
# Editor v3
scope module: 'carto', path: '(/user/:user_domain)(/u/:user_domain)' do
namespace :editor do
scope '/builder', module: :editor do
# Visualizations
resources :visualizations, only: :show, path: '/', constraints: { id: /[0-z\.\-]+/ } do
namespace :public, path: '/' do
@ -56,6 +56,10 @@ CartoDB::Application.routes.draw do
end
end
end
namespace :editor do
match '(*path)', to: redirect { |params, request| CartoDB.base_url_from_request(request) + '/builder/' + params[:path] }
end
end
# Internally, some of this methods will forcibly rewrite to the org-url if user belongs to an organization

Loading…
Cancel
Save