orbit-basic/app/controllers/pages_controller.rb

45 lines
1.1 KiB
Ruby
Raw Normal View History

class PagesController < ApplicationController
before_filter :get_item, :only => [:index_from_link, :show_from_link]
def index
@item = Page.find_by_name('home')
if @item
2011-02-22 08:00:13 +00:00
render_page
else
render :text => 'You need a home page'
end
end
2011-12-23 10:34:21 +00:00
def show
2012-01-24 03:38:53 +00:00
#begin
2011-12-23 10:34:21 +00:00
item = Item.first(:conditions => {:full_name => params[:page_name]})
case item._type
when 'Page'
@item = item
render_page(params[:id])
2011-12-23 10:34:21 +00:00
when 'Link'
redirect_to "http://#{item[:url]}"
end
2012-01-24 03:38:53 +00:00
#rescue
# render :file => "#{Rails.root}/public/404.html", :status => :not_found
#end
2011-12-23 10:34:21 +00:00
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 => {:key => params[:app_name]})
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action]})
end
2011-12-23 10:34:21 +00:00
end