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
Click here to lend your support to: will_paginate and make a donation at www.pledgie.com !
rename :prev_label to :previous_label for consistency. old name still functions 
but is deprecated
Mislav Marohnić (author)
Wed Aug 13 04:37:55 -0700 2008
commit  9a93720c9f27c763ed58ec3a4d3a2e6b1a02379f
tree    909be9dac2f0ed287ac218bb7b33955e1a139621
parent  7a3b81b10724f4798aef93eecd45ed045366209d
...
14
15
16
17
 
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 
 
 
 
 
 
 
 
 
 
 
35
36
37
...
41
42
43
44
 
45
46
47
...
92
93
94
 
 
 
 
95
96
97
...
214
215
216
217
 
218
219
220
...
14
15
16
 
17
18
19
20
21
22
23
 
 
 
 
 
 
 
 
 
 
 
24
25
26
27
28
29
30
31
32
33
34
35
36
37
...
41
42
43
 
44
45
46
47
...
92
93
94
95
96
97
98
99
100
101
...
218
219
220
 
221
222
223
224
0
@@ -14,24 +14,24 @@ module WillPaginate
0
   # WillPaginate::ViewHelpers.pagination_options hash. You can write to this hash to
0
   # override default options on the global level:
0
   #
0
-  #   WillPaginate::ViewHelpers.pagination_options[:prev_label] = 'Previous page'
0
+  #   WillPaginate::ViewHelpers.pagination_options[:previous_label] = 'Previous page'
0
   #
0
   # By putting this into your environment.rb you can easily translate link texts to previous
0
   # and next pages, as well as override some other defaults to your liking.
0
   module ViewHelpers
0
     # default options that can be overridden on the global level
0
     @@pagination_options = {
0
-      :class        => 'pagination',
0
-      :prev_label   => '« Previous',
0
-      :next_label   => 'Next »',
0
-      :inner_window => 4, # links around the current page
0
-      :outer_window => 1, # links around beginning and end
0
-      :separator    => ' ', # single space is friendly to spiders and non-graphic browsers
0
-      :param_name   => :page,
0
-      :params       => nil,
0
-      :renderer     => 'WillPaginate::LinkRenderer',
0
-      :page_links   => true,
0
-      :container    => true
0
+      :class          => 'pagination',
0
+      :previous_label => '« Previous',
0
+      :next_label     => 'Next »',
0
+      :inner_window   => 4, # links around the current page
0
+      :outer_window   => 1, # links around beginning and end
0
+      :separator      => ' ', # single space is friendly to spiders and non-graphic browsers
0
+      :param_name     => :page,
0
+      :params         => nil,
0
+      :renderer       => 'WillPaginate::LinkRenderer',
0
+      :page_links     => true,
0
+      :container      => true
0
     }
0
     mattr_reader :pagination_options
0
 
0
@@ -41,7 +41,7 @@ module WillPaginate
0
     # 
0
     # ==== Options
0
     # * <tt>:class</tt> -- CSS class name for the generated DIV (default: "pagination")
0
-    # * <tt>:prev_label</tt> -- default: "« Previous"
0
+    # * <tt>:previous_label</tt> -- default: "« Previous"
0
     # * <tt>:next_label</tt> -- default: "Next »"
0
     # * <tt>:inner_window</tt> -- how many links are shown around the current page (default: 4)
0
     # * <tt>:outer_window</tt> -- how many links are around the first and the last page (default: 1)
0
@@ -92,6 +92,10 @@ module WillPaginate
0
       return nil unless WillPaginate::ViewHelpers.total_pages_for_collection(collection) > 1
0
       
0
       options = options.symbolize_keys.reverse_merge WillPaginate::ViewHelpers.pagination_options
0
+      if options[:prev_label]
0
+        WillPaginate::Deprecation::warn(":prev_label view parameter is now :previous_label; the old name has been deprecated.")
0
+        options[:previous_label] = options.delete(:prev_label)
0
+      end
0
       
0
       # get the renderer instance
0
       renderer = case options[:renderer]
0
@@ -214,7 +218,7 @@ module WillPaginate
0
     def to_html
0
       links = @options[:page_links] ? windowed_links : []
0
       # previous/next buttons
0
-      links.unshift page_link_or_span(@collection.previous_page, 'disabled prev_page', @options[:prev_label])
0
+      links.unshift page_link_or_span(@collection.previous_page, 'disabled prev_page', @options[:previous_label])
0
       links.push    page_link_or_span(@collection.next_page,     'disabled next_page', @options[:next_label])
0
       
0
       html = links.join(@options[:separator])
...
36
37
38
39
 
40
41
42
...
80
81
82
 
 
 
 
 
 
 
 
83
84
85
...
36
37
38
 
39
40
41
42
...
80
81
82
83
84
85
86
87
88
89
90
91
92
93
0
@@ -36,7 +36,7 @@ class ViewTest < WillPaginate::ViewTestCase
0
 
0
   def test_will_paginate_with_options
0
     paginate({ :page => 2 },
0
-             :class => 'will_paginate', :prev_label => 'Prev', :next_label => 'Next') do
0
+             :class => 'will_paginate', :previous_label => 'Prev', :next_label => 'Next') do
0
       assert_select 'a[href]', 4 do |elements|
0
         validate_page_numbers [1,1,3,3], elements
0
         # test rel attribute values:
0
@@ -80,6 +80,14 @@ class ViewTest < WillPaginate::ViewTestCase
0
       assert_select 'a.next_page[href]:last-child'
0
     end
0
   end
0
+  
0
+  def test_prev_label_deprecated
0
+    assert_deprecated ':previous_label' do
0
+      paginate({ :page => 2 }, :prev_label => 'Deprecated') do
0
+        assert_select 'a[href]:first-child', 'Deprecated'
0
+      end
0
+    end
0
+  end
0
 
0
   def test_full_output
0
     paginate

Comments