-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.cr
38 lines (32 loc) · 864 Bytes
/
index.cr
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
require "http/client"
require "json"
require "kemal"
require "kilt/slang"
require "sqlite3"
require "yaml"
require "./handlers/sass_handler"
macro partial(id, title)
config_path = "./config/{{id.id}}.yaml"
config = YAML.parse(
begin
File.read(config_path)
rescue
""
end
)
id = {{id.stringify}}
title = {{title}}
stylesheet = %{<link href="/css/{{id.id}}.css" rel="stylesheet">} if File.exists?("./scss/{{id.id}}.scss")
# TODO: fix Slang to allow unescaped interpolation
HTML.unescape(render "./views/{{id.id}}.slang", "./views/layout.slang")
end
get "/" do
partial :index, "Home"
end
get "/cycling" do
DB.open "sqlite3://./misc.db" do |db|
cyclists = db.query_all("select name, falls from cycling order by falls desc", as: {name: String, falls: Int32})
partial :cycling, "Cycling"
end
end
Kemal.run 3692