From 071b59a99fa74ea5c8591475450cedc42dda7203 Mon Sep 17 00:00:00 2001 From: interp Date: Sun, 19 Jan 2003 11:03:14 +0000 Subject: [PATCH] Hopefully last restructuring. --- .../web-server/root/surflets/news.scm | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/scheme/httpd/surflets/web-server/root/surflets/news.scm b/scheme/httpd/surflets/web-server/root/surflets/news.scm index 2c16f25..97af118 100644 --- a/scheme/httpd/surflets/web-server/root/surflets/news.scm +++ b/scheme/httpd/surflets/web-server/root/surflets/news.scm @@ -2,25 +2,27 @@ (open scheme-with-scsh servlets) (begin - (define *data* '()) + (define *news* '()) - (define (read-data) - (let ((news-input (open-input-file "news.txt"))) - (do ((next-line (read-line news-input) - (read-line news-input)) - (data '() (cons next-line data))) - ((eof-object? next-line) - (close news-input) - data)))) + (define (read-news news-file-name) + (close-after (open-input-file news-file-name) + (lambda (news-input) + (let loop ((next-line (read-line news-input)) + (news '())) + (if (eof-object? next-line) + news + (loop (read-line news-input) + (cons next-line news))))))) (define (main req) - (if (null? *data*) (set! *data* (read-data))) - (let loop ((count (- (length *data*) 1))) - (if (< count 0) + (if (null? *news*) + (set! *news* (read-news "news.txt"))) + (let loop ((news *news*)) + (if (null? news) (show-final-page) (begin - (show-news-page (list-ref *data* count)) - (loop (- count 1)))))) + (show-news-page (car news)) + (loop (cdr news)))))) (define (show-final-page) (send-html/finish