one question is what images-resize should do with source images that are not under public
. i kinda think they should not be moved to public
…
i guess the rule should be that if out-dir
is not specified, keep the resized images with the original. otherwise, put them in out-dir
. i can do that 🙂
(i figured i’d talk about this here since it’s relevant to perun, this channel is very low traffic, and i was hoping maybe someone who knew more about the internals would have some advice)
so the thing about this is that the correct output path seems differently to everyone
that said, it does look like I intended the parent-path
option in resize-paths
to allow you to do what you want
this could be exposed in the task, or the idea behind this design is that it's easy for you to hook into perun's machinery with your own tasks - a my-image-resize
would be easy to write, for instance
I'd caution against messing too much with the default handling of out-dir. it was tricky to get it so that everyone involved at the time was happy, and modifying only one task is going to result in a confusing inconsistency
i’m hoping any changes will be limited to the images-resize
task, which is hard to see as being very useful in its current state except in very limited circumstances--since it will happily overwrite images that happen to have the same name but exist in different subdirectories. a quick check of the real world examples in the readme doesn’t turn up any sites that use images-resize
.
this definitely is something that could run into people’s differing expectations
and speaking of parent-path
, yeah, a smallish change of just moving that binding down into the reduce function actually gives the behavior i’d expect (almost)
Yeah it’s the changing of just one thing that worries me, as it might mess with consistency between tasks — out-dir should work the same everywhere
I don’t have the correct behavior loaded into my cache though, so it’s very possible that this is a bug (aka inconsistent with out-dir handling in other tasks)
i think it might be inconsistent, just based on the observation that foo/2019-05-22-woo.md
gets rendered into public/foo/woo.html
, even though it appears that the markdown
task has "public"
as the default :out-dir
.
(edited to fix a path)
okay yeah, if that's the case I'd call it a bug
like the message says, there’s probably a better way of doing this, but in the spirit of setting out something that’s wrong as a way to motivate someone to come up with a better way… 🙂 https://github.com/hashobject/perun/pull/235
I think the default out-dir should remain "public", again for consistency. I don't think I understand your use-case though. do you want, say, markdown to go somewhere under public/ but not the images?
i just want resized images to stay next to their sources, wherever they are, if i don’t specify otherwise. so if i have public/images/src.jpg
, the result should be target/public/images/src_{resolutions}.jpg
.
the specific use-case was to support keeping posts and their assets in their own subdirectories.
i guess i need to rework this a little based on the assumption that markdown
has the correct behavior wrt subdirectories
ah, okay, so you have a public
directory in your input path
are your markdown files also in public
in your input?
hrm ... this is ringing a bell. I feel like I remember handling the case where the out-dir
would be repeated, like public/public/foo.html
feels related
right, that was the behavior of versions previous to 0.4.3-SNAPSHOT (at least through 0.3.0)--an extra level of public
i know this because i was asked to check the behavior in every version of the past 3 years 🙂
hahahaha, i'm sorry
(i haven’t been putting markdown files in public
on the input side, but i was thinking i might try that)
fwiw, I am pretty sure that the behavior you're describing for img-resize is correct and consistent, except for the defaulting to nil for out-dir
in other words, I think if you want src.jpg
to end up in the same place as src_{resolutions}.jpg
, there are several options:
- put src.jpg
inside the same directory as your out-dir
- sift
src.jpg
to the location you want it to be after img-resize
runs
- pass an out-dir
to img-resize
that matches src.jpg
's input location
I've got to run, but I'll check back, probably tomorrow
all right, thanks for the input
Working on another small change: https://github.com/hashobject/perun/pull/236