Sha256: 781fbb98a3050fa04e421bc853230487404783be5741ddc3065ccbf80e55591d

Contents?: true

Size: 713 Bytes

Versions: 2

Compression:

Stored size: 713 Bytes

Contents

module AdminData
  class PublicController < ApplicationController

    def serve
      path = File.join(AdminData::LIBPATH, 'public', params[:file])

      unless File.expand_path(path) =~ /admin_data/
        render :nothing => true, :status => 404 and return
      end

      case params[:file]
      when /\.css$/i
        content_type = "text/css"
      when /\.js$/i
        content_type = "text/javascript"
      when /\.png$/i
        content_type = "image/png"
      when /\.jpg$/i
        content_type = "image/jpg"
      else
        render :nothing => true, :status => 404 and return
      end

      render({:text => File.read(path), :cache => true, :content_type => content_type})
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
admin_data-1.1.14 app/controllers/admin_data/public_controller.rb
admin_data-1.1.13 app/controllers/admin_data/public_controller.rb