archive_tree 1.0.0.rc2 → 1.0.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -56,7 +56,9 @@ Post.archive_tree(:years_and_months => { 2010 => [1] }) #=> { 2010 => { 1 => [Po
|
|
56
56
|
|
57
57
|
### Views
|
58
58
|
|
59
|
-
|
59
|
+
<pre>
|
60
|
+
draw_archive_tree(:model_sym => :post, :route => :archive_published_at_path, :toggle => false)
|
61
|
+
</pre>
|
60
62
|
|
61
63
|
## Documentation
|
62
64
|
|
@@ -13,20 +13,27 @@ module ArchiveTree
|
|
13
13
|
#
|
14
14
|
# Default behavior
|
15
15
|
# * It will attempt to create a tree of your Post model
|
16
|
-
# * Will use the
|
16
|
+
# * Will use the posts_path route
|
17
17
|
# * Will display a toggle link
|
18
|
-
# * Will use "[ + ]" as the link
|
18
|
+
# * Will use "[ + ]" as the text for the toggle link
|
19
|
+
#
|
20
|
+
# Options
|
21
|
+
# * model_sym #=> the symbol of the model to request the archive_nodes
|
22
|
+
# * route #=> the route that handles the archived posts requests
|
23
|
+
# * toggle #=> when true, includes a toggle link before the years
|
24
|
+
# * toggle_text #=> the text used in the toggle link
|
19
25
|
#
|
20
26
|
# Example using the default settings:
|
21
27
|
# <%= draw_archive_tree %>
|
22
28
|
#
|
23
29
|
# Overriding the defaults example:
|
24
|
-
# <%= draw_archive_tree :
|
30
|
+
# <%= draw_archive_tree :model_sym => :post, :route => :archive_published_at_path, :toggle => false %>
|
25
31
|
|
26
|
-
def draw_archive_tree(
|
27
|
-
|
32
|
+
def draw_archive_tree(options = {})
|
33
|
+
options.reverse_merge!({ :model_sym => :post, :route => :posts_path, :toggle => true, :toggle_text => '[ + ]' })
|
34
|
+
model = options[:model_sym].to_s.capitalize.constantize
|
28
35
|
|
29
|
-
raw model.count > 0 ? draw_years(
|
36
|
+
raw model.count > 0 ? draw_years(model, options[:route], options[:toggle], options[:toggle_text]) : ''
|
30
37
|
end # draw_archive_tree
|
31
38
|
|
32
39
|
private
|
metadata
CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 1
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.0.
|
9
|
+
- rc3
|
10
|
+
version: 1.0.0.rc3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Diogo Almeida
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-11-
|
19
|
+
date: 2010-11-03 00:00:00 +00:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|