Hopefully last restructuring.
This commit is contained in:
parent
bee74b3867
commit
071b59a99f
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue