forked from saurabh/orbit4-5
Fix route
This commit is contained in:
parent
05f0900621
commit
ddba41ce06
|
@ -17,22 +17,36 @@ class PagesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
path = request.original_fullpath.split('/')
|
||||||
|
if path.size == 2
|
||||||
|
redirect_to '/'
|
||||||
|
else
|
||||||
|
if path.last.include? '-'
|
||||||
|
params[:page_id] = path[-2]
|
||||||
|
params[:slug] = path[-1]
|
||||||
|
params[:uid] = path[-1].split("-").last
|
||||||
|
params[:target_action] = "show"
|
||||||
|
else
|
||||||
|
params[:page_id] = path[-1]
|
||||||
|
params[:slug] = nil
|
||||||
|
params[:uid] = nil
|
||||||
|
params[:target_action] = "index"
|
||||||
|
end
|
||||||
|
|
||||||
page = Page.find_by_param(params[:page_id])
|
page = Page.find_by_param(params[:page_id])
|
||||||
module_app = page.module.downcase.pluralize
|
module_app = page.module.downcase.pluralize
|
||||||
params[:target_controller] = "#{module_app}"
|
params[:target_controller] = "#{module_app}"
|
||||||
|
params[:url] = page.url
|
||||||
|
|
||||||
@manifest = @key
|
@manifest = @key
|
||||||
@dataApi = nil
|
@dataApi = nil
|
||||||
if params[:slug]
|
|
||||||
params[:target_action] = "show"
|
|
||||||
params[:uid] = params[:slug].split("-").last
|
|
||||||
else
|
|
||||||
params[:target_action] = "index"
|
|
||||||
params[:url] = page.url
|
|
||||||
end
|
|
||||||
OrbitHelper.set_params params
|
OrbitHelper.set_params params
|
||||||
OrbitHelper.set_site_locale locale
|
OrbitHelper.set_site_locale locale
|
||||||
|
|
||||||
render render_final_page("#{module_app}/#{params[:target_action]}",page)
|
render render_final_page("#{module_app}/#{params[:target_action]}",page)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def preview
|
def preview
|
||||||
render render_final_page
|
render render_final_page
|
||||||
|
|
|
@ -18,7 +18,7 @@ OrbitStore::Application.routes.draw do
|
||||||
# You can have the root of your site routed with "root"
|
# You can have the root of your site routed with "root"
|
||||||
root 'home#index'
|
root 'home#index'
|
||||||
scope "(:locale)", locale: /en|zh_tw/ do
|
scope "(:locale)", locale: /en|zh_tw/ do
|
||||||
get ':page_id((/:page_id)/:page_id/:slug)', to: 'pages#show'
|
get ':page(/:page)(/:page)(/:page)', to: 'pages#show'
|
||||||
resources :pages
|
resources :pages
|
||||||
end
|
end
|
||||||
# Example of regular route:
|
# Example of regular route:
|
||||||
|
|
Loading…
Reference in New Issue