Hopefully last restructuring.

This commit is contained in:
interp 2003-01-19 11:03:14 +00:00
parent bee74b3867
commit 071b59a99f
1 changed files with 16 additions and 14 deletions

View File

@ -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