#9 ✓resolved
jana4u

Cascading Stylesheets Compatibility with will_paginate

Reported by jana4u | October 15th, 2008 @ 01:21 PM

It would be fine to have same styles for both paginations. This would ease usage of both plugins/gems together in one application.

will_paginate is wide spread and already has nice built-in pagination styles. To make theese styles accessible for Searchgasm, it would require only small changes in classes added to pagination anchors and spans.

Maybe it could be new option in configuration - something like this:

Searchgasm::Config.configure do |config|
  config.will_paginate_compatiblity = true
end

Or all classes could be parametrized - that would be much more flexible.

Comments and changes to this ticket

  • Ben Johnson

    Ben Johnson October 15th, 2008 @ 01:25 PM

    • State changed from “new” to “open”

    I have not used will_paginate extensively, but making this change should be pretty simple. If you can outline the changes for me, I'll get it implemented. That is, what are the class names for will_paginate.

  • jana4u

    jana4u October 15th, 2008 @ 02:30 PM

    <%= will_paginate @customers %>

    produces:

    <div class="pagination">
      <span class="disabled prev_page">&laquo; Previous</span>
      <span class="current">1</span>
      <a href="/customers?page=2" rel="next">2</a>
      <a href="/customers?page=2" class="next_page" rel="next">Next &raquo;</a>
    </div>
    
    

    class names: * disabled * current * prev_page * next_page

    Additional helper that would wrap current pagination in

    would be fine too. I have already created one for myself:
    def pagination_links(options = {})
      links = page_links(options)
      if links
        "<div class=\"pagination\">#{links}</div>"
      else
        nil
      end
    end
    
    
  • jana4u

    jana4u October 15th, 2008 @ 02:38 PM

    final part again and hopefully well formatted

    class names:

    • disabled
    • current
    • prev_page
    • next_page

    Additional helper that would wrap current pagination in

    <div class="pagination"></div>
    
    

    would be fine too. I have already created one for myself:

    def pagination_links(options = {})
      links = page_links(options)
      if links
        "<div class=\"pagination\">#{links}</div>"
      else
        nil
      end
    end
    
    
  • Ben Johnson

    Ben Johnson October 15th, 2008 @ 02:52 PM

    Cool, this should be easy enough. I'll have it added soon.

  • Ben Johnson

    Ben Johnson October 16th, 2008 @ 04:12 PM

    Just to update, I am on vacation and will return on Monday. I plan to have this implemented by then. Sorry for the delay.

  • Georg Ledermann

    Georg Ledermann October 16th, 2008 @ 04:20 PM

    Have a good rest, your work on Searchgasm is most appreciated!

  • jana4u

    jana4u October 18th, 2008 @ 06:07 PM

    Enjoy your vacation - I have already made some other fixes myself ;-)

  • Ben Johnson

    Ben Johnson October 20th, 2008 @ 09:51 PM

    • State changed from “open” to “resolved”

    This is all set. I had to change configuration a little bit, it was getting out of hand and since I am anal I wanted it to be organized. Since it breaks backwards compatibility I increased the version. But you can do this now:

    Searchgasm::Config.configure do |config|
      config.helpers.page_links_first_page_class_name = "first_page"
      config.helpers.page_links_last_page_class_name = "last_page"
      config.helpers.page_links_next_page_class_name = "next_page"
      config.helpers.page_links_prev_page_class_name = "prev_page"
      config.helpers.page_links_prev_page_class_name = "current_page"
      config.helpers.page_links_prev_page_class_name = "disabled_page"
    end
    

    Check out the doc for more info. But you can change any class name you want now. I also modified how some other options work as well. Let me know if you have any problems.

  • Ben Johnson

    Ben Johnson November 17th, 2008 @ 04:33 PM

    Thought Id update this. I added:

    config.helpers.page_links_act_like_will_paginate = true

    Hopefully this makes switching from will_paginate easier.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Provides common named scopes and object based searching.

People watching this ticket

Tags

Pages