web: use /hx as standard API path for htmx-type response; dom: use pre-defined elements
This commit is contained in:
parent
f9011dd9c6
commit
5835c54b36
6 changed files with 16 additions and 9 deletions
|
@ -12,7 +12,7 @@
|
||||||
:port "8800"
|
:port "8800"
|
||||||
:address "0.0.0.0"
|
:address "0.0.0.0"
|
||||||
:routes
|
:routes
|
||||||
`((("api") server:message-handler :html-responder cs-hx:response)
|
`((("hx") server:message-handler :html-responder cs-hx:response)
|
||||||
(() server:fileserver :doc-root
|
(() server:fileserver :doc-root
|
||||||
,(config:path "/var/www/html/" :env-key :docroot))))
|
,(config:path "/var/www/html/" :env-key :docroot))))
|
||||||
(config:add-action '(:test :data) #'core:echo)
|
(config:add-action '(:test :data) #'core:echo)
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
:class 'server:config
|
:class 'server:config
|
||||||
:port "8899"
|
:port "8899"
|
||||||
:routes
|
:routes
|
||||||
`((("api") server:message-handler :html-responder cs-hx:response)
|
`((("hx") server:message-handler :html-responder cs-hx:response)
|
||||||
(() server:fileserver
|
(() server:fileserver
|
||||||
:doc-root ,(t:test-path "" "docs"))))
|
:doc-root ,(t:test-path "" "docs"))))
|
||||||
(config:add-action '(:test :data) #'core:echo)
|
(config:add-action '(:test :data) #'core:echo)
|
||||||
|
@ -22,4 +22,4 @@
|
||||||
(config:add :client
|
(config:add :client
|
||||||
:class 'client:config
|
:class 'client:config
|
||||||
:base-url "http://localhost:8899"
|
:base-url "http://localhost:8899"
|
||||||
:doc-path "/" :api-path "/api/")
|
:doc-path "/" :api-path "/hx/")
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
(deftest test-dom ()
|
(deftest test-dom ()
|
||||||
(== (dom:render
|
(== (dom:render
|
||||||
(dom:element :a '(:href "https://example.com"
|
(dom:a '(:href "https://example.com"
|
||||||
:title "Demo" :class (:demo-link :plain))
|
:title "Demo" :class (:demo-link :plain))
|
||||||
"Link to example.com"))
|
"Link to example.com"))
|
||||||
"<a href=\"https://example.com\" title=\"Demo\" class=\"demo-link plain\">Link to example.com</a>"))
|
"<a href=\"https://example.com\" title=\"Demo\" class=\"demo-link plain\">Link to example.com</a>"))
|
||||||
|
|
|
@ -56,6 +56,9 @@
|
||||||
|
|
||||||
;;;; utilities
|
;;;; utilities
|
||||||
|
|
||||||
|
(defmacro normalize (&rest xs)
|
||||||
|
)
|
||||||
|
|
||||||
(defun test-path (name &rest dirs)
|
(defun test-path (name &rest dirs)
|
||||||
(apply #'scopes/util:system-path *current-system* name "test" dirs))
|
(apply #'scopes/util:system-path *current-system* name "test" dirs))
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,10 @@
|
||||||
|
|
||||||
;;;; strings, symbols, keywords, ...
|
;;;; strings, symbols, keywords, ...
|
||||||
|
|
||||||
(defun flatten-str (s &key (with " "))
|
(defun flatten-str (s &key (sep " "))
|
||||||
(str:join with (str:lines s)))
|
(str:join sep
|
||||||
|
(mapcar (lambda (x) (str:trim x))
|
||||||
|
(str:lines s))))
|
||||||
|
|
||||||
(defun to-string (k &key (sep " ") lower-case)
|
(defun to-string (k &key (sep " ") lower-case)
|
||||||
(let ((pattern (if lower-case "~(~a~)" "~a")))
|
(let ((pattern (if lower-case "~(~a~)" "~a")))
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
(put c))
|
(put c))
|
||||||
(end tag))))
|
(end tag))))
|
||||||
|
|
||||||
;;;; element = HTML element - no self-closing (<... />) of empty elements
|
;;;; element = HTML element - no self-closing of empty elements
|
||||||
|
|
||||||
(defclass element (xml-element) ())
|
(defclass element (xml-element) ())
|
||||||
|
|
||||||
|
@ -58,6 +58,8 @@
|
||||||
|
|
||||||
;;;; void element (e.g. <input ...>): no body, no explicit closing of tag
|
;;;; void element (e.g. <input ...>): no body, no explicit closing of tag
|
||||||
|
|
||||||
|
(defclass void-element (xml-element) ())
|
||||||
|
|
||||||
(defun void-element (tag attrs)
|
(defun void-element (tag attrs)
|
||||||
(make-instance 'void-element :tag tag :attrs attrs))
|
(make-instance 'void-element :tag tag :attrs attrs))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue