summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/endpoints.lisp10
-rw-r--r--src/names.lisp3
-rw-r--r--src/pages/adventure-page.lisp8
-rw-r--r--src/render.lisp16
4 files changed, 29 insertions, 8 deletions
diff --git a/src/endpoints.lisp b/src/endpoints.lisp
index 288f39e..f1151cf 100644
--- a/src/endpoints.lisp
+++ b/src/endpoints.lisp
@@ -149,4 +149,14 @@ functions in url parameters in endpoint definitions."
:description description
:seers possible-seers)))))))
+(defun an-adventure-with-id (id)
+ (let ((object (object-with-uid (string-upcase id))))
+ (unless (typep object 'adventure)
+ (lzb:http-err 404))
+ object))
+
+(defendpoint* :get "/adventure/:adventure an-adventure-with-id:/:title:" () ()
+ (with-session (player)
+ (render (page-render-mode)
+ adventure))) ;; for now, render raw adventure.
diff --git a/src/names.lisp b/src/names.lisp
index 3bc0c16..05397a6 100644
--- a/src/names.lisp
+++ b/src/names.lisp
@@ -21,6 +21,7 @@
incorporate it into the urlpath. Otherwise use the object's uid.
Returns /class/identifier."
- (format nil "/~a/~a"
+ (format nil "/~a/~a/~a"
(urlify (class-name (class-of object)))
+ (urlify (uid object))
(urlify (or (unique-name object) (uid object))))))
diff --git a/src/pages/adventure-page.lisp b/src/pages/adventure-page.lisp
new file mode 100644
index 0000000..fd9cb09
--- /dev/null
+++ b/src/pages/adventure-page.lisp
@@ -0,0 +1,8 @@
+;;;; adventure-page.lisp -- shows a particular adventure
+
+(in-package :dnd)
+
+(defrender :page ((adventure adventure))
+ (with-page (:title (title adventure))
+ (:h1 (title adventure))
+ (:p "uhh......")))
diff --git a/src/render.lisp b/src/render.lisp
index 140e1ec..71f07b4 100644
--- a/src/render.lisp
+++ b/src/render.lisp
@@ -14,10 +14,12 @@ be a keyword for usin in EQL method specializers."))
(defmacro with-page ((&key title) &body body)
"A helper macro fordefining some standard page boilerplate."
- `(with-html-string
- (:doctype)
- (:html
- (:head
- (:title ,title))
- (:body
- ,@body))))
+ (let ((title-var (gensym)))
+ `(let ((,title-var ,title))
+ (with-html-string
+ (:doctype)
+ (:html
+ (:head
+ (:title ,title-var))
+ (:body
+ ,@body))))))