Sha256: 853fef7bd958a9ed041a9e3731c9c7a4978d1628e374be6a57c6434a24f54fb2

Contents?: true

Size: 964 Bytes

Versions: 8

Compression:

Stored size: 964 Bytes

Contents

# frozen_string_literal: true

class Ckeditor::PicturesController < Ckeditor::ApplicationController
  skip_before_action :verify_authenticity_token, only: :create, raise: false

  def index
    @pictures = Ckeditor.picture_adapter.find_all(ckeditor_pictures_scope)
    @pictures = Ckeditor::Paginatable.new(@pictures).page(params[:page])

    respond_to do |format|
      format.html { render layout: @pictures.first_page? }
    end
  end

  def create
    @picture = Ckeditor.picture_model.new
    respond_with_asset(@picture)
  end

  def destroy
    @picture.destroy

    respond_to do |format|
      format.html { redirect_to pictures_path }
      format.json { render json: @picture, status: 204 }
    end
  end

  protected

  def find_asset
    @picture = Ckeditor.picture_adapter.get!(params[:id])
  end

  def authorize_resource
    model = (@picture || Ckeditor.picture_model)
    @authorization_adapter.try(:authorize, params[:action], model)
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
ckeditor-5.1.3 app/controllers/ckeditor/pictures_controller.rb
ckeditor-5.1.2 app/controllers/ckeditor/pictures_controller.rb
ckeditor-5.1.1 app/controllers/ckeditor/pictures_controller.rb
glebtv-ckeditor-4.14.1 app/controllers/ckeditor/pictures_controller.rb
ckeditor-5.1.0 app/controllers/ckeditor/pictures_controller.rb
glebtv-ckeditor-4.13.1 app/controllers/ckeditor/pictures_controller.rb
glebtv-ckeditor-4.13.0 app/controllers/ckeditor/pictures_controller.rb
ckeditor-5.0.0 app/controllers/ckeditor/pictures_controller.rb