diff options
author | Grant Shangreaux <shoshin@cicadas.surf> | 2023-02-21 22:39:29 -0600 |
---|---|---|
committer | Grant Shangreaux <shoshin@cicadas.surf> | 2023-02-21 22:39:29 -0600 |
commit | 04df19a88a381e6bdc60d7f566e02e99b40c0087 (patch) | |
tree | a7e13f6f466ac6212687d8b1a8704bee09dc5d89 /endpoints.lisp | |
parent | 13465bd2bd281d1a45589c156423322bd85438b9 (diff) |
Add: text browser tavern view
Diffstat (limited to 'endpoints.lisp')
-rw-r--r-- | endpoints.lisp | 10 |
1 files changed, 8 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)))))) + |