Sha256: 2a766eaa9ebb8715c0696fca5c24db80c86c2cc2c3e52d0f7faf180b7a93971e

Contents?: true

Size: 1.7 KB

Versions: 1

Compression:

Stored size: 1.7 KB

Contents

module ContentEngine
  class PagesController < ContentEngineController
    respond_to :html, :xml
  
    # GET /pages
    # GET /pages.xml
    def index
      @pages = @site.pages.order('created_at desc').all.paginate(:page => params[:page])
      @rootpage = @site.pages.root

      if request.xhr? and params[:parent_id]
        @rootpage = @site.pages.find(params[:parent_id])
        return render(:partial => 'treeview')
      end
    
      respond_with @pages
    end

    # GET /pages/1
    # GET /pages/1.xml
    def show
      respond_with @page = @site.pages.find(params[:id])
    end

    def lookup
      @page = @site.pages.find_by_url(params[:url])
      
      render :template => 'content_engine/pages/show'
    end

    # GET /pages/new
    # GET /pages/new.xml
    def new
      respond_with @page = @site.pages.new
    end

    # GET /pages/1/edit
    def edit
      respond_with @page = @site.pages.find(params[:id])
    end

    # POST /pages
    # POST /pages.xml
    def create
      @page = @site.pages.new(params[:page])
      flash[:notice] = "Page was successfully created." if @page.save
      respond_with @page
    end

    # PUT /pages/1
    # PUT /pages/1.xml
    def update
      @page = @site.pages.find(params[:id])
      flash[:notice] = "Page was successfully updated." if @page.update_attributes(params[:page])
      respond_with @page
    end

    # DELETE /pages/1
    # DELETE /pages/1.xml
    def destroy
      @page = @site.pages.find(params[:id])
      @page.destroy
    
      respond_with @page
    end
  

    # # GET /pages/1/move?to=(up|down)
    # def move
    #   @page = @site.pages.find(params[:id])
    #   @page.move_left
    #   
    #   redirect_to pages_path
    # end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
content_engine-0.1.0 app/controllers/content_engine/pages_controller.rb