diff options
author | Daniel Beauchamp <daniel.beauchamp@shopify.com> | 2012-08-08 18:02:56 -0400 |
---|---|---|
committer | Daniel Beauchamp <daniel.beauchamp@shopify.com> | 2012-08-08 18:06:58 -0400 |
commit | 780fe49f715c2fced88e958b02541bf8e7dca934 (patch) | |
tree | 7cd147e96913c9f95cda54f4bd341d0630e34c66 /lib | |
parent | cdd8ff258582f5eba7e3941a5a18007e7aabbbfa (diff) |
Rename project to 'Dashing', and do some other cleanups
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dashing.rb (renamed from lib/allthethings.rb) | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/lib/allthethings.rb b/lib/dashing.rb index 8fbef07..8b2af2f 100644 --- a/lib/allthethings.rb +++ b/lib/dashing.rb @@ -5,20 +5,15 @@ require 'coffee-script' require 'sass' require 'json' -Dir[File.join(Dir.pwd, 'lib/**/*.rb')].each {|file| require file } - SCHEDULER = Rufus::Scheduler.start_new set server: 'thin', connections: [], history: {} -helpers Sinatra::ContentFor - -def configure(&block) - set :public_folder, Dir.pwd + '/public' - set :views, Dir.pwd + '/dashboards' - set :default_dashboard, nil - instance_eval(&block) -end +set :public_folder, File.join(Dir.pwd, 'public') +set :views, File.join(Dir.pwd, 'dashboards') +set :default_dashboard, nil +set :auth_token, nil +helpers Sinatra::ContentFor helpers do def protected! # override with auth logic @@ -50,14 +45,14 @@ end get '/views/:widget?.html' do protected! widget = params[:widget] - send_file File.join(Dir.pwd, "widgets/#{widget}/#{widget}.html") + send_file File.join(Dir.pwd, 'widgets', widget, "#{widget}.html") end post '/widgets/:id' do request.body.rewind body = JSON.parse(request.body.read) auth_token = body.delete("auth_token") - if auth_token == settings.auth_token + if !settings.auth_token || settings.auth_token == auth_token send_event(params['id'], body) 204 # response without entity body else @@ -68,7 +63,7 @@ end def framework_javascripts ['jquery.js', 'es5-shim.js', 'batman.js', 'batman.jquery.js', 'application.coffee', 'widget.coffee'].collect do |f| - File.join(File.expand_path("../../vendor/javascripts", __FILE__), f) + File.join(File.expand_path('../../vendor/javascripts', __FILE__), f) end end @@ -119,11 +114,13 @@ def latest_events end def first_dashboard - files = Dir[settings.views + "/*.erb"].collect { |f| f.match(/(\w*).erb/)[1] } + files = Dir[File.join(settings.views, '*.erb')].collect { |f| f.match(/(\w*).erb/)[1] } files -= ['layout'] files.first end +Dir[File.join(Dir.pwd, 'lib', '**', '*.rb')].each {|file| require file } + job_path = ENV["JOB_PATH"] || 'jobs' -files = Dir[Dir.pwd + "/#{job_path}/*.rb"] +files = Dir[File.join(Dir.pwd, job_path, '/*.rb')] files.each { |job| require(job) }
\ No newline at end of file |