summaryrefslogtreecommitdiff
path: root/pages.lisp
blob: 9900980213ccef05188957811a9a1d41130ae808 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
;;;; 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 "Wot's yer name 'ero?"))
  (with-page (:title "Tavern Door")
    (:h1 message)
    (:form :method "POST" :action "/tavern-door"
	   (:label :for "NAME" "Thy Hero's Appelation:")
	   (:input :name "NAME")
	   (:button :type "submit" "Announce Thyself"))
    (:h2 "Eh? Ye need to birth a new hero?")
    (:a :href "/godess-shrine" "Follow me...")))

(defun tavern (hero)
  (with-page (:title "A Bustling Tavern")
    (navbar)
    (:h1 "Aye! Welcome " (hero-name hero))
    (:div
     :class "heroes-container"
     (:h2 "Heroes of rampant renown:")
     (hall-of-heroes))))

(defun navbar ()
  (with-html
    (:div
     :class "navbar"
     (:div :class "logo" "DND")
     (:ul :class "nav-links"
	  (:li (:a :href "/hero" "Hero"))
	  (:li (:a :href "/inventory" "Loot"))
	  (:li (:a :href "/quests" "Quests"))
	  (:li (:a :href "/tavern" "Tavern"))))))

(defun hall-of-heroes ()
  (with-html
    (:ul :class "hall-of-heroes")
    (loop for hero in (all-heroes)
	  collect (:li (hero-name hero) "the" (hero-class hero) (hero-title hero)))))