Class: Qlive::SourcesController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/qlive/sources_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



4
5
6
7
8
9
10
11
# File 'app/controllers/qlive/sources_controller.rb', line 4

def show
  base_path = Qlive.setup[:base_path]
  rel_path = params[:rel_path]
  path = File.expand_path("./#{rel_path}#{rel_path.end_with?('.js') ? '' : '.js'}", base_path)
  raise "Illegal path: #{path}" unless path.start_with?(base_path)
  headers['Content-Type'] = 'application/javascript'  # serve other types?  If so: (Mime::Type.lookup_by_extension(params[:format]).to_s rescue 'text/text')
  render :text => IO.read(path), :status => 200
end