Move all assets to assets directory
This commit is contained in:
parent
84bbbce9b9
commit
544cbfcb6a
22 changed files with 15 additions and 17 deletions
src
|
@ -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/"))))
|
|
@ -1,9 +0,0 @@
|
|||
document.addEventListener('alpine:init', () => {
|
||||
Alpine.store('darkMode', {
|
||||
on: Alpine.$persist(false).as('darkMode'),
|
||||
|
||||
toggle() {
|
||||
this.on = ! this.on
|
||||
}
|
||||
})
|
||||
})
|
|
@ -1,7 +0,0 @@
|
|||
export const aboutPage = () => ({
|
||||
count: 0,
|
||||
|
||||
decrement() {
|
||||
this.count--
|
||||
}
|
||||
})
|
|
@ -1,7 +0,0 @@
|
|||
export const indexPage = () => ({
|
||||
count: 0,
|
||||
|
||||
increment() {
|
||||
this.count++
|
||||
}
|
||||
})
|
|
@ -1,12 +0,0 @@
|
|||
@charset "utf-8";
|
||||
|
||||
body {
|
||||
font-family: "Noto Sans JP", sans-serif;
|
||||
font-optical-sizing: auto;
|
||||
font-weight: 400;
|
||||
font-style: normal;
|
||||
|
||||
&[data-dark] {
|
||||
background-color: slategrey;
|
||||
}
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
@scope ([data-style='pages/about.css']) {
|
||||
:scope {
|
||||
height: 100svh;
|
||||
display: grid;
|
||||
place-content: center;
|
||||
}
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
@scope ([data-style='pages/index.css']) {
|
||||
:scope {
|
||||
height: 100svh;
|
||||
display: grid;
|
||||
place-content: center;
|
||||
}
|
||||
}
|
|
@ -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