Sha256: 03e78cc423a6fa0f4f6a191acb3fb64dfeb5f68c644f30d9d46815f17af3124d

Contents?: true

Size: 1.42 KB

Versions: 36

Compression:

Stored size: 1.42 KB

Contents

class Refinery::LinkRenderer < WillPaginate::ViewHelpers::LinkRenderer

# TODO: Rewrite for WillPaginate 3 API

=begin

  attr_accessor :url

  def url_for(page)
    # extract any url parameter and store it for subsequent requests but delete it
    # this is so that we don't end up with it being an attribute of the resulting HTML.
    @url ||= @options.delete(:url) || {}
    page_one = page == 1
    @url_params = {}
    # page links should preserve GET parameters
    stringified_merge @url_params, @template.params if @template.request.get?
    stringified_merge @url_params, @options[:params] if @options[:params]

    if complex = param_name.index(/[^\w-]/)
      page_param = parse_query_parameters("#{param_name}=#{page}")

      stringified_merge @url_params, page_param
    else
      @url_params[param_name] = page_one ? 1 : 2
    end

    url = @template.url_for(@url_params.merge!(@url).to_options)
    return url if page_one

    if complex
      @url_string = url.sub(%r!((?:\?|&amp;)#{CGI.escape param_name}=)#{page}!, '\1@')
      return url
    else
      @url_string = url
      @url_params[param_name] = 3
      @template.url_for(@url_params).split(//).each_with_index do |char, i|
        if char == '3' and url[i, 1] == '2'
          @url_string[i] = '@'
          break
        end
      end
    end
    # finally!
    @url_string.sub '@', page.to_s
  end

private

  def param_name
    @options[:param_name].to_s
  end

=end

end

Version data entries

36 entries across 36 versions & 2 rubygems

Version Path
refinerycms-core-1.0.4 lib/refinery/link_renderer.rb
refinerycms-core-1.0.3 lib/refinery/link_renderer.rb
refinerycms-core-1.0.1 lib/refinery/link_renderer.rb
refinerycms-core-1.0.0 lib/refinery/link_renderer.rb
refinerycms-core-0.9.9.22 lib/refinery/link_renderer.rb
refinerycms-core-0.9.9.21 lib/refinery/link_renderer.rb
refinerycms-core-0.9.9.20 lib/refinery/link_renderer.rb
refinerycms-core-0.9.9.19 lib/refinery/link_renderer.rb
refinerycms-core-0.9.9.18 lib/refinery/link_renderer.rb
refinerycms-core-0.9.9.17 lib/refinery/link_renderer.rb
refinerycms-core-0.9.9.16 lib/refinery/link_renderer.rb
refinerycms-core-0.9.9.15 lib/refinery/link_renderer.rb
refinerycms-core-0.9.9.14 lib/refinery/link_renderer.rb
refinerycms-core-0.9.9.13 lib/refinery/link_renderer.rb
refinerycms-core-0.9.9.12 lib/refinery/link_renderer.rb
refinerycms-core-0.9.9.11 lib/refinery/link_renderer.rb
refinerycms-core-0.9.9.10 lib/refinery/link_renderer.rb
refinerycms-core-0.9.9.9 lib/refinery/link_renderer.rb
refinerycms-core-0.9.9.8 lib/refinery/link_renderer.rb
refinerycms-core-0.9.9.7 lib/refinery/link_renderer.rb