Change "NewBlog" folders into "new_blog" in assets

Modify routes and pages handling for clean front-end urls
This commit is contained in:
Christophe Vilayphiou committed 2012-01-24 18:16:58 +08:00
1 parent 6a196c5d3d
commit 783eae4597
12 files changed
+40 -26

No files matched your search

+2 -2
View File
@@ -43,9 +43,9 @@ class ApplicationController < ActionController::Base
end
# Render the page
def render_page(url = nil)
def render_page(id = nil)
if @item
render :text => parse_page(@item,url)
render :text => parse_page(@item, id)
else
render :text => '404 Not Found'
end
+18 -10
View File
@@ -1,5 +1,7 @@
class PagesController < ApplicationController
before_filter :get_item, :only => [:index_from_link, :show_from_link]
def index
@item = Page.find_by_name('home')
if @item
@@ -9,22 +11,13 @@ class PagesController < ApplicationController
end
end
def appfront
pre_uri = URI.split request.env['HTTP_REFERER']
pre_item_fullname = pre_uri[5][1..-1]
@item = Item.first(:conditions => {:full_name => pre_item_fullname})
redirect_to (request.env['HTTP_REFERER'].partition("?")[0]+"?app_url=#{request.fullpath}")
end
def show
#begin
item = Item.first(:conditions => {:full_name => params[:page_name]})
case item._type
when 'Page'
@item = item
render_page ((params[:app_url]+'?inner='+"true" if params[:app_url]))
render_page(params[:id])
when 'Link'
redirect_to "http://#{item[:url]}"
end
@@ -32,5 +25,20 @@ class PagesController < ApplicationController
# render :file => "#{Rails.root}/public/404.html", :status => :not_found
#end
end
def index_from_link
redirect_to "/#{@item.full_name}"
end
def show_from_link
redirect_to "/#{@item.full_name}?id=#{params[:id]}"
end
protected
def get_item
module_app = ModuleApp.first(:conditions => {:title => params[:app_name]})
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action]})
end
end