From 4fcf67b7c1b9ce5c35e87e9bdc39ee48c22dd3fd Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Thu, 24 Mar 2011 14:01:08 +0100 Subject: Introduce site variables *BASE-URI/SSL* and *BASE-URI/PLAIN*. When using SSL, set *BASE-URI* to the former, otherwise set it to the latter. --- mulkcms-hunchentoot.lisp | 4 +++- mulkcms.lisp | 19 ++++++++++++------- site.lisp | 3 ++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/mulkcms-hunchentoot.lisp b/mulkcms-hunchentoot.lisp index 9cd4b9c..9f81cb0 100644 --- a/mulkcms-hunchentoot.lisp +++ b/mulkcms-hunchentoot.lisp @@ -13,7 +13,9 @@ (lambda () (handle-static-file file))))) (defun dispatch-mulkcms-request (request) - (let* ((relative-path (subseq (script-name request) 1))) + (let* ((relative-path (subseq (script-name request) 1)) + (mulkcms::*use-ssl-p* (equal (header-in* :x-use-ssl) + "true"))) (mulkcms::find-request-handler relative-path (append (get-parameters*) (post-parameters*)) diff --git a/mulkcms.lisp b/mulkcms.lisp index 0119418..df29b46 100644 --- a/mulkcms.lisp +++ b/mulkcms.lisp @@ -6,6 +6,8 @@ (defvar *requested-characteristics*) (defvar *propagated-params*) +(defvar *use-ssl-p*) +(defvar *base-uri*) (unless (member "html-human-date" *template-formatters* :key #'car :test #'equal) (setq *template-formatters* @@ -558,7 +560,7 @@ "feed" "feed/" "journal/feed" "journal/feed") :test #'string=) - (dynamic-lambda (*propagated-params*) () + (dynamic-lambda (*propagated-params* *base-uri*) () (with-db (with-cache (path (query "SELECT max(date) FROM article_revisions" :single) @@ -810,7 +812,7 @@ *requested-characteristics*)) (declare (ignore characteristics action)) (when (string= path "admin/comments") - (dynamic-lambda (*propagated-params*) () + (dynamic-lambda (*propagated-params* *base-uri*) () (with-authorization (user-id :require :admin) (declare (ignore user-id)) (with-db @@ -858,7 +860,7 @@ *requested-characteristics*)) (declare (ignore characteristics action)) (when (string= path "admin/articles") - (dynamic-lambda (*propagated-params*) () + (dynamic-lambda (*propagated-params* *base-uri*) () (with-authorization (user-id :require :admin) (with-db (labels ((paramify-revision-row (row article-id) @@ -963,7 +965,7 @@ :single))) (ecase action (:edit - (dynamic-lambda (*propagated-params*) () + (dynamic-lambda (*propagated-params* *base-uri*) () (with-authorization (user-id :require :admin) (with-db (with-transaction () @@ -1062,7 +1064,7 @@ :content-label "Content" :characteristics-label "Characteristics")))))))) (:view - (dynamic-lambda (*propagated-params*) () + (dynamic-lambda (*propagated-params* *base-uri*) () (with-db (with-cache (path (query "SELECT max(date) @@ -1176,7 +1178,7 @@ (defun find-transaction-key-handler (path) (when (string= path "RPC/generate-transaction-key") - (dynamic-lambda (*propagated-params*) () + (dynamic-lambda (*propagated-params* *base-uri*) () (with-db (setf (hunchentoot:content-type*) "text/plain; charset=utf-8") (format nil "~D" (query "SELECT nextval('transaction_key_seq')" :single!)))))) @@ -1212,7 +1214,10 @@ (member (car x) (list "lang" "hl") :test #'equal)) - params))) + params)) + (*base-uri* (if *use-ssl-p* + *base-uri/plain* + *base-uri/ssl*))) (or (find-article-summary-handler path params) (find-comment-moderation-handler path params) (find-journal-archive-request-handler diff --git a/site.lisp b/site.lisp index 502eb71..6d0b431 100644 --- a/site.lisp +++ b/site.lisp @@ -18,7 +18,8 @@ (defparameter *static-files* "/var/mulkcms/static-files/") (defparameter *templates* "/var/mulkcms/templates/") -(defparameter *base-uri* "http://127.0.0.1:9201/") +(defparameter *base-uri/plain* "http://127.0.0.1:9201/") +(defparameter *base-uri/ssl* "http://127.0.0.1:9201/") (defparameter *server-address* "127.0.0.1") (defparameter *server-port* 9201) -- cgit v1.2.3