-
Notifications
You must be signed in to change notification settings - Fork 1
/
template.lisp
67 lines (60 loc) · 2.12 KB
/
template.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
55
56
57
58
59
60
61
62
63
64
65
;;;;;; template.lisp
(in-package #:linkdemo)
(<:augment-with-doctype "html" "" :auto-emit-p t)
(defun html-frame (context)
(<:html
(<:head (<:title (getf context :title))
;;style
(<:link :rel "stylesheet" :type "text/css" :href "/static/css/style.css"))
(<:body
(<:div
(<:h1 (getf context :title))
(<:a :href (genurl 'home) "Home") " | "
(if (logged-on-p)
(list (<:a :href (genurl 'submit) "Submit a link")
" | "
(<:a :href (genurl '-authdemo-.logout)
(format nil "Logout ~A"
(logged-on-p))))
(list (<:a :href (genurl '-authdemo-.login) "Log in")
" or "
(<:a :href (genurl '-authdemo-.register) "Register")))
(<:hr))
(getf context :body))))
(defun home-page (links)
(loop
for link in links
collect
(<:div (if (logged-on-p)
(if (getf link :voted-p)
"*"
(<:a :href (genurl 'upvote-link :id (getf link :id))
"upvote"))
"*")
" "
(getf link :votes)
" "
(<:a :href (getf link :url) (getf link :title)))))
;(defun login-form ()
; (<:form :action (genurl 'login/post) :method "post"
; "User name:"
; (<:input :type "text" :name "username")(<:br)
; "Password:" (<:br)
; (<:input :type "password" :name "password") (<:br)
; (<:input :type "submit" :value "Log in")))
;
;(defun register-form ()
; (<:form :action (genurl 'register/post) :method "post"
; "User name:" (<:br)
; (<:input :type "text" :name "username")(<:br)
; "Password:" (<:br)
; (<:input :type "password" :name "password") (<:br)
; (<:input :type "submit" :value "Register")))
;
(defun submit-form ()
(<:form :action (genurl 'submit/post) :method "post"
"Title:" (<:br)
(<:input :type "text" :name "title") (<:br)
"URL:" (<:br)
(<:input :type "text" :name "url") (<:br)
(<:input :type "submit" :value "Submit")))