Class: AdminData::PublicController

Inherits:
ApplicationController show all
Defined in:
app/controllers/admin_data/public_controller.rb

Instance Attribute Summary

Attributes inherited from ApplicationController

#klass

Instance Method Summary collapse

Instance Method Details

#serveObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/admin_data/public_controller.rb', line 4

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

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

  case params[:format].to_s.downcase
  when 'css'
    content_type = "text/css"
  when 'js'
    content_type = "text/javascript"
  when 'png'
    content_type = "image/png"
  when 'jpg'
    content_type = "image/jpg"
  else
    render :nothing => true, :status => 404 and return
  end

  render({:text => File.read("#{path}.#{params[:format]}"), :cache => true, :content_type => content_type})
end