menumatic 0.1.3 → 0.1.4

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.md CHANGED
@@ -85,7 +85,7 @@ helper:
85
85
  <!-- snip -->
86
86
  <header>
87
87
  <nav>
88
- <%= navigation :application %>
88
+ <%= navigation :navigation => 'application' %>
89
89
  </nav>
90
90
  </header>
91
91
 
@@ -103,17 +103,19 @@ easily achiveable:
103
103
  <!-- snip -->
104
104
  <header>
105
105
  <nav>
106
- <%= navigation :application, :level => :primary %>
106
+ <%= render :navigation => 'application', :level => :primary %>
107
107
  </nav>
108
108
  </header>
109
109
 
110
110
  <div class="sub_navigation">
111
- <%= navigation :application, :levels => [:secondary, :tertiary] %>
111
+ <%= render :navigation => application, :levels => [:secondary, :tertiary] %>
112
112
  </div>
113
113
 
114
114
  The above example would render the top-level navigation in the
115
115
  `<header>` and everything else in the `sub_navigation` div below.
116
116
 
117
+ __Note:__ numbers are also acceptable parameters here, where 1 is the primary level.
118
+
117
119
 
118
120
  ## Sitemap generation
119
121
 
@@ -0,0 +1,7 @@
1
+ class Hash
2
+ # Behaves the same as [merge] but instead of replacing values, they are
3
+ # automatically joined using the separator parameter
4
+ def merge_with_join(other_hash, separator = " ")
5
+ self.merge(other_hash){ |key, value_1, value_2| [value_1, value_2].join(separator) }
6
+ end
7
+ end
@@ -9,7 +9,7 @@ module Menumatic
9
9
  options[:groups] ||= [options[:groups]].delete_if{ |g| g.blank? }
10
10
 
11
11
  options[:class] ||= ""
12
- options[:class] += "navigation #{navigation_id.to_s}"
12
+ options[:class] = (options[:class].split(" ") + ["navigation #{navigation_id.to_s}"]).join(" ")
13
13
 
14
14
  navigation = Menumatic::Navigation::Base.load_navigation(navigation_id.to_sym)
15
15
  navigation.root.render(request, options)
@@ -10,7 +10,11 @@ module Menumatic
10
10
 
11
11
  if args.length > 2
12
12
  options = args[2]
13
- self.active_paths = options[:active_on]
13
+
14
+ if options[:active_on]
15
+ self.active_paths = options[:active_on]
16
+ options.delete(:active_on)
17
+ end
14
18
  end
15
19
  self.active_paths ||= []
16
20
  end
@@ -9,7 +9,9 @@ module Menumatic
9
9
  options[:current_level] ||= 0
10
10
 
11
11
  html_options = {}
12
- html_options[:class] = options[:class]
12
+ html_options[:id] = options[:id] if options[:id]
13
+ html_options[:class] = options[:class] if options[:class]
14
+ options.delete(:id)
13
15
  options.delete(:class)
14
16
  options = options.merge({})
15
17
  options[:current_level] += 1
@@ -36,15 +38,15 @@ module Menumatic
36
38
 
37
39
  # render link
38
40
  link = ""
39
- link = link_to(self.label, self.destination).html_safe if self.is_link? && !options[:group]
41
+ link = link_to(self.label, self.destination, self.html_options).html_safe if self.is_link? && !options[:group]
40
42
 
41
43
  if on_valid_level?(options[:levels], options[:current_level])
42
44
  if options[:current_level] == 1 || (self.is_group? && options[:group] == self.group_id)
43
45
  list.html_safe
44
46
  elsif options[:show] == :all || self.is_active?(request)
45
- content_tag(options[:item_tag], link.to_s + list.to_s, html_options).to_s.html_safe
47
+ content_tag(options[:item_tag], link.to_s + list.to_s, html_options.merge_with_join(self.wrapper_options)).to_s.html_safe
46
48
  elsif self.is_link?
47
- content_tag(options[:item_tag], link, html_options).to_s.html_safe
49
+ content_tag(options[:item_tag], link, html_options.merge_with_join(self.wrapper_options)).to_s.html_safe
48
50
  end
49
51
  elsif self.is_active?(request)
50
52
  list.html_safe
@@ -2,13 +2,18 @@ module Menumatic
2
2
  module Navigation
3
3
  module Item
4
4
  class Base
5
- attr_accessor :items, :options
5
+ attr_accessor :items, :html_options, :wrapper_options
6
6
 
7
7
  include Menumatic::Navigation::Item::Renderers
8
8
  include Menumatic::Navigation::Item::Navigators
9
9
 
10
10
  def initialize(*args)
11
- self.options = args.last
11
+ self.html_options = {}
12
+ self.wrapper_options = {}
13
+ if(args.last.is_a?(Hash))
14
+ self.html_options = args.last[:link_html] || {}
15
+ self.wrapper_options = args.last[:wrapper_html] || {}
16
+ end
12
17
  self.items = []
13
18
  end
14
19
 
@@ -1,5 +1,9 @@
1
1
  module ActionView
2
2
  module Rendering
3
+
4
+ # Aliased function for standard rails render function. Adds an option
5
+ # for :navigation, which will render the selected navigation from the
6
+ # `app/navigation` directory.
3
7
  def render_with_navigation_option(options = {}, locals = {}, &block)
4
8
  if options.has_key? :navigation
5
9
  navigation_id = options[:navigation]
@@ -1,3 +1,3 @@
1
1
  module Menumatic
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
data/lib/menumatic.rb CHANGED
@@ -21,3 +21,4 @@ end
21
21
  require 'menumatic/rails/routes'
22
22
  require 'menumatic/rails/rendering'
23
23
  require 'menumatic/engine'
24
+ require 'menumatic/hash'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: menumatic
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Nicholas Bruning
@@ -49,6 +49,7 @@ files:
49
49
  - lib/menumatic.rb
50
50
  - lib/menumatic/.DS_Store
51
51
  - lib/menumatic/engine.rb
52
+ - lib/menumatic/hash.rb
52
53
  - lib/menumatic/helpers/navigation_helper.rb
53
54
  - lib/menumatic/navigation.rb
54
55
  - lib/menumatic/navigation/.DS_Store