[bknr-cvs] r2420 - in branches/trunk-reorg/bknr/web/src: . web

hhubner at common-lisp.net hhubner at common-lisp.net
Wed Jan 30 10:11:24 UTC 2008


Author: hhubner
Date: Wed Jan 30 05:11:21 2008
New Revision: 2420

Modified:
   branches/trunk-reorg/bknr/web/src/packages.lisp
   branches/trunk-reorg/bknr/web/src/web/handlers.lisp
   branches/trunk-reorg/bknr/web/src/web/templates.lisp
Log:
Add static file handling.


Modified: branches/trunk-reorg/bknr/web/src/packages.lisp
==============================================================================
--- branches/trunk-reorg/bknr/web/src/packages.lisp	(original)
+++ branches/trunk-reorg/bknr/web/src/packages.lisp	Wed Jan 30 05:11:21 2008
@@ -296,6 +296,7 @@
 	   #:publish-handler
 	   #:unpublish
 
+	   #:handler-matches
 	   #:handle-object
 	   #:handle-object-form
 	   #:handle-form

Modified: branches/trunk-reorg/bknr/web/src/web/handlers.lisp
==============================================================================
--- branches/trunk-reorg/bknr/web/src/web/handlers.lisp	(original)
+++ branches/trunk-reorg/bknr/web/src/web/handlers.lisp	Wed Jan 30 05:11:21 2008
@@ -318,6 +318,15 @@
   ((destination :initarg :destination
 		:reader page-handler-destination)))
 
+(defmethod handler-matches ((handler directory-handler))
+  (and (call-next-method)
+       (probe-file (merge-pathnames (script-name)
+				    (page-handler-destination handler)))))
+
+(defmethod handle ((handler directory-handler))
+  (handle-static-file (merge-pathnames (subseq (script-name) (1+ (length (page-handler-prefix handler))))
+				       (page-handler-destination handler))))
+
 (defclass file-handler (page-handler)
   ((destination :initarg :destination
 		:reader page-handler-destination)
@@ -325,6 +334,9 @@
 		 :reader page-handler-content-type))
   (:default-initargs :content-type "text/plain"))
 
+(defmethod handle ((handler file-handler))
+  (handle-static-file (page-handler-destination handler)))
+
 (defclass object-handler (prefix-handler)
   ((query-function :initarg :query-function :reader object-handler-query-function)
    (object-class :initarg :object-class :reader object-handler-object-class))

Modified: branches/trunk-reorg/bknr/web/src/web/templates.lisp
==============================================================================
--- branches/trunk-reorg/bknr/web/src/web/templates.lisp	(original)
+++ branches/trunk-reorg/bknr/web/src/web/templates.lisp	Wed Jan 30 05:11:21 2008
@@ -292,6 +292,13 @@
 (defmacro with-error-handlers ((handler) &body body)
   `(invoke-with-error-handlers (lambda () , at body) ,handler))
 
+(defmethod handler-matches ((handler template-handler))
+  (handler-case 
+      (find-template-pathname handler (request-uri))
+    (template-not-found (c)
+      (declare (ignore c))
+      nil)))
+
 (defmethod handle ((handler template-handler))
   (with-error-handlers (handler)
     ;; Erst body ausfuehren...



More information about the Bknr-cvs mailing list