perun

Discuss perun static site generator
bhagany 2016-11-16T03:20:04.000189Z

requesting a sanity check on this - I have some tagged articles. I would like to generate a page per tag, and list the appropriate articles per tag. This is almost what collection does, but the issue in this case is that each article can have multiple tags, and will therefore appear on multiple tag pages. Since collection only exposes a predicate for group-by, I don’t see a way to achieve this behavior, other than manually specifying a collection per tag in my build task.

bhagany 2016-11-16T03:23:52.000190Z

I copied and modified collection to accept a function that does all of the grouping instead of a predicate for group-by, which is pretty much the only path I see to get automatically-generated pages per tag without knowing the tags ahead of time. I question this approach, because it feels like perun doesn’t want me to do things like this.

bhagany 2016-11-16T03:24:21.000191Z

In particular, I end up copying private functions over to my own code, which is a warning flag for me

bhagany 2016-11-16T03:24:39.000192Z

(in this case, I needed render-in-pod, wrap-pool, and commit)

bhagany 2016-11-16T03:25:43.000193Z

Can anyone set me straight?

podviaznikov 2016-11-16T05:39:24.000194Z

it’s an interesting use case. It does seems that right now it’s hard to do. I usually do specify all my collections manually per one file. And it does seems to be problematic if you have a lot of tags and the list is not fixed

podviaznikov 2016-11-16T05:42:50.000195Z

I’m now even doubting if group-by should be an option of collection task. Maybe collection should always map to one file and grouping and other cases like yours should be solved using other primitive tasks. Or maybe we should continue with what we have right now and make collection more flexible

podviaznikov 2016-11-16T05:47:52.000196Z

one way for you do solve problem for now can be writing something like <https://github.com/hashobject/perun/blob/master/src/io/perun.clj#L298> sitemap task. What you want to do is to create a task that will create new files in the fileset for each tag (and files would have some specific key you can use to filter those created by you later). Than you would defined render task and would apply it only to the files you’ve created. Does such idea make sense?

bhagany 2016-11-16T13:04:58.000197Z

This is basically what my modification of collection does. It just doesn’t feel “right” to me, because I end up having to copy and paste a bunch of private functions from perun.clj. Because of this, it feels like perun doesn’t want me to define these kinds of tasks. Or is there another reason that functions like render-in-pod are private?

bhagany 2016-11-16T13:11:17.000199Z

I could go either way on the group-by option in collection. I was surprised that it was there, and maybe it feels a bit complected, but I don’t mind it so much.

martinklepsch 2016-11-16T16:27:13.000200Z

I think maybe there could be a task that takes a function that returns a map of {path-in-fileset contents} and these will be written into the fileset then by the task. Kind of a mix of the render and collection tasks sort of? Hope that makes sense.

martinklepsch 2016-11-16T16:27:50.000201Z

@bhagany I think at this point it would make sense to stress that the API is not considered stable and if you have any interesting ideas we should totally discuss them.

martinklepsch 2016-11-16T16:28:20.000202Z

(Maybe this discussion is better done in a Github issue though. Just so that it isn't lost later on.)

bhagany 2016-11-16T17:05:42.000203Z

heh, don’t worry, I’m under no illusions about the stability of perun’s API. That’s part of the reason I picked it 🙂

bhagany 2016-11-16T17:10:23.000204Z

My question, if I can rephrase it again is this - am I, as just a consumer of perun’s API, supposed to write tasks that add to the fileset? Or is it perun’s intent that it manages the fileset, while consumers write tasks that modify the metadata?

martinklepsch 2016-11-16T17:10:27.000205Z

One thing I've been thinking about as well is using Rum to render HTML and potentially do something interesting with server side rendered stuff in that context

martinklepsch 2016-11-16T17:13:07.000206Z

@bhagany I think perun's tasks should handle most use-cases. When it doesn't you need to do your own thing. Where the border between these two sides is isn't clear yet I'd say. Also consumers don't really modify the metadata directly in most cases but use tasks that enrich it & are specialized (permalink, etc.).

bhagany 2016-11-16T17:13:46.000207Z

ah, yes, I think I mean the same thing by “modify” as you mean by “enrich"

bhagany 2016-11-16T17:15:49.000208Z

I will think a bit, and see if I can come up with a proposal that is interesting enough. I’ll use github for that.

bhagany 2016-11-16T17:15:56.000209Z

Thanks for your patience with me 🙂

martinklepsch 2016-11-16T17:17:49.000210Z

Thanks for your patience with this whole thing as well 😄 I think it's quite hard still but there are some rough diamonds somewhere 🙂

bhagany 2016-11-16T17:18:21.000211Z

sure! the whole idea has a lot of promise, and finding those diamonds is fun.

👍 1
martinklepsch 2016-11-16T17:18:52.000212Z

appreciate that attitude 🙂