nanoc-toolbox 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,9 +1,13 @@
1
1
  # Changelog
2
2
 
3
3
  ## developement
4
- * NEW: add_section Filter
5
- * CHANGED: bugfix on navigation helper
6
4
 
5
+ ## Release 0.0.5
6
+ * CHANGED: add the ability to filter by an attributes of an item on navigation_for
7
+
8
+ ## Release 0.0.4
9
+ * NEW: add_section Filter
10
+ * CHANGED: bugfix on navigation helper
7
11
 
8
12
  ## Release 0.0.3
9
13
 
@@ -21,5 +25,4 @@
21
25
  * NEW: Add Yardoc
22
26
 
23
27
  ## Release 0.0.1
24
-
25
28
  * First Release
@@ -19,6 +19,7 @@ module Nanoc::Toolbox::Helpers
19
19
  # @param [String] identifier - the identifier string of the root element
20
20
  # @param [Hash] options - The Optional parameters
21
21
  # @option options (see #render_menu)
22
+ # @option options [String] :kind ('article') The kind of items to display in the menu
22
23
  #
23
24
  # @return [String] The output ready to be displayed by the caller
24
25
  def navigation_for(identifier, options={})
@@ -29,7 +30,7 @@ module Nanoc::Toolbox::Helpers
29
30
  return nil unless root.children
30
31
 
31
32
  # Find all sections, and render them
32
- sections = find_item_tree(root)
33
+ sections = find_item_tree(root, options)
33
34
  render_menu(sections, options)
34
35
  end
35
36
 
@@ -40,7 +41,8 @@ module Nanoc::Toolbox::Helpers
40
41
  # @param [String] item_rep - the representation of desired item
41
42
  # @param [Hash] options - The Optional parameters
42
43
  # @option options (see #render_menu)
43
- #
44
+ # @option options [String] :path ('div[@class="section"]') Generic XPath for the sections
45
+ #
44
46
  # @return [String] The output ready to be displayed by the caller
45
47
  #
46
48
  # @see http://nokogiri.org/
@@ -140,7 +142,7 @@ module Nanoc::Toolbox::Helpers
140
142
  options[:depth] += 1 # Increase the depth level after the call of navigation_for
141
143
  end
142
144
  output ||= ""
143
- content_tag(options[:item_tag], link_to(item[:title], item[:link]) + output)
145
+ content_tag(options[:item_tag], link_to_unless_current(item[:title], item[:link]) + output)
144
146
 
145
147
  end.join()
146
148
 
@@ -175,11 +177,14 @@ module Nanoc::Toolbox::Helpers
175
177
  # Recursive method that extract from an XPath pattern the document structure
176
178
  # and return the "permalinks" in a Array of Hash that could be used by the
177
179
  # rendering method
178
- def find_item_tree(root)
180
+ def find_item_tree(root, options={})
179
181
  return nil unless root.children
180
-
182
+
183
+ # filter the elements to contain only the kind requested
184
+ children = options[:kind] ? root.children.select { |item| item[:kind] == options[:kind] } : root.children
185
+
181
186
  # For each child call the find_item_tree on it and then generate the hash
182
- sections = root.children.map do |child|
187
+ sections = children.map do |child|
183
188
  subsections = find_item_tree(child)
184
189
 
185
190
  { :title => (child[:title] || child.identifier),
@@ -4,7 +4,7 @@ module Nanoc
4
4
  module Version
5
5
  MAJOR = 0
6
6
  MINOR = 0
7
- PATCH = 4
7
+ PATCH = 5
8
8
  BUILD = nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join(".")
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 4
9
- version: 0.0.4
8
+ - 5
9
+ version: 0.0.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Anouar ADLANI
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-17 00:00:00 +01:00
17
+ date: 2011-01-24 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency