;;; utilities.lisp (in-package :arclade) (defun read-from-file (path) (read-from-string (alexandria:read-file-into-string path))) (defvar *epoch* (encode-universal-time 0 0 0 1 1 1970) "Jan 1 1970 Unix Epoch time in CL universal time.") (defun format-time (time) (multiple-value-bind (_ min hour day month year) (decode-universal-time time) (declare (ignore _)) (format nil "~2,'0d-~2,'0d-~a ~2,'0d:~2,'0d" month day year hour min))) (defun host-path (str) (with-slots (host port) *config* (quri:render-uri (quri:make-uri-http :host host :port port :path str)))) (defmacro with-page ((&key title) &body body) "A helper macro for defining some standard page boilerplate." (let ((title-var (gensym))) `(let ((,title-var ,title)) (with-html-string (:doctype) (:html (:head (:script :src "http://localhost:8080/skewer") (:link :href ,(host-path "css/style.css") :rel "stylesheet") (:title ,title-var)) (:body ,@body))))))