From eb0a1c677e42979c5506f0bf078365dbf3022cbc Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Sat, 16 Apr 2016 17:38:32 -0700 Subject: [PATCH] add `publish-directory` and `extra-published-path?` to setup --- pollen/private/command.rkt | 19 +++++++++++++++---- pollen/private/file-utils.rkt | 2 +- pollen/private/ts.rktd | 2 +- pollen/scribblings/raco.scrbl | 4 +++- pollen/scribblings/setup.scrbl | 8 +++++++- pollen/setup.rkt | 4 +++- 6 files changed, 30 insertions(+), 9 deletions(-) diff --git a/pollen/private/command.rkt b/pollen/private/command.rkt index 463d773..b316a54 100644 --- a/pollen/private/command.rkt +++ b/pollen/private/command.rkt @@ -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) diff --git a/pollen/private/file-utils.rkt b/pollen/private/file-utils.rkt index d2b08be..e450955 100644 --- a/pollen/private/file-utils.rkt +++ b/pollen/private/file-utils.rkt @@ -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? diff --git a/pollen/private/ts.rktd b/pollen/private/ts.rktd index ab3d7de..6137f67 100644 --- a/pollen/private/ts.rktd +++ b/pollen/private/ts.rktd @@ -1 +1 @@ -1460223406 +1460853512 diff --git a/pollen/scribblings/raco.scrbl b/pollen/scribblings/raco.scrbl index 25ab7cf..86e1043 100644 --- a/pollen/scribblings/raco.scrbl +++ b/pollen/scribblings/raco.scrbl @@ -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}} diff --git a/pollen/scribblings/setup.scrbl b/pollen/scribblings/setup.scrbl index be5ef21..a6a212e 100644 --- a/pollen/scribblings/setup.scrbl +++ b/pollen/scribblings/setup.scrbl @@ -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].} diff --git a/pollen/setup.rkt b/pollen/setup.rkt index f7b43e7..a48083c 100644 --- a/pollen/setup.rkt +++ b/pollen/setup.rkt @@ -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)