Move messages to /room/*/messages; per-room index
This allows the navigation frame to highlight the current room; and for the user-list frame to reflect current room.
This commit is contained in:
parent
21c7a4d694
commit
a4da1b6da9
|
@ -119,28 +119,35 @@
|
||||||
`(("USER_NAME" . ,user))))
|
`(("USER_NAME" . ,user))))
|
||||||
|
|
||||||
|
|
||||||
;; Generate the HTML listing a room's chat messages.
|
(define (room-index-html irc-dir channel)
|
||||||
(define (room-chat-html irc-dir channel)
|
|
||||||
(html-from-template
|
(html-from-template
|
||||||
"templates/room-chat.html"
|
"templates/room-index.html"
|
||||||
|
`(("ROOM_TITLE" . ,(uri:uri-decode-string channel))
|
||||||
|
("ROOM_ID" . ,(uri:uri-encode-string channel)))))
|
||||||
|
|
||||||
|
|
||||||
|
;; Generate the HTML listing a room's chat messages.
|
||||||
|
(define (room-messages-html irc-dir channel)
|
||||||
|
(html-from-template
|
||||||
|
"templates/room-messages.html"
|
||||||
`(("ROOM_TITLE" . ,(uri:uri-decode-string channel))
|
`(("ROOM_TITLE" . ,(uri:uri-decode-string channel))
|
||||||
("LIST_ITEMS"
|
("LIST_ITEMS"
|
||||||
. ,(reduce-right
|
. ,(reduce-right
|
||||||
string-append ""
|
string-append ""
|
||||||
(map (lambda (message)
|
(map (lambda (message)
|
||||||
(room-chat-item-html irc-dir channel message))
|
(room-messages-item-html irc-dir channel message))
|
||||||
(channel-messages-sorted
|
(channel-messages-sorted
|
||||||
irc-dir
|
irc-dir
|
||||||
(uri:uri-decode-string channel))))))))
|
(uri:uri-decode-string channel))))))))
|
||||||
|
|
||||||
|
|
||||||
;; Generate the HTML for a specific message in a specific room.
|
;; Generate the HTML for a specific message in a specific room.
|
||||||
;; Used to substitute {{LIST_ITEMS}} in the room-chat template.
|
;; Used to substitute {{LIST_ITEMS}} in the room-messages template.
|
||||||
(define (room-chat-item-html irc-dir channel message)
|
(define (room-messages-item-html irc-dir channel message)
|
||||||
(if (and (list? message)
|
(if (and (list? message)
|
||||||
(string? (car message)))
|
(string? (car message)))
|
||||||
(html-from-template
|
(html-from-template
|
||||||
"templates/room-chat-item.html"
|
"templates/room-messages-item.html"
|
||||||
`(("MESSAGE_SENDER"
|
`(("MESSAGE_SENDER"
|
||||||
. ,(html-encode-string
|
. ,(html-encode-string
|
||||||
(alist-ref 'user.chat.sender (cdr message))))
|
(alist-ref 'user.chat.sender (cdr message))))
|
||||||
|
@ -166,6 +173,7 @@
|
||||||
body: (room-listing-html irc-dir)))
|
body: (room-listing-html irc-dir)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(define (http-get-room-dir irc-dir #!optional request path)
|
(define (http-get-room-dir irc-dir #!optional request path)
|
||||||
(let* ([channel (third path)]
|
(let* ([channel (third path)]
|
||||||
[channel? (member channel (chatdir:channels irc-dir))]
|
[channel? (member channel (chatdir:channels irc-dir))]
|
||||||
|
@ -178,9 +186,13 @@
|
||||||
[(equal? sub-path "users")
|
[(equal? sub-path "users")
|
||||||
(spiffy:send-response status: 'ok
|
(spiffy:send-response status: 'ok
|
||||||
body: (room-users-html irc-dir channel))]
|
body: (room-users-html irc-dir channel))]
|
||||||
[#t
|
[(equal? sub-path "messages")
|
||||||
(spiffy:send-response status: 'ok
|
(spiffy:send-response status: 'ok
|
||||||
body: (room-chat-html irc-dir channel))])))
|
body: (room-messages-html irc-dir channel))]
|
||||||
|
[(or (not sub-path) (string=? sub-path ""))
|
||||||
|
(spiffy:send-response status: 'ok
|
||||||
|
body: (room-index-html irc-dir channel))])))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>{{ROOM_TITLE}} — spidercat</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
</head>
|
||||||
|
<frameset cols="300px,*,200px">
|
||||||
|
<frame name="rooms" src="/room#{{ROOM_ID}}">
|
||||||
|
<frame name="messages" src="messages">
|
||||||
|
<frame name="users" src="users">
|
||||||
|
</frameset>
|
||||||
|
</html>
|
|
@ -5,8 +5,7 @@
|
||||||
<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">
|
||||||
|
<base href="" target="_top">
|
||||||
<base href="" target="main">
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{{LIST_ITEMS}}
|
{{LIST_ITEMS}}
|
||||||
|
|
Reference in New Issue