Skip to content

Instantly share code, notes, and snippets.

@heavysixer
Created September 3, 2009 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save heavysixer/180328 to your computer and use it in GitHub Desktop.
Save heavysixer/180328 to your computer and use it in GitHub Desktop.
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] = "&#9668; prev"
@options[:next_label] = "next &#9658;"
@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