2003-01-19 11:57:27 -05:00
|
|
|
(define-structure surflet surflet-interface
|
2002-12-08 10:49:27 -05:00
|
|
|
(open scheme-with-scsh
|
2003-01-19 11:57:27 -05:00
|
|
|
surflets)
|
2002-09-13 03:21:19 -04:00
|
|
|
(begin
|
2003-01-19 06:03:14 -05:00
|
|
|
(define *news* '())
|
2002-09-14 11:18:12 -04:00
|
|
|
|
2003-01-19 06:03:14 -05:00
|
|
|
(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)))))))
|
2002-09-14 11:18:12 -04:00
|
|
|
|
|
|
|
(define (main req)
|
2003-01-19 06:03:14 -05:00
|
|
|
(if (null? *news*)
|
|
|
|
(set! *news* (read-news "news.txt")))
|
|
|
|
(let loop ((news *news*))
|
|
|
|
(if (null? news)
|
2003-01-19 04:47:15 -05:00
|
|
|
(show-final-page)
|
2002-09-14 11:18:12 -04:00
|
|
|
(begin
|
2003-01-19 06:03:14 -05:00
|
|
|
(show-news-page (car news))
|
|
|
|
(loop (cdr news))))))
|
2003-01-19 04:47:15 -05:00
|
|
|
|
|
|
|
(define (show-final-page)
|
|
|
|
(send-html/finish
|
|
|
|
`(html (body (p (h1 "THAT'S IT"))
|
|
|
|
(p ("That's it..."))
|
|
|
|
(hr)
|
2003-03-09 15:15:08 -05:00
|
|
|
(p (url "news.scm" "See news again.") (br)
|
|
|
|
(url "/" "Return to main menu."))))))
|
2003-01-19 04:47:15 -05:00
|
|
|
|
2003-01-19 05:31:16 -05:00
|
|
|
(define (show-news-page news)
|
2003-01-19 04:47:15 -05:00
|
|
|
(send-html/suspend
|
|
|
|
(lambda (next-url)
|
2003-01-19 05:31:16 -05:00
|
|
|
`(html (body (p (h1 ,news))
|
2003-01-19 04:47:15 -05:00
|
|
|
(a (@ href ,next-url) "read more...")
|
|
|
|
(hr)
|
2003-03-09 15:15:08 -05:00
|
|
|
(p (url "news.scm" "See news again from beginning.") (br)
|
|
|
|
(url "/" "Return to main menu.")))))))
|
2002-09-13 03:21:19 -04:00
|
|
|
))
|
2002-09-14 11:18:12 -04:00
|
|
|
|