Apacheのmod_autoindexもどきのindex.htmlをスタティックに生成するだけのスクリプト。 こんなのいくらでもあると思ったんだけど、あんまりいいのが見つからなかった。 仕方がないので自作。
誰かもっとfancyなやつ作ってください。
(use srfi-1) (use file.util) (use text.html-lite) (use text.tree) (define (make-index path abspath) (define (filter e) (not (string=? e "index.html"))) (receive (dirs files) (directory-list2 path :children? #t :filter filter) (for-each (lambda (dir) (write-index-html (build-path path dir) (build-path abspath dir))) dirs) (let* ((l (if (string=? abspath "/") '() (list (cons (sys-dirname abspath) "Parent Directory")))) (l (fold (lambda (dir r) (let ((d (string-append dir "/"))) (cons (cons d d) r))) l dirs)) (l (fold (lambda (file r) (cons (cons file file) r)) l files))) (map (lambda (a) (html:li (html:a :href (car a) (cdr a)))) (reverse l))))) (define (write-index-html path abspath) (with-output-to-file (build-path path "index.html") (lambda () (write-tree (html:html (html:head (html:title "Index of " abspath)) (html:body (html:h1 "Index of " abspath) (html:ul (make-index path abspath)))) )))) (define (main args) (let-optionals* (cdr args) ((path ".") (abspath "/")) (write-index-html (sys-realpath path) abspath)))