anchor.diff: -(in-package :sykosomatic)
  -(defpackage :templ
  -  (:export :404 :/ :login :stage :role :scenes :view-scene :signup :newchar))
  +(cl:defpackage :templ
  +  (:use :cl :yaclml :alexandria)
  +  (:export :404 :home :login :stage :role :scenes :view-scene :signup :newchar))
  +(cl:in-package :templ)
   
   ;;; General
  -(defun templ::page (title body-fun &optional head-fun)
  +(defun page (title body-fun &optional head-fun)
     (with-yaclml-output-to-string
       (<:html :prologue "<!DOCTYPE html>"
        (<:head
  
positive.code:       (<:meta :http-equiv "Content-type"
                :content "text/html;charset=UTF-8")
        (<:link :rel "stylesheet" :type "text/css" :href "res/styles.css")
        (templ::jquery-libs)
        (when head-fun (funcall head-fun)))
       (<:body
        (funcall body-fun)))))
  
  (defmacro defpage (name lambda-list (&rest head) title &body body)
    `(defun ,name ,lambda-list
       (templ::page ,title
                    (lambda ()
                      ,@body)
                    ,@(when head
                       `((lambda () ,@head))))))
  
  (defun templ::jquery-libs ()
    (<:link :rel "stylesheet" :type "text/css" :href "res/css/smoothness/jquery-ui-1.8.14.custom.css")
    (<:script :type "text/javascript" :src "res/js/jquery-1.5.1.min.js")
    (<:script :type "text/javascript" :src "res/js/jquery-ui-1.8.14.custom.min.js"))
  
  (defun templ::login-component ()
    (<:form :name "login" :action "/login" :method "post"
            (<:label (<:ah "Log in"))
            (<:br)
            (<:label (<:ah "Email"))
            (<:text :name "account-name")
            (<:br)
            (<:label (<:ah "Password"))
            (<:input :type "password" :name "password")
            (<:br)
            (<:submit :value "Submit")))
  
  (defun templ::logout-button ()
    (<:form :class "logout-button" :action "/logout" :method "post"
            (<:submit :class "btn" :value "Log Out")))
  
  (defun templ::error-messages ()
    ;; This one's a bit leaky. It's pretty special, anyway.
    (when-let ((errors (session-value 'errors)))
      (<:ul :class "errors"
            (mapc (lambda (err) (<:li (<:ah err))) errors))
      (setf (session-value 'errors) nil)))
  
  ;;; 404
  (defpage templ::404 () ()
      "404 Not Found"
    (<:p (<:ah "Sorry, that page does not exist.")))
  
  ;;; /
  (defpage templ::/ () ()
      "Sykosomatic.org Dev Site"
    (<:p (<:ah "Sykosomatic is a cooperative storytelling system, currently in development. ")
         (<:href "/login" (<:ah "Log in.")))
    (<:p (<:ah "Already logged in? What are you doing here?! Head to the ")
         (<:href "/stage" (<:ah "Stage!"))))
  
  ;;; /login
  (defpage templ::login () ()
      "Log in"
    (templ::error-messages)
    (templ::login-component)
    (<:href "/signup" (<:ah "Create account.")))
  
  ;;; /stage
  (defpage templ::stage () ((templ::gameplay-js-libs))
      "All the World's a Stage"
    (templ::chat-area)
    #+nil
    (templ::scene-recording)
    #+nil
    (templ::scene-list-link)
    #+nil
    (templ::logout-button))
  
  (defun templ::gameplay-js-libs ()
    ;; When you feel like figuring out why optional loading fails, take the following
    ;; two lines out...
    (<:script :type "text/javascript" :src "res/swfobject.js")
  
negative.code:                           (action-txt (jsown:val entry-obj "action")))
                        ;; TODO - Smelly, smelly.
                        (<:ah (format nil "sykosomatic.add_action(~S,~S);~%" actor action-txt)))))))
           (sykosomatic::find-scene-entries id))))
  
  ;;; /signup
  (defpage signup () ()
      "Sign up"
    (error-messages)
    (signup-component))
  
  (defun signup-component ()
    (<:form :name "signup" :action "/signup" :method "post"
            (<:label (<:ah "Sign up:"))
            (<:br)
  