@@ -6,3 +6,32 @@ def gravatar_for(user, options = { size: 80})
6
6
image_tag ( gravatar_url , alt : user . username , class : "img-circle" )
7
7
end
8
8
end
9
+
10
+ module ApplicationHelper
11
+ def will_paginate ( collection_or_options = nil , options = { } )
12
+ if collection_or_options . is_a? Hash
13
+ options , collection_or_options = collection_or_options , nil
14
+ end
15
+ unless options [ :renderer ]
16
+ options = options . merge :renderer => BootstrapRenderer
17
+ end
18
+ super *[ collection_or_options , options ] . compact
19
+ end
20
+
21
+ class BootstrapRenderer < WillPaginate ::ActionView ::LinkRenderer
22
+ protected
23
+ def html_container ( html )
24
+ tag :nav , tag ( :ul , html , class : "pagination pagination-sm" ) , container_attributes
25
+ end
26
+
27
+ def page_number ( page )
28
+ tag :li , link ( page , page , rel : rel_value ( page ) , class : 'page-link' ) ,
29
+ class : ( page == current_page ? 'page-item active' : 'page-item' )
30
+ end
31
+
32
+ def previous_or_next_page ( page , text , classname )
33
+ tag :li , link ( text , page || '#' , class : 'page-link' ) ,
34
+ class : [ 'page-item' , classname , ( 'disabled' unless page ) ] . join ( ' ' )
35
+ end
36
+ end
37
+ end
0 commit comments