Report abuse


			
Index: lib/will_paginate.rb
===================================================================
--- lib/will_paginate.rb        (revision 120)
+++ lib/will_paginate.rb        (working copy)
@@ -1,43 +1,51 @@
 module WillPaginate
-  def will_paginate(total_count, per_page, page = @page)
-    adjacents = 2
-    prev_page = page - 1
-    next_page = page + 1
-    last_page = (total_count / per_page.to_f).ceil
-    lpm1      = last_page - 1
+  def will_paginate(total_count, per_page, page = @page, options = {})
+    total = (total_count / per_page.to_f).ceil

-    returning '' do |pgn|
-      if last_page > 1
-        pgn << %{'
+        list
       end
+      
+      prev,succ = page-1, page+1
+      links.unshift link_or_span(prev, prev.zero?, 'disabled', options.delete(:prev_label))
+      links.push link_or_span(succ, succ > total, 'disabled', options.delete(:next_label))
+      
+      content_tag :div, links.join(' '), options
+    else
+      nil
     end
   end
 end
Index: lib/finder.rb
===================================================================
--- lib/finder.rb       (revision 120)
+++ lib/finder.rb       (working copy)
@@ -7,23 +7,22 @@
         define_method(:per_page) { 30 } unless respond_to? :per_page
       end
     end
-
+    
     module ClassMethods
-      def method_missing_with_will_paginate(method_id, *args, &block)
-        unless match = /^paginate/.match(method_id.to_s)
-          return method_missing_without_will_paginate(method_id, *args, &block) 
+      def method_missing_with_will_paginate(method, *args, &block)
+        unless match = /^paginate/.match(method.to_s)
+          return method_missing_without_will_paginate(method, *args, &block) 
         end
-
-        options = args.last.is_a?(Hash) ? args.pop : {}
-        page    = options[:page].to_i.zero? ? 1 : options[:page].to_i
-        options.delete(:page)
-        limit_per_page = options[:per_page] || per_page
-        options.delete(:per_page)
-        args << options
-
-        with_scope :find => { :offset => (page - 1) * limit_per_page, :limit => limit_per_page } do
-          [send(method_id.to_s.sub(/^paginate/, 'find'), *args), page]
+        
+        if (options = args.last).is_a? Hash
+          page = options[:page].to_i.zero? ? 1 : options[:page].to_i
+          options.delete(:page)
+          entries_per_page = options.delete(:per_page) || per_page
         end
+        
+        with_scope :find => { :offset => (page - 1) * limit_per_page, :limit => entries_per_page } do
+          [send(method.to_s.sub(/^paginate/, 'find'), *args), page]
+        end
       end
     end
   end