class PagesController < ApplicationController
  
  def index
    @page = Home.find_by_name('home')
    if @page
      render_liquid_page
    else
      render :text => 'You need a home page'
    end
  end
  
  def show  
    begin  
      item = Item.first(:conditions => {:full_name => params[:page_name]})
      case item._type
        when 'Page'
          @page = item
          render_liquid_page
        when 'Link'
          redirect_to "http://#{item[:url]}"
      end
    rescue
      render :file => "#{Rails.root}/public/404.html", :status => :not_found
    end
  end
  
end