(in-package :u02s03)

(setf (html-mode) :html5)

(defmacro with-basic-page ((&key title) &body body)
  `(with-html-output-to-string (*standard-output* nil :prologue t :indent t)
     (:html
      (:head
       (:link
	:rel "stylesheet"
	:href "https://cdn.rawgit.com/Chalarangelo/mini.css/v3.0.1/dist/mini-default.min.css")
       (:title (esc ,title)))
      (:body
       ,@body))))

(defmacro with-redirect-page ((&key title url) &body body)
  `(with-html-output-to-string (*standard-output* nil :indent t :prologue t)
     (htm
      (:html
       (:head
        (:meta :charset "utf-8")
        (:meta :http-equiv "refresh"
               :content ,(format nil "1; url=~a" url))
        (:link
	:rel "stylesheet"
	:href "https://cdn.rawgit.com/Chalarangelo/mini.css/v3.0.1/dist/mini-default.min.css")
        (:title (esc ,title)))
       (:body
        ,@body
        (:hr)
        (:small
         ,(format nil "Redirecting you to ~a..." url)))))))

(defmacro navbar (&key node)
  `(htm
    (:header :class "sticky"
	     (:a :href "/" :class "logo"
		 "The JoJua Inexpert System")
	     (:a :href "/nodes" :class "button" "Node list")
	     ,(when node
		`(htm
		  (:a :href (format nil "/backwards?node=~d" ,node)
		      :class "button"
		      "Backtrace"))))))

(defmacro footer ()
  `(htm
    (:footer
     (:p "&copy; FooBar Co. 1980-2018. All rights defenestrated."))))
