5 (defun brs (&optional (n 1))
12 (defun html-file (base &optional (ext 'html))
13 (format nil "~(~A~).~(~A~)" base ext))
15 (defmacro link-item (dest text)
21 (defun button (dest text)
30 (labels ((rec (curr prev next left)
31 (funcall fn curr prev next)
38 (rec (car lst) nil (cadr lst) (cdr lst)))))
41 (defparameter *sections* nil)
49 (defmacro defitem (id title text)
55 (defmacro defsection (id title &body items)
57 (make-section :id ',id
59 :items (list ,@items))))
61 (defmacro defsite (&body sections)
63 (setf *sections* ,sections)))
66 (defconstant contents "contents")
67 (defconstant index "index")
69 (defun gen-contents (&optional (sections *sections*))
70 (page (html-file contents)
74 (link-item (section-id s) (section-title s))
76 (link-item index (string-capitalize index)))))
78 (defun gen-index (&optional (sections *sections*))
79 (page (html-file index)
82 (dolist (i (all-items sections))
83 (link-item (item-id i) (item-title i))
86 (defun all-items (sections)
89 (dolist (i (section-items s))
90 (setf is (merge 'list (list i) is #'title<))))
94 (string-lessp (item-title x) (item-title y)))
98 (map3 #'gen-section *sections*)
102 (defun gen-section (sect <sect sect>)
103 (page (html-file (section-id sect))
107 (map3 #'(lambda (item <item item>)
108 (link-item (item-id item)
111 (gen-item sect item <item item>))
112 (section-items sect)))
114 (gen-move-buttons (if <sect (section-id <sect))
116 (if sect> (section-id sect>))))))
118 (defun gen-item (sect item <item item>)
119 (page (html-file (item-id item))
122 (princ (item-text item))
124 (gen-move-buttons (if <item (item-id <item))
126 (if item> (item-id item>))))))
128 (defun gen-move-buttons (back up forward)
129 (if back (button back "Back"))
130 (if up (button up "Up"))
131 (if forward (button forward "Forward")))