octopress / paginate

A simple paginator for Jekyll sites.
MIT License
105 stars 37 forks source link

(WIP) Jekyll3 Support #7

Closed imathis closed 8 years ago

imathis commented 9 years ago

Add support for native Jekyll hooks.

imathis commented 9 years ago

I've tracked down my problems to the fact that apparently my Jekyll::Page subclass doesn't trigger Jekyll hooks. You can find that subclass here

@parkr, have any ideas what I can do to get this joker to trigger the :pre_render page hook?

parkr commented 9 years ago

@imathis Thanks for working on this! I think the problem with the hooks is that we don't have one for :page, :post_render afaict. @envygeeks, is this intentional? What's the alternative?

paulrobertlloyd commented 9 years ago

Trying out this branch, as I’m also using Jekyll 3.0.beta (I like to live dangerously). Right now this plugin generates the right number of pages for a paginated template, but pages beyond the first don’t contain any posts. Does this issue relate to what I’m seeing?

For reference, here’s my template:

---
layout: index
title: Journal
paginate:
  permalink: :num/
  limit: false
  per_page: 12
  title_suffix: ''
---
{% for item in paginator.posts %}
    {% case item.layout %}
    {% when "post-link" %}
        {% include item/link.html %}
    {% when "post-album" %}
        {% include item/album.html %}
    {% else %}
        {% include item/entry.html %}
    {% endcase %}
{% endfor %}

(After porting my existing pagination over to this plugin, hoping to see how far it will allow me to paginate other collections, something that I’ve been hoping to see in jekyll-paginate for a while now. Secretly hoping it will allow me to paginate tag pages, too!)

envygeeks commented 9 years ago

@parkr @imathis this was originally intentional to make hooks easier, but I've been discussing with @stevecrozz making hooks more flexible so that hooks can be triggered with data without the need of it relating to a class, this way our ability to add hooks scales better.

stevecrozz commented 9 years ago

@parkr Why do you say we don't have a page post_render hook? There's a cheesy example here in the cucumber tests: https://github.com/jekyll/jekyll/blob/v3.0.0.pre.beta8/features/hooks.feature#L101-L111

envygeeks commented 9 years ago

@stevecrozz we do but @imathis hook isn't triggering because the #class doesn't match, whereas #is_a? would match because it tracks sub-classes.

envygeeks commented 9 years ago

I would personally like to see the reliance on classes removed in favor of triggering a point and a hook set so that things are more flexible to both plugins and us (re: the configuration hook problem we discussed a week ago.)

stevecrozz commented 9 years ago

Ah. He has a subclass of Page and not an instance of Page. Thanks @envygeeks.

I opened an issue with jekyll to track this: https://github.com/jekyll/jekyll/issues/3870 and I suppose we can discuss it over there.

mshick commented 8 years ago

This PR and the jekyll3 branch is working well for me on jekyll 3.0.1. Maybe there were incompatibilities in the pre-release versions that have been dealt with?

I'd imagine there are improvements that can be made to the codebase, but would love to have the released gem working with jekyll 3.

Edit: There is a small bug in the PR however -- posted the fix inline.

ChrisChinchilla commented 8 years ago

@imathis @mshick This plugin not working with Jekyll 3 is currently breaking my upgrade, not sure if this is helpful, but on build / serve I get this error repeatedly:

"Deprecation: Document#categories is now a key in the #data hash. Called by /usr/local/lib/ruby/gems/2.3.0/bundler/gems/paginate-f15799044ad6/lib/octopress-paginate.rb:147:in `block in collection'."

The site build and serves, but anything using pagination is blank.

Happy to help fix if someone can point me in the right direction, lack of proper and decent pagination in default Jekyll makes this plugin invaluable!

mshick commented 8 years ago

@ChrisChinchilla this plugin is broken in Jekyll 3. My fork fixes all warnings and problems, and is based upon an earlier patch made by @imathis. I'm not sure what the hold-up is getting out a proper fix...

You can use my fork by adding this to your Gemfile and bundle installing

gem "octopress-paginate", :git => "git://github.com/mshick/paginate", :branch => "jekyll3"

ChrisChinchilla commented 8 years ago

@mshick Thanks! I was using the jekyll3 branch of this repo. I can confirm yours does fix everything. Awesome!

timwis commented 8 years ago

Hey guys, what's going on with this PR? Looks like octopress-paginate doesn't work with Jekyll 3 still. Should I use the fork mentioned above? Has anyone submitted a PR from the fork to this repo?

mshick commented 8 years ago

@timwis If you follow this convo you'll see there are some code style issues holding this up. It's a major rewrite, so I think the maintainer needs to set it off. Until then I can say my fork works quite well.

lorenzschmid commented 8 years ago

@mshick your fork works great, thank you! Why not merge the PR?

mkava commented 8 years ago

@mshick Solid changes with your fork mate. No more deprecation messages is quite appreciated!

parkr commented 8 years ago

@mshick If you submit your fork for a PR, I can work out a release for this.