Improve asset

This commit is contained in:
Akira Tempaku 2024-04-22 13:14:26 +09:00
parent 5d1cbd4b9f
commit 4cc94d5090
6 changed files with 18 additions and 12 deletions

View file

@ -3,7 +3,7 @@
(:use #:cl)
(:local-nicknames (#:jg #:jingle))
(:local-nicknames (#:fbr #:ningle-fbr))
(:local-nicknames (#:cfg #:hp/config/*))
(:local-nicknames (#:cfg #:hp/config/env))
(:local-nicknames (#:asset #:hp/view/asset))
(:local-nicknames (#:mw #:hp/middlewares/*))
(:export #:start

12
src/config/asset.lisp Normal file
View file

@ -0,0 +1,12 @@
(defpackage #:hp/config/asset
(:use #:cl)
(:export #:*asset-roots*))
(in-package #:hp/config/asset)
(defparameter *asset-roots*
'(:img "/img/"
:css "/css/"
:js "/js/"
:vendor "/vendor/"
:htmx-ext "/vendor/htmx-ext/"
:alpine-ext "/vendor/alpine-ext/"))

View file

@ -1,7 +1,7 @@
(defpackage #:hp/routes/about
(:use #:cl)
(:local-nicknames (#:pi #:piccolo))
(:local-nicknames (#:view #:hp/view/**/*))
(:local-nicknames (#:view #:hp/view/*))
(:export #:handle-get))
(in-package #:hp/routes/about)

View file

@ -1,7 +1,7 @@
(defpackage #:hp/routes/index
(:use #:cl)
(:local-nicknames (#:pi #:piccolo))
(:local-nicknames (#:view #:hp/view/**/*))
(:local-nicknames (#:view #:hp/view/*))
(:export #:handle-get))
(in-package #:hp/routes/index)

View file

@ -2,7 +2,7 @@
(:use #:cl)
(:local-nicknames (#:jg #:jingle))
(:local-nicknames (#:pi #:piccolo))
(:local-nicknames (#:view #:hp/view/**/*))
(:local-nicknames (#:view #:hp/view/*))
(:export #:handle-not-found))
(in-package #:hp/routes/not-found)

View file

@ -1,21 +1,15 @@
(defpackage #:hp/view/asset
(:use #:cl)
(:local-nicknames (#:re #:cl-ppcre))
(:local-nicknames (#:cfg #:hp/config/asset))
(:export #:asset-root
#:define-assets
#:get-css-paths
#:cmp-props))
(in-package #:hp/view/asset)
(defparameter *asset-roots*
'(:css "/css/"
:js "/js/"
:vendor "/vendor/"
:htmx-ext "/vendor/htmx-ext/"
:alpine-ext "/vendor/alpine-ext/"))
(defun asset-root (kind)
(getf *asset-roots* kind))
(getf cfg:*asset-roots* kind))
(defun asset-path (kind path)
(concatenate 'string (asset-root kind) path))