2009-05-07 17:18:16 +00:00
|
|
|
class PagesController < ApplicationController
|
|
|
|
|
2009-06-01 06:20:15 +00:00
|
|
|
def index
|
2011-05-25 06:50:56 +00:00
|
|
|
@item = Page.find_by_name('home')
|
|
|
|
if @item
|
2011-02-22 08:00:13 +00:00
|
|
|
render_page
|
2009-06-01 06:20:15 +00:00
|
|
|
else
|
|
|
|
render :text => 'You need a home page'
|
|
|
|
end
|
|
|
|
end
|
2009-05-07 18:13:27 +00:00
|
|
|
|
2011-12-23 10:34:21 +00:00
|
|
|
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}")
|
|
|
|
|
2009-05-07 17:18:16 +00:00
|
|
|
end
|
|
|
|
|
2011-12-23 10:34:21 +00:00
|
|
|
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]))
|
|
|
|
when 'Link'
|
|
|
|
redirect_to "http://#{item[:url]}"
|
|
|
|
end
|
|
|
|
rescue
|
|
|
|
render :file => "#{Rails.root}/public/404.html", :status => :not_found
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-05-07 17:18:16 +00:00
|
|
|
end
|