def manageable_pagination(options = {})
      current_page = options[:current_page] || 1
      num_pages    = options[:num_pages] || 1
      outer_window = options[:outer_window] || 4
      page_param   = options[:param_name] || :page

      if current_page <= num_pages
        previous_page = current_page - 1
        next_page     = current_page + 1
        left_window   = ((current_page - outer_window)...current_page).to_a.select{|i| i > 0}
        right_window  = ((current_page + 1)..(current_page + outer_window)).to_a.select{|i| i <= num_pages}

        elements = []

        if 1 != current_page
          # First
          elements <<  {:value => t("manageable.pagination.first"), :href => params.merge(page_param => 1)}

          # Previous
          elements <<  {:value => t("manageable.pagination.previous"), :href => params.merge(page_param => previous_page)}
        end

        # Left Gap
        if left_window.first && left_window.first != 1
          elements <<  {:value => t("manageable.pagination.gap")}
        end

        # Left window
        left_window.each do |i|
          elements <<  {:value => i, :href => params.merge(page_param => i)}
        end

        # Current Page
        elements <<  {:value => current_page, :html => {:class => "current"}}

        # Right window
        right_window.each do |i|
          elements <<  {:value => i, :href => params.merge(page_param => i)}
        end

        # Right Gap
        if right_window.last && right_window.last != num_pages
          elements <<  {:value => t("manageable.pagination.gap")}
        end

        if num_pages != current_page
          # Next
          elements <<  {:value => t("manageable.pagination.next"), :href => params.merge(page_param => next_page)}

          # Last
          elements <<  {:value => t("manageable.pagination.last"), :href => params.merge(page_param => num_pages)}
        end

        content_tag :div, :class => "pagination" do
          elements.map do |options|
            if options[:href]
              link_to options[:value], options[:href]
            else
              content_tag(:span, options[:value], options[:html])
            end
          end.join.html_safe
        end
      end
    end
def manageable_pagination(options = {})
      current_page = options[:current_page] || 1
      num_pages    = options[:num_pages] || 1
      outer_window = options[:outer_window] || 4
      page_param   = options[:param_name] || :page

      if current_page <= num_pages
        previous_page = current_page - 1
        next_page     = current_page + 1
        left_window   = ((current_page - outer_window)...current_page).to_a.select{|i| i > 0}
        right_window  = ((current_page + 1)..(current_page + outer_window)).to_a.select{|i| i <= num_pages}

        elements = []

        if 1 != current_page
          # First
          elements <<  {:value => t("manageable.pagination.first"), :href => params.merge(page_param => 1)}

          # Previous
          elements <<  {:value => t("manageable.pagination.previous"), :href => params.merge(page_param => previous_page)}
        end

        # Left Gap
        if left_window.first && left_window.first != 1
          elements <<  {:value => t("manageable.pagination.gap")}
        end

        # Left window
        left_window.each do |i|
          elements <<  {:value => i, :href => params.merge(page_param => i)}
        end

        # Current Page
        elements <<  {:value => current_page, :html => {:class => "current"}}

        # Right window
        right_window.each do |i|
          elements <<  {:value => i, :href => params.merge(page_param => i)}
        end

        # Right Gap
        if right_window.last && right_window.last != num_pages
          elements <<  {:value => t("manageable.pagination.gap")}
        end

        if num_pages != current_page
          # Next
          elements <<  {:value => t("manageable.pagination.next"), :href => params.merge(page_param => next_page)}

          # Last
          elements <<  {:value => t("manageable.pagination.last"), :href => params.merge(page_param => num_pages)}
        end

        content_tag :div, :class => "pagination" do
          elements.map do |options|
            if options[:href]
              link_to options[:value], options[:href]
            else
              content_tag(:span, options[:value], options[:html])
            end
          end.join.html_safe
        end
      end
    end
Prints a pagination block. Accepts the following options:

 *current_page*
 *num_pages*
 *param_name*