summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-03-24 14:01:08 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-03-24 14:01:08 +0100
commit4fcf67b7c1b9ce5c35e87e9bdc39ee48c22dd3fd (patch)
tree188dd80eee9f13c0bd4ab4d14f757bc9b9f087a6
parent2049f93f991e72f05d73c5d640327fb6343ef245 (diff)
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.
-rw-r--r--mulkcms-hunchentoot.lisp4
-rw-r--r--mulkcms.lisp19
-rw-r--r--site.lisp3
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)