Archived
1
0
Disbranĉigi 0

User-lists for rooms

This commit is contained in:
Jaidyn Ann 2023-05-31 01:31:52 -05:00
parent 2029df1cfc
commit 21c7a4d694
3 changed files with 57 additions and 5 deletions

View File

@ -16,8 +16,8 @@
;;
(import scheme
(chicken io) (chicken sort) (chicken string) (chicken irregex)
(chicken pretty-print)
(chicken file) (chicken io) (chicken sort) (chicken string)
(chicken irregex) (chicken pretty-print)
srfi-1 srfi-19
(prefix chatdir chatdir:)
(prefix intarweb intarweb:)
@ -94,6 +94,30 @@
(alist-ref 'user.chat.date (cdr b))))))
(define (channel-online-users irc-dir channel)
(directory
(string-append irc-dir "/" channel "/.users/online/")))
(define (room-users-html irc-dir channel)
(html-from-template
"templates/room-user-list.html"
`(("ROOM_TITLE" . ,(uri:uri-decode-string channel))
("LIST_ITEMS"
. ,(reduce-right
string-append ""
(map (lambda (user)
(room-users-item-html irc-dir channel user))
(channel-online-users
irc-dir
(uri:uri-decode-string channel))))))))
(define (room-users-item-html irc-dir channel user)
(html-from-template
"templates/room-user-list-item.html"
`(("USER_NAME" . ,user))))
;; Generate the HTML listing a room's chat messages.
(define (room-chat-html irc-dir channel)
@ -143,9 +167,20 @@
(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))]
[sub-path (if (eq? (length path) 4)
(fourth path) #f)])
(cond
[(not channel?)
(spiffy:send-response code: 404
body: "<h1>That's not a channel, smh!!</h1>")]
[(equal? sub-path "users")
(spiffy:send-response status: 'ok
body: (room-chat-html irc-dir channel))))
body: (room-users-html irc-dir channel))]
[#t
(spiffy:send-response status: 'ok
body: (room-chat-html irc-dir channel))])))

View File

@ -0,0 +1 @@
<li>{{USER_NAME}}</li>

View File

@ -0,0 +1,16 @@
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Users — {{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">
<base href="" target="main">
</head>
<body>
<ul>
{{LIST_ITEMS}}
</ul>
</body>
</html>