perun

Discuss perun static site generator
2019-05-23T00:15:27.026700Z

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

2019-05-23T00:25:36.027500Z

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 🙂

2019-05-23T00:26:10.028300Z

(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)

bhagany 2019-05-23T00:46:13.028700Z

so the thing about this is that the correct output path seems differently to everyone

bhagany 2019-05-23T00:47:39.029600Z

that said, it does look like I intended the parent-path option in resize-paths to allow you to do what you want

bhagany 2019-05-23T00:49:07.031Z

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

bhagany 2019-05-23T00:52:48.032300Z

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

2019-05-23T01:46:29.035800Z

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.

2019-05-23T01:48:15.036300Z

this definitely is something that could run into people’s differing expectations

2019-05-23T01:50:26.037200Z

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)

bhagany 2019-05-23T01:59:50.039Z

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

bhagany 2019-05-23T02:00:50.040400Z

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)

2019-05-23T02:04:58.041900Z

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.

2019-05-23T02:05:48.042200Z

(edited to fix a path)

bhagany 2019-05-23T02:09:26.042500Z

okay yeah, if that's the case I'd call it a bug

2019-05-23T02:11:04.043600Z

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

bhagany 2019-05-23T02:16:05.044800Z

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?

2019-05-23T02:21:47.046Z

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.

2019-05-23T02:24:00.047700Z

the specific use-case was to support keeping posts and their assets in their own subdirectories.

2019-05-23T02:26:59.048300Z

i guess i need to rework this a little based on the assumption that markdown has the correct behavior wrt subdirectories

bhagany 2019-05-23T02:27:56.048800Z

ah, okay, so you have a public directory in your input path

bhagany 2019-05-23T02:28:45.049400Z

are your markdown files also in public in your input?

bhagany 2019-05-23T02:30:12.050500Z

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

bhagany 2019-05-23T02:30:23.050900Z

feels related

2019-05-23T02:30:51.051400Z

right, that was the behavior of versions previous to 0.4.3-SNAPSHOT (at least through 0.3.0)--an extra level of public

2019-05-23T02:31:15.051800Z

i know this because i was asked to check the behavior in every version of the past 3 years 🙂

bhagany 2019-05-23T02:31:25.052Z

hahahaha, i'm sorry

2019-05-23T02:33:07.053700Z

(i haven’t been putting markdown files in public on the input side, but i was thinking i might try that)

bhagany 2019-05-23T02:34:02.054100Z

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

bhagany 2019-05-23T02:36:33.056500Z

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

bhagany 2019-05-23T02:37:31.057Z

I've got to run, but I'll check back, probably tomorrow

2019-05-23T02:41:55.057200Z

all right, thanks for the input

2019-05-23T22:05:09.057400Z

Working on another small change: https://github.com/hashobject/perun/pull/236