;;;; pages.lisp -- html generation functions for dnd
(in-package :dnd)
(defmacro with-page ((&key title) &body body)
`(with-html-string
(:doctype)
(:html
(:head
(:title ,title))
(:body ,@body))))
(defun godess-shrine ()
(with-page (:title "A Sacred Shrine")
(:header
(:h1 "Pray and become a hero..."))
(:form :method "POST" :action "/godess-shrine"
(:label :for "NAME" "Enter the epithet by which the ages shall know thy hero:")
(:input :name "NAME")
(:button :type "submit" "Pray To The Goddess"))))
(defun doorkeeper (&key (message "Come ye player, Wot's yer name?"))
(with-page (:title "Tavern Door")
(:h1 message)
(:form :method "POST" :action "/tavern-door"
(:label :for "NICK" "Wut's yer handle?:")
(:input :name "NICK")
(:button :type "submit" "Announce Thyself"))
(:h2 "Eh? Ye need to announce thyeself?")
(:a :href "/register" "Follow me...")))
(defun register ()
(with-page (:title "Register Player")
(:header
(:h1 "Choose a Nickname Player"))
(:form :method "POST" :action "/register"
(:label :for "NICK" "Choose a nickname. No spaces. Letters, Numbers, and -._")
(:input :name "NICK" :placeholder "superbob")
(:button :type "submit" "Register"))))
(defun tavern (player)
(with-page (:title "A Bustling Tavern")
(navbar)
(:div
:class "heroes-container"
(:h2 "Heroes of rampant renown:")
(hall-of-heroes))))
(defun navbar ()
(with-html
(:nav :class "navbar" :aria-label "Navigation"
(:div :class "logo" :aria-label "DND logo" "DND")
(:ul :class "nav-links" :aria-label "Nav links"
(:li (:a :href "/hero" :aria-label "Hero profile" "🧝"))
(:li (:a :href "/inventory" :aria-label "Inventory" "🎒"))
(:li (:a :href "/quests" :aria-label "Quests" "📜"))
(:li (:a :href "/tavern" :aria-label "Tavern" "🍺"))))))
(defun hall-of-heroes ()
(with-html
(:ul :class "hall-of-heroes"
(dolist (hero (all-heroes))
(:li (hero-name hero)
"the"
(hero-class hero)
(hero-title hero))))))