Sha256: 252c0871389bfdbd6c783c8c77c43b55c00f843dbadc60498611b7861a7d152d
Contents?: true
Size: 1.47 KB
Versions: 1
Compression:
Stored size: 1.47 KB
Contents
class Cms::ComponentsController < Cms::MainController authenticate_user :all before_filter :load_component_path, :except => :upload 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 def update if Cms::Component.editable?(@path) @component = Cms::Component.new(@context, @path) @component.write params[:file_content] flash[:notice] = "The component file has been updated." redirect_to cms_root_path else flash[:error] = "Not an editable component." redirect_to :controller => 'cms/components', :action => 'edit', :url => @path end end 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 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 protected def load_component_path @path = params[:url] @path = CGI::unescape(@path) if @path.present? end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
liquid_cms-0.3.1.0 | app/controllers/cms/components_controller.rb |