Move all assets to assets directory
This commit is contained in:
parent
84bbbce9b9
commit
544cbfcb6a
22 changed files with 15 additions and 17 deletions
assets
css
img
js
vendor
src
Before ![]() (image error) Size: 211 KiB After ![]() (image error) Size: 211 KiB ![]() ![]() |
|
@ -26,9 +26,7 @@
|
|||
(fbr:assign-routes *app*
|
||||
:system "hp"
|
||||
:directory "src/routes")
|
||||
(jg:static-path *app* (asset:asset-root :script) "src/scripts/")
|
||||
(jg:static-path *app* (asset:asset-root :style) "src/styles/")
|
||||
(jg:install-middleware *app* mw:*public-files*)
|
||||
(jg:install-middleware *app* mw:*serve-assets*)
|
||||
(jg:install-middleware *app* mw:*recovery*)
|
||||
(jg:install-middleware *app* mw:*normalize-path*)
|
||||
(jg:install-middleware *app* mw:*accesslog*)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
(defpackage #:hp/config/vendor
|
||||
(defpackage #:hp/config/logger
|
||||
(:use #:cl)
|
||||
(:import-from #:log4cl))
|
||||
(in-package #:hp/config/vendor)
|
||||
(in-package #:hp/config/logger)
|
||||
|
||||
(log:config :nofile)
|
|
@ -1,18 +1,18 @@
|
|||
(defpackage #:hp/middlewares/public-files
|
||||
(defpackage #:hp/middlewares/serve-assets
|
||||
(:use #:cl)
|
||||
(:import-from #:lack.middleware.static
|
||||
#:*lack-middleware-static*)
|
||||
(:export #:*public-files*))
|
||||
(in-package #:hp/middlewares/public-files)
|
||||
(:export #:*serve-assets*))
|
||||
(in-package #:hp/middlewares/serve-assets)
|
||||
|
||||
(defun exist-public-file-p (path)
|
||||
(let ((pathname (probe-file (concatenate 'string "public" path))))
|
||||
(let ((pathname (probe-file (concatenate 'string "assets" path))))
|
||||
(and pathname (pathname-name pathname))))
|
||||
|
||||
(defparameter *public-files*
|
||||
(defparameter *serve-assets*
|
||||
(lambda (app)
|
||||
(funcall *lack-middleware-static*
|
||||
app
|
||||
:path (lambda (path)
|
||||
(and (exist-public-file-p path) path))
|
||||
:root (asdf:system-relative-pathname :hp "public/"))))
|
||||
:root (asdf:system-relative-pathname :hp "assets/"))))
|
|
@ -14,8 +14,8 @@
|
|||
(in-package #:hp/view/asset)
|
||||
|
||||
(defparameter *asset-roots*
|
||||
'(:style "/styles/"
|
||||
:script "/scripts/"
|
||||
'(:css "/css/"
|
||||
:js "/js/"
|
||||
:vendor "/vendor/"
|
||||
:htmx-ext "/vendor/htmx-ext/"
|
||||
:alpine-ext "/vendor/alpine-ext/"))
|
||||
|
@ -37,10 +37,10 @@
|
|||
|
||||
(define-asset *ress* :vendor
|
||||
"ress@5.0.2.css")
|
||||
(define-asset *global-css* :style
|
||||
(define-asset *global-css* :css
|
||||
"global.css")
|
||||
|
||||
(define-asset *global-js* :script
|
||||
(define-asset *global-js* :js
|
||||
"global.js")
|
||||
|
||||
(define-asset *htmx* :vendor
|
||||
|
@ -64,13 +64,13 @@
|
|||
:test #'string=))
|
||||
|
||||
(defun get-css-paths (html-str)
|
||||
(mapcar (asset-path-under :style)
|
||||
(mapcar (asset-path-under :css)
|
||||
(detect-data-props html-str "data-style")))
|
||||
|
||||
(defun asset-props (&key style script x-data)
|
||||
(append (and style `(:data-style ,style))
|
||||
(and script x-data
|
||||
`(:ax-load t
|
||||
:ax-load-src ,(asset-path :script script)
|
||||
:ax-load-src ,(asset-path :js script)
|
||||
:x-ignore t
|
||||
:x-data ,x-data))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue