Split 'send message' input into its own frame
This commit is contained in:
parent
a4da1b6da9
commit
340b9feee1
|
@ -126,6 +126,10 @@
|
||||||
("ROOM_ID" . ,(uri:uri-encode-string channel)))))
|
("ROOM_ID" . ,(uri:uri-encode-string channel)))))
|
||||||
|
|
||||||
|
|
||||||
|
(define (room-send-html)
|
||||||
|
(html-from-template "templates/room-send.html" '()))
|
||||||
|
|
||||||
|
|
||||||
;; Generate the HTML listing a room's chat messages.
|
;; Generate the HTML listing a room's chat messages.
|
||||||
(define (room-messages-html irc-dir channel)
|
(define (room-messages-html irc-dir channel)
|
||||||
(html-from-template
|
(html-from-template
|
||||||
|
@ -189,23 +193,22 @@
|
||||||
[(equal? sub-path "messages")
|
[(equal? sub-path "messages")
|
||||||
(spiffy:send-response status: 'ok
|
(spiffy:send-response status: 'ok
|
||||||
body: (room-messages-html irc-dir channel))]
|
body: (room-messages-html irc-dir channel))]
|
||||||
|
[(equal? sub-path "send")
|
||||||
|
(spiffy:send-response status: 'ok
|
||||||
|
body: (room-send-html))]
|
||||||
[(or (not sub-path) (string=? sub-path ""))
|
[(or (not sub-path) (string=? sub-path ""))
|
||||||
(spiffy:send-response status: 'ok
|
(spiffy:send-response status: 'ok
|
||||||
body: (room-index-html irc-dir channel))])))
|
body: (room-index-html irc-dir channel))])))
|
||||||
|
|
||||||
|
|
||||||
|
(define (http-post-room-dir irc-dir #!optional request path)
|
||||||
|
(let* ([channel (third path)]
|
||||||
(define (http-send-room-message irc-dir #!optional request path)
|
[request-data (intarweb:read-urlencoded-request-data request 50000)])
|
||||||
(let ([request-data (intarweb:read-urlencoded-request-data request 50000)]
|
|
||||||
[channel (third path)])
|
|
||||||
(if (alist-ref 'message request-data)
|
(if (alist-ref 'message request-data)
|
||||||
(begin
|
(begin
|
||||||
(send-message irc-dir channel (alist-ref 'message request-data))
|
(send-message irc-dir channel (alist-ref 'message request-data))
|
||||||
;; We don't want the page to render before the message has been sent!
|
|
||||||
;; Then the user might think, “uhh my message not sent¿?”
|
|
||||||
(sleep 1)))
|
(sleep 1)))
|
||||||
(http-get-room-dir irc-dir request path)))
|
(http-get-room-dir irc-dir request (list '/ "room" channel "messages"))))
|
||||||
|
|
||||||
|
|
||||||
;; Send response for the / index.
|
;; Send response for the / index.
|
||||||
|
@ -239,7 +242,7 @@
|
||||||
|
|
||||||
;; An associative list of POST handlers, to be used by assoc-by-path.
|
;; An associative list of POST handlers, to be used by assoc-by-path.
|
||||||
(define http-post-handlers
|
(define http-post-handlers
|
||||||
`(((/ "room" "*") . ,http-send-room-message)))
|
`(((/ "room" "*") . ,http-post-room-dir)))
|
||||||
|
|
||||||
|
|
||||||
;; Get a pair from an associative list based on the closest match to the
|
;; Get a pair from an associative list based on the closest match to the
|
||||||
|
|
|
@ -7,7 +7,10 @@
|
||||||
</head>
|
</head>
|
||||||
<frameset cols="300px,*,200px">
|
<frameset cols="300px,*,200px">
|
||||||
<frame name="rooms" src="/room#{{ROOM_ID}}">
|
<frame name="rooms" src="/room#{{ROOM_ID}}">
|
||||||
|
<frameset rows="*,50px">
|
||||||
<frame name="messages" src="messages">
|
<frame name="messages" src="messages">
|
||||||
|
<frame name="send" src="send">
|
||||||
|
</frameset>
|
||||||
<frame name="users" src="users">
|
<frame name="users" src="users">
|
||||||
</frameset>
|
</frameset>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -5,15 +5,11 @@
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="stylesheet" href="/style.css" type="text/css">
|
<link rel="stylesheet" href="/style.css" type="text/css">
|
||||||
<meta http-equiv="refresh" content="20">
|
<meta http-equiv="refresh" content="5">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<table>
|
<table>
|
||||||
{{LIST_ITEMS}}
|
{{LIST_ITEMS}}
|
||||||
</table>
|
</table>
|
||||||
<form id="send" method="post">
|
|
||||||
<input name="message" />
|
|
||||||
<button>Send</button>
|
|
||||||
</form>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>{{ROOM_TITLE}}</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link rel="stylesheet" href="/style.css" type="text/css">
|
||||||
|
<meta http-equiv="refresh" content="20">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<form id="send" method="post" target="messages" action="messages">
|
||||||
|
<input name="message" />
|
||||||
|
<button>Send</button>
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
Reference in New Issue