Open Geobert opened 6 years ago
I've added some sections we'll want to fill out to help guide the conversation
Activation of pagination feature will also say on which index pagination will be enabled In _cobalt.yml:
So the things you can paginate on and their permalink are being defined in _cobalt.yml
but how do I associate my index.md
with one of these?
permalink: "/{{ year }}/{{ month }}/p{{ num }}"
When we crate an index by published_date
, are they all only available by year/month or are we parsing the permalink to see what variables are being used?
added prior art, still thinking about your questions :)
Thanks!
Some feedback
For gutenberg, that only talks about what variables are available but not how you set it up.
It's in https://www.getgutenberg.io/documentation/content/section/
In short you just set paginate_by
to a positive integer in any section front-matter and it will paginate this section by this much. I'll add some docs on that I guess
updated proposal :)
I just update the jekyll v2 section with some interesting highlights.
In particular, I want to call out the fact thatthe global settings are defaults and not the main way to configure. I think its important that we allow pagination configuration to happen in the frontmatter. I then assume we should just rely on the frontmatter default system we have in the config file for pagination rather than creating another way of creating unique instances of pagination.
btw for Hugo, I think _index.md
is what they use but this is one area where I feel there docs are lacking
https://gohugo.io/content-management/organization/#index-pages-index-md
Thank you :) What are trails?
I agree with the fact that _cobalt.yml should hold only defaults and same values can be override in fronts
Nice, I'll add this to our version :)
updated the config to pagination
instead of index
, more intuitive.
add the info that we can override the config values in frontmatter
Added trails, total ripoff of Jekyll pagination v2
I agree with the fact that _cobalt.yml should hold only defaults and same values can be override in fronts
I think it'd be a good exercise to document the frontmatter changes first and then to see how that plays out with the _cobalt.yml
configuration.
Currently, the way to default frontmatter is to set is by filling in the default
sections in the configuration. Maybe some of that will work with pagination defaults? Maybe some will still need a unique way to default in the config. Maybe some won't need defaults because they are too unique.
And if we do maintain defaults in the config, we should also consider whether the defaults are set globally and/or per-collection.
What do you mean? That I write the documentation first?
I'm not expecting documentation, just a description, like you did for _cobalt.yml
, of what will be supported in the frontmatter after this.
Sorry for this huge delay, a video game sucked me out real life x)
I've updated the proposal with more paginator object description.
All the values in _cobalt.yml
are available on each page front as well if needed to be override.
Understandable. I've had health issues in the family plus the CLI-WG sucking me away.
Not sure if its lack of clarity on my part or if it fell through the cracks since its been so long since we've talked, but I feel like some of my feedback hasn't been applied.
I think it'd be a good exercise to document the frontmatter changes first and then to see how that plays out with the _cobalt.yml configuration.
Maybe I'm misunderstanding something but this part:
all the values in config can be overriden in frontmatter of each page
Means all the values I defined in the _cobalt.yml
are valid for the frontmatter as well. They will override the value set in _cobalt.yml
I hope the health issues are not too serious and that everybody will get better soon :-/
I'm trying to understand how Cobalt is working to identify where I will put the pagination code. Correct me if I'm wrong: I'll need to work on liquid.rs
project as well in order to make this work, won't I? If I got it properly, Cobalt is only responsible for:
But the rendering is done by Liquid.rs, isn't it?
So, for the pagination, I'll need to enrich Liquid to understand what to do with a paginator
, and Cobalt will generate Collection
s for each needed index and determine their destination on the hardrive. Am I correct?
EDIT: this is totally wrong, no need to add anything to Liquid at least for the for block
part
Also, I'm studying Liquid, and especially the for loop block. But I can't understand how collections.posts.pages
is resolve in Liquid, can you give me some insight on this please? :)
Got it! It's in generate_doc
in cobalt.rs
when we put "collections" into globals
:D
After studying the code and made the refactoring I understand a bit more the implication of pagination. I'm rewriting the proposal
Rewritten proposal posted! :D
I've made an attempt at closing our any of the comments that have been resolved to make it easier to browse the discussion. I feel like github needs a batch hide option :).
We've been going back and forth on this several times. I'm wondering if scheduling a discussion on gitter would be helpful. I'll go ahead and give this another shot.
How appropriate is it for pagination information to only be configured globally? Should it instead be configured on the actual page?
I suspect that it should be on the page.
The current pattern in cobalt for this is to define this configuration on the Frontmatter. In going this route, I'd expect a proposal to document these new Frontmatter fields. The only reason to discuss _cobalt.yml
is to discuss how defaulting works which is of particular note here.
The way to globally set defaults for the frontmatter is then to use default
, posts.default
, and pages.default
. The challenge is we don't want to globally enable pagination. A limited way of handling this is the user sets all of the default fields they want except an enable
flag. They just then need to enable
it and get the rest.
This makes defaulting limited to one kind of index, whether by year, category, etc. Its probably common enough for users to configure multiple, that we should consider our options. One option is to adopt jekyll's defaulting system which is based on global patterns, like "if the file uses this path, set these defaults".
An alternative system is to provide named defaults that a page opts-in to.
Here is a rough sketch of how named defaults might work
_cobalt.yml
:
pages:
default:
data:
foo: bar
posts:
default:
- name: ""
permalink: "/something"
- name: "category_index"
pagination:
...
- name: "date_index"
pagination:
...
index.md
:
default: "category_index"
---
Hello world!@
(field names subject to change, this is just for illustrative purposes)
With serde
, we can make a fields support multiple types of values. I chose to make default
be a Either<FrontMatter, Vec<KeyedFrontMatter>>
(where KeyedFrontmatter
adds name
) rather than using a HashMap to avoid ambiguous situations where it might not be clear whether is is a Frontmatter or a HashMap.
Of course this is me exploring one line of solving these problems based on the current design of cobalt, allowing for consistent patterns for the user to be aware of. There are of course other possible solutions and it'd be great for us to consider and evaluate them. I think this gets down to recording requirements which should be the first role of a proposal which we don't have written down and agreed to yet.
I think this gets down to recording requirements which should be the first role of a proposal which we don't have written down and agreed to yet.
I've seen you have filled the section :)
My first need is to paginate collections.posts.pages
and then in a second time, I'll need tag and year/month as well. I don't know if my first need is covered by one of your proposals.
How appropriate is it for pagination information to only be configured globally? Should it instead be configured on the actual page?
This is a good idea, at least for my use case, it's true that having global default value then only having a switch is not really logic. I was following Jekyll's scheme here. So I'm all for "only in the front configuration" idea.
- Should we support narrowing by additional tags?
In a second step, I think yes but maybe having a first version working then enrich it?
- Should we support hierarchical tags (like
parent::child
)?
For me, tags have no hierarchy, categories are here for that.
- Should we support nested indexing, like tags within a category?
Hm… not sure, but even if yes, let's not do a mega big feature in one shot, let's paginate collections.posts.pages
first and then move forward?
Otherwise the feature will take years to get out.
For me, tags have no hierarchy, categories are here for that.
Oh the joy of complex data models to map :)
Hm… not sure, but even if yes, let's not do a mega big feature in one shot, let's paginate collections.posts.pages first and then move forward?
Otherwise the feature will take years to get out.
I support that as long as we don't feel we have designed ourselves out of doing more.
I've seen you have filled the section :)
Well, started it. There are probably more for us to consider.
I've read what you wrote as requirements and I quite agree with all. I just added published_date
with no year nor month in order to paginate collections.posts.pages
.
I've read what you wrote as requirements and I quite agree with all.
Feel free to speak up if you do have a concern over an edit I make. This is a proposal, even my contributions, and all is fair game.
I just added published_date with no year nor month in order to paginate collections.posts.pages.
I redid that to just include all content. I assume your intent was sorting. That is orthogonal, so I created a separate item for it.
Updated the proposal with no global config and activation from frontmatter
The keys under pagination are the types of content you can paginate?
pagination:
posts:
enable: false // mandatory
per_page: 10
permalink: "/_p/{{ num }}/"
trails:
before: 0
after: 0
Why not make that a field?
pagination:
include: categories // default: `None`, can also be `all`, `years`, etc
per_page: 10
permalink: "/_p/{{ num }}/"
trails:
before: 0
after: 0
Also, we can make the schema auto-adapt
pagination: true
maps to pagination: all
pagination: categories
pagination: categories, tags
How do you specify different per_page
by types of content? Or different permalinks as well etc…
I think I'm missing something in your comment.
Are you referring to my auto-adapt schema? Those are shortcuts for the full-form and defaults are applied to fields, like when declaring a dependency in Cargo.toml
, you can say toml="1.0"
and toml = { version = "1.0" }
.
I thought you were suggesting to use include
instead of
pagination:
post:
but if it's to use defaults values, yeah, good idea :)
I don't know how the permalink
part will fit though.
Good points. It could be that the idea of the shortcut might not work.
Some options, though probably not great:
include
directly to a permalink variable and append them, in order, to {{ parent }}/
.To add, we should probably just note that this is an idea for future consideration in the "Potential" section.
We could translate each include directly to a permalink variable and append them, in order, to {{ parent }}/.
This is also what I had in mind while thinking how permalink can fit with shortcuts. I'll go for that.
I've started to work (slowly) on the implementation to get my head around this feature and to understand more on how cobalt works. I'm ok with redoing it while this discussion evolved to match the specification but I need to code to get more details that I might miss.
Sounds good.
I've cleaned up the proposal, added sorting fields, and documented how user-defined defaults can work, At some point we'll need to compare the proposal against requirements to make sure they are all satisfied.
While coding, I noticed that first_page
and last_page
have no added value so I didn't put them in. We keep first_page_path
and last_page_path
of course.
I'm trying to get my head around the permalink permalink: "/{{parent}}/{{include}}/_p/{{ num }}/"
concept.
Do we have something that already translate this into a file system path? Or do I need to code how to interpret {{parent}}
?
Do we have something that already translate this into a file system path?
To expand a permalink https://github.com/cobalt-org/cobalt.rs/blob/master/src/document.rs#L97
To format it as a file path https://github.com/cobalt-org/cobalt.rs/blob/master/src/document.rs#L121
Or do I need to code how to interpret {{parent}}?
parent is already dumped into the available variables: https://github.com/cobalt-org/cobalt.rs/blob/master/src/document.rs#L40
Thanks! What about {{num}}
?
I've ended with https://github.com/Geobert/cobalt.rs/blob/pagination/src/cobalt_model/pagination.rs#L212
I might need to rewrite this to use the existing functions
EDIT: and {{include}}
is new as well
Yeah I need to rewrite this, or I'll end to rewrite the same thing anyway for future pagination include (year and categories for exemple).
I need to make the functions you showed me as pub
is that ok?
As for the 2 new {{num}}
and {{include}}
, do I treat them in a new func or inside permalink_attributes
?
If in the existing permalink_attributes
, I need to add more params, so it may not be a great idea.
I need to make the functions you showed me as pub is that ok?
src
calls into src/cobalt_model
, we shouldn't be doing it the other way around.
I'd recommend preparing a PR that splits the parsing logic out into a src/cobalt_model/permalink.rs
file. permalink_attributes
would not move over. I've not dug in to see how you plumb everything together but hopefully we can keep that near document logic for now.
As for the 2 new {{num}} and {{include}}, do I treat them in a new func or inside permalink_attributes?
Separate function. Merge the objects.
What is {{include}}
? Its not listed in the RFC.
Ok for the PR, I'll work on that tonigth :)
What is {{include}}? Its not listed in the RFC.
It's this:
pagination:
include: categories // default: `None`, can also be `all`, `years`, etc
Oh, include
is what we are paginating over. I was looking in the RFC for where we talk about permalinks and it wasn't discussed there. I added a brief permalink section. Feel free to correct me :)
btw have we figured out a solution to this open question in the RFC: "Should we ensure there is a way to avoid a 0 when that is the index?"
A lot of times, when paginating, there is a page
and a page/1
or something. Maybe we could expose the default
filter in liquid and do permalink: "/{{parent}}/{{include}}/{{ num | default "" }}/"
Feel free to correct me :)
No need to :D
"Should we ensure there is a way to avoid a 0 when that is the index?"
What do you mean? 0 page? if so paginator will have an empty posts
attribute
A lot of times, when paginating, there is a page and a page/1 or something.
I don't understand what you are talking about, do you have an example? As for the filter, it can't hurt to add functionality to liquid :) I can do that in a second time.
"Should we ensure there is a way to avoid a 0 when that is the index?"
Say there are 10 pages.
{{ num + 1 }}
, it can't hurt to add functionality to liquid :) I can do that in a second time.
FYI I kept the liquid parser we use for permalinks barebones with the idea that we would add features as needed. It felt weird to have things like for
for doing permalinks.
On the user point of view, I think 1-index is more natural. It's what I've coded.
for the trailing number, I let the user do it using {{ paginator.page }} / {{ paginator.total_pages }}
permalink_attributes
would not move over.
How do I call it to interpret parent
then, as it's not pub
?
Feature to paginate a collection of documents so we can avoid a landing page which is thousands of kilometer long :p
Requirements
Initial
Index pages should be able to index by
Index pages should be able to sort by multiple factors at once:
Index page behavior
collections.<name>.pages
Index page permalinks
0
when that is the index?nil
? Like day variables when indexing by month.index=0
Potential
Narrowing and nesting
Unplanned
Index pages should be able to index by
parent::child
)?Proposal
Activation
This feature is activated in the frontmatter.
Default values and use shortcut
include
to activate indexing:Also, we can make the schema auto-adapt
pagination: true
maps topagination: All
pagination: categories
pagination: categories, tags
User-defined defaults can be set in
_cobalt.yml
by filling in thedefault
,pages.default
, orposts.default
pagination
field, just leavinginclude
asNone
to avoid activating it for all pages.Permalink
This permalink attribute is not to be confused with the one outside
pagination
section. It defines the location of the generated indexes.New permalink attributes specific to this context
include
: a built-in representation of the paginated conceptnum
: the index numberPaginator
Pagination would be accessible through a
paginator
object (total ripoff from jekyll's pagination v2):Once activated, a
paginator
object replacecollection
object in liquid template.Tags
Moved to RFC https://github.com/cobalt-org/cobalt.rs/issues/549
Publication Date
Open Question
["%Y', "%m"]
would have year/month hierarchical indexes)Prior Art
Jekyll
Deprecated method
https://jekyllrb.com/docs/pagination/
Activation in
_config.yml
:Quoting the page:
Pagination V2
https://github.com/sverrirs/jekyll-paginate-v2/
Advanced sorting:
pagination trails:
Gutenberg
Paginator object: https://www.getgutenberg.io/documentation/templates/pagination/
To activate pagination on a page: https://www.getgutenberg.io/documentation/content/section/
Tags and categories management: https://www.getgutenberg.io/documentation/content/tags-categories/
Hugo
https://gohugo.io/templates/pagination/
In configuration:
Activation in page:
or