1 (in-package :lisp-on-lines
)
3 (export '(html-description) (find-package :lisp-on-lines
))
5 (defvar *escape-html
* t
)
7 (defmethod generic-format ((display lol-ucw
:component
) string
&rest args
)
8 (<:as-html
(with-output-to-string (stream)
9 (apply #'call-next-method stream string args
))))
12 (define-description html-description
()
15 (define-description t
()
16 ((css-class :value
"lol-description" :activep nil
)
17 (dom-id :function
(lambda (x)
22 (:in-description html-description
))
24 (define-layered-class html-attribute
()
25 ((css-class :accessor attribute-css-class
26 :initform
"lol-attribute")
27 (dom-id :accessor attribute-dom-id
:initform nil
)))
29 (define-layered-class standard-attribute
30 :in-layer
#.
(defining-description 'html-description
)
34 (define-layered-function display-html-attribute-label
(object attribute
)
35 (:method
(object attribute
)
36 (let ((label (attribute-label attribute
)))
38 :class
"lol-attribute-label"
41 (with-output-to-string (*display
*)
42 (display-attribute-label attribute
)))))))
44 :in-layer
#.
(defining-description 'inline
)
46 (let ((label (attribute-label attribute
)))
49 (with-output-to-string (*display
*)
50 (display-attribute-label attribute
)))))))
52 (define-layered-function display-html-attribute-value
(object attribute
)
53 (:method
(object attribute
)
55 :class
"lol-attribute-value"
57 (display-attribute-value attribute
))))
60 :in-layer
#.
(defining-description 'inline
) (object attribute
)
61 (display-attribute-value attribute
)))
63 (define-layered-function display-html-attribute
(object attribute
)
65 (:method
(object attribute
)
67 :class
(attribute-css-class attribute
)
68 (when (attribute-dom-id attribute
)
69 :id
(attribute-dom-id attribute
))
70 (display-html-attribute-label object attribute
)
71 (display-html-attribute-value object attribute
)))
74 :in-layer
#.
(defining-description 'inline
)
77 :class
(attribute-css-class attribute
)
78 (when (attribute-dom-id attribute
)
79 :id
(attribute-dom-id attribute
))
80 (display-html-attribute-label object attribute
)
81 (display-html-attribute-value object attribute
))))
83 (define-layered-method display-using-description
84 :in-layer
#.
(defining-description 'html-description
)
85 :around
((attribute standard-attribute
) display object
&rest args
)
86 (declare (ignore args
))
87 (display-html-attribute object attribute
))
91 (define-layered-method display-html-attribute-value
92 :in-layer
#.
(defining-description 'editable
) (object attribute
)
95 :class
"lol-attribute-value"
96 (if (attribute-editp object attribute
)
97 (<lol
:input
:reader
(attribute-value attribute
)
98 :writer
(let ((obj (described-object (attribute-description attribute
))))
100 (dletf (((described-object attribute
) obj
))
101 (setf (attribute-value attribute
) val
)))))
105 (define-layered-function display-html-description
(description display object
&optional next-method
)
106 (:method
(description display object
&optional
(next-method #'display-using-description
))
110 div.lol-description .lol-attribute-label,
111 div.lol-description .lol-attribute-value {
119 .lol-attribute-label {
131 (with-attributes (css-class dom-id
) description
135 :class
(list (attribute-value css-class
) "lol-description" "t")
136 :id
(attribute-value dom-id
)
137 (funcall next-method
)))))
140 (define-layered-method display-html-description
141 :in-layer
#.
(defining-description 'inline
) (description display object
&optional next-method
)
142 (with-attributes (css-class dom-id
) description
144 :class
(list (attribute-value css-class
) "lol-description")
145 :id
(attribute-value dom-id
)
146 (funcall next-method
))))
150 :in-description html-description
((description t
)
151 (display lol-ucw
:component
)
153 (display-html-description description display object
(lambda ()
154 (call-next-method))))