Created
September 3, 2009 14:27
-
-
Save heavysixer/180328 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FacebookPaginator < WillPaginate::LinkRenderer | |
include WillPaginate::ViewHelpers | |
def stringified_merge(target, other) | |
other.each do |key, value| | |
key = key.to_s # this line is what it's all about! | |
next if "fb_sig_friends" == key | |
existing = target[key] | |
if value.is_a?(Hash) and (existing.is_a?(Hash) or existing.nil?) | |
stringified_merge(existing || (target[key] = {}), value) | |
else | |
target[key] = value | |
end | |
end | |
end | |
def to_html | |
@options[:previous_label] = "◄ prev" | |
@options[:next_label] = "next ►" | |
@options[:separator] = " | " | |
@options[:container] = false | |
@options[:page_entries_info] ||= false | |
links = [] | |
# previous/next buttons | |
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]) | |
html = @options[:container] ? @template.content_tag(:div, html, html_attributes) : html | |
@template.content_tag(:span, :class => 'pagination') do | |
if @options[:page_entries_info] == true | |
@template.content_tag(:span, page_entries_info(@collection, :entry_name => @options[:entry_name] || nil), :class => 'page_entries_info') + html | |
else | |
html | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment