;;; wiki.scm -- dead simple static HTML "wiki", intended for use with VCS ;;; ;;; Walk over a directory, transforming every markdown-file into HTML. ;;; Then, generate a per-directory index.x?html over the titles (first h1) of ;;; every markdown file and directory within. (use srfi-1 files posix lowdown ports) (define html-extension "html") (define vcs-directories '("RCS" "CVS" ".git" ".hg" ".svn" "_darcs" "{arch}")) (define (markdown-file? e) (let ((ext (pathname-extension e))) (and ext (regular-file? e) (string-ci=? ext "md")))) (define (vcs-directory? e) (and (directory? e) (member (pathname-strip-directory e) vcs-directories))) (define (walk filt fun #!optional (path ".")) (and (filt path) (if (directory? path) (map (lambda (dirent) (walk filt fun dirent)) (directory path)) ; FIXME (directory) seems to return names relative to path (fun path)))) (define (markdown-transform path) (let* ((new-path (pathname-replace-extension path html-extension)) (out-fd (begin (delete-file* new-path) ; just to be sure (open-output-file new-path))) (in-fd (open-input-file path))) ; TODO (with-output-to-port out-fd (lambda () (markdown->html in-fd))))) (define (make-index) '()) ;TODO (define (transform-.) (walk (lambda (x) (not (vcs-directory? x))) (lambda (x) (and (markdown-file? x) (markdown-transform x))))) ; vim:set ts=2 et: