-
Notifications
You must be signed in to change notification settings - Fork 36
/
config.ru
50 lines (45 loc) · 1.02 KB
/
config.ru
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
# -*- ruby -*-
baseurl = nil
basepath = ''
themedir = nil
%w[theme bitclust/theme ../bitclust/theme].each do |theme|
dir = File.expand_path(theme, File.dirname(__FILE__))
if File.directory?(dir)
themedir = dir
end
end
$LOAD_PATH.unshift File.expand_path('lib', File.dirname(__FILE__))
$LOAD_PATH.unshift File.expand_path('bitclust/lib', File.dirname(__FILE__))
require 'bitclust/app'
dbpath = Dir.glob("db-*")
if dbpath.empty?
raise 'database not found' unless File.directory? 'db'
app = BitClust::App.new(
:dbpath => 'db',
:viewpath => "/view/",
:rack => true,
:capi => true
)
app.interfaces.each do |viewpath, interface|
map viewpath do
run interface
end
end
else
app = BitClust::App.new(
:dbpath => dbpath,
:rack => true,
:capi => true
)
app.interfaces.each do |version, interface|
map "#{basepath}/#{version}/" do
run interface
end
end
end
map "#{basepath}/" do
run app
end
map File.join(basepath, 'theme/') do
run Rack::File.new(themedir)
end