simple-navigation-bootstrap 0.0.4 → 1.0.0
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/.gitignore +1 -0
- data/.ruby-gemset +1 -0
- data/README.md +69 -0
- data/lib/simple-navigation-bootstrap.rb +1 -0
- data/lib/simple-navigation-bootstrap/engine.rb +5 -0
- data/lib/simple-navigation-bootstrap/version.rb +1 -1
- data/lib/simple_navigation/rendering/renderer/bootstrap.rb +23 -10
- data/simple-navigation-bootstrap.gemspec +1 -1
- data/vendor/assets/stylesheets/bootstrap_navbar_split_dropdowns.css +6 -0
- metadata +26 -8
- data/README.rdoc +0 -45
data/.gitignore
CHANGED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
simple-navigation-bootstrap
|
data/README.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# Simple Navigation for Bootstrap
|
2
|
+
This gem adds a renderer for [Simple Navigation](http://github.com/andi/simple-navigation) to output markup compatible
|
3
|
+
with [Twitter Bootstrap](http://twitter.github.com/bootstrap/).
|
4
|
+
|
5
|
+
## Getting Started
|
6
|
+
For Rails >= 3, simply add this gem to your `Gemfile`:
|
7
|
+
```ruby
|
8
|
+
gem 'simple-navigation-bootstrap'
|
9
|
+
```
|
10
|
+
and run
|
11
|
+
```
|
12
|
+
bundle install
|
13
|
+
```
|
14
|
+
Follow the [configuration instructions](https://github.com/andi/simple-navigation/wiki/Configuration) on the Simple Navigation wiki for initial configuration.
|
15
|
+
|
16
|
+
To use the Bootstrap renderer, specify it in your view:
|
17
|
+
```ruby
|
18
|
+
render_navigation :expand_all => true, :renderer => :bootstrap
|
19
|
+
```
|
20
|
+
|
21
|
+
## Additional Functionality
|
22
|
+
In addition to generating Bootstrap-comptible list markup, you may specify
|
23
|
+
an `:icon` attribute on your navigation items, either as an array
|
24
|
+
or string, containing Bootstrap [icon classes](http://twitter.github.com/bootstrap/base-css.html#icons), to add an icon to the item.
|
25
|
+
|
26
|
+
For items with sub-navigation, you may specify `:split => true` to enable a
|
27
|
+
split dropdown. Split dropdowns allow using an url on the primary navigation
|
28
|
+
item, as well as having a dropdown containing sub-navigation. If you plan on
|
29
|
+
using this feature, in your `application.css` or equivalent you must require
|
30
|
+
the `bootstrap_navbar_split_dropdowns` stylesheet after requiring Bootstrap.
|
31
|
+
|
32
|
+
For example:
|
33
|
+
```css
|
34
|
+
/*
|
35
|
+
*= require bootstrap_and_overrides
|
36
|
+
*= require bootstrap_navbar_split_dropdowns
|
37
|
+
*/
|
38
|
+
```
|
39
|
+
|
40
|
+
## Examples
|
41
|
+
To create a navigation menu, you might do something like this:
|
42
|
+
```ruby
|
43
|
+
SimpleNavigation::Configuration.run do |navigation|
|
44
|
+
navigation.items do |primary|
|
45
|
+
primary.item :music, 'Music', musics_path
|
46
|
+
primary.item :dvds, 'Dvds', dvds_path, :split => true do |dvds|
|
47
|
+
dvds.item :action, 'Action', dvds_action_path
|
48
|
+
dvds.item :drama, 'Drama', dvds_drama_path
|
49
|
+
end
|
50
|
+
primary.item :books, 'Books', :icon => ['icon-book', 'icon-white'] do |books|
|
51
|
+
books.item :fiction, 'Fiction', books_fiction_path
|
52
|
+
books.item :history, 'History', books_history_path
|
53
|
+
end
|
54
|
+
primary.dom_class = 'nav'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
```
|
58
|
+
|
59
|
+
## Caveats
|
60
|
+
Requires Bootstrap version >= 2.1.0
|
61
|
+
|
62
|
+
## Further Reading
|
63
|
+
* [Twitter Bootstrap Documentation](http://twitter.github.com/bootstrap/)
|
64
|
+
* [Simple Navigation Wiki](https://github.com/andi/simple-navigation/wiki/)
|
65
|
+
|
66
|
+
## TODO
|
67
|
+
So far, only nav markup and dropdowns are supported, may also implement
|
68
|
+
buttons and nav lists in the future. And tests, there are currently no
|
69
|
+
tests.
|
@@ -6,11 +6,21 @@ module SimpleNavigation
|
|
6
6
|
SimpleNavigation.config.selected_class = 'active'
|
7
7
|
list_content = item_container.items.inject([]) do |list, item|
|
8
8
|
li_options = item.html_options.reject {|k, v| k == :link}
|
9
|
-
|
9
|
+
icon = li_options.delete(:icon)
|
10
|
+
split = (include_sub_navigation?(item) and li_options.delete(:split))
|
11
|
+
li_content = tag_for(item, item.name, icon, split)
|
10
12
|
if include_sub_navigation?(item)
|
11
|
-
|
13
|
+
if split
|
14
|
+
lio = li_options.dup
|
15
|
+
lio[:class] = [li_options[:class], 'dropdown-split-left'].flatten.compact.join(' ')
|
16
|
+
list << content_tag(:li, li_content, lio)
|
17
|
+
item.html_options[:link] = nil
|
18
|
+
li_options[:id] = nil
|
19
|
+
li_content = tag_for(item)
|
20
|
+
end
|
21
|
+
item.sub_navigation.dom_class = [item.sub_navigation.dom_class, 'dropdown-menu', split ? 'pull-right' : nil].flatten.compact.join(' ')
|
12
22
|
li_content << render_sub_navigation_for(item)
|
13
|
-
li_options[:class] = [li_options[:class], 'dropdown'].flatten.compact.join(' ')
|
23
|
+
li_options[:class] = [li_options[:class], 'dropdown', split ? 'dropdown-split-right' : nil].flatten.compact.join(' ')
|
14
24
|
end
|
15
25
|
list << content_tag(:li, li_content, li_options)
|
16
26
|
end.join
|
@@ -24,26 +34,29 @@ module SimpleNavigation
|
|
24
34
|
|
25
35
|
protected
|
26
36
|
|
27
|
-
def tag_for(item, icon = nil)
|
37
|
+
def tag_for(item, name = '', icon = nil, split = false)
|
28
38
|
unless item.url or include_sub_navigation?(item)
|
29
39
|
return item.name
|
30
40
|
end
|
31
41
|
url = item.url
|
32
42
|
link = Array.new
|
33
43
|
link << content_tag(:i, '', :class => [icon].flatten.compact.join(' ')) unless icon.nil?
|
34
|
-
link <<
|
44
|
+
link << name
|
35
45
|
if include_sub_navigation?(item)
|
36
|
-
url = '#'
|
37
46
|
item_options = item.html_options
|
38
47
|
item_options[:link] = Hash.new if item_options[:link].nil?
|
39
48
|
item_options[:link][:class] = Array.new if item_options[:link][:class].nil?
|
40
|
-
|
41
|
-
|
49
|
+
unless split
|
50
|
+
item_options[:link][:class] << 'dropdown-toggle'
|
51
|
+
item_options[:link][:'data-toggle'] = 'dropdown'
|
52
|
+
item_options[:link][:'data-target'] = '#'
|
53
|
+
link << content_tag(:b, '', :class => 'caret')
|
54
|
+
end
|
42
55
|
item.html_options = item_options
|
43
|
-
link << content_tag(:b, '', :class => 'caret')
|
44
56
|
end
|
45
|
-
link_to(link.join(" "), url, options_for(item))
|
57
|
+
link_to(link.join(" ").html_safe, url, options_for(item))
|
46
58
|
end
|
59
|
+
|
47
60
|
end
|
48
61
|
end
|
49
62
|
end
|
@@ -15,9 +15,9 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
17
|
s.require_paths = ["lib"]
|
18
|
-
s.extra_rdoc_files = ["README.rdoc"]
|
19
18
|
|
20
19
|
# specify any dependencies here; for example:
|
21
20
|
s.add_development_dependency "rake"
|
22
21
|
s.add_runtime_dependency "simple-navigation", ">= 3.7.0"
|
22
|
+
s.add_runtime_dependency "railties", ">= 3.1"
|
23
23
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple-navigation-bootstrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-06-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -43,23 +43,41 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: 3.7.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: railties
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.1'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.1'
|
46
62
|
description: simple-navigation-bootstrap is a simple-navigation renderer for twitter-bootstrap
|
47
63
|
navigation and dropdowns.
|
48
64
|
email:
|
49
65
|
- github@obfusc8.org
|
50
66
|
executables: []
|
51
67
|
extensions: []
|
52
|
-
extra_rdoc_files:
|
53
|
-
- README.rdoc
|
68
|
+
extra_rdoc_files: []
|
54
69
|
files:
|
55
70
|
- .gitignore
|
71
|
+
- .ruby-gemset
|
56
72
|
- Gemfile
|
57
|
-
- README.
|
73
|
+
- README.md
|
58
74
|
- Rakefile
|
59
75
|
- lib/simple-navigation-bootstrap.rb
|
76
|
+
- lib/simple-navigation-bootstrap/engine.rb
|
60
77
|
- lib/simple-navigation-bootstrap/version.rb
|
61
78
|
- lib/simple_navigation/rendering/renderer/bootstrap.rb
|
62
79
|
- simple-navigation-bootstrap.gemspec
|
80
|
+
- vendor/assets/stylesheets/bootstrap_navbar_split_dropdowns.css
|
63
81
|
homepage: https://github.com/pdf/simple-navigation-bootstrap
|
64
82
|
licenses: []
|
65
83
|
post_install_message:
|
@@ -74,7 +92,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
74
92
|
version: '0'
|
75
93
|
segments:
|
76
94
|
- 0
|
77
|
-
hash:
|
95
|
+
hash: 4218250063998013409
|
78
96
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
97
|
none: false
|
80
98
|
requirements:
|
@@ -83,10 +101,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
101
|
version: '0'
|
84
102
|
segments:
|
85
103
|
- 0
|
86
|
-
hash:
|
104
|
+
hash: 4218250063998013409
|
87
105
|
requirements: []
|
88
106
|
rubyforge_project:
|
89
|
-
rubygems_version: 1.8.
|
107
|
+
rubygems_version: 1.8.25
|
90
108
|
signing_key:
|
91
109
|
specification_version: 3
|
92
110
|
summary: simple-navigation-bootstrap is a simple-navigation renderer for twitter-bootstrap
|
data/README.rdoc
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
== Simple Navigation for Bootstrap
|
2
|
-
This gem adds a renderer for {Simple Navigation}[http://github.com/andi/simple-navigation] to output markup compatible
|
3
|
-
with {Twitter Bootstrap}[http://twitter.github.com/bootstrap/].
|
4
|
-
|
5
|
-
== Getting Started
|
6
|
-
For Rails >= 3, simply add this gem to your <tt>Gemfile</tt>:
|
7
|
-
gem 'simple-navigation-bootstrap'
|
8
|
-
and run
|
9
|
-
bundle install
|
10
|
-
Follow the {configuration instructions}[https://github.com/andi/simple-navigation/wiki/Configuration] on the Simple Navigation wiki for initial configuration.
|
11
|
-
|
12
|
-
To use the Bootstrap renderer, specify it in your view:
|
13
|
-
render_navigation :expand_all => true, :renderer => :bootstrap
|
14
|
-
|
15
|
-
== Additional Functionality
|
16
|
-
In addition to generating Bootstrap-comptible list markup, you may specify
|
17
|
-
an <tt>:icon</tt> attribute on your navigation items, either as an array
|
18
|
-
or string, containing Bootstrap {icon classes}[http://twitter.github.com/bootstrap/base-css.html#icons], to add an icon to the item.
|
19
|
-
|
20
|
-
== Examples
|
21
|
-
To create a navigation menu, you might do something like this:
|
22
|
-
SimpleNavigation::Configuration.run do |navigation|
|
23
|
-
navigation.items do |primary|
|
24
|
-
primary.item :music, 'Music', musics_path
|
25
|
-
primary.item :dvds, 'Dvds', dvds_path
|
26
|
-
primary.item :books, 'Books', :icon => ['icon-book', 'icon-white'] do |books|
|
27
|
-
books.item :fiction, 'Fiction', books_fiction_path
|
28
|
-
books.item :history, 'History', books_history_path
|
29
|
-
end
|
30
|
-
primary.dom_class = 'nav'
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
== Caveats
|
35
|
-
Because Bootstrap only supports dropdown on-click, items with sub-navigation
|
36
|
-
may not contain links - any links will be overwritten with a <tt>#</tt> anchor.
|
37
|
-
|
38
|
-
== Further Reading
|
39
|
-
* {Twitter Bootstrap Documentation}[http://twitter.github.com/bootstrap/]
|
40
|
-
* {Simple Navigation Wiki}[https://github.com/andi/simple-navigation/wiki/]
|
41
|
-
|
42
|
-
== TODO
|
43
|
-
So far, only nav markup and dropdowns are supported, may also implement
|
44
|
-
buttons and nav lists in the future. And tests, there are currently no
|
45
|
-
tests.
|