Permalink
Browse files

modify the plugin to use (and require) will_paginate

  • Loading branch information...
1 parent 712d5ef commit dc223837ff05daafc77651a077ca45713642acde @defunkt committed Jan 13, 2008
Showing with 28 additions and 18 deletions.
  1. +2 −1 init.rb
  2. +3 −3 lib/logged_exceptions_controller.rb
  3. +18 −9 lib/logged_exceptions_helper.rb
  4. +5 −5 views/logged_exceptions/_exceptions.rhtml
View
@@ -1 +1,2 @@
-LoggedExceptionsController.view_paths = [File.join(directory, 'views')]
+WillPaginate.enable
+LoggedExceptionsController.view_paths = [File.join(directory, 'views')]
@@ -31,8 +31,8 @@ def query
conditions << 'controller_name = ? AND action_name = ?'
parameters += params[:controller_actions_filter].split('/').collect(&:downcase)
end
- @exception_pages, @exceptions = paginate :logged_exceptions, :order => 'created_at desc', :per_page => 30,
- :conditions => conditions.empty? ? nil : parameters.unshift(conditions * ' and ')
+ @exceptions = LoggedException.paginate :order => 'created_at desc', :per_page => 30,
+ :conditions => conditions.empty? ? nil : parameters.unshift(conditions * ' and '), :page => params[:page]
respond_to do |format|
format.html { redirect_to :action => 'index' unless action_name == 'index' }
@@ -68,4 +68,4 @@ def get_auth_data
auth_data = request.env[auth_key].to_s.split unless auth_key.blank?
return auth_data && auth_data[0] == 'Basic' ? Base64.decode64(auth_data[1]).split(':')[0..1] : [nil, nil]
end
-end
+end
@@ -3,13 +3,22 @@ def filtered?
[:query, :date_ranges_filter, :exception_names_filter, :controller_actions_filter].any? { |p| params[p] }
end
- def pagination_remote_links(paginator, options={}, html_options={})
- name = options[:name] || ActionController::Pagination::DEFAULT_OPTIONS[:name]
- params = (options[:params] || ActionController::Pagination::DEFAULT_OPTIONS[:params]).clone
-
- pagination_links_each(paginator, options) do |n|
- params[name] = n
- link_to_function n.to_s, "ExceptionLogger.setPage(#{n})"
- end
+ def pagination_remote_links(collection)
+ will_paginate collection,
+ :renderer => 'LoggedExceptionsHelper::PaginationRenderer',
+ :prev_label => '',
+ :next_label => '',
+ :container => false
end
-end
+
+ class PaginationRenderer < WillPaginate::LinkRenderer
+ def page_link_or_span(page, span_class = 'current', text = nil)
+ text ||= page.to_s
+ if page and page != current_page
+ @template.link_to_function text, "ExceptionLogger.setPage(#{page})"
+ else
+ @template.content_tag :span, text, :class => span_class
+ end
+ end
+ end
+end
@@ -1,8 +1,8 @@
<div id="exceptions">
<div class="pages">
<%= link_to_remote 'Delete Visible', :url => { :action => 'destroy_all' }, :with => "ExceptionLogger.deleteAll()" %>
-<% if @exception_pages.page_count > 1 %>
-:: Pages: <strong><%= pagination_remote_links @exception_pages, :params => { :action => :index } %></strong>
+<% if @exceptions.page_count > 1 %>
+:: Pages: <strong><%= pagination_remote_links @exceptions %></strong>
<% end %>
</div>
@@ -48,11 +48,11 @@ if Date.today == exc.created_at.to_date
</table>
-<% if @exception_pages.page_count > 1 %>
+<% if @exceptions.page_count > 1 %>
<div class="pages pages-bottom">
-Pages: <strong><%= pagination_remote_links @exception_pages, :params => { :action => :index } %></strong>
+Pages: <strong><%= pagination_remote_links @exceptions %></strong>
</div>
<% end %>
-</div> <!-- #exceptions -->
+</div> <!-- #exceptions -->

0 comments on commit dc22383

Please sign in to comment.