public
Rubygem
Description: Most awesome pagination solution for Ruby
Homepage: http://github.com/mislav/will_paginate/wikis
Clone URL: git://github.com/mislav/will_paginate.git
rename LinkRenderer#url_params to #url_for and drastically optimize it
mislav (author)
Sun Apr 06 19:40:53 -0700 2008
commit  f48248f8900a94a50325c6330b12f161c1ed064f
tree    38d9d037500c885161e9b79b801551b0469e8f87
parent  9afc5e83dc2e6cd0ce49b184a50ba6858524e474
...
245
246
247
248
 
249
250
251
...
253
254
255
256
257
258
 
 
 
259
260
261
262
263
264
265
266
 
 
267
268
269
 
 
 
270
271
272
273
274
275
276
 
 
277
 
 
 
 
278
279
280
 
281
282
283
...
245
246
247
 
248
249
250
251
...
253
254
255
 
 
 
256
257
258
259
260
261
262
263
 
 
 
264
265
266
 
 
267
268
269
270
271
 
 
 
 
 
272
273
274
275
276
277
278
279
 
 
280
281
282
283
0
@@ -245,7 +245,7 @@ module WillPaginate
0
       classnames = Array[*span_class]
0
       
0
       if page and page != current_page
0
- @template.link_to text, url_params(page), :rel => rel_value(page), :class => classnames[1]
0
+ @template.link_to text, url_for(page), :rel => rel_value(page), :class => classnames[1]
0
       else
0
         @template.content_tag :span, text, :class => classnames.join(' ')
0
       end
0
@@ -253,31 +253,31 @@ module WillPaginate
0
 
0
     # Returns URL params for +page_link_or_span+, taking the current GET params
0
     # and <tt>:params</tt> option into account.
0
- def url_params(page)
0
- unless @url_params
0
- @url_params = @param_hash = { }
0
+ def url_for(page)
0
+ unless @url_string
0
+ @url_params = { :escape => false }
0
         # page links should preserve GET parameters
0
         stringified_merge @url_params, @template.params if @template.request.get?
0
         stringified_merge @url_params, @options[:params] if @options[:params]
0
         
0
         if param_name.index(/[^\w-]/)
0
- page_param = if defined? CGIMethods
0
- # Rails 1.2
0
- CGIMethods.parse_query_parameters(param_name)
0
+ page_param = unless defined? CGIMethods
0
+ ActionController::AbstractRequest
0
           else
0
- ActionController::AbstractRequest.parse_query_parameters(param_name)
0
- end
0
+ # Rails 1.2
0
+ CGIMethods
0
+ end.parse_query_parameters("#{param_name}=#{page}")
0
           
0
           stringified_merge @url_params, page_param
0
-
0
- until page_param[@param_name = page_param.keys.first].nil?
0
- @param_hash = @param_hash[@param_name]
0
- page_param = page_param[@param_name]
0
- end
0
+ else
0
+ @url_params[param_name] = page
0
         end
0
+
0
+ url = @template.url_for(@url_params)
0
+ @url_string = url.sub(/([?&]#{CGI.escape param_name}=)#{page}/, '\1@')
0
+ return url
0
       end
0
- @param_hash[param_name] = page
0
- @url_params
0
+ @url_string.sub '@', page.to_s
0
     end
0
 
0
   private

Comments

    No one has commented yet.