2002-10-01 08:33:39 -04:00
|
|
|
(define-structure servlet servlet-interface
|
2002-09-13 03:21:19 -04:00
|
|
|
(open scsh
|
|
|
|
scheme
|
2002-09-25 09:02:31 -04:00
|
|
|
servlets
|
2002-09-13 03:21:19 -04:00
|
|
|
crlf-io)
|
|
|
|
(begin
|
2002-09-14 11:18:12 -04:00
|
|
|
(define *data* '())
|
|
|
|
|
|
|
|
(define (read-data)
|
2002-09-13 03:21:19 -04:00
|
|
|
(let ((news-input (open-input-file "news.txt")))
|
2002-09-14 11:18:12 -04:00
|
|
|
(let loop ((next-line (read-crlf-line news-input)))
|
|
|
|
(if (eof-object? next-line)
|
|
|
|
(close news-input)
|
|
|
|
(begin
|
|
|
|
(set! *data* (cons next-line *data*))
|
|
|
|
(loop (read-crlf-line news-input)))))))
|
|
|
|
|
|
|
|
(define (main req)
|
|
|
|
(if (null? *data*) (read-data))
|
|
|
|
(let loop ((count (- (length *data*) 1)))
|
|
|
|
(if (< count 0)
|
2002-09-19 07:16:29 -04:00
|
|
|
(send-html/finish
|
|
|
|
`(html (body (p (h1 "THAT'S IT"))
|
2002-10-21 04:38:46 -04:00
|
|
|
(p ("That's it..."))
|
|
|
|
(hr)
|
|
|
|
(p (URL "news.scm" "See news again.") (br)
|
|
|
|
(URL "/" "Return to main menu.")))))
|
2002-09-14 11:18:12 -04:00
|
|
|
(begin
|
2002-09-19 07:16:29 -04:00
|
|
|
(send-html/suspend
|
2002-09-14 11:18:12 -04:00
|
|
|
(lambda (next-url)
|
2002-10-21 04:38:46 -04:00
|
|
|
`(html (body (p (h1 ,(list-ref *data* count)))
|
|
|
|
(a (@ href ,next-url) "read more...")
|
|
|
|
(hr)
|
|
|
|
(p (URL "news.scm" "See news again from beginning.") (br)
|
|
|
|
(URL "/" "Return to main menu."))))))
|
2002-09-14 11:18:12 -04:00
|
|
|
(loop (- count 1))))))
|
2002-09-13 03:21:19 -04:00
|
|
|
))
|
2002-09-14 11:18:12 -04:00
|
|
|
|