module Main where

import Network.CGI
import Data.Maybe
import System.IO

import DB
import Now
import ShowMessages
import FancyHtml

main = runCGI $ handleErrors cgiMain

cgiMain = do
    let min = 20
    cutoff   <- liftIO $ now_plus_min (-min)
    messages <- liftIO $ db_select $ "SELECT msg_digest, sender, recipient, subject, sent_date FROM messages WHERE sent_date > '" ++ cutoff ++ "' ORDER BY sent_date DESC"
    output $ header ++ "<p><h1>Messages sent in the last " ++ show min ++ " minutes</h1><table border=1><tr><th>Digest</th><th>Sender</th><th>Recipient</th><th>Subject</th><th>Sent date</th></tr>" ++ (showMessagesWithLink messages) ++ "</table></p>" ++ (quote "Ordinarily technology changes fast. But programming languages are different: programming languages are not just technology, but what programmers think in. They're half technology and half religion. And so the median language, meaning whatever language the median programmer uses, moves as slow as an iceberg." "http://www.paulgraham.com/paulgraham/avg.html" "Paul Graham") ++ footer
