3 (defvar *lol-example-application
*
4 (make-instance 'cookie-session-application
5 :url-prefix
"/lisp-on-lines/"
6 :tal-generator
(make-instance 'yaclml
:file-system-generator
8 :root-directories
(list *ucw-tal-root
*))
9 :www-roots
(list (merge-pathnames "./" *ucw-tal-root
*))
12 (defentry-point "reddit" (:application
*lol-example-application
*) ()
15 (defcomponent front-page
(simple-window-component)
18 :javascript
"/dojo/dojo.js"))
20 (defmethod render ((self front-page
))
21 (with-component (self)
22 (<:h1
(<:as-html
"Lisp on Lines : Reddit Example"))
24 (<ucw
:a
:action
(add-link self
)
25 (<:as-html
"Add Lispy Link"))
30 (submitter :label
"Submitted By :")
31 (score :label
"Score :")
34 (defclass/meta link
()
35 ((url :accessor url
:initarg
:url
:type string
)
36 (title :accessor title
:initarg
:title
:type string
)
37 (submitter :accessor submitter
:initarg
:submitter
:type string
)
38 (score :accessor score
:initarg
:score
:type integer
:initform
0)))
40 (define-attributes (link)
42 (buttons score-buttons
:label
""))
44 (defvar *links
* (list))
46 (defaction add-link
((self component
))
47 (let ((l (call-display (make-instance 'link
)
49 (when l
(push l
*links
*))))
52 (sort (copy-list *links
*) #'> :key
#'score
))
54 (defattribute link-attribute
()
58 (defdisplay (:description
(link link-attribute
))
59 (<:a
:href
(url object
)
60 (<:as-html
(title object
))))
62 (defattribute score-buttons
()
64 (:type-name score-buttons
))
66 (defdisplay (:description
(score score-buttons
))
68 :action
(incf (score object
))
71 :action
(decf (score object
))
72 (<:as-html
" Down" )))
75 (defdisplay (:combination
:around
:in-layer editor
:class link
)
76 (with-component (component)
79 :action
(refresh-component component
)
80 (<:h2
(<:as-html
"Add a new Link"))
90 ;;;; We are going to use a POSTGRES database.
91 ;;;; It's a good idea to have created it already.
93 ;; template1=# CREATE USER lol PASSWORD 'lol';
95 ;; template1=# CREATE DATABASE lol OWNER lol;