Compare commits
4 commits
5a05f440a8
...
fa0c60d475
Author | SHA1 | Date | |
---|---|---|---|
fa0c60d475 | |||
cb7062028e | |||
d508d9ec70 | |||
f9dbc124b3 |
12 changed files with 65 additions and 39 deletions
2
qlfile
2
qlfile
|
@ -9,3 +9,5 @@ ql clack-errors
|
||||||
git microcms https://github.com/skyizwhite/microcms-lisp-sdk
|
git microcms https://github.com/skyizwhite/microcms-lisp-sdk
|
||||||
ql local-time
|
ql local-time
|
||||||
ql function-cache
|
ql function-cache
|
||||||
|
ql jonathan
|
||||||
|
ql access
|
||||||
|
|
|
@ -46,3 +46,11 @@
|
||||||
(:class qlot/source/ql:source-ql
|
(:class qlot/source/ql:source-ql
|
||||||
:initargs (:%version :latest)
|
:initargs (:%version :latest)
|
||||||
:version "ql-2023-10-21"))
|
:version "ql-2023-10-21"))
|
||||||
|
("jonathan" .
|
||||||
|
(:class qlot/source/ql:source-ql
|
||||||
|
:initargs (:%version :latest)
|
||||||
|
:version "ql-2020-09-25"))
|
||||||
|
("access" .
|
||||||
|
(:class qlot/source/ql:source-ql
|
||||||
|
:initargs (:%version :latest)
|
||||||
|
:version "ql-2024-10-12"))
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
(defpackage #:website/components/header
|
(defpackage #:website/components/header
|
||||||
(:use #:cl
|
(:use #:cl
|
||||||
#:hsx
|
#:website/helper)
|
||||||
#:jingle)
|
|
||||||
(:export #:~header))
|
(:export #:~header))
|
||||||
(in-package #:website/components/header)
|
(in-package #:website/components/header)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
(defpackage #:website/components/metadata
|
(defpackage #:website/components/metadata
|
||||||
(:use #:cl
|
(:use #:cl
|
||||||
#:hsx
|
#:website/helper)
|
||||||
#:jingle)
|
|
||||||
(:import-from #:website/lib/env
|
(:import-from #:website/lib/env
|
||||||
#:website-url)
|
#:website-url)
|
||||||
(:export #:~metadata))
|
(:export #:~metadata))
|
||||||
|
|
15
src/helper.lisp
Normal file
15
src/helper.lisp
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
(uiop:define-package #:website/helper
|
||||||
|
(:use #:cl)
|
||||||
|
(:use-reexport #:hsx
|
||||||
|
#:jingle
|
||||||
|
#:jonathan
|
||||||
|
#:access)
|
||||||
|
(:export #:api-p))
|
||||||
|
(in-package #:website/helper)
|
||||||
|
|
||||||
|
(defun starts-with-p (prefix string)
|
||||||
|
(let ((pos (search prefix string :start1 0 :end1 (length prefix) :start2 0)))
|
||||||
|
(and pos (= pos 0))))
|
||||||
|
|
||||||
|
(defun api-p ()
|
||||||
|
(starts-with-p "/api/" (request-uri *request*)))
|
|
@ -24,12 +24,14 @@
|
||||||
(defcached (,name :timeout ,timeout) (&key query)
|
(defcached (,name :timeout ,timeout) (&key query)
|
||||||
(,origin :query query)))))
|
(,origin :query query)))))
|
||||||
|
|
||||||
|
(defparameter *timeout* 60)
|
||||||
|
|
||||||
(define-object-client about)
|
(define-object-client about)
|
||||||
(memorize get-about 60)
|
(memorize get-about *timeout*)
|
||||||
|
|
||||||
(define-object-client work)
|
(define-object-client work)
|
||||||
(memorize get-work 60)
|
(memorize get-work *timeout*)
|
||||||
|
|
||||||
(define-list-client blog)
|
(define-list-client blog)
|
||||||
(memorize get-blog-list 60)
|
(memorize get-blog-list *timeout*)
|
||||||
(memorize get-blog-detail 60)
|
(memorize get-blog-detail *timeout*)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
(defpackage #:website/renderer
|
(defpackage #:website/renderer
|
||||||
(:use #:cl
|
(:use #:cl
|
||||||
#:hsx
|
#:website/helper)
|
||||||
#:jingle)
|
|
||||||
(:import-from #:hsx/element
|
(:import-from #:hsx/element
|
||||||
#:element)
|
#:element)
|
||||||
(:import-from #:website/components/metadata
|
(:import-from #:website/components/metadata
|
||||||
|
@ -13,17 +12,21 @@
|
||||||
(in-package #:website/renderer)
|
(in-package #:website/renderer)
|
||||||
|
|
||||||
(defmethod jingle:process-response :around ((app jingle:app) result)
|
(defmethod jingle:process-response :around ((app jingle:app) result)
|
||||||
(set-response-header :content-type "text/html; charset=utf-8")
|
|
||||||
(when (eq (request-method *request*) :get)
|
(when (eq (request-method *request*) :get)
|
||||||
(set-response-header :cache-control "public, max-age=60"))
|
(set-response-header :cache-control "public, max-age=60"))
|
||||||
(call-next-method app
|
(cond ((api-p)
|
||||||
(render-to-string
|
(set-response-header :content-type "application/json; charset=utf-8")
|
||||||
(hsx (html :lang "ja"
|
(call-next-method app (to-json result)))
|
||||||
(head
|
(t
|
||||||
(~metadata :metadata (context :metadata))
|
(set-response-header :content-type "text/html; charset=utf-8")
|
||||||
(~scripts))
|
(call-next-method app
|
||||||
(body
|
(render-to-string
|
||||||
:hx-ext "head-support, response-targets, preload"
|
(hsx (html :lang "ja"
|
||||||
:hx-boost "true" :hx-swap "transition:true"
|
(head
|
||||||
:hx-target-404 "body" :hx-target-5* "body"
|
(~metadata :metadata (context :metadata))
|
||||||
(~layout result)))))))
|
(~scripts))
|
||||||
|
(body
|
||||||
|
:hx-ext "head-support, response-targets, preload"
|
||||||
|
:hx-boost "true" :hx-swap "transition:true"
|
||||||
|
:hx-target-404 "body" :hx-target-5* "body"
|
||||||
|
(~layout result)))))))))
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
(defpackage #:website/routes/about
|
(defpackage #:website/routes/about
|
||||||
(:use #:cl
|
(:use #:cl
|
||||||
#:hsx
|
#:website/helper)
|
||||||
#:jingle)
|
|
||||||
(:import-from #:website/lib/cms
|
(:import-from #:website/lib/cms
|
||||||
#:get-about)
|
#:get-about)
|
||||||
(:import-from #:website/lib/time
|
(:import-from #:website/lib/time
|
||||||
|
@ -25,7 +24,7 @@
|
||||||
(div :class "flex justify-center"
|
(div :class "flex justify-center"
|
||||||
(figure :class "flex flex-col items-center"
|
(figure :class "flex flex-col items-center"
|
||||||
(img
|
(img
|
||||||
:src (getf (getf about :avatar) :url)
|
:src (accesses about :avatar :url)
|
||||||
:alt "avatar" :class "size-40 rounded-xl shadow-sm avatar")
|
:alt "avatar" :class "size-40 rounded-xl shadow-sm avatar")
|
||||||
(figcaption (getf about :avatar-caption))))
|
(figcaption (getf about :avatar-caption))))
|
||||||
(raw! (getf about :content))
|
(raw! (getf about :content))
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
(defpackage #:website/routes/blog
|
(defpackage #:website/routes/blog
|
||||||
(:use #:cl
|
(:use #:cl
|
||||||
#:hsx
|
#:website/helper)
|
||||||
#:jingle)
|
|
||||||
(:export #:handle-get))
|
(:export #:handle-get))
|
||||||
(in-package #:website/routes/blog)
|
(in-package #:website/routes/blog)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
(defpackage #:website/routes/index
|
(defpackage #:website/routes/index
|
||||||
(:use #:cl
|
(:use #:cl
|
||||||
#:hsx)
|
#:website/helper)
|
||||||
(:import-from #:website/lib/cms
|
(:import-from #:website/lib/cms
|
||||||
#:get-about)
|
#:get-about)
|
||||||
(:export #:handle-get
|
(:export #:handle-get
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
(hsx
|
(hsx
|
||||||
(div :class "flex flex-col items-center justify-center h-full"
|
(div :class "flex flex-col items-center justify-center h-full"
|
||||||
(img
|
(img
|
||||||
:src (getf (getf about :avatar) :url)
|
:src (accesses about :avatar :url)
|
||||||
:alt "avatar" :class "size-40 rounded-xl shadow-sm avatar")
|
:alt "avatar" :class "size-40 rounded-xl shadow-sm avatar")
|
||||||
(div :class "flex flex-col items-center gap-2 py-6"
|
(div :class "flex flex-col items-center gap-2 py-6"
|
||||||
(h1 :class "font-bold text-2xl text-center"
|
(h1 :class "font-bold text-2xl text-center"
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
(defpackage #:website/routes/not-found
|
(defpackage #:website/routes/not-found
|
||||||
(:use #:cl
|
(:use #:cl
|
||||||
#:hsx
|
#:website/helper)
|
||||||
#:jingle)
|
|
||||||
(:export #:handle-not-found))
|
(:export #:handle-not-found))
|
||||||
(in-package #:website/routes/not-found)
|
(in-package #:website/routes/not-found)
|
||||||
|
|
||||||
|
@ -12,9 +11,11 @@
|
||||||
|
|
||||||
(defun handle-not-found ()
|
(defun handle-not-found ()
|
||||||
(setf (context :metadata) *metadata*)
|
(setf (context :metadata) *metadata*)
|
||||||
(hsx
|
(if (api-p)
|
||||||
(div :class "flex flex-col h-full items-center justify-center gap-y-6"
|
'(:|message| "404 Not Found")
|
||||||
(h1 :class "font-bold text-2xl"
|
(hsx
|
||||||
"404 Not Found")
|
(div :class "flex flex-col h-full items-center justify-center gap-y-6"
|
||||||
(a :href "/" :class "text-lg text-pink-500 hover:underline"
|
(h1 :class "font-bold text-2xl"
|
||||||
"Back to TOP"))))
|
"404 Not Found")
|
||||||
|
(a :href "/" :class "text-lg text-pink-500 hover:underline"
|
||||||
|
"Back to TOP")))))
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
(defpackage #:website/routes/work
|
(defpackage #:website/routes/work
|
||||||
(:use #:cl
|
(:use #:cl
|
||||||
#:hsx
|
#:website/helper)
|
||||||
#:jingle)
|
|
||||||
(:import-from #:website/lib/cms
|
(:import-from #:website/lib/cms
|
||||||
#:get-work)
|
#:get-work)
|
||||||
(:import-from #:website/lib/time
|
(:import-from #:website/lib/time
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue