diff options
-rw-r--r-- | endpoints.lisp | 10 | ||||
-rw-r--r-- | pages.lisp | 14 |
2 files changed, 22 insertions, 2 deletions
diff --git a/endpoints.lisp b/endpoints.lisp index af07f6e..4cd9aef 100644 --- a/endpoints.lisp +++ b/endpoints.lisp @@ -49,6 +49,10 @@ NIL if there is no session for the current request. I.e. It should be called within the scope of a request handler." (session-with-id (lzb:request-cookie +session-cookie-name+ ))) +(defun text-browser-p (user-agent) + "Returns T if user agent string matches on a list of known text browsers." + (some (lambda (s) (search s user-agent)) '("Emacs" "Lynx" "w3m"))) + (defmacro with-session ((player &key session (redirect "/tavern-door")) &body body) (let ((session (or session (gensym "SESSION")))) `(a:if-let (,session (current-session)) @@ -57,7 +61,6 @@ I.e. It should be called within the scope of a request handler." ,@body) (redirect-to ,redirect)))) - (defmacro with-checked-plist (typed-keys plist &rest body) "Like WITH-PLIST, but allows you to pass a checking function to automatically tansform plist values into something you actually @@ -126,7 +129,9 @@ functions in url parameters in endpoint definitions." (defendpoint* :get "/tavern" () () (with-session (me) - (tavern me))) + (if (text-browser-p (lzb:request-header :user-agent)) + (tavern-text me) + (tavern me)))) (defendpoint* :get "/godess-shrine" () () (with-session (player) @@ -144,3 +149,4 @@ functions in url parameters in endpoint definitions." (let ((campaign (create-campaign creator title))) (redirect-to (urlpath :details campaign)))))) + @@ -95,6 +95,20 @@ must specialize :left :milsddle :right on your desired data type." (with-page (:title "A Bustling Tavern") (render :three-column-layout tavern))) +(defun tavern-text (player) + (with-page (:title "A Bustling Tavern") + (render :page-text (make-instance 'tavern :player player)))) + +(defrender :page-text ((tavern tavern)) + (let ((player (player tavern))) + (with-html + (render :details player) + (:table + (:tr (:td (:h4 "Your Heroes")) + (:td (:h4 "Your Campaigns"))) + (:tr (:td (:h4 "Gossip & Gab")) + (:td (:h4 "Comrades in Arms"))))))) + (defrender :left ((tavern tavern)) (let ((player (player tavern))) (with-html |