|
|
@ -15,8 +15,8 @@
|
|
|
|
compile
|
|
|
|
compile
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
(import chicken scheme files srfi-1 extras ports)
|
|
|
|
(import chicken scheme files srfi-1 extras ports irregex)
|
|
|
|
(use sxml-transforms srfi-69 scss srfi-13 lowdown doctype)
|
|
|
|
(use sxml-transforms srfi-69 scss srfi-13 lowdown doctype posix)
|
|
|
|
|
|
|
|
|
|
|
|
(define *pages* (make-hash-table))
|
|
|
|
(define *pages* (make-hash-table))
|
|
|
|
(define *stylesheets* (make-hash-table))
|
|
|
|
(define *stylesheets* (make-hash-table))
|
|
|
@ -25,7 +25,7 @@
|
|
|
|
(define src-dir (make-parameter "src"))
|
|
|
|
(define src-dir (make-parameter "src"))
|
|
|
|
(define out-dir (make-parameter "out"))
|
|
|
|
(define out-dir (make-parameter "out"))
|
|
|
|
(define res-dir (make-parameter "res"))
|
|
|
|
(define res-dir (make-parameter "res"))
|
|
|
|
(define link-root (make-parameter "/home"))
|
|
|
|
(define link-root (make-parameter ""))
|
|
|
|
(define doctype (make-parameter doctype-html))
|
|
|
|
(define doctype (make-parameter doctype-html))
|
|
|
|
|
|
|
|
|
|
|
|
(define ++ string-append)
|
|
|
|
(define ++ string-append)
|
|
|
@ -76,31 +76,42 @@
|
|
|
|
(hash-table-delete! *stylesheets* path))
|
|
|
|
(hash-table-delete! *stylesheets* path))
|
|
|
|
|
|
|
|
|
|
|
|
(define (add-file-resource! path)
|
|
|
|
(define (add-file-resource! path)
|
|
|
|
(cons path *file-resources*))
|
|
|
|
(set! *file-resources* (cons path *file-resources*)))
|
|
|
|
|
|
|
|
|
|
|
|
(define (delete-file-resource! path)
|
|
|
|
(define (delete-file-resource! path)
|
|
|
|
(remove (lambda (p) (equal? p path)) *file-resources*))
|
|
|
|
(set! *file-resources* (remove (lambda (p) (equal? p path)) *file-resources*)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define (create-dirs path)
|
|
|
|
|
|
|
|
(create-directory (pathname-directory path) #t))
|
|
|
|
|
|
|
|
|
|
|
|
(define (output-pages)
|
|
|
|
(define (output-pages)
|
|
|
|
(hash-table-for-each
|
|
|
|
(hash-table-for-each
|
|
|
|
*pages*
|
|
|
|
*pages*
|
|
|
|
(lambda (k v)
|
|
|
|
(lambda (k v)
|
|
|
|
(with-output-to-file (++ (out-dir) "/" k)
|
|
|
|
(let ((p (++ (out-dir) "/" k)))
|
|
|
|
(lambda () (print (doctype) (sxml->html v)))))))
|
|
|
|
(create-dirs p)
|
|
|
|
|
|
|
|
(with-output-to-file p
|
|
|
|
|
|
|
|
(lambda () (print (doctype) (sxml->html v))))))))
|
|
|
|
|
|
|
|
|
|
|
|
(define (output-stylesheets)
|
|
|
|
(define (output-stylesheets)
|
|
|
|
(hash-table-for-each
|
|
|
|
(hash-table-for-each
|
|
|
|
*stylesheets*
|
|
|
|
*stylesheets*
|
|
|
|
(lambda (k v)
|
|
|
|
(lambda (k v)
|
|
|
|
(with-output-to-file (++ (out-dir) "/" k)
|
|
|
|
(let ((p (++ (out-dir) "/" k)))
|
|
|
|
(lambda () (scss->css v))))))
|
|
|
|
(create-dirs p)
|
|
|
|
|
|
|
|
(with-output-to-file p
|
|
|
|
|
|
|
|
(lambda () (scss->css v)))))))
|
|
|
|
|
|
|
|
|
|
|
|
(define (copy-file-resources)
|
|
|
|
(define (copy-file-resources)
|
|
|
|
(for-each (lambda (p)
|
|
|
|
(for-each
|
|
|
|
(file-copy (++ (res-dir) "/" p) (++ (out-dir) "/" p)))
|
|
|
|
(lambda (p)
|
|
|
|
*file-resources*))
|
|
|
|
(let ((path-out (++ (out-dir) "/" p)))
|
|
|
|
|
|
|
|
(create-dirs path-out)
|
|
|
|
|
|
|
|
(file-copy (++ (res-dir) "/" p) path-out)))
|
|
|
|
|
|
|
|
*file-resources*))
|
|
|
|
|
|
|
|
|
|
|
|
(define (compile)
|
|
|
|
(define (compile)
|
|
|
|
|
|
|
|
(and (directory? (out-dir)) (delete-directory (out-dir) #t))
|
|
|
|
(output-pages)
|
|
|
|
(output-pages)
|
|
|
|
(output-stylesheets)
|
|
|
|
(output-stylesheets)
|
|
|
|
(copy-file-resources))
|
|
|
|
(copy-file-resources))
|
|
|
|