This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/app/controllers/pages_controller.rb

64 lines
1.9 KiB
Ruby
Raw Normal View History

class PagesController < ApplicationController
2012-03-21 17:51:16 +00:00
include ApplicationHelper
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
2012-02-17 06:54:11 +00:00
@item = Item.first(:conditions => {:full_name => params[:page_name]})
if @item && @item.is_published && (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s))
2012-02-17 06:54:11 +00:00
case @item._type
when 'Page'
2012-05-03 06:57:10 +00:00
render_page(params)
2012-02-17 06:54:11 +00:00
when 'Link'
redirect_to "http://#{@item[:url]}"
end
else
render :file => "#{Rails.root}/public/404.html", :status => :not_found
2011-12-23 10:34:21 +00:00
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
if params[:page]
2012-04-29 22:27:38 +00:00
redirect_to "/#{@item.full_name}?page=#{params[:page]}&category_id=#{params[:category_id]}&tag_id=#{params[:tag_id]}"
else
2012-04-29 22:27:38 +00:00
redirect_to "/#{@item.full_name}?category_id=#{params[:category_id]}&tag_id=#{params[:tag_id]}"
end
end
def show_from_link
2012-05-03 06:57:10 +00:00
# debugger
# a=1
redirect_to "/#{@item.full_name}?id=#{params[:id]}&preview=#{params[:preview]}"
end
def load_orbit_bar
render :partial => 'layouts/orbit_bar', :locals => {:referer => request.referer}
end
protected
def get_item
module_app = ModuleApp.first(:conditions => {:key => params[:app_name]})
2012-04-29 22:27:38 +00:00
# if params[:category_id]
# @item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id]})
# else
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action]})
2012-04-29 22:27:38 +00:00
# end
end
2011-12-23 10:34:21 +00:00
end