forked from tobykurien/MxitRuby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.rb
38 lines (29 loc) · 799 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
require 'rubygems'
require 'sinatra'
require 'ruty'
require 'modules/mxit/mxit'
@@loader = nil
before do
@@loader = Ruty::Loaders::Filesystem.new(:dirname => './views') if @@loader == nil
# Strip the last / from the path
request.env['PATH_INFO'].gsub!(/\/$/, '')
@mxit = Mxit.new request.env
end
get '/event_details/:e_uri' do |e_uri|
do_render :coming_soon, :message => "coming soon for #{e_uri}"
end
get '' do
data = {
:mxit => @mxit,
:events => [
{ :uri => 1, :name => "Test event 1" },
{ :uri => 2, :name => "Test event 2" }
]
}
do_render :index, data
end
private
def do_render(template, obj)
obj = { :root => @env['SCRIPT_NAME'] + "/" }.merge obj # add root variable
@@loader.get_template(template.to_s + ".html").render(obj)
end