forked from zapnap/sinatra-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.rb
55 lines (43 loc) · 801 Bytes
/
app.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
require "bundler"
Bundler.require
Dir["./lib/**/*.rb"].each { |file| require file }
if development?
require "dotenv"
Dotenv.load
end
configure do
set :haml, format: :html5
set :environment, :development
enable :logging
if production?
set :scss, style: :compressed, debug_info: false
end
end
helpers do
def development?
settings.development?
end
def production?
settings.production?
end
end
error ActiveRecord::RecordNotFound do
status(404)
@error = "Page not found"
haml :error
end
not_found do
status(404)
@error ||= "We don't know about that!"
haml :error
end
error do
@error = request.env["sinatra.error"].to_s
haml :error
end if production?
get "/application.css" do
scss :"/stylesheets/application"
end
get "/" do
haml :index
end