Sha256: 8272ee8c70bbf39d4fed00a3a1c939573a786362a4adb7303b1f5a1faed5d1c8

Contents?: true

Size: 1.46 KB

Versions: 17

Compression:

Stored size: 1.46 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[:contents]

      flash[:notice] = "Component file updated."
      redirect_to :controller => 'cms/components', :action => 'edit', :url => @path
    else
      flash[:error] = "Not an editable file."
      redirect_to cms_root_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.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

protected
  def load_component_path
    @path = params[:url].first
    @path = CGI::unescape(@path) if @path.present?
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
liquid_cms-0.2.0.9 app/controllers/cms/components_controller.rb
liquid_cms-0.3.0.7 app/controllers/cms/components_controller.rb
liquid_cms-0.3.0.6 app/controllers/cms/components_controller.rb
liquid_cms-0.2.0.8 app/controllers/cms/components_controller.rb
liquid_cms-0.3.0.5 app/controllers/cms/components_controller.rb
liquid_cms-0.2.0.7 app/controllers/cms/components_controller.rb
liquid_cms-0.3.0.4 app/controllers/cms/components_controller.rb
liquid_cms-0.2.0.6 app/controllers/cms/components_controller.rb
liquid_cms-0.3.0.3 app/controllers/cms/components_controller.rb
liquid_cms-0.2.0.5 app/controllers/cms/components_controller.rb
liquid_cms-0.2.0.4 app/controllers/cms/components_controller.rb
liquid_cms-0.3.0.2 app/controllers/cms/components_controller.rb
liquid_cms-0.2.0.3 app/controllers/cms/components_controller.rb
liquid_cms-0.2.0.2 app/controllers/cms/components_controller.rb
liquid_cms-0.3.0.1 app/controllers/cms/components_controller.rb
liquid_cms-0.3.0 app/controllers/cms/components_controller.rb
liquid_cms-0.2.0 app/controllers/cms/components_controller.rb