2009-05-07 17:18:16 +00:00
|
|
|
class Admin::PagesController < ApplicationController
|
2009-05-07 18:13:27 +00:00
|
|
|
|
|
|
|
layout "admin"
|
|
|
|
|
2009-05-07 17:18:16 +00:00
|
|
|
# GET /pages
|
|
|
|
# GET /pages.xml
|
|
|
|
def index
|
2009-05-22 06:43:52 +00:00
|
|
|
@pages = Page.all( :conditions => { :parent_page_id => "root" } )
|
2009-05-07 17:18:16 +00:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html # index.html.erb
|
|
|
|
format.xml { render :xml => @pages }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# GET /pages/1
|
|
|
|
# GET /pages/1.xml
|
|
|
|
def show
|
|
|
|
@page = Page.find(params[:id])
|
|
|
|
|
|
|
|
redirect_to "/#{@page.name}"
|
|
|
|
end
|
|
|
|
|
|
|
|
# GET /pages/new
|
|
|
|
# GET /pages/new.xml
|
|
|
|
def new
|
|
|
|
@page = Page.new
|
2009-05-22 06:43:52 +00:00
|
|
|
@page.is_published = true
|
|
|
|
@page.parent_page_id = params[:parent_page_id]
|
|
|
|
|
2009-05-07 17:18:16 +00:00
|
|
|
respond_to do |format|
|
|
|
|
format.html # new.html.erb
|
|
|
|
format.xml { render :xml => @pages }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# GET /pages/1/edit
|
|
|
|
def edit
|
|
|
|
@page = Page.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
# POST /pages
|
|
|
|
# POST /pages.xml
|
|
|
|
def create
|
|
|
|
@page = Page.new(params[:page])
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
if @page.save
|
|
|
|
flash[:notice] = 'Page was successfully created.'
|
|
|
|
format.html { redirect_to admin_pages_url }
|
|
|
|
format.xml { render :xml => @page, :status => :created, :location => @pages }
|
|
|
|
else
|
|
|
|
format.html { render :action => "new" }
|
|
|
|
format.xml { render :xml => @page.errors, :status => :unprocessable_entity }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# PUT /pages/1
|
|
|
|
# PUT /pages/1.xml
|
|
|
|
def update
|
|
|
|
@page = Page.find(params[:id])
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
if @page.update_attributes(params[:page])
|
|
|
|
flash[:notice] = 'Page was successfully updated.'
|
|
|
|
format.html { redirect_to admin_pages_url }
|
|
|
|
format.xml { head :ok }
|
|
|
|
else
|
|
|
|
format.html { render :action => "edit" }
|
|
|
|
format.xml { render :xml => @page.errors, :status => :unprocessable_entity }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# DELETE /pages/1
|
|
|
|
# DELETE /pages/1.xml
|
|
|
|
def destroy
|
|
|
|
@page = Page.find(params[:id])
|
|
|
|
@page.destroy
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html { redirect_to admin_pages_url }
|
|
|
|
format.xml { head :ok }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|