racket/collects/little-helper/web-root/servlets/home.scm
Jens Axel Soegaard ac47e02961 Initial checkin of Little Helper.
Little Helper contains a full text search engine. 
Currently it indexes all html-files in /collects/doc.
A mockup web-interface is present in order to facilitate easy experimentation with searches.
Run run-indexer to generate the index for your documentation dir. 
Run launch to start a web-server with the search interface.
Note: Currently assumes w3m is in your path (used to precompute the 
           preview-snippets shown in the search results.

svn: r8836
2008-03-01 13:26:18 +00:00

65 lines
2.2 KiB
Scheme

(module home mzscheme
(provide interface-version timeout start)
(provide do-home-page)
(require scheme/port
setup/dirs
(all-except (lib "xml.ss" "xml")
document document? make-document struct:document)
(lib "servlet.ss" "web-server")
"private/request.scm"
"private/html.scm")
(define interface-version 'v1)
(define timeout 6000)
(define (start request)
(current-request request)
(with-errors-to-browser send/finish
do-home-page))
(define (do-home-page)
(html-home-page))
(define (file->string file)
(let ([s (open-output-string)])
(with-input-from-file file
(λ ()
(copy-port (current-input-port) s)))
(get-output-string s)))
(define (html-home-page)
(make-response/full 200 ; code
"Okay" ; message
(current-seconds) ; seconds
TEXT/HTML-MIME-TYPE
; ; headers
(list (make-header #"Pragma" #"No-cache")
(make-header #"Cache-Control" #"no-cache")
(make-header #"Expires" #"Thu, 01 Jan 1970 00:00:00 GMT"))
(list doctype-HTML-4.01-Transitional
(string-append
(xexpr->string
(html-page
#:title (title "Home")
#:body ""))
(file->string
(build-path (find-doc-dir) "index.html"))))))
#;(html-page
#:title (title "Home")
#:body
`(div (h1 "Manuals")
,@(map (lambda (rep)
`(p (a ((href ,(format "~a/servlets/view.scm/~a/~a"
base-url
(repository-id rep)
(repository-home-id rep))))
,(repository-name rep))))
all-repositories)))
)