[43] | 1 | #!/usr/bin/env gosh |
---|
| 2 | ;; |
---|
| 3 | ;; logview.cgi |
---|
| 4 | ;; |
---|
| 5 | (require "../setting") |
---|
| 6 | (require "../lib/rawlog") |
---|
| 7 | |
---|
| 8 | (define (it s) #`"<i>,|s|</i>") |
---|
| 9 | (define (tt s) #`"<tt>,|s|</tt>") |
---|
| 10 | (define (brown s) #`"<font color=\"#cc9999\">,|s|</font>") |
---|
| 11 | (define (green s) #`"<font color=\"#339966\">,|s|</font>") |
---|
| 12 | (define (gray s) #`"<font color=\"#999999\">,|s|</font>") |
---|
| 13 | |
---|
| 14 | (define (logview-filter timestamp user cmd room msg) |
---|
| 15 | (case cmd |
---|
| 16 | [(JOIN) |
---|
| 17 | (string-append (brown timestamp) " " |
---|
| 18 | (gray (tt #`"[,|user|'in]")) |
---|
| 19 | "<br>\n")] |
---|
| 20 | [(PART QUIT) |
---|
| 21 | (string-append (brown timestamp) " " |
---|
| 22 | (gray (tt #`"[,|user|'out]")) |
---|
| 23 | (gray (it #`" ; ,|msg|")) |
---|
| 24 | "<br>\n")] |
---|
| 25 | [(PRIVMSG) |
---|
| 26 | (string-append (brown timestamp) " " |
---|
| 27 | (green #`"<,|user|> ,|msg|") |
---|
| 28 | "<br>\n")] |
---|
| 29 | [(NICK) |
---|
| 30 | (string-append (brown timestamp) " " |
---|
| 31 | (gray (it "<,|user| => |msg|>")) |
---|
| 32 | "<br>\n")] |
---|
| 33 | [(TOPIC) |
---|
| 34 | (string-append (brown timestamp) " " |
---|
| 35 | (green (string-append "<" user "> " |
---|
| 36 | #`"TOPIC => ,|msg|")) |
---|
| 37 | "<br>\n")] |
---|
| 38 | [else #f])) |
---|
| 39 | |
---|
| 40 | (define query-string (sys-getenv "QUERY_STRING")) |
---|
| 41 | |
---|
| 42 | (unless (and query-string (rxmatch #/^20[0-9][0-9]-[01][0-9]-[0-3][0-9]$/ query-string)) |
---|
| 43 | (display "Content-type: text/html") (newline) (newline) |
---|
| 44 | (error "invalid query string")) |
---|
| 45 | |
---|
| 46 | (define date-str query-string) |
---|
| 47 | |
---|
| 48 | (display "Content-type: text/html\r\n\r\n") |
---|
| 49 | (print "<html> |
---|
| 50 | <head> |
---|
| 51 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"> |
---|
| 52 | <title>" irc-channel " : " date-str "</title> |
---|
| 53 | </head> |
---|
| 54 | <body> |
---|
| 55 | " |
---|
| 56 | |
---|
| 57 | (daily-log date-str logview-filter) |
---|
| 58 | |
---|
| 59 | " |
---|
| 60 | </body> |
---|
| 61 | </html>") |
---|