X-Git-Url: http://git.kpe.io/?p=wol.git;a=blobdiff_plain;f=project.lisp;fp=project.lisp;h=346ccd31b302744946e6ba62d18290a75fbff7e5;hp=1c9a89d474aee1d31c6c0dd4c6f3bb70f5e3dc39;hb=b2a8ce33193d1621e9232521e779adf6a7d872f3;hpb=ad10f85ccddf4cdc4fdabe5bc28622975338d552 diff --git a/project.lisp b/project.lisp index 1c9a89d..346ccd3 100644 --- a/project.lisp +++ b/project.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: July 2003 ;;;; -;;;; $Id: project.lisp,v 1.6 2003/08/05 23:00:28 kevin Exp $ +;;;; $Id: project.lisp,v 1.7 2003/08/08 09:03:45 kevin Exp $ ;;;; ;;;; This file and Wol are Copyright (c) 2001-2003 by Kevin M. Rosenberg ;;;; ************************************************************************* @@ -142,13 +142,26 @@ (string= (puri:uri-path (request-raw-uri req)) (project-prefix (entity-project ent)))) -(defun redirect-entity (page ent &optional plist) - (redirect-to-location (apply #'make-wol-url page ent plist))) +(defun redirect-entity (page req ent &optional plist) + (let ((proj (entity-project ent)) + (url (make-wol-url page ent plist))) + (ecase (project-connector proj) + (:aserve + (net.aserve:with-http-response + ((aserve-request req) + (entity-aserve-entity ent) + :response net.aserve:*response-moved-permanently*) + (net.aserve:with-http-body + ((aserve-request req) + (entity-aserve-entity ent) + :headers `((:location . ,url)))))) + (:modlisp + (redirect-to-location url))))) (defun dispatch-request (req ent) (let ((proj (entity-project ent))) (if (is-index-request req ent) - (redirect-entity (project-index proj) ent) + (redirect-entity (project-index proj) req ent) (progn (request-decompile-uri req ent) (compute-session req ent) @@ -196,9 +209,9 @@ (let ((next-page (funcall handler req ent))) (typecase next-page (string - (redirect-entity next-page ent)) + (redirect-entity next-page req ent)) (cons - (redirect-entity (car next-page) ent (cadr next-page))) + (redirect-entity (car next-page) req ent (cadr next-page))) (null t) (t @@ -215,24 +228,33 @@ (defun wol-version-string () (format nil "~{~D~^.~}" *wol-version*)) - + +(defun alist-key->keyword (alist) + (loop for a in alist + collect (cons (kmrcl:ensure-keyword (car a)) (cdr a)))) + (defun request-query (req &key (uri t) (post t)) - (let ((desired (cons uri post))) - (if (equal desired (request-desired-query req)) - ;; Same desired as cached - (request-query-alist req) - (progn - (setf (request-desired-query req) desired) - (setf (request-query-alist req) - (append - (when (and uri (request-uri-query req)) - (query-to-alist (request-uri-query req))) - (when (and post (request-posted-content req)) - (query-to-alist (request-posted-content req))))))))) + (aif (aserve-request req) + (alist-key->keyword + (net.aserve:request-query it :uri uri :post post)) + (let ((desired (cons uri post))) + (if (equal desired (request-desired-query req)) + ;; Same desired as cached + (request-query-alist req) + (progn + (setf (request-desired-query req) desired) + (setf (request-query-alist req) + (append + (when (and uri (request-uri-query req)) + (query-to-alist (request-uri-query req))) + (when (and post (request-posted-content req)) + (query-to-alist (request-posted-content req)))))))))) (defun request-query-value (key req &key (uri t) (post t)) - (cdr (assoc key (request-query req :uri uri :post post) - :test 'equal))) + (aif (aserve-request req) + (net.aserve:request-query-value (string key) it :uri uri :post post) + (cdr (assoc key (request-query req :uri uri :post post) + :test 'equal)))) (defun websession-variable (ws name) (when ws @@ -244,6 +266,27 @@ (defmacro with-wol-page ((req ent + &key (format :html) (precompute t) headers) + &body body) + `(ecase (project-connector (entity-project ,ent)) + (:aserve + (net.aserve:with-http-response + ((aserve-request ,req) + (entity-aserve-entity ,ent) + :content-type (ml::format-string ,format)) + (net.aserve:with-http-body + ((aserve-request ,req) + (entity-aserve-entity ,ent) + :headers ,headers) + (let ((*html-stream* net.html.generator:*html-stream*)) + ,@body)))) + (:modlisp + (%with-wol-page (,req ,ent :format ,format :precompute ,precompute + :headers ,headers) + ,@body)))) + + +(defmacro %with-wol-page ((req ent &key (format :html) (precompute t) headers) &body body) (declare (ignore req ent)) @@ -299,7 +342,7 @@ (:body (:h1 "Not Found") (:p "The request for " - (:b (:write-string (request-uri req))) + (:b (:write-string (render-uri (request-uri req) nil))) " was not found on this server.") (:hr) (:div (:i "WOL "