-
Notifications
You must be signed in to change notification settings - Fork 1
/
web.arc
62 lines (52 loc) · 1.46 KB
/
web.arc
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
55
56
57
58
59
60
61
62
; Web init
; Starts the web page server and sets a number of variables
;(def web-init
; (= staticdir* "../../metagame/static/"))
; Define a main page. If there is no login cookie, pop out a login prompt,
;
; Later it will display player-relavent data such owned objects
(defopr || req "main")
(defop main req
(doctype)
(tag (html)
(tag (head)
(add-js "js/jquery.js")
(add-js "metagame.js"))
(tag (body)
(tag (div)
(login-prompt))
(tag (div)
(if (req 'cooks) (pr (req 'cooks))
(pr "no cookies")))
(tag (p)))))
(defop register req
(doctype)
(tag (html)
(tag (head)
(add-js "js/jquery.js")
(add-js "metagame.js"))
(tag (body)
(tag (div)
(register-prompt))
(tag (div)
(link "Go back to main page" "main")))))
; Various HTML printing functions
; prints doctype for HTML5
(def doctype ()
(pr "<!DOCTYPE HTML>"))
(def add-js (filename)
(tag (script src filename type "text/javascript")))
(def login-prompt ()
(aform web-login
(myinput "text" "login_username")
(myinput "password" "login_password")
(but "Login" "login_button")
(nbsp)
(link "Register" "register")))
(def register-prompt ()
(aform web-register
(myinput "text" "register_username")
(myinput "password" "register_password")
(but "Register" "register_button")))
(def myinput (type name (o val "") (o size 10))
(gentag input type type name name value val size size))