def link_to_page(page, paginated_set, options = {}, html_options = {})
      page_parameter = peiji_san_option(:page_parameter, options)
      
      # Sinatra/Rails differentiator
      pageable_params = respond_to?(:controller) ? controller.params : self.params
      
      url_options = (page == 1 ? pageable_params.except(page_parameter) : pageable_params.merge(page_parameter => page))
      anchor = peiji_san_option(:anchor, options)
      url_options[:anchor] = anchor if anchor
      html_options[:class] = peiji_san_option(:current_class, options) if paginated_set.current_page?(page)
      
      # Again a little fork here
      normalized_url_options = if respond_to?(:controller) # Rails
        url_for(url_options)
      else # Sinatra
        root_path = env['PATH_INFO'].blank? ? "/" : env["PATH_INFO"]
        url_for(root_path, url_options)
      end
      
      link_to page, normalized_url_options, html_options
    end
def link_to_page(page, paginated_set, options = {}, html_options = {})
      page_parameter = peiji_san_option(:page_parameter, options)
      
      # Sinatra/Rails differentiator
      pageable_params = respond_to?(:controller) ? controller.params : self.params
      
      url_options = (page == 1 ? pageable_params.except(page_parameter) : pageable_params.merge(page_parameter => page))
      anchor = peiji_san_option(:anchor, options)
      url_options[:anchor] = anchor if anchor
      html_options[:class] = peiji_san_option(:current_class, options) if paginated_set.current_page?(page)
      
      # Again a little fork here
      normalized_url_options = if respond_to?(:controller) # Rails
        url_for(url_options)
      else # Sinatra
        root_path = env['PATH_INFO'].blank? ? "/" : env["PATH_INFO"]
        url_for(root_path, url_options)
      end
      
      link_to page, normalized_url_options, html_options
    end
Creates a link using +link_to+ for a page in a pagination collection. If
 the specified page is the current page then its class will be `current'.

 Options:
   [:page_parameter]
     The name of the GET parameter used to indicate the page to display.
     Defaults to <tt>:page</tt>.
   [:current_class]
     The CSS class name used when a page is the current page in a pagination
     collection. Defaults to <tt>:current</tt>.