tj_bootstrap_helper 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +1 -1
- data/config/initializers/bootstrap_will_paginate.rb +30 -0
- data/lib/tj_bootstrap_helper/helper.rb +2 -2
- data/lib/tj_bootstrap_helper/version.rb +1 -1
- data/lib/tj_bootstrap_helper.rb +2 -0
- data/test/dummy/app/controllers/home_controller.rb +1 -1
- data/test/dummy/app/views/home/index.html.erb +3 -1
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/seeds.rb +1 -1
- data/test/dummy/log/development.log +4198 -0
- data/test/dummy/tmp/pids/server.pid +1 -0
- metadata +27 -3
data/README.rdoc
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
if defined?(WillPaginate)
|
2
|
+
module WillPaginate
|
3
|
+
module ActionView
|
4
|
+
def will_paginate(collection = nil, options = {})
|
5
|
+
options[:renderer] ||= BootstrapLinkRenderer
|
6
|
+
super(collection, options).try(:html_safe)
|
7
|
+
end
|
8
|
+
|
9
|
+
class BootstrapLinkRenderer < LinkRenderer
|
10
|
+
protected
|
11
|
+
|
12
|
+
def html_container(html)
|
13
|
+
tag :div, tag(:ul, html), container_attributes
|
14
|
+
end
|
15
|
+
|
16
|
+
def page_number(page)
|
17
|
+
tag :li, link(page, page, :rel => rel_value(page)), :class => ('active' if page == current_page)
|
18
|
+
end
|
19
|
+
|
20
|
+
def previous_or_next_page(page, text, classname)
|
21
|
+
tag :li, link(text, page || '#'), :class => [classname[0..3], classname, ('disabled' unless page)].join(' ')
|
22
|
+
end
|
23
|
+
|
24
|
+
def gap
|
25
|
+
tag :li, link(super, '#'), :class => 'disabled'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -22,7 +22,7 @@ module TJBootstrapHelper
|
|
22
22
|
# slice:: integer between 1..12. Items per slice (row).
|
23
23
|
# fluid:: boolean. Whether the div tag is fluid.
|
24
24
|
def spans resources, options = {}, &block
|
25
|
-
return unless resources.is_a?
|
25
|
+
return unless resources.is_a?(Array) || resources.is_a?(ActiveRecord::Relation)
|
26
26
|
options[:span] ||= 4
|
27
27
|
options[:slice] ||= 12/options[:span]
|
28
28
|
options[:fluid] ||= false
|
@@ -48,7 +48,7 @@ module TJBootstrapHelper
|
|
48
48
|
# slice:: integer between 1..12. Items per slice.
|
49
49
|
# url_method:: string or symbol. URL method of items, default is resources' RESTful URL.
|
50
50
|
def thumbs resources, image_url_method, options = {}, &block
|
51
|
-
return unless resources.is_a?
|
51
|
+
return unless resources.is_a?(Array) || resources.is_a?(ActiveRecord::Relation)
|
52
52
|
options[:span] ||= 4
|
53
53
|
options[:slice] ||= 12/options[:span]
|
54
54
|
ret = "".html_safe
|
data/lib/tj_bootstrap_helper.rb
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
<p><a class="btn btn-primary btn-large">Learn more »</a></p>
|
5
5
|
</div>
|
6
6
|
|
7
|
+
<%= will_paginate @posts %>
|
7
8
|
<%= spans %w(asfd qwer zxcv), fluid: true do |word| %>
|
8
9
|
<h2><%= word %></h2>
|
9
10
|
<p>content</p>
|
@@ -21,4 +22,5 @@
|
|
21
22
|
<h2><%= post.title %></h2>
|
22
23
|
<p><%= post.content %></p>
|
23
24
|
<p><a class="btn" href="#">View details »</a></p>
|
24
|
-
<% end %>
|
25
|
+
<% end %>
|
26
|
+
<%= will_paginate @posts %>
|
Binary file
|
data/test/dummy/db/seeds.rb
CHANGED