-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.rb
More file actions
62 lines (50 loc) · 1.38 KB
/
app.rb
File metadata and controls
62 lines (50 loc) · 1.38 KB
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
60
61
62
class App < Sinatra::Base
logger filename: "log/sinatra.log", level: :trace
configure do
set :root, File.dirname(__FILE__) # You must set app root
set :cache_enabled, false
set :sessions, false
set :show_exceptions, true
set :environment, ENV['RACK_ENV'].to_sym
set :haml, layout: :layout
set :partial_template_engine, :haml
register Sinatra::Partial
enable :partial_underscores
register Sinatra::AssetPack
register Sinatra::Reloader
set :page_size, 15
set :offset, 0
set :query, ""
end
assets {
serve '/js', from: 'assets/js'
serve '/css', from: 'assets/css'
serve '/images', from: 'assets/images'
css :main, ['/css/reset.css','/css/app.css']
js :main, ['/js/app.js']
}
configure :production do
assets {
css_compression :sass
js_compression :jsmin
}
end
Dir.glob('./routes/*.rb').each do |route|
print "Loading Routes: #{route}..."
begin
t = require route
puts t ? "Success!" : "Failed!"
rescue Exception => e
puts "#{route}... Failed!"
puts "Route Error: #{e.message}"
end
end
before do
logger.debug "Offset: #{settings.offset}, Query:#{settings.query[0..20]}"
headers "Content-Type" => "text/html; charset=utf-8"
@js = []
end
get '/' do
haml :index, layout: :layout, locals: {page_title: 'Home'}
end
end # Website