lib/fnordmetric/app.rb in fnordmetric-0.6.2 vs lib/fnordmetric/app.rb in fnordmetric-0.6.3
- old
+ new
@@ -1,20 +1,25 @@
# encoding: utf-8
class FnordMetric::App < Sinatra::Base
@@sessions = Hash.new
+ @@public_files = {
+ "fnordmetric.css" => "text/css",
+ "fnordmetric.js" => "application/x-javascript",
+ "vendor/jquery-1.6.1.min.js" => "application/x-javascript",
+ "vendor/highcharts.js" => "application/x-javascript"
+ }
Encoding.default_external = Encoding::UTF_8
#use Rack::Reloader, 0
enable :session
set :haml, :format => :html5
- set :views, ::File.expand_path('../../../haml', __FILE__)
- set :public_folder, ::File.expand_path('../../../pub', __FILE__)
+ set :views, ::File.expand_path('../../../haml', __FILE__)
def initialize(namespaces, opts)
@namespaces = {}
@redis = Redis.connect(:url => opts[:redis_url])
@opts = opts
@@ -124,9 +129,15 @@
post '/events' do
halt 400, 'please specify the event_type (_type)' unless params["_type"]
track_event((8**32).to_s(36), parse_params(params))
end
+ @@public_files.each do |public_file, public_file_type|
+ get "/#{public_file}" do
+ content_type(public_file_type)
+ ::File.open(::File.expand_path("../../../pub/#{public_file}", __FILE__)).read
+ end
+ end
private
def parse_params(hash)
hash.tap do |h|
h.keys.each{ |k| h[k] = parse_param(h[k]) }