Permalink
Browse files

Update Radiant::Pagination::LinkRenderer to work with will_paginate 3.x

  • Loading branch information...
jomz committed Feb 19, 2014
1 parent 4224df8 commit 22e625aadc80a606f6e0830762022b5d0afbd236
Showing with 4 additions and 20 deletions.
  1. +1 −0 app/models/standard_tags.rb
  2. +3 −20 lib/radiant/pagination/link_renderer.rb
@@ -4,6 +4,7 @@ module StandardTags
require "will_paginate/view_helpers"
include WillPaginate::ViewHelpers
+ require "radiant/pagination/link_renderer"
class TagError < StandardError; end
class RequiredAttributeError < StandardError; end
@@ -4,30 +4,13 @@
module Radiant
module Pagination
- class LinkRenderer < WillPaginate::LinkRenderer
+ class LinkRenderer < WillPaginate::ViewHelpers::LinkRenderer
def initialize(url_stem)
@url_stem = url_stem
end
-
- def to_html
- links = @options[:page_links] ? windowed_links : []
- links.unshift page_link_or_span(@collection.previous_page, 'disabled prev_page', @options[:previous_label])
- links.push page_link_or_span(@collection.next_page, 'disabled next_page', @options[:next_label])
- html = links.join(@options[:separator])
- @options[:container] ? %{<div class="pagination">#{html}</div>} : html
- end
- # this is rather crude compared to the WillPaginate link-builder,
- # but it can get by without much context to draw on
- def page_link(page, text, attributes = {})
- linkclass = %{ class="#{attributes[:class]}"} if attributes[:class]
- linkrel = %{ rel="#{attributes[:rel]}"} if attributes[:rel]
- param_name = WillPaginate::ViewHelpers.pagination_options[:param_name]
- %Q{<a href="#{@url_stem}?#{param_name}=#{page}"#{linkrel}#{linkclass}>#{text}</a>}
- end
-
- def page_span(page, text, attributes = {})
- %{<span class="#{attributes[:class]}">#{text}</span>}
+ def url(page)
+ "#{@url_stem}?#{param_name}=#{page}"
end
end
end

0 comments on commit 22e625a

Please sign in to comment.