-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
page.lisp
25 lines (20 loc) · 983 Bytes
/
page.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
(in-package #:org.shirakumo.radiance.core)
(defmethod documentation ((name symbol) (type (eql 'page)))
(documentation name 'uri-dispatcher))
(defmethod (setf documentation) (string (name symbol) (type (eql 'page)))
(setf (documentation name 'uri-dispatcher) string))
(defun remove-page (name)
(remove-uri-dispatcher name))
(defmacro define-page (name uri options &body body)
(destructuring-bind (uri &optional priority) (enlist uri)
(let ((uri (ensure-uri uri)))
(multiple-value-bind (body forms) (expand-options 'page options name body uri)
`(eval-when (:compile-toplevel :load-toplevel :execute)
,@forms
,@(when (module)
`((pushnew ',name (module-storage ,(module) 'radiance-pages))))
(define-uri-dispatcher ,name (,uri ,priority)
,@body))))))
(define-delete-hook (module 'radiance-destroy-pages)
(dolist (page (module-storage module 'radiance-pages))
(remove-uri-dispatcher page)))