def create
      @page = Humpyard::config.page_types[params[:type]].new params[:page]
      @page.title_for_url = @page.page.suggested_title_for_url
      
      authorize! :create, @page.page
      
      if @page.save
        @prev = Humpyard::Page.find_by_id(params[:prev_id])
        @next = Humpyard::Page.find_by_id(params[:next_id])
        
        #do_move(@page, @prev, @next)
      
        # insert_options = {
        #   :element => "hy-id-#{@page.id}",
        #   :url => @page.page.human_url,
        #   :parent => @page.parent ? "hy-page-dialog-item-#{@page.id}" : "hy-page-dialog-pages"
        # }
        
        # insert_options[:before] = "hy-page-dialog-item-#{@next.id}" if @next
        # insert_options[:after] = "hy-page-dialog-item-#{@prev.id}" if not @next and @prev

        # just reload the tree
      
        replace_options = {
          :element => "hy-page-treeview",
          :content => render_to_string(:partial => "tree.html", :locals => {:page => @page})
        }
      
        render :json => {
          :status => :ok,
          #:dialog => :close,
          # :insert => [insert_options],
          :replace => [replace_options],
          :flash => {
            :level => 'info',
            :content => I18n.t('humpyard_form.flashes.create_success', :model => Humpyard::Page.model_name.human)
          }
        }
      else
        render :json => {
          :status => :failed, 
          :errors => @page.errors,
          :flash => {
            :level => 'error',
            :content => I18n.t('humpyard_form.flashes.create_fail', :model => Humpyard::Page.model_name.human)
          }
        }
      end
    end
def create
      @page = Humpyard::config.page_types[params[:type]].new params[:page]
      @page.title_for_url = @page.page.suggested_title_for_url
      
      authorize! :create, @page.page
      
      if @page.save
        @prev = Humpyard::Page.find_by_id(params[:prev_id])
        @next = Humpyard::Page.find_by_id(params[:next_id])
        
        #do_move(@page, @prev, @next)
      
        # insert_options = {
        #   :element => "hy-id-#{@page.id}",
        #   :url => @page.page.human_url,
        #   :parent => @page.parent ? "hy-page-dialog-item-#{@page.id}" : "hy-page-dialog-pages"
        # }
        
        # insert_options[:before] = "hy-page-dialog-item-#{@next.id}" if @next
        # insert_options[:after] = "hy-page-dialog-item-#{@prev.id}" if not @next and @prev

        # just reload the tree
      
        replace_options = {
          :element => "hy-page-treeview",
          :content => render_to_string(:partial => "tree.html", :locals => {:page => @page})
        }
      
        render :json => {
          :status => :ok,
          #:dialog => :close,
          # :insert => [insert_options],
          :replace => [replace_options],
          :flash => {
            :level => 'info',
            :content => I18n.t('humpyard_form.flashes.create_success', :model => Humpyard::Page.model_name.human)
          }
        }
      else
        render :json => {
          :status => :failed, 
          :errors => @page.errors,
          :flash => {
            :level => 'error',
            :content => I18n.t('humpyard_form.flashes.create_fail', :model => Humpyard::Page.model_name.human)
          }
        }
      end
    end
Create a new page