More restructuring.

This commit is contained in:
interp 2003-01-19 10:31:16 +00:00
parent 7c33c9ba08
commit bee74b3867
1 changed files with 9 additions and 7 deletions

View File

@ -7,17 +7,19 @@
(define (read-data)
(let ((news-input (open-input-file "news.txt")))
(do ((next-line (read-line news-input)
(read-line news-input)))
((eof-object? next-line) (close news-input))
(set! *data* (cons next-line *data*)))))
(read-line news-input))
(data '() (cons next-line data)))
((eof-object? next-line)
(close news-input)
data))))
(define (main req)
(if (null? *data*) (read-data))
(if (null? *data*) (set! *data* (read-data)))
(let loop ((count (- (length *data*) 1)))
(if (< count 0)
(show-final-page)
(begin
(show-news-page count)
(show-news-page (list-ref *data* count))
(loop (- count 1))))))
(define (show-final-page)
@ -28,10 +30,10 @@
(p (URL "news.scm" "See news again.") (br)
(URL "/" "Return to main menu."))))))
(define (show-news-page count)
(define (show-news-page news)
(send-html/suspend
(lambda (next-url)
`(html (body (p (h1 ,(list-ref *data* count)))
`(html (body (p (h1 ,news))
(a (@ href ,next-url) "read more...")
(hr)
(p (URL "news.scm" "See news again from beginning.") (br)