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