Class: Cms::ComponentsController
Instance Method Summary
collapse
#index
#authenticate_user
#authorize_role, #current_user
Instance Method Details
#destroy ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'app/controllers/cms/components_controller.rb', line 28
def destroy
if @path.present? && Cms::Component.new(@context, @path).delete
flash[:notice] = 'The component has been removed.'
else
flash[:error] = 'The component path was invalid.'
end
redirect_to cms_root_path
end
|
#edit ⇒ Object
6
7
8
9
10
11
12
13
|
# File 'app/controllers/cms/components_controller.rb', line 6
def edit
if Cms::Component.editable?(@path)
@component = Cms::Component.new(@context, @path)
else
flash[:error] = "Not an editable component."
redirect_to cms_root_path
end
end
|
#update ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'app/controllers/cms/components_controller.rb', line 15
def update
if Cms::Component.editable?(@path)
@component = Cms::Component.new(@context, @path)
@component.write params[:file_content]
flash[:notice] = "Component file updated."
redirect_to cms_root_path
else
flash[:error] = "Not an editable file."
redirect_to :controller => 'cms/components', :action => 'edit', :url => @path
end
end
|
#upload ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'app/controllers/cms/components_controller.rb', line 38
def upload
component_zip = params[:zip_file]
if component_zip.present? && File.extname(component_zip.original_filename) == '.zip'
Cms::Component.new(@context).expand component_zip.path
flash[:notice] = 'The component has been uploaded.'
else
flash[:error] = 'The component file must be a zip archive.'
end
redirect_to cms_root_path
end
|