Skip to content

Instantly share code, notes, and snippets.

View indolent-gnathostome's full-sized avatar

indolent-gnathostome

View GitHub Profile
@indolent-gnathostome
indolent-gnathostome / pagination.rb
Last active December 31, 2015 10:38
Independent, sortable pagination for ruhoh.rb (plugin)
module SortablePaginator
# provides helpful metrics for the paginator and mustache templates
def paginator_data
per_page = config["paginator"]["per_page"] rescue 5
paginator_sort = config["paginator"]["sort"] rescue 'desc'
current_page = master.page_data['current_page'].to_i
post_count = all.length
page_count = (post_count.to_f/per_page).ceil
if paginator_sort == 'asc'