Fork me on GitHub
#perun
<
2016-11-16
>
bhagany03:11:04

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.

bhagany03:11:52

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.

bhagany03:11:21

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

bhagany03:11:39

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

bhagany03:11:43

Can anyone set me straight?

podviaznikov05:11:24

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

podviaznikov05:11:50

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

podviaznikov05:11:52

one way for you do solve problem for now can be writing something like 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?

bhagany13:11:58

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?

bhagany13:11:17

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.

martinklepsch16:11:13

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.

martinklepsch16:11:50

@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.

martinklepsch16:11:20

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

bhagany17:11:42

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 🙂

bhagany17:11:23

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?

martinklepsch17:11:27

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

martinklepsch17:11:07

@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.).

bhagany17:11:46

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

bhagany17:11:49

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.

bhagany17:11:56

Thanks for your patience with me 🙂

martinklepsch17:11:49

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

bhagany17:11:21

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

martinklepsch17:11:52

appreciate that attitude 🙂