clean up useless code

This commit is contained in:
Wen-Tien Chang 2010-01-04 17:49:55 +08:00
parent 9aeeed140f
commit a674e46c91
4 changed files with 39 additions and 137 deletions

View File

@ -2,84 +2,51 @@ class Admin::LayoutsController < ApplicationController
layout "admin"
# GET /layouts
# GET /layouts.xml
def index
@layouts = Layout.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @layouts }
end
end
# GET /layouts/1
# GET /layouts/1.xml
def show
@layout = Layout.find(params[:id])
redirect_to "/#{@layout.name}"
end
# GET /layouts/new
# GET /layouts/new.xml
def new
@layout = Layout.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @layouts }
end
end
# GET /layouts/1/edit
def edit
@layout = Layout.find(params[:id])
end
# POST /layouts
# POST /layouts.xml
def create
@layout = Layout.new(params[:layout])
respond_to do |format|
if @layout.save
flash[:notice] = 'Layout was successfully created.'
format.html { redirect_to admin_layouts_url }
format.xml { render :xml => @layout, :status => :created, :location => @layouts }
else
format.html { render :action => "new" }
format.xml { render :xml => @layout.errors, :status => :unprocessable_entity }
end
if @layout.save
flash[:notice] = 'Layout was successfully created.'
redirect_to admin_layouts_url
else
render :action => "new"
end
end
# PUT /layouts/1
# PUT /layouts/1.xml
def update
@layout = Layout.find(params[:id])
respond_to do |format|
if @layout.update_attributes(params[:layout])
flash[:notice] = 'Layout was successfully updated.'
format.html { redirect_to admin_layouts_url }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @layout.errors, :status => :unprocessable_entity }
end
if @layout.update_attributes(params[:layout])
flash[:notice] = 'Layout was successfully updated.'
redirect_to admin_layouts_url
else
render :action => "edit"
end
end
# DELETE /layouts/1
# DELETE /layouts/1.xml
def destroy
@layout = Layout.find(params[:id])
@layout.destroy
respond_to do |format|
format.html { redirect_to admin_layouts_url }
format.xml { head :ok }
end
redirect_to admin_layouts_url
end
end

View File

@ -2,86 +2,53 @@ class Admin::PagesController < ApplicationController
layout "admin"
# GET /pages
# GET /pages.xml
def index
@pages = Page.all( :conditions => { :parent_page_id => "root" } )
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
@page.is_published = true
@page.parent_page_id = params[:parent_page_id]
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
if @page.save
flash[:notice] = 'Page was successfully created.'
redirect_to admin_pages_url
else
render :action => "new"
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
if @page.update_attributes(params[:page])
flash[:notice] = 'Page was successfully updated.'
redirect_to admin_pages_url
else
render :action => "edit"
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
redirect_to admin_pages_url
end
end

View File

@ -2,27 +2,16 @@ class Admin::SnippetsController < ApplicationController
layout "admin"
# GET /snippets
# GET /snippets.xml
def index
@snippets = Snippet.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @snippets }
end
end
# GET /snippets/1
# GET /snippets/1.xml
def show
@snippet = Snippet.find(params[:id])
redirect_to "/#{@snippet.name}"
end
# GET /snippets/new
# GET /snippets/new.xml
def new
@snippet = Snippet.new
@ -42,60 +31,39 @@ class Admin::SnippetsController < ApplicationController
end
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @snippets }
end
end
# GET /snippets/1/edit
def edit
@snippet = Snippet.find(params[:id])
end
# POST /snippets
# POST /snippets.xml
def create
@snippet = Snippet.new(params[:snippet])
respond_to do |format|
if @snippet.save
flash[:notice] = 'Snippet was successfully created.'
format.html { redirect_to admin_snippets_url }
format.xml { render :xml => @snippet, :status => :created, :location => @snippets }
else
format.html { render :action => "new" }
format.xml { render :xml => @snippet.errors, :status => :unprocessable_entity }
end
if @snippet.save
flash[:notice] = 'Snippet was successfully created.'
redirect_to admin_snippets_url
else
render :action => "new"
end
end
# PUT /snippets/1
# PUT /snippets/1.xml
def update
@snippet = Snippet.find(params[:id])
respond_to do |format|
if @snippet.update_attributes(params[:snippet])
flash[:notice] = 'Snippet was successfully updated.'
format.html { redirect_to admin_snippets_url }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @snippet.errors, :status => :unprocessable_entity }
end
if @snippet.update_attributes(params[:snippet])
flash[:notice] = 'Snippet was successfully updated.'
redirect_to admin_snippets_url
else
render :action => "edit"
end
end
# DELETE /snippets/1
# DELETE /snippets/1.xml
def destroy
@snippet = Snippet.find(params[:id])
@snippet.destroy
respond_to do |format|
format.html { redirect_to admin_snippets_url }
format.xml { head :ok }
end
redirect_to admin_snippets_url
end
end

View File

@ -29,7 +29,7 @@ Rails::Initializer.run do |config|
# Skip frameworks you're not going to use. To use Rails without a database,
# you must remove the Active Record framework.
# config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
config.frameworks -= [ :active_record ]
# Activate observers that should always be running
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer