nikola icon indicating copy to clipboard operation
nikola copied to clipboard

Support breaking pages/posts into multiple pages

Open tritium21 opened this issue 8 years ago • 9 comments

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.

tritium21 avatar Feb 21 '16 03:02 tritium21

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.

ralsina avatar Mar 09 '16 15:03 ralsina

I think that may be a better idea.

tritium21 avatar Mar 09 '16 21:03 tritium21

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

felixfontein avatar Oct 15 '16 11:10 felixfontein

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 avatar Jan 15 '20 10:01 hilcharge

@hilcharge Yes, it still is. Feel free to work on it, and to ask about any details you are unsure of.

Kwpolska avatar Jan 15 '20 11:01 Kwpolska

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.

hilcharge avatar Jun 03 '20 14:06 hilcharge

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

Kwpolska avatar Jun 04 '20 22:06 Kwpolska

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?

hilcharge avatar Sep 23 '20 11:09 hilcharge

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)

Kwpolska avatar Sep 23 '20 11:09 Kwpolska