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
|
|
|
def index
|
2010-01-08 10:36:36 +00:00
|
|
|
@pages = Page.all( :conditions => { :parent_page_name => params[:parent] || "root" } )
|
2009-05-07 17:18:16 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
@page = Page.find(params[:id])
|
|
|
|
|
|
|
|
redirect_to "/#{@page.name}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@page = Page.new
|
2009-05-22 06:43:52 +00:00
|
|
|
@page.is_published = true
|
2010-01-08 10:36:36 +00:00
|
|
|
@page.parent_page_name = params[:parent_page_name]
|
2009-05-07 17:18:16 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
@page = Page.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@page = Page.new(params[:page])
|
|
|
|
|
2010-01-04 09:49:55 +00:00
|
|
|
if @page.save
|
|
|
|
flash[:notice] = 'Page was successfully created.'
|
2010-01-08 10:36:36 +00:00
|
|
|
redirect_to admin_pages_url( :parent_page_name => @page.parent_page_name )
|
2010-01-04 09:49:55 +00:00
|
|
|
else
|
|
|
|
render :action => "new"
|
2009-05-07 17:18:16 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@page = Page.find(params[:id])
|
|
|
|
|
2010-01-04 09:49:55 +00:00
|
|
|
if @page.update_attributes(params[:page])
|
|
|
|
flash[:notice] = 'Page was successfully updated.'
|
|
|
|
redirect_to admin_pages_url
|
|
|
|
else
|
|
|
|
render :action => "edit"
|
2009-05-07 17:18:16 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@page = Page.find(params[:id])
|
|
|
|
@page.destroy
|
|
|
|
|
2010-01-04 09:49:55 +00:00
|
|
|
redirect_to admin_pages_url
|
2009-05-07 17:18:16 +00:00
|
|
|
end
|
2010-01-04 09:49:55 +00:00
|
|
|
|
2009-05-07 17:18:16 +00:00
|
|
|
end
|