Sha256: 1f2be9026f01cd132518c76b46419b1862bad830b9221aea90acdac4bc91848f

Contents?: true

Size: 969 Bytes

Versions: 19

Compression:

Stored size: 969 Bytes

Contents

require "rack/mime"
require "mimemagic"

class Jets::PublicController < Jets::Controller::Base
  layout false
  internal true

  if Jets::Commands::Build.poly_only?
    # Use python if poly only so we don't have to upload rubuy
    python :show
  else
    def show
      public_path = Jets.root + "public"
      catchall_path = "#{public_path}/#{params[:catchall]}"
      if File.exist?(catchall_path)
        content_type = Rack::Mime.mime_type(File.extname(catchall_path))
        binary = !MimeMagic.by_path(catchall_path).text?
        puts "content_type #{content_type.inspect}"
        puts "binary #{binary}"

        if binary
          encoded_content = Base64.encode64(IO.read(catchall_path))
          render plain: encoded_content, content_type: content_type, base64: true
        else
          render file: catchall_path, content_type: content_type
        end
      else
        render file: "#{public_path}/404", status: 404
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
jets-0.9.2 lib/jets/internal/app/controllers/jets/public_controller.rb
jets-0.9.1 lib/jets/internal/app/controllers/jets/public_controller.rb
jets-0.9.0 lib/jets/internal/app/controllers/jets/public_controller.rb
jets-0.8.18 lib/jets/internal/app/controllers/jets/public_controller.rb
jets-0.8.17 lib/jets/internal/app/controllers/jets/public_controller.rb
jets-0.8.15 lib/jets/internal/app/controllers/jets/public_controller.rb
jets-0.8.14 lib/jets/internal/app/controllers/jets/public_controller.rb
jets-0.8.13 lib/jets/internal/app/controllers/jets/public_controller.rb
jets-0.8.12 lib/jets/internal/app/controllers/jets/public_controller.rb
jets-0.8.11 lib/jets/internal/app/controllers/jets/public_controller.rb
jets-0.8.10 lib/jets/internal/app/controllers/jets/public_controller.rb
jets-0.8.9 lib/jets/internal/app/controllers/jets/public_controller.rb
jets-0.8.8 lib/jets/internal/app/controllers/jets/public_controller.rb
jets-0.8.6 lib/jets/internal/app/controllers/jets/public_controller.rb
jets-0.8.5 lib/jets/internal/app/controllers/jets/public_controller.rb
jets-0.8.4 lib/jets/internal/app/controllers/jets/public_controller.rb
jets-0.8.3 lib/jets/internal/app/controllers/jets/public_controller.rb
jets-0.8.2 lib/jets/internal/app/controllers/jets/public_controller.rb
jets-0.8.1 lib/jets/internal/app/controllers/jets/public_controller.rb