/
web.lisp
54 lines (41 loc) · 942 Bytes
/
web.lisp
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
51
52
53
54
;; Helper
(defmacro (defun)
(defun name parameter expr)
(label name (lambda parameter expr)))
(defun tag (name text) (string "<" name ">" text "</" name ">"))
(defun tag_class (name class text) (
string "<" name " class='" class "'>" text "</" name ">"))
(defun h1 (text) (tag h1 text))
(defun para (text) (tag p text))
(defun div (class text) (tag_class div class text))
(defun pre (text) (tag pre text))
(defun html (title text)
(string
(tag html
(string
(tag head (tag "title" title))
(tag body text)
)
)
)
)
;; Website
(setq TITLE "RLISP Webserver")
(defun template (content)
(html TITLE
(string
(div container content)
)
)
)
(defun start_page(env)
(template
(string
(h1 TITLE)
(para "Welcome to the first rlisp site!")
(para "It's very cool")
(para (string (+ 23 42)))
)
)
)
(defun rack_handler (env) (start_page env))