diff --git a/src/components/.keep b/src/components/.keep new file mode 100644 index 0000000..e69de29 diff --git a/src/components/document.lisp b/src/components/document.lisp deleted file mode 100644 index dc5c2a4..0000000 --- a/src/components/document.lisp +++ /dev/null @@ -1,22 +0,0 @@ -(defpackage #:hp/components/document - (:use #:cl - #:hsx) - (:export #:document)) -(in-package #:hp/components/document) - -(defcomp document (&key title description children) - (hsx - (html :lang "ja" - (head - (meta :charset "UTF-8") - (meta :name "viewport" :content "width=device-width, initial-scale=1") - (link :rel "stylesheet" :href "https://cdn.jsdelivr.net/npm/uikit@3.21.5/dist/css/uikit.min.css") - (script :src "https://cdn.jsdelivr.net/npm/uikit@3.21.5/dist/js/uikit.min.js") - (script :src "https://cdn.jsdelivr.net/npm/htmx.org@1.9.12/dist/htmx.min.js") - (script :src "https://cdn.jsdelivr.net/npm/htmx.org@1.9.12/dist/ext/head-support.js") - (script :src "https://cdn.jsdelivr.net/npm/alpinejs@3.14.0/dist/cdn.min.js" :defer t) - (title (format nil "~@[~a - ~]skyizwhite.dev" title)) - (meta - :name "description" - :content (or description "pakuの個人サイト"))) - children))) diff --git a/src/components/layout.lisp b/src/components/layout.lisp deleted file mode 100644 index b48ba30..0000000 --- a/src/components/layout.lisp +++ /dev/null @@ -1,11 +0,0 @@ -(defpackage #:hp/components/layout - (:use #:cl - #:hsx) - (:export #:layout)) -(in-package #:hp/components/layout) - -(defcomp layout (&key children) - (hsx - (body :hx-ext "head-support" - (main :class "uk-container" - children)))) diff --git a/src/middlewares/recoverer.lisp b/src/middlewares/recoverer.lisp index 2193c0c..c1239cc 100644 --- a/src/middlewares/recoverer.lisp +++ b/src/middlewares/recoverer.lisp @@ -16,6 +16,5 @@ (handler-case (funcall app env) (error (c) - (log:error "Unhandled error caught: ~a" c) `(500 (:content-type "text/plain") (,(message c)))))))) diff --git a/src/response.lisp b/src/response.lisp index 22a16ea..e00a1fe 100644 --- a/src/response.lisp +++ b/src/response.lisp @@ -1,19 +1,39 @@ (defpackage #:hp/response - (:use #:cl) - (:import-from #:hsx) + (:use #:cl + #:hsx) (:local-nicknames (#:jg #:jingle)) - (:local-nicknames (#:cmp #:hp/components/*)) (:export #:response #:partial-response)) (in-package #:hp/response) +(defcomp document (&key title description children) + (hsx + (html :lang "ja" + (head + (meta :charset "UTF-8") + (meta :name "viewport" :content "width=device-width, initial-scale=1") + (link :rel "stylesheet" :href "https://cdn.jsdelivr.net/npm/uikit@3.21.5/dist/css/uikit.min.css") + (script :src "https://cdn.jsdelivr.net/npm/uikit@3.21.5/dist/js/uikit.min.js") + (script :src "https://cdn.jsdelivr.net/npm/htmx.org@1.9.12/dist/htmx.min.js") + (script :src "https://cdn.jsdelivr.net/npm/htmx.org@1.9.12/dist/ext/head-support.js") + (script :src "https://cdn.jsdelivr.net/npm/alpinejs@3.14.0/dist/cdn.min.js" :defer t) + (title (format nil "~@[~a - ~]skyizwhite.dev" title)) + (meta + :name "description" + :content (or description "pakuの個人サイト")) + (body :hx-ext "head-support" + (main :class "uk-container" + children)))))) + (defun response (page &key status metadata) (jg:with-html-response - (if status (jg:set-response-status status)) - (hsx:render-to-string (cmp:document metadata - (cmp:layout page))))) + (when status + (jg:set-response-status status)) + (hsx:render-to-string (document metadata + page)))) (defun partial-response (component &key status) (jg:with-html-response - (if status (jg:set-response-status status)) + (when status + (jg:set-response-status status)) (hsx:render-to-string component)))