navGATE 0.1.10 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 25146f37e880338a8de76209b970042f016cc9ee
4
- data.tar.gz: 4ad974fcf24b99600ef3ac6a04abe0899950bf64
3
+ metadata.gz: 7f97d5aa0c38ee129c8473a6ea18ef3d06d62fac
4
+ data.tar.gz: 38edac708c417e5dbe26dca0b1477448f71df769
5
5
  SHA512:
6
- metadata.gz: 80997c648b789911fc3ffae818699ca4a9f570d9662feed4b63e5a119a00a8922c6f0962728c2029c069b28b79dd6d3c46c58281ddcc0904e66627bd8de9e466
7
- data.tar.gz: 5c8e90dc82ac470d078a05e456107ef2987485457bd7efcbb621821bde5ab56c6b0f869326f8ae6217303b46c5cfa5fa9896cd5f60f83e3bf791bac6f761c9ee
6
+ metadata.gz: 659282d0ae5e95f53f1ee5388647f52ade8fc0e75345c055de5fdb2b1de01a575a65a303137c1ea769c864947fb396bbfe307c600b853370591bdb918df98191
7
+ data.tar.gz: 64f1f896645de10eacda8b3eee3991391d71f9536c2c1d677ce7c1f4e1c241b7567b4cac7ab216de04bc2684d4fff072555c5c8c95fd52d36ab1bbfb1e80b4e0
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'rake'
3
3
  require 'echoe'
4
4
 
5
5
 
6
- Echoe.new('navGATE','0.1.10') do |p|
6
+ Echoe.new('navGATE','0.1.13') do |p|
7
7
  p.summary = "Allows the easy creation of navigation with config files"
8
8
  p.description = "Can create navigation from objects using the nav builder,from database tables or from a yaml file"
9
9
  p.url = "https://github.com/Thermatix/navGATE"
data/lib/navgate.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'navgate/base'
2
2
  require 'navgate/application_controller'
3
- require 'navgate/application_helper'
4
3
  class Navgate
5
4
  class Builder < Base
6
5
 
@@ -111,6 +110,7 @@ class Navgate
111
110
 
112
111
  def select params
113
112
  nav = select_nav(params[:controller])
113
+ raise ArgumentError, "params[:selection] is blank or nil" if !params[:selection] || params[:selection].blank?
114
114
  return params[:selection] ? params[:selection] : nav.default
115
115
  end
116
116
  private
@@ -4,7 +4,7 @@ class ApplicationController < ActionController::Base
4
4
  helper_method :render_navigation
5
5
  def make_menu
6
6
  @navgate = NAVGATE
7
- @selected ||= @navgate.select(params)
7
+ @selected ||= @navgate.select(params) if params[:selection]
8
8
  end
9
9
  def render_navigation options = nil
10
10
  @navgate.render_nav(params, options)
data/lib/readme.rdoc CHANGED
@@ -4,7 +4,7 @@ This gem is provided as is, please read through the initializer file "build_menu
4
4
 
5
5
  This gem was built with Rails in mind.
6
6
 
7
- note: this is my first gem, I am still trying to set it up, so be careful when downloading this.
7
+ note: this is my first gem.
8
8
 
9
9
  lastly the gem is up on rubygems.org
10
10
  ==Building the menus
@@ -58,7 +58,25 @@ Be sure to pass it as {model_name: :field}
58
58
  end
59
59
  ]
60
60
  end
61
+ ===Building multiple menus
61
62
 
63
+ NAVGATE = Navgate.new do |build|
64
+ build.navs = [
65
+ Navgate::Builder.new do |options|
66
+ options[:selection] = %w(selection site_settings users images misc)
67
+ options[:default] = 'users'
68
+ options[:namespace] = 'admin'
69
+ options[:controller] = 'admin_panel'
70
+ options[:css_class] = 'nav button'
71
+ end,
72
+ Navgate::Builder.new do |options|
73
+ options[:selection] = %w(welcome about_us gallery news)
74
+ options[:default] = 'news'
75
+ options[:controller] = 'front_page'
76
+ options[:css_class] = 'nav button'
77
+ end
78
+ ]
79
+ end
62
80
 
63
81
  === Using a yml file to build the menu
64
82
  There is also a third option to build the menu, you can use a structured yml file, there is an example yaml file in the config directory called "build_menu.yml".
@@ -99,5 +117,28 @@ Wrap: This allows you to wrap each link in a html tag, wrap can itself take two
99
117
  example:
100
118
  render_navigation({:class => "'nav button'", styling: :vertical, wrap: ['li','test']}) %>
101
119
 
102
- note: There is no point in passing a class here if you have one set when you first build the menu, it will just be overridden.
120
+ note: There is no point in passing a class here if you have one set when you first build the menu, it will just be overridden,
121
+ unless of course you're using multiple menus and some of them don't have css overides then they will take this option up.
122
+
123
+ ==Using the selection to automatically render a matching partial
124
+
125
+ naveGATE is set up so you can use it to render out a partial using <tt>@selected</tt>, to do this you have to pass a route param of <tt>:selection</tt>
126
+ in the route, then you can use <tt><%= render @selected %></tt> to automatically select either the default selection or the current selection.
127
+
128
+ That said you don't have use this feature, it will still route to whatever url you set up as a normal url, but <tt>@selected</tt> won't work without <tt>:selection</tt>
129
+ example:
103
130
 
131
+ routes.rb
132
+ get "/:selection", to: "front_page#index"
133
+ root to: "front_page#index"
134
+
135
+ front_page/index.html.erb
136
+ <%= render @selected %>
137
+
138
+ resulting url
139
+ host.com/books
140
+ host.com/games
141
+
142
+ routes to the root but the paritals rendered would be respectively
143
+ _books.html.erb
144
+ _games.html.erb
data/navGATE.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "navGATE"
5
- s.version = "0.1.10"
5
+ s.version = "0.1.13"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Martin Becker"]
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.extra_rdoc_files = ["lib/navgate.rb", "lib/navgate/application_controller.rb", "lib/navgate/base.rb", "lib/readme.rdoc"]
13
13
  s.files = ["Manifest", "Rakefile", "config/build_menu.yml", "config/initializers/build_menu.rb", "init.rb", "lib/navgate.rb", "lib/navgate/application_controller.rb", "lib/navgate/base.rb", "lib/readme.rdoc", "navGATE.gemspec"]
14
14
  s.homepage = "https://github.com/Thermatix/navGATE"
15
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "navGATE"]
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "navGATE", "--main", "readme.rdoc"]
16
16
  s.require_paths = ["lib"]
17
17
  s.rubyforge_project = "navgate"
18
18
  s.rubygems_version = "2.0.6"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: navGATE
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Becker
@@ -40,6 +40,8 @@ rdoc_options:
40
40
  - --inline-source
41
41
  - --title
42
42
  - navGATE
43
+ - --main
44
+ - readme.rdoc
43
45
  require_paths:
44
46
  - lib
45
47
  required_ruby_version: !ruby/object:Gem::Requirement