root/lang/gauche/irc-logger/trunk/htdocs/logview.cgi @ 72

Revision 46, 1.8 kB (checked in by naoya_t, 17 years ago)

irc-logger/htdocs/logview.cgi: make today the default date

Line 
1#!/usr/bin/env gosh
2;;
3;; logview.cgi
4;;
5(require "../setting")
6(require "../lib/rawlog")
7
8(use srfi-19)
9
10(define (it s) #`"<i>,|s|</i>")
11(define (tt s) #`"<tt>,|s|</tt>")
12(define (brown s) #`"<font color=\"#cc9999\">,|s|</font>")
13(define (green s) #`"<font color=\"#339966\">,|s|</font>")
14(define (gray s) #`"<font color=\"#999999\">,|s|</font>")
15
16(define (logview-filter timestamp user cmd room msg)
17    (case cmd
18      [(JOIN)
19       (string-append (brown timestamp) " "
20                      (gray (tt #`"[,|user|'in]"))
21                      "<br>\n")]
22      [(PART QUIT)
23       (string-append (brown timestamp) " "
24                      (gray (tt #`"[,|user|'out]"))
25                      (gray (it #`" ; ,|msg|"))
26                      "<br>\n")]
27      [(PRIVMSG)
28       (string-append (brown timestamp) " "
29                      (green #`"&lt;,|user|&gt; ,|msg|")
30                      "<br>\n")]
31      [(NICK)
32       (string-append (brown timestamp) " "
33                      (gray (it "&lt;,|user| =&gt; |msg|&gt;"))
34                      "<br>\n")]
35      [(TOPIC)
36       (string-append (brown timestamp) " "
37                      (green (string-append "&lt;" user "&gt; "
38                                            #`"TOPIC =&gt; ,|msg|"))
39                      "<br>\n")]
40      [else #f]))
41 
42(define query-string (sys-getenv "QUERY_STRING"))
43
44(define date-str (if (and query-string (rxmatch #/^20[0-9][0-9]-[01][0-9]-[0-3][0-9]$/ query-string))
45                     query-string
46                     (date->string (current-date) "~Y-~m-~d")))
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>")
Note: See TracBrowser for help on using the browser.