Class: Cms::PagesController
Instance Method Summary
collapse
Methods included from PageHelper
#able_to?, #cms_toolbar, #container, #container_has_block?, #current_page, #page_title, #render_breadcrumbs, #render_portlet
Methods included from PathHelper
#cms_connectable_path, #cms_index_path_for, #cms_index_url_for, #cms_new_path_for, #cms_new_url_for, #edit_cms_connectable_path
#handle_access_denied, #handle_server_error, included
Instance Method Details
#create ⇒ Object
24
25
26
27
28
29
30
31
32
33
|
# File 'app/controllers/cms/pages_controller.rb', line 24
def create
@page = Page.new(params[:page])
@page.section = @section
if @page.save
flash[:notice] = "Page was '#{@page.name}' created."
redirect_to [:cms, @page]
else
render :action => "new"
end
end
|
#destroy ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'app/controllers/cms/pages_controller.rb', line 47
def destroy
respond_to do |format|
if @page.destroy
message = "Page '#{@page.name}' was deleted."
format.html { flash[:notice] = message; redirect_to(cms_sitemap_url) }
format.json { render :json => {:success => true, :message => message } }
else
message = "Page '#{@page.name}' could not be deleted"
format.html { flash[:error] = message; redirect_to(cms_sitemap_url) }
format.json { render :json => {:success => false, :message => message } }
end
end
end
|
#new ⇒ Object
12
13
14
15
16
17
18
|
# File 'app/controllers/cms/pages_controller.rb', line 12
def new
@page = Page.new(:section => @section, :cacheable => true)
if @section.child_nodes.count < 1
@page.name = "Overview"
@page.path = @section.path
end
end
|
#revert_to ⇒ Object
89
90
91
92
93
94
95
96
97
98
|
# File 'app/controllers/cms/pages_controller.rb', line 89
def revert_to
if @page.revert_to(params[:version])
flash[:notice] = "Page '#{@page.name}' was reverted to version #{params[:version]}"
end
respond_to do |format|
format.html { redirect_to @page.path }
format.js { render :template => 'cms/shared/show_notice' }
end
end
|
#show ⇒ Object
20
21
22
|
# File 'app/controllers/cms/pages_controller.rb', line 20
def show
redirect_to Page.find(params[:id]).path
end
|
#update ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
|
# File 'app/controllers/cms/pages_controller.rb', line 35
def update
if @page.update_attributes(params[:page])
flash[:notice] = "Page was '#{@page.name}' updated."
redirect_to [:cms, @page]
else
render :action => "edit"
end
rescue ActiveRecord::StaleObjectError => e
@other_version = @page.class.find(@page.id)
render :action => "edit"
end
|
#version ⇒ Object
80
81
82
83
84
85
86
87
|
# File 'app/controllers/cms/pages_controller.rb', line 80
def version
@page = @page.as_of_version(params[:version])
@show_toolbar = true
@show_page_toolbar = true
@_connectors = @page.connectors.for_page_version(@page.version)
@_connectables = @_connectors.map(&:connectable_with_deleted)
render :layout => @page.layout, :template => 'cms/content/show'
end
|