Class: Cms::ComponentsController
Instance Method Summary
collapse
#index
#authenticate_user
#authorize_role, #current_user
Instance Method Details
#destroy ⇒ Object
36
37
38
39
40
41
42
43
44
|
# File 'app/controllers/cms/components_controller.rb', line 36
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
27
28
29
30
31
32
33
34
|
# File 'app/controllers/cms/components_controller.rb', line 15
def update
edit_url = {:controller => 'cms/components', :action => 'edit', :url => @path}
if Cms::Component.editable?(@path)
@component = Cms::Component.new(@context, @path)
@component.write params[:file_content]
respond_to do |format|
format.html {
redirect_to edit_url, :notice => t('components.flash.updated')
}
format.js {
flash.now[:notice] = t('components.flash.updated')
}
end
else
flash[:error] = "Not an editable component."
redirect_to edit_url
end
end
|
#upload ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'app/controllers/cms/components_controller.rb', line 46
def upload
component_zip = params[:zip_file]
if component_zip.present? && File.extname(component_zip.original_filename) == '.zip'
Cms::Component.expand @context, 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
|