Sha256: 9e742266d2fdfb450861e6fb5f219f072aecd23be534a5537f3bd43bd649ec95

Contents?: true

Size: 841 Bytes

Versions: 3

Compression:

Stored size: 841 Bytes

Contents

class MountainGoatController < ActionController::Base
  
  self.prepend_view_path File.join([File.dirname(__FILE__), '../../views/mountain_goat/'])
  
  
  def fetch
    ct = { :png => 'image/png', :css => 'text/css', :html => 'text/html', :js => 'text/javascript' }
    
    Dir.open(File.join([File.dirname(__FILE__), '../../public/'])).each do |file|
      if file == params[:file].gsub('_','.')
        if file =~ /[.]([a-z0-9]+)$/
          response.headers['Content-Type'] = ct[$1.to_sym]
        end
        response.headers['Content-Disposition'] = 'inline'
        render :text => open(File.join([File.dirname(__FILE__), '../../public/', file]), "rb").read
        return
      end
    end
    
    render :file => "#{Rails.root}/public/404.html", :status => :not_found
  end
  
  layout 'mountain_goat'
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mountain-goat-0.0.8 lib/mountain-goat/controllers/mountain_goat/mountain_goat_controller.rb
mountain-goat-0.0.6 lib/mountain_goat/controllers/mountain_goat/mountain_goat_controller.rb
mountain-goat-0.0.5 lib/mountain_goat/controllers/mountain_goat/mountain_goat_controller.rb