forked from assimovt/statusboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication.rb
59 lines (47 loc) · 1.28 KB
/
application.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
require 'rubygems'
require 'bundler/setup'
require 'compass'
require 'sinatra'
require 'sass'
require 'haml'
require File.join(File.dirname(__FILE__), 'config', 'environment')
# set sinatra's variables
set :app_file, __FILE__
set :root, File.dirname(__FILE__)
set :views, "views"
set :public_folder, "public"
set :haml, {:format => :html5} # default Haml format is :xhtml
# at a minimum, the main scss file must reside within the ./views directory. here, we create a ./views/stylesheets directory where all of the sass files can safely reside.
get '/stylesheets/:name.css' do
content_type 'text/css', :charset => 'utf-8'
scss(:"stylesheets/#{params[:name]}", Compass.sass_engine_options )
end
error do
e = request.env['sinatra.error']
Kernel.puts e.backtrace.join("\n")
'Application error'
end
helpers do
# add your helpers here
end
# root page
get '/' do
haml :root
end
get '/uptimes' do
haml :uptimes
end
get '/statuses.json' do
content_type :json
Status.current.to_json
end
get '/uptime' do
@start_time = Time.at(params[:start_time].to_i) rescue 0
@end_time = Time.at(params[:end_time].to_i) rescue 0
@node = Node.new(params[:node])
Status.uptime(@start_time, @end_time, @node)
end
get '/feed.json' do
content_type :json
Status.feed.to_json
end