-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsite.rb
42 lines (33 loc) · 836 Bytes
/
site.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
require 'rubygems'
require "bundler/setup"
require 'sinatra/base'
require 'sinatra/content_for'
require './config'
class Site < Sinatra::Base
enable :static, :sessions
set :root, File.dirname(__FILE__)
set :public, Proc.new { File.join(root, "public") }
helpers Sinatra::ContentFor
helpers do
def title(t = nil)
@title = t if t
@title
end
end
before do
session[:user_id] ||= Time.now.to_i
end
get '/?' do
title 'Index'
erb :index
end
get '/panel' do
title "Sumavisos Properties Parsers Dashboard"
erb :panel, :layout => :layout_panel
end
get '/:example_name' do |example_name|
titles = { "chat" => "Basic Chat", "todo" => "ToDo List", "drawing" => "Drawing Board"}
title titles[example_name]
erb example_name.to_sym
end
end