[bknr-cvs] hans changed trunk/bknr/web/src/web/template-handler.lisp
BKNR Commits
bknr at bknr.net
Wed Sep 10 15:59:45 UTC 2008
Revision: 3883
Author: hans
URL: http://bknr.net/trac/changeset/3883
Implement :catch-all template handler option. If it is set, the
default-template is used for all requests that do not match a
specific template. It obviously needs to be put at the end of the
handler list.
U trunk/bknr/web/src/web/template-handler.lisp
Modified: trunk/bknr/web/src/web/template-handler.lisp
===================================================================
--- trunk/bknr/web/src/web/template-handler.lisp 2008-09-10 15:55:20 UTC (rev 3882)
+++ trunk/bknr/web/src/web/template-handler.lisp 2008-09-10 15:59:45 UTC (rev 3883)
@@ -43,7 +43,11 @@
:reader template-expander-default-template
:documentation
"Name of the default template to use when no path
-name has been specified.")))
+name has been specified.")
+ (catch-all :initarg :catch-all :initform nil
+ :reader template-expander-catch-all
+ :documentation "If non-NIL, direct all requests to the
+ default template.")))
(defmethod find-tag-function ((expander template-expander) name ns)
(let ((package-name (cdr (find ns (template-expander-command-packages expander)
@@ -226,11 +230,15 @@
(remove "" (split "/" path) :test #'equal))
(defmethod find-template-pathname ((expander template-expander) template-name)
- (let ((components (or (split-path template-name)
- (and (template-expander-default-template expander)
- (split-path (template-expander-default-template expander))))))
+ (let* ((default-template-components (and (template-expander-default-template expander)
+ (split-path (template-expander-default-template expander))))
+ (components (or (split-path template-name) default-template-components)))
(multiple-value-bind (pathname ret-components)
- (find-template (template-expander-destination expander) components)
+ (find-template (template-expander-destination expander) components)
+ (when (and (not pathname)
+ (template-expander-catch-all expander))
+ (multiple-value-setq (pathname ret-components)
+ (find-template (template-expander-destination expander) default-template-components)))
(unless pathname
(template-not-found template-name))
(values pathname
More information about the Bknr-cvs
mailing list