add `publish-directory` and `extra-published-path?` to setup

pull/111/head
Matthew Butterick 8 years ago
parent 5bfc461cd0
commit eb0a1c677e

@ -56,12 +56,12 @@ start [dir] [port] starts project server in dir (default is current dir)
render [dir] [dest] render project in dir (default is current dir)
to dest (default is desktop)
render filename render filename only (can be source or output name)
publish copy project to desktop without source files
publish copy project to ~a without source files
publish [dir] [dest] copy project in dir to dest without source files
(warning: overwrites existing dest dir)
setup preload cache
reset reset cache
version print the version" (current-server-port))))
version print the version" (current-server-port) (make-publish-dir-name))))
(define (handle-version)
@ -124,12 +124,20 @@ version print the version" (current-server-port))))
(displayln "Starting project server ...")
((dynamic-require 'pollen/private/project-server 'start-server))))
(define (make-publish-dir-name [arg-command-name #f])
(let ([user-publish-path (expand-user-path (->path (setup:publish-directory)))])
(if (complete-path? user-publish-path)
user-publish-path
(build-path (find-system-path 'desk-dir)
(->path (if (equal? arg-command-name "clone") ; bw compat
"clone"
user-publish-path))))))
(define (handle-publish directory-maybe rest-args arg-command-name)
(define target-path
(or
(and rest-args (not (null? rest-args)) (path->complete-path (string->path (car rest-args))))
(build-path (find-system-path 'desk-dir) (string->path (if (equal? arg-command-name "clone") "clone" (setup:publish-directory-name))))))
(make-publish-dir-name arg-command-name)))
(define (delete-it path)
(cond
@ -157,7 +165,10 @@ version print the version" (current-server-port))))
(delete-directory/files target-dir))
(copy-directory/files source-dir target-dir)
(parameterize ([current-project-root (current-directory)])
(for-each delete-it (find-files pollen-related-file? target-dir)))
(define (delete-from-publish-dir? p)
(and (unpublished-path? p)
(not ((setup:extra-published-path?) p))))
(for-each delete-it (find-files delete-from-publish-dir? target-dir)))
(displayln (format "completed to ~a" target-dir)))
(define (handle-unknown command)

@ -305,7 +305,7 @@
(ormap (λ(cache-name) (ends-with? (path->string path) cache-name)) default-cache-names))
(define+provide (pollen-related-file? file)
(define+provide (unpublished-path? file)
(ormap (λ(proc) (proc file)) (list
preproc-source?
markup-source?

@ -1 +1 @@
1460223406
1460853512

@ -107,7 +107,9 @@ Make a copy of the project directory on the desktop, but without any source file
If you're already in your project directory and want to publish somewhere other than the desktop, use @racket[raco pollen publish _. _dest-dir].
You can determine the files that get filtered out in a particular project by overriding @racket[default-unpublished-path?].
You can determine the default publishing destination for a project by overriding @racket[default-publish-directory].
You can determine the files that get filtered out in a project by overriding @racket[default-unpublished-path?]. You can override these filters — that is, force a path to be published — by overriding @racket[default-extra-published-path?].
@section{@exec{raco pollen setup}}

@ -114,7 +114,13 @@ Default separators used in decoding. The first two are initialized to @racket["\
@defoverridable[compile-cache-max-size exact-positive-integer?]{Maximum size of the compile cache. Default is 10 megabytes.}
@defoverridable[unpublished-path? (path? . -> . boolean?)]{Predicate that determines whether a path is omitted from @secref{raco_pollen_publish} operations. If the predicate is @racket[#t], then the path is omitted. The default, therefore, is @racket[#f].}
(define-settable publish-directory "publish")
@defoverridable[publish-directory (or/c path-string? path-for-some-system?)]{Default target for @secref{raco_pollen_publish}. A complete path is used as is; a relative path is published to the desktop. Default is @racket["publish"].}
@defoverridable[unpublished-path? (path? . -> . boolean?)]{Predicate that determines whether a path is omitted from @secref{raco_pollen_publish} operations. If the predicate evaluated to @racket[#t], then the path is omitted. The default predicate, therefore, is @racket[(lambda (path) #f)].}
@defoverridable[extra-published-path? (path? . -> . boolean?)]{Predicate that determines if path is published, overriding @racket[(setup:unpublished-path?)] above, and Pollen's default publish settings. For instance, Pollen automatically omits files with a @racket[.rkt] extension. If you wanted to force a @racket[.rkt] file to be published, you could include it here. Default is @racket[(lambda (path) #f)].}
@defoverridable[splicing-tag symbol?]{Key used to signal that an X-expression should be spliced into its containing X-expression. Default is @val[default-splicing-tag].}

@ -101,7 +101,7 @@
(define-runtime-path server-extras-dir "private/server-extras")
(define+provide current-server-extras-path (make-parameter server-extras-dir))
(define-settable publish-directory-name "publish")
(define-settable publish-directory "publish")
(define-settable extension-escape-char #\_)
@ -110,6 +110,8 @@
(define-settable compile-cache-max-size (* 10 1024 1024)) ; = 10 megabytes
(define-settable unpublished-path? (λ(path) #f))
(define-settable extra-published-path? (λ(path) #f))
(define-settable here-path-key 'here-path)

Loading…
Cancel
Save