-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsample.rb
33 lines (29 loc) · 844 Bytes
/
sample.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
# Require sinatra/base instead of sinatra to avoid some of the magic
# This keeps us from polluting the top level namespace with sinatra's
# magic methods.
require 'sinatra/base'
module Sample
class SampleBase < Sinatra::Base
# setup some options we want shared between all 'controllers'
set :static, true
set :public, File.join(File.dirname(__FILE__),'public')
enable :sessions
end
class Main < SampleBase
set :views, File.join(File.dirname(__FILE__),'views','main')
# Pretty normal application here
get '/' do
erb :index
end
end
class Blog < SampleBase
set :views, File.join(File.dirname(__FILE__),'views','blog')
# We define it this way to not require a hard / at the end of the url
get '/?' do
erb :blog
end
get '/list' do
erb :blog_list
end
end
end