nikola
nikola copied to clipboard
Support breaking pages/posts into multiple pages
It would be nice if posts could be broken into multiple parts.
For example, you could do something like insert a comment .. PAGE_BREAK
into a page, then nikola could create a second page, and automatically paginate between them.
The structure would result in something like:
/posts/my-post.html /posts/my-post-page-2.html
or
/posts/my-post/index.html /posts/my-post/page-2/index.html
This is a low priority suggestion, but would be very handy for me. My pages tend to be in the 20k words range.
If client-side pagination is good enough, you can use something like http://flaviusmatis.github.io/simplePagination.js/ and make it paginate over sections, which have a nice and handy div around them.
I think that may be a better idea.
If this is implemented in Nikola, it would be good if also a full version of the page/post is created. I hate server-side pagination when I notice there's a second page at the bottom of the page and my internet connection is gone... :)
Hi,
Is this feature still desired? If yes, I am interested in helping out with it or at least taking a shot at it.
@hilcharge Yes, it still is. Feel free to work on it, and to ask about any details you are unsure of.
Hi @Kwpolska and others,
Have taken a shot at pagination of a long post:
https://github.com/getnikola/nikola/pull/3418
It is just based on extra css/js in the template, not any parsing of rst etc
There are some questions raised in the pull request though, most pressing:
- To include by theme or some other way?
- How to parameterize the page-length - currently it is hard-coded at 10-paragraphs - was struggling to think of way to pass this value to the JS from template or elsewhere.
I think that an implementation of the pagination feature should:
- work and integrate with all themes (with small, single-line changes to templates), not require a special theme (we tried that for Jupyter, that means really bad UX),
- primarily be based on user markers, not a paragraph count (just like we do for teasers),
- not require JS to operate.
The implementation would operate with the same/similar structure as mentioned in the original issue, and would primarily be a change in how posts are rendered (probably in the render_pages task plugin, but the page URLs might also require changes to the Post class or other things).
Just to clarify about the point "not require JS to operate":
If I understand correctly, avoiding javascript is not compatible with client-side-only pagination. Rather, the target should be multiple individual html pages, as mentioned in OP?
Multiple HTML pages would be the best approach. I think I could accept a solution which is JS-based (but not jQuery-based, and without any third-party libraries), that would implement pagination by adding and removing display: none
to <div>
items, but if someone has JS disabled, they could see all pages. (The JS bit I am thinking of would be less than 50 LOC)