allow `raco pollen render` to synthesize a default pagetree

pull/58/head
Matthew Butterick 10 years ago
parent 2de2fbad6e
commit 0216df6c86

@ -16,16 +16,23 @@ clone copy project to desktop without source files" ,(world:curr
(define (handle-render dir-or-path rest-args) (define (handle-render dir-or-path rest-args)
`(begin `(begin
(require pollen/render pollen/world pollen/file sugar) (require pollen/render pollen/world pollen/file sugar pollen/pagetree racket/list)
(parameterize ([current-directory (world:current-project-root)]) (parameterize ([current-directory (world:current-project-root)])
(define dir-or-path ,dir-or-path) (define dir-or-path ,dir-or-path)
(apply render-batch (map ->complete-path (if (not (directory-exists? dir-or-path)) (apply render-batch (map ->complete-path (if (not (directory-exists? dir-or-path))
(begin (begin
(displayln (format "Rendering ~a" dir-or-path)) (displayln (format "Rendering ~a" dir-or-path))
(cons dir-or-path ',rest-args)) (cons dir-or-path ',rest-args))
(begin (let ([dir dir-or-path]) ; now we know it's a dir
(displayln (format "Rendering preproc & pagetree files in directory ~a" dir-or-path)) (displayln (format "Rendering preproc & pagetree files in directory ~a" dir))
(apply append (map (λ(proc) (filter proc (directory-list dir-or-path))) (list preproc-source? pagetree-source?)))))))))) (define preprocs (filter preproc-source? (directory-list dir)))
(define static-pagetrees (filter pagetree-source? (directory-list dir)))
;; if there are no static pagetrees, use make-project-pagetree
;; (which will synthesize a pagetree if needed, which includes all sources)
(define pagetrees (if (empty? static-pagetrees)
(list (make-project-pagetree dir))
static-pagetrees))
(append* preprocs pagetrees))))))))
(define (handle-start directory [port #f]) (define (handle-start directory [port #f])

Loading…
Cancel
Save