Class: Cms::ContentBlockController
Instance Method Summary
collapse
#handle_access_denied_on_page, #handle_draft_not_found, #handle_not_found_on_page, #handle_server_error_on_page, #show_content_as_page
allow_guests_to
#no_browser_caching
Instance Method Details
#bulk_update ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'app/controllers/cms/content_block_controller.rb', line 25
def bulk_update
ids = params[:content_id] || []
models = ids.collect do |id|
model_class.find(id.to_i)
end
if params[:commit] == 'Delete'
deleted = models.select do |m|
m.destroy
end
flash[:notice] = "Deleted #{deleted.size} records."
else
published = models.select do |m|
m.publish!
end
flash[:notice] = "Published #{published.size} records."
end
redirect_to action: :index
end
|
#create ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'app/controllers/cms/content_block_controller.rb', line 84
def create
return render_not_implemented if readonly?
if create_block
after_create_on_success
else
after_create_on_failure
end
rescue Exception => @exception
raise @exception if @exception.is_a?(Cms::Errors::AccessDenied)
after_create_on_error
end
|
#destroy ⇒ Object
125
126
127
128
129
130
131
132
133
134
|
# File 'app/controllers/cms/content_block_controller.rb', line 125
def destroy
return render_not_implemented if readonly?
do_command("deleted") { @block.destroy }
respond_to do |format|
format.html { redirect_to_first params[:_redirect_to], engine_aware_path(@block.class) }
format.json { render :json => { :success => true } }
end
end
|
#edit ⇒ Object
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'app/controllers/cms/content_block_controller.rb', line 97
def edit
load_block_draft
if readonly?
url = [params[:_redirect_to], engine_aware_path(@block)].map(&:presence).compact.first
if url
return redirect_to url, alert: 'Read only models cannot be edited'
else
return render_not_implemented
end
end
end
|
#index ⇒ Object
21
22
23
|
# File 'app/controllers/cms/content_block_controller.rb', line 21
def index
load_blocks
end
|
#inline ⇒ Object
Getting the content for the editing frame.
64
65
66
67
|
# File 'app/controllers/cms/content_block_controller.rb', line 64
def inline
load_block_draft
render_block_in_main_container
end
|
#new ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'app/controllers/cms/content_block_controller.rb', line 69
def new
build_block
if readonly?
url = [params[:_redirect_to], engine_aware_path(@block, nil)].map(&:presence).compact.first
if url
return redirect_to url, alert: 'Read only models cannot be created'
else
return render_not_implemented
end
end
set_default_category
end
|
170
171
172
|
# File 'app/controllers/cms/content_block_controller.rb', line 170
def new_button_path
new_engine_aware_path(content_type) unless readonly?
end
|
#publish ⇒ Object
138
139
140
141
142
143
|
# File 'app/controllers/cms/content_block_controller.rb', line 138
def publish
return render_not_implemented if readonly?
do_command("published") { @block.publish! }
redirect_to_first params[:_redirect_to], engine_aware_path(@block, nil)
end
|
#revert_to ⇒ Object
145
146
147
148
149
150
151
152
|
# File 'app/controllers/cms/content_block_controller.rb', line 145
def revert_to
return render_not_implemented if readonly?
do_command("reverted to version #{params[:version]}") do
revert_block(params[:version])
end
redirect_to_first params[:_redirect_to], engine_aware_path(@block, nil)
end
|
#show ⇒ Object
Getting content by its id (i.e. /products/:id) Logged in editors will get the editing frame.
58
59
60
61
|
# File 'app/controllers/cms/content_block_controller.rb', line 58
def show
load_block_draft
render_editing_frame_or_block_in_main_container
end
|
#show_via_slug ⇒ Object
Getting content by its path (i.e. /products/:slug)
48
49
50
51
52
53
54
|
# File 'app/controllers/cms/content_block_controller.rb', line 48
def show_via_slug
@block = model_class.with_slug(params[:slug])
unless @block
raise Cms::Errors::ContentNotFound.new("No Content at #{model_class.calculate_path(params[:slug])}")
end
render_block_in_main_container
end
|
#update ⇒ Object
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'app/controllers/cms/content_block_controller.rb', line 110
def update
return render_not_implemented if readonly?
if update_block
after_update_on_success
else
after_update_on_failure
end
rescue ActiveRecord::StaleObjectError => @exception
after_update_on_edit_conflict
rescue Exception => @exception
raise @exception if @exception.is_a?(Cms::Errors::AccessDenied)
after_update_on_error
end
|
#version ⇒ Object
154
155
156
157
158
159
160
161
162
|
# File 'app/controllers/cms/content_block_controller.rb', line 154
def version
return render_not_implemented unless versioned?
load_block
if params[:version]
@block = @block.as_of_version(params[:version])
end
render "show_in_isolation"
end
|
#versions ⇒ Object
164
165
166
167
168
|
# File 'app/controllers/cms/content_block_controller.rb', line 164
def versions
return render_not_implemented unless versioned?
load_block
end
|