diff options
author | Matthias Benkard <code@mail.matthias.benkard.de> | 2009-10-11 11:34:44 +0200 |
---|---|---|
committer | Matthias Benkard <code@mail.matthias.benkard.de> | 2009-10-11 11:34:44 +0200 |
commit | 468ea3a95aa82824559da26f623b2f201983388b (patch) | |
tree | 7d336c6eecea3c0b450f4c7aadf7efaa2277faa5 | |
parent | d5dc28513708e867aa744f77315a11542c609abf (diff) |
Introduce a *MODE* variable that distinguishes between static and dynamic mode.
Ignore-this: fada9480007419d11bed4ab86bb06c48
darcs-hash:dd4ba6d22a835ec8db31a88de184186429733563
-rw-r--r-- | globals.lisp | 4 | ||||
-rwxr-xr-x | journal.lisp | 30 | ||||
-rw-r--r-- | utils.lisp | 3 |
3 files changed, 23 insertions, 14 deletions
diff --git a/globals.lisp b/globals.lisp index e832646..67d78b7 100644 --- a/globals.lisp +++ b/globals.lisp @@ -81,3 +81,7 @@ (defparameter *if-modified-since* nil) (defparameter *wsse* nil) (defparameter *wsse-key* nil) + +(defparameter *mode* :http ;either :HTTP or :FILE + "Whether we are serving stuff dynamically over HTTP or storing it into + files for later static service.") diff --git a/journal.lisp b/journal.lisp index b84e1a7..317f87a 100755 --- a/journal.lisp +++ b/journal.lisp @@ -55,9 +55,10 @@ (defun show-comment-feed () #.(locally-enable-sql-reader-syntax) (revalidate-cache-or-die "application/atom+xml; charset=UTF-8") - (http-add-header "Last-Modified" (http-timestamp (compute-journal-last-modified-date))) - (http-add-header "Content-Language" "de") - (http-send-headers "application/atom+xml; charset=UTF-8") + (when (eq *mode* :http) + (http-add-header "Last-Modified" (http-timestamp (compute-journal-last-modified-date))) + (http-add-header "Content-Language" "de") + (http-send-headers "application/atom+xml; charset=UTF-8")) (flet ((atom-time (time) (format-date nil @@ -128,9 +129,10 @@ (defun show-atom-entry () #.(locally-enable-sql-reader-syntax) (revalidate-cache-or-die "application/atom+xml; charset=UTF-8") - (http-add-header "Last-Modified" (http-timestamp (compute-journal-last-modified-date))) - (http-add-header "Content-Language" "de") - (http-send-headers "application/atom+xml; charset=UTF-8") + (when (eq *mode* :http) + (http-add-header "Last-Modified" (http-timestamp (compute-journal-last-modified-date))) + (http-add-header "Content-Language" "de") + (http-send-headers "application/atom+xml; charset=UTF-8")) (with-xml-output (*standard-output* :encoding "utf-8") (show-atom-entry-xml (find-entry *post-number*) :full-content t :include-edit-links t))) @@ -184,9 +186,10 @@ (defun show-atom-feed (&key include-edit-links full-content) #.(locally-enable-sql-reader-syntax) (revalidate-cache-or-die "application/atom+xml; charset=UTF-8") - (http-add-header "Last-Modified" (http-timestamp (compute-journal-last-modified-date))) - (http-add-header "Content-Language" "de") - (http-send-headers "application/atom+xml; charset=UTF-8") + (when (eq *mode* :http) + (http-add-header "Last-Modified" (http-timestamp (compute-journal-last-modified-date))) + (http-add-header "Content-Language" "de") + (http-send-headers "application/atom+xml; charset=UTF-8")) (flet ((atom-time (time) (format-date nil @@ -413,10 +416,11 @@ ;; termination, which makes generating a Last-Modified header ;; feel slower to the end user rather than faster. ;; - (http-add-header "Last-Modified" (http-timestamp (compute-journal-last-modified-date))) - (http-add-header "Content-Language" "de") - (http-add-header "Cache-Control" "public") - (http-send-headers "text/html; charset=UTF-8") + (when (eq *mode* :http) + (http-add-header "Last-Modified" (http-timestamp (compute-journal-last-modified-date))) + (http-add-header "Content-Language" "de") + (http-add-header "Cache-Control" "public") + (http-send-headers "text/html; charset=UTF-8")) (<xhtml :xmlns "http://www.w3.org/1999/xhtml" :lang "de" @@ -368,6 +368,7 @@ ELEMENT-TYPE as the stream's." (excerpt-of comment)))) (defun revalidate-cache-or-die (content-type) + (when (eq *mode* :http) #+clisp (when *if-modified-since* (let* ((date-recognisers (mapcar #'cybertiggyr-time::make-fmt-recognizer '("%A, %d-%B-%y %H:%M:%S GMT" "%A, %d %B %Y %H:%M:%S GMT" "%A %B %d %H:%M:%S %Y"))) @@ -380,7 +381,7 @@ ELEMENT-TYPE as the stream's." (http-send-headers content-type) (ext:quit 0)))) #-clisp - nil) + nil)) (defun call-with-wsse-authentication (thunk) |