Sha256: 7facb4f2c63d7b9acd0c46a376e3aa6fb8752682aeea05d51e5bcd718e20f4be

Contents?: true

Size: 1.05 KB

Versions: 37

Compression:

Stored size: 1.05 KB

Contents

class PrometheeController < ApplicationController
  # This is acceptable because the iframe is sandboxed
  skip_before_action :verify_authenticity_token, only: :preview

  def preview
    @data = params[:data]
    render 'preview', layout: params[:preview_layout] if params.include? :preview_layout
  end

  def blob_create
    io = params[:file].to_io
    filename = params[:file].original_filename
    content_type = params[:file].content_type
    blob = ActiveStorage::Blob.create_after_upload! io: io, filename: filename, content_type: content_type
    render json: { id: blob.signed_id, name: filename }
  end

  def blob_show
    # as this is called only from promethee preview it sends an image resized to 720
    begin
      blob = ActiveStorage::Blob.find_signed(params[:id])
    rescue
      raise ActiveRecord::RecordNotFound
    end

    if blob.image? && blob.variable?
      redirect_to url_for(blob.variant(resize: '720>'))
    elsif blob.video?
      redirect_to url_for(blob.preview(resize: '720>'))
    else
      redirect_to url_for(blob)
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
promethee-4.1.24 app/controllers/promethee_controller.rb
promethee-4.1.23 app/controllers/promethee_controller.rb
promethee-4.1.22 app/controllers/promethee_controller.rb
promethee-4.1.21 app/controllers/promethee_controller.rb
promethee-4.1.20 app/controllers/promethee_controller.rb
promethee-4.1.19 app/controllers/promethee_controller.rb
promethee-4.1.18 app/controllers/promethee_controller.rb
promethee-4.1.17 app/controllers/promethee_controller.rb
promethee-4.1.16 app/controllers/promethee_controller.rb
promethee-4.1.15 app/controllers/promethee_controller.rb
promethee-4.1.14 app/controllers/promethee_controller.rb
promethee-4.1.13 app/controllers/promethee_controller.rb
promethee-4.1.12 app/controllers/promethee_controller.rb
promethee-4.1.11 app/controllers/promethee_controller.rb
promethee-4.1.10 app/controllers/promethee_controller.rb
promethee-4.1.9 app/controllers/promethee_controller.rb
promethee-4.1.8 app/controllers/promethee_controller.rb
promethee-4.1.7 app/controllers/promethee_controller.rb
promethee-4.1.6 app/controllers/promethee_controller.rb
promethee-4.1.5 app/controllers/promethee_controller.rb