Improve and format
This commit is contained in:
parent
da279fc12b
commit
b40471bde2
5 changed files with 28 additions and 36 deletions
src
|
@ -1,6 +1,6 @@
|
|||
(defpackage #:hp/config/logger
|
||||
(defpackage #:hp/config/lib
|
||||
(:use #:cl)
|
||||
(:import-from #:log4cl))
|
||||
(in-package #:hp/config/logger)
|
||||
(in-package #:hp/config/lib)
|
||||
|
||||
(log:config :nofile)
|
|
@ -23,14 +23,14 @@
|
|||
(,(if (listp files) 'mapcar 'funcall)
|
||||
(asset-path-under ,kind) ',files)))
|
||||
|
||||
(defun detect-data-props (html-str data-prop-name)
|
||||
(let* ((regex (format nil "(?<=~a=\")[^\"]*(?=\")" data-prop-name))
|
||||
(data-props (re:all-matches-as-strings regex html-str)))
|
||||
(remove-duplicates data-props :test #'string=)))
|
||||
(defun detect-attr-vals (html attr)
|
||||
(let* ((regex (format nil "(?<=~a=\")[^\"]*(?=\")" attr))
|
||||
(vals (re:all-matches-as-strings regex html)))
|
||||
(remove-duplicates vals :test #'string=)))
|
||||
|
||||
(defun get-css-paths (html-str)
|
||||
(defun get-css-paths (html)
|
||||
(mapcar (asset-path-under :css)
|
||||
(detect-data-props html-str "data-css")))
|
||||
(detect-attr-vals html "data-css")))
|
||||
|
||||
(defun cmp-props (&key css js x-data)
|
||||
(append (and css `(:data-css ,css))
|
||||
|
|
|
@ -6,24 +6,19 @@
|
|||
(:export #:scripts))
|
||||
(in-package #:hp/view/components/document/scripts)
|
||||
|
||||
(defasset *global-js*
|
||||
:js "global.js")
|
||||
|
||||
(defasset *htmx*
|
||||
:vendor "htmx@1.9.12.js")
|
||||
|
||||
(defasset *htmx-extentions*
|
||||
:htmx-ext ("alpine-morph@1.9.12.js"
|
||||
(defasset *htmx* :vendor "htmx@1.9.12.js")
|
||||
(defasset *htmx-exts* :htmx-ext
|
||||
("alpine-morph@1.9.12.js"
|
||||
"head-support@1.9.12.js"))
|
||||
|
||||
(defasset *alpine*
|
||||
:vendor "alpine@3.13.8.js")
|
||||
|
||||
(defasset *alpine-extentions*
|
||||
:alpine-ext ("async-alpine@1.2.2.js"
|
||||
(defasset *alpine* :vendor "alpine@3.13.8.js")
|
||||
(defasset *alpine-exts* :alpine-ext
|
||||
("async-alpine@1.2.2.js"
|
||||
"persist@3.13.8.js"
|
||||
"morph@3.13.8.js"))
|
||||
|
||||
(defasset *global* :js "global.js")
|
||||
|
||||
(pi:define-element extentions (paths defer)
|
||||
(pi:h
|
||||
(<>
|
||||
|
@ -35,7 +30,7 @@
|
|||
(pi:h
|
||||
(<>
|
||||
(script :src *htmx*)
|
||||
(extentions :paths *htmx-extentions*)
|
||||
(extentions :paths *alpine-extentions* :defer t)
|
||||
(script :src *global-js* :defer t)
|
||||
(extentions :paths *htmx-exts*)
|
||||
(extentions :paths *alpine-exts* :defer t)
|
||||
(script :src *global* :defer t)
|
||||
(script :src *alpine* :defer t))))
|
||||
|
|
|
@ -8,15 +8,12 @@
|
|||
#:styles))
|
||||
(in-package #:hp/view/components/document/styles)
|
||||
|
||||
(defasset *ress*
|
||||
:vendor "ress@5.0.2.css")
|
||||
|
||||
(defasset *global-css*
|
||||
:css "global.css")
|
||||
(defasset *ress* :vendor "ress@5.0.2.css")
|
||||
(defasset *global* :css "global.css")
|
||||
|
||||
(pi:define-element on-demand-styles ()
|
||||
(let* ((pi:*escape-html* nil)
|
||||
(html-str (pi:elem-str pi:children))
|
||||
(let* ((html-str (let ((pi:*escape-html* nil))
|
||||
(pi:elem-str pi:children)))
|
||||
(css-paths (get-css-paths html-str)))
|
||||
(pi:h
|
||||
(<>
|
||||
|
@ -28,7 +25,7 @@
|
|||
(pi:h
|
||||
(<>
|
||||
(link :rel "stylesheet" :type "text/css" :href *ress*)
|
||||
(link :rel "stylesheet" :type "text/css" :href *global-css*)
|
||||
(link :rel "stylesheet" :type "text/css" :href *global*)
|
||||
(on-demand-styles pi:children)
|
||||
(link :rel "preconnect" :href "https://fonts.googleapis.com")
|
||||
(link :rel "preconnect" :href "https://fonts.gstatic.com" :crossorigin t)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue