From ff1106123fd16f31164a73b19bf22394d29015c8 Mon Sep 17 00:00:00 2001 From: Bubblegumdrop Date: Sun, 13 Oct 2024 01:26:33 -0400 Subject: [PATCH] Navbar, messing with HTML. --- live-chat-ui.lisp | 25 +++++++++++++++++++++---- live-chat-ws.lisp | 20 +++++++++++--------- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/live-chat-ui.lisp b/live-chat-ui.lisp index 7ef4ef4..77cd45f 100644 --- a/live-chat-ui.lisp +++ b/live-chat-ui.lisp @@ -59,13 +59,29 @@ (cl-who:str (render-chat-messages))))) (:nav :role "navigation" :class "navbar is-fixed-bottom is-spaced has-shadow" + :aria-label "main navigation" + (:div :class "navbar-brand" + (:a :class "navbar-item" + :href "https://phntsm.ddns.net/" + (:img :src "/favicon.png" + :alt "icon")) + (:a :role "button" + :class "navbar-burger" + :aria-label "menu" + :aria-expanded "false" + :data-target "navbarBasicExample" + (:span :aria-hidden "true") + (:span :aria-hidden "true") + (:span :aria-hidden "true") + (:span :aria-hidden "true"))) (:div :class "navbar-menu is-active" :id "navbarBasicExample" - (:div :class "navbar-start") - (:div :class "container" + (:div :class "navbar-start" + :style "display: none;") + (:div :class "navbar-middle container" (:div :class "field has-addons" (:div :class "control is-expanded" - (:input :class "input is-expanded" + (:input :class "input" :id "chat-input" :autocomplete "off" :placeholder "Enter your message..." @@ -73,7 +89,8 @@ (:div :class "control" (:button :class "button is-link is-light" :type "submit" "Send")))) - (:div :class "navbar-end"))) + (:div :class "navbar-end" + :style "display: none;"))) (:script (cl-who:str (js-snippet (subpath-prefix "/ws-chat-messages")))))))) (defun js-snippet (path) diff --git a/live-chat-ws.lisp b/live-chat-ws.lisp index 08cdb6a..6ba1458 100644 --- a/live-chat-ws.lisp +++ b/live-chat-ws.lisp @@ -12,23 +12,25 @@ (setf (gethash con *connections*) (princ-to-string (gensym "USER-")))) +(defun generate-html-message (content) + (cl-who:with-html-output-to-string (*standard-output*) + (:div :class "box" + :style "overflow: auto; white-space: nowrap;" + (cl-who:str content)))) + (defun broadcast-to-room (connection message) (handle-post-message message) (let ((message - (cl-who:with-html-output-to-string (*standard-output*) - (:div :class "box" - :style "overflow: auto; white-space: nowrap;" - (format t "~a: ~a" (gethash connection *connections*) message))))) + (generate-html-message + (format nil "~a: ~a" (gethash connection *connections*) message)))) (loop :for con :being :the :hash-key :of *connections* :do (send con message)))) (defun handle-close-connection (connection) (let ((message - (cl-who:with-html-output-to-string (*standard-output*) - (:div :class "box" - :style "overflow: auto; white-space: nowrap;" - (format t "... ~a disconnected." - (gethash connection *connections*)))))) + (generate-html-message + (format nil "... ~a disconnected." + (gethash connection *connections*))))) (loop :for con :being :the :hash-key :of *connections* :do (send con message))))