#!/usr/bin/env gosh
;;
;; logview.cgi
;;
(require "../setting")
(require "../lib/rawlog")
(use srfi-19)
(define (it s) #`",|s|")
(define (tt s) #`",|s|")
(define (brown s) #`",|s|")
(define (green s) #`",|s|")
(define (gray s) #`",|s|")
(define (logview-filter timestamp user cmd room msg)
(case cmd
[(JOIN)
(string-append (brown timestamp) " "
(gray (tt #`"[,|user|'in]"))
"
\n")]
[(PART QUIT)
(string-append (brown timestamp) " "
(gray (tt #`"[,|user|'out]"))
(gray (it #`" ; ,|msg|"))
"
\n")]
[(PRIVMSG)
(string-append (brown timestamp) " "
(green #`"<,|user|> ,|msg|")
"
\n")]
[(NICK)
(string-append (brown timestamp) " "
(gray (it "<,|user| => |msg|>"))
"
\n")]
[(TOPIC)
(string-append (brown timestamp) " "
(green (string-append "<" user "> "
#`"TOPIC => ,|msg|"))
"
\n")]
[else #f]))
(define query-string (sys-getenv "QUERY_STRING"))
(define date-str (if (and query-string (rxmatch #/^20[0-9][0-9]-[01][0-9]-[0-3][0-9]$/ query-string))
query-string
(date->string (current-date) "~Y-~m-~d")))
(display "Content-type: text/html\r\n\r\n")
(print "