Shrutarshi Basu
unread,Jul 11, 2019, 2:22:20 PM7/11/19Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Pollen
Hello everyone,
I’m a little confused about the use of `omitted-path?`, and how paths
are handled in general.
Here is the setup: I have a project with a bunch of subdirectories.
Some of those subdirectories have JavaScript, or images, etc. These
directories *do not* need to be processed by `pollen render -s`, but
*do* need to be processed by `pollen publish`. As a start, I tried to
override `setup:omitted-path?` as directed in the documentation, and
printed out the paths that were being handled by the function. I
noticed some behavior that seems odd to me.
First, during `pollen render -s`, the paths getting sent to
`omitted-path?` seem to be paths of the subdirectories, not the files
that are being rendered. This seems a little odd to me: what if I want
some files in a directory to be rendered, and not others? But this is
fine for omitting image or script directories for my use case.
Second, during `pollen publish`, the paths sent to `omitted-path?` are
(1) the paths in the `publish-directory` that the files will get
copied to, not in the source directory, and (2) this time, the entire
paths to the target files, not just the directories. (1) makes it
harder to implement the functionality I want above, because I now I
need to think in terms of the target directory, not the current
project directory, and (2) seems inconsistent with what happens for
`pollen render`, so `omitted-path?` will have to handle both cases.
I’m not familiar with the internals of pollen, so maybe there is a
good reason for `omitted-path?` to be used this way. But here are some
suggestions for making things more uniform?
1. `omitted-path?` is always given the full source path for each
*file* being considered.
2. `omitted-path?` is called for *every* file that is being considered
for rendering, unless...
3. There is a `omitted-directory?` function that is called when pollen
is about to descend into a directory. If it returns true, the entire
directory is skipped, and the files and subdirectories in it do not
need to be processed by `omitted-path?`.
4. There is an optional argument to `omitted-path?` that describes
whether it is being called as part of a render or publish operation.
This lets things like image directories be skipped during render, but
included during publishing. Alternatively, render and publish could
call separate functions to check for omission (that might be cleaner
actually).
I’m interested in helping develop pollen, so I’m happy to try and make
these changes in a fork and send a pull request.
I know there’s a note in the docs saying that `publish` might need
improvement, so maybe my thoughts above relate to that?
For reference, my `omitted-path?` implementation is below. Do let me
know if I’m doing something wrong, or am just being ignorant.
Thanks,
Basu
;; Override Pollen parameters
(module setup racket/base
(require racket/path pollen/setup)
(provide (all-defined-out))
(define publish-directory (expand-user-path "~/output/"))
(define img-path (path->complete-path "images/"))
(define js-path (path->complete-path "js/"))
(define (omitted-path? path)
(printf "Checking path: ~a\n" path)
(define p-only (path-only (path->complete-path path)))
(or (default-omitted-path? path)
(equal? p-only img-path)
(equal? p-only js-path)))
)