sunet/scheme/httpd/surflets/web-server/root/surflets/news.scm

39 lines
1.0 KiB
Scheme
Raw Normal View History

2002-10-01 08:33:39 -04:00
(define-structure servlet servlet-interface
2002-09-13 03:21:19 -04:00
(open scsh
scheme
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)
(send-html/finish
`(html (body (p (h1 "THAT'S IT"))
(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
(send-html/suspend
2002-09-14 11:18:12 -04:00
(lambda (next-url)
`(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