diff --git a/src/scripts/components/.keep b/assets/css/components/.keep similarity index 100% rename from src/scripts/components/.keep rename to assets/css/components/.keep diff --git a/src/styles/global.css b/assets/css/global.css similarity index 100% rename from src/styles/global.css rename to assets/css/global.css diff --git a/src/styles/pages/about.css b/assets/css/pages/about.css similarity index 100% rename from src/styles/pages/about.css rename to assets/css/pages/about.css diff --git a/src/styles/pages/index.css b/assets/css/pages/index.css similarity index 100% rename from src/styles/pages/index.css rename to assets/css/pages/index.css diff --git a/public/img/me.jpg b/assets/img/me.jpg similarity index 100% rename from public/img/me.jpg rename to assets/img/me.jpg diff --git a/src/scripts/pages/.keep b/assets/js/components/.keep similarity index 100% rename from src/scripts/pages/.keep rename to assets/js/components/.keep diff --git a/src/scripts/global.js b/assets/js/global.js similarity index 100% rename from src/scripts/global.js rename to assets/js/global.js diff --git a/src/scripts/pages/about.js b/assets/js/pages/about.js similarity index 100% rename from src/scripts/pages/about.js rename to assets/js/pages/about.js diff --git a/src/scripts/pages/index.js b/assets/js/pages/index.js similarity index 100% rename from src/scripts/pages/index.js rename to assets/js/pages/index.js diff --git a/public/vendor/alpine-ext/async-alpine@1.2.2.js b/assets/vendor/alpine-ext/async-alpine@1.2.2.js similarity index 100% rename from public/vendor/alpine-ext/async-alpine@1.2.2.js rename to assets/vendor/alpine-ext/async-alpine@1.2.2.js diff --git a/public/vendor/alpine-ext/morph@3.13.8.js b/assets/vendor/alpine-ext/morph@3.13.8.js similarity index 100% rename from public/vendor/alpine-ext/morph@3.13.8.js rename to assets/vendor/alpine-ext/morph@3.13.8.js diff --git a/public/vendor/alpine-ext/persist@3.13.8.js b/assets/vendor/alpine-ext/persist@3.13.8.js similarity index 100% rename from public/vendor/alpine-ext/persist@3.13.8.js rename to assets/vendor/alpine-ext/persist@3.13.8.js diff --git a/public/vendor/alpine@3.13.8.js b/assets/vendor/alpine@3.13.8.js similarity index 100% rename from public/vendor/alpine@3.13.8.js rename to assets/vendor/alpine@3.13.8.js diff --git a/public/vendor/htmx-ext/alpine-morph@1.9.12.js b/assets/vendor/htmx-ext/alpine-morph@1.9.12.js similarity index 100% rename from public/vendor/htmx-ext/alpine-morph@1.9.12.js rename to assets/vendor/htmx-ext/alpine-morph@1.9.12.js diff --git a/public/vendor/htmx-ext/head-support@1.9.12.js b/assets/vendor/htmx-ext/head-support@1.9.12.js similarity index 100% rename from public/vendor/htmx-ext/head-support@1.9.12.js rename to assets/vendor/htmx-ext/head-support@1.9.12.js diff --git a/public/vendor/htmx@1.9.12.js b/assets/vendor/htmx@1.9.12.js similarity index 100% rename from public/vendor/htmx@1.9.12.js rename to assets/vendor/htmx@1.9.12.js diff --git a/public/vendor/ress@5.0.2.css b/assets/vendor/ress@5.0.2.css similarity index 100% rename from public/vendor/ress@5.0.2.css rename to assets/vendor/ress@5.0.2.css diff --git a/src/app.lisp b/src/app.lisp index b1dcd8b..9c4f838 100644 --- a/src/app.lisp +++ b/src/app.lisp @@ -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*) diff --git a/src/config/vendor.lisp b/src/config/logger.lisp similarity index 50% rename from src/config/vendor.lisp rename to src/config/logger.lisp index 40a857c..05a549d 100644 --- a/src/config/vendor.lisp +++ b/src/config/logger.lisp @@ -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) diff --git a/src/middlewares/public-files.lisp b/src/middlewares/serve-assets.lisp similarity index 56% rename from src/middlewares/public-files.lisp rename to src/middlewares/serve-assets.lisp index aa2d612..83be20c 100644 --- a/src/middlewares/public-files.lisp +++ b/src/middlewares/serve-assets.lisp @@ -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/")))) diff --git a/src/styles/components/.keep b/src/styles/components/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/src/view/asset.lisp b/src/view/asset.lisp index 41dd3f3..5918e38 100644 --- a/src/view/asset.lisp +++ b/src/view/asset.lisp @@ -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))))