More restructuring.
This commit is contained in:
parent
7c33c9ba08
commit
bee74b3867
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue