rails_bootstrap_navbar 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -2
- data/CHANGELOG.md +1 -1
- data/Guardfile +9 -0
- data/README.md +12 -274
- data/lib/rails_bootstrap_navbar/railtie.rb +1 -1
- data/lib/rails_bootstrap_navbar/version.rb +1 -1
- data/rails_bootstrap_navbar.gemspec +3 -1
- data/spec/rails_bootstrap_navbar/railtie_spec.rb +10 -0
- metadata +24 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f3b0a4d55967ebe2514aea476dcf4d2b4da5bfb
|
4
|
+
data.tar.gz: 19adbf3681cecdc3faa524df379da4bbebdb1a8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7efeb135c758e3a74ce1002918cb2a8a94165a6764eb7a83fc45460d4dd26ce85cb311d702cd8f7392927a4718b1f6fa4d59e740258cfeab3637516ae1d33e9
|
7
|
+
data.tar.gz: dc364a4823c87eba3d550b839ea5afb2bedca23215cf5f4658886b9c75f542587511c8dce14d4c6fbd6cad165479d62d9c45f71813baf50096711fa75ab393a0
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Guardfile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
guard 'rspec', cli: '--drb --profile', all_after_pass: false do
|
2
|
+
# Specs
|
3
|
+
watch(%r(^spec/.+_spec\.rb$))
|
4
|
+
watch('spec/spec_helper.rb') { 'spec' }
|
5
|
+
watch(%r(^spec/support/(.+)\.rb$)) { 'spec' }
|
6
|
+
|
7
|
+
# Files
|
8
|
+
watch(%r(^lib/(.+)\.rb$)) { |m| "spec/#{m[1]}_spec.rb" }
|
9
|
+
end
|
data/README.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
-
#
|
1
|
+
# Rails Bootstrap Navbar
|
2
2
|
|
3
|
-
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/rails_bootstrap_navbar.png)](http://badge.fury.io/rb/Rails-Bootstrap-Navbar)
|
4
|
+
[![Build Status](https://secure.travis-ci.org/julescopeland/Rails-Bootstrap-Navbar.png)](http://travis-ci.org/julescopeland/Rails-Bootstrap-Navbar)
|
5
|
+
[![Dependency Status](https://gemnasium.com/julescopeland/Rails-Bootstrap-Navbar.png)](https://gemnasium.com/julescopeland/Rails-Bootstrap-Navbar)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/julescopeland/Rails-Bootstrap-Navbar.png)](https://codeclimate.com/github/julescopeland/Rails-Bootstrap-Navbar)
|
7
|
+
|
8
|
+
Easily generate a [Twitter Bootstrap navbar](http://twitter.github.io/bootstrap/components.html#navbar) in your Rails app
|
4
9
|
|
5
10
|
## Installation
|
6
11
|
|
@@ -8,9 +13,6 @@ Add this line to your application's Gemfile:
|
|
8
13
|
|
9
14
|
gem 'rails_bootstrap_navbar'
|
10
15
|
|
11
|
-
|
12
|
-
You need some form of Twitter bootstrap integration as well (I use Thomas McDonald's excellent [bootstrap-sass](https://github.com/thomas-mcdonald))
|
13
|
-
|
14
16
|
And then execute:
|
15
17
|
|
16
18
|
$ bundle
|
@@ -19,282 +21,18 @@ Or install it yourself as:
|
|
19
21
|
|
20
22
|
$ gem install rails_bootstrap_navbar
|
21
23
|
|
22
|
-
##
|
23
|
-
|
24
|
-
This gem aims to automate all of the features currently mentioned on the [twitter bootstrap docs re. the navbar](http://twitter.github.com/bootstrap/components.html#navbar).
|
25
|
-
|
26
|
-
It should let you write things like:
|
27
|
-
|
28
|
-
````
|
29
|
-
<%= nav_bar :fixed => :top, :brand => "Fashionable Clicheizr 2.0", :responsive => true do %>
|
30
|
-
<%= menu_group do %>
|
31
|
-
<%= menu_item "Home", root_path %>
|
32
|
-
<%= menu_divider %>
|
33
|
-
<%= drop_down "Products" do %>
|
34
|
-
<%= menu_item "Things you can't afford", expensive_products_path %>
|
35
|
-
<%= menu_item "Things that won't suit you anyway", harem_pants_path %>
|
36
|
-
<%= menu_item "Things you're not even cool enough to buy anyway", hipster_products_path %>
|
37
|
-
<% if current_user.lives_in_hackney? %>
|
38
|
-
<%= menu_item "Bikes", fixed_wheel_bikes_path %>
|
39
|
-
<% end %>
|
40
|
-
<% end %>
|
41
|
-
<%= menu_item "About Us", about_us_path %>
|
42
|
-
<%= menu_item "Contact", contact_path %>
|
43
|
-
<% end %>
|
44
|
-
<%= menu_group :pull => :right do %>
|
45
|
-
<% if current_user %>
|
46
|
-
<%= menu_item "Log Out", log_out_path %>
|
47
|
-
<% else %>
|
48
|
-
<%= form_for @user, :url => session_path(:user), html => {:class=> "navbar-form pull-right"} do |f| -%>
|
49
|
-
<p><%= f.text_field :email %></p>
|
50
|
-
<p><%= f.password_field :password %></p>
|
51
|
-
<p><%= f.submit "Sign in" %></p>
|
52
|
-
<% end -%>
|
53
|
-
<% end %>
|
54
|
-
<% end %>
|
55
|
-
<% end %>
|
56
|
-
````
|
57
|
-
|
58
|
-
### Navbar scaffolding
|
59
|
-
|
60
|
-
In your view file (most likely application.html.erb) to get a basic navbar set up you need to do this:
|
61
|
-
|
62
|
-
````
|
63
|
-
<%= nav_bar %>
|
64
|
-
````
|
65
|
-
|
66
|
-
Which will render:
|
67
|
-
|
68
|
-
<div class="navbar">
|
69
|
-
<div class="navbar-inner">
|
70
|
-
<div class="container">
|
71
|
-
</div>
|
72
|
-
</div>
|
73
|
-
</div>
|
74
|
-
|
75
|
-
|
76
|
-
### Fixed navbar
|
77
|
-
|
78
|
-
If you want the navbar to stick to the top of the screen, pass in the option like this:
|
79
|
-
|
80
|
-
````
|
81
|
-
<%= nav_bar :fixed => :top %>
|
82
|
-
````
|
83
|
-
|
84
|
-
To render:
|
85
|
-
|
86
|
-
<div class="navbar navbar-fixed-top">
|
87
|
-
<div class="navbar-inner">
|
88
|
-
<div class="container">
|
89
|
-
</div>
|
90
|
-
</div>
|
91
|
-
</div>
|
92
|
-
|
93
|
-
### Static navbar
|
94
|
-
|
95
|
-
If you want a full-width navbar that scrolls away with the page, pass in the option like this:
|
96
|
-
|
97
|
-
````
|
98
|
-
<%= nav_bar :static => :top %>
|
99
|
-
````
|
100
|
-
|
101
|
-
To render:
|
102
|
-
|
103
|
-
<div class="navbar navbar-static-top">
|
104
|
-
<div class="navbar-inner">
|
105
|
-
<div class="container">
|
106
|
-
</div>
|
107
|
-
</div>
|
108
|
-
</div>
|
109
|
-
|
110
|
-
|
111
|
-
### Brand name
|
112
|
-
|
113
|
-
Add the name of your site on the left hand edge of the navbar. By default, it will link to root_url. Passing a brand_link option will set the url to whatever you want.
|
114
|
-
|
115
|
-
````
|
116
|
-
<%= nav_bar :brand => "We're sooo web 2.0alizr", :brand_link => account_dashboard_path %>
|
117
|
-
````
|
118
|
-
|
119
|
-
Which will render:
|
120
|
-
|
121
|
-
<div class="navbar">
|
122
|
-
<div class="navbar-inner">
|
123
|
-
<div class="container">
|
124
|
-
<a class="brand" href="/accounts/dashboard">
|
125
|
-
We're sooo web 2.0alizr
|
126
|
-
</a>
|
127
|
-
</div>
|
128
|
-
</div>
|
129
|
-
</div>
|
130
|
-
|
131
|
-
|
132
|
-
### Optional responsive variation
|
133
|
-
|
134
|
-
If you want the responsive version of the navbar to work (One that shrinks down on mobile devices etc.), you need to pass this option:
|
135
|
-
|
136
|
-
````
|
137
|
-
<%= nav_bar :responsive => true %>
|
138
|
-
````
|
139
|
-
Which renders the html quite differently:
|
24
|
+
## Requirements
|
140
25
|
|
26
|
+
The necessary files from Bootstrap >= 2.0 have to be included separately, they are not part of this gem.
|
141
27
|
|
142
|
-
|
143
|
-
<div class="navbar-inner">
|
144
|
-
<div class="container">
|
145
|
-
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
|
146
|
-
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
147
|
-
<span class="icon-bar"></span>
|
148
|
-
<span class="icon-bar"></span>
|
149
|
-
<span class="icon-bar"></span>
|
150
|
-
</a>
|
151
|
-
<!-- Everything in here gets hidden at 940px or less -->
|
152
|
-
<div class="nav-collapse">
|
153
|
-
<!-- menu items gets rendered here instead -->
|
154
|
-
</div>
|
155
|
-
</div>
|
156
|
-
</div>
|
157
|
-
</div>
|
28
|
+
At least the CSS files for the navbar are required, and the JS files for dropdowns and responsive features, if you want to use those in the navbar.
|
158
29
|
|
30
|
+
## Usage
|
159
31
|
|
160
|
-
|
161
|
-
|
162
|
-
This is the 'meat' of the code where you define your menu items.
|
163
|
-
|
164
|
-
You can group menu items in theoretical boxes which you can apply logic to - e.g. show different collections for logged in users/logged out users, or simply right align a group.
|
165
|
-
|
166
|
-
The active menu item will be inferred from the link for now.
|
167
|
-
|
168
|
-
The important methods here are menu_group and menu_item.
|
169
|
-
|
170
|
-
menu_group only takes one argument - :pull - this moves the group left or right when passed :left or :right.
|
171
|
-
|
172
|
-
menu_item generates a link wrapped in an li tag. It takes two arguments and an options hash. The first argument is the name (the text that will appear in the menu), and the path (which defaults to "#" if left blank). The rest of the options are passed straight through to the link_to helper, so that you can add classes, ids, methods or data tags etc.
|
173
|
-
|
174
|
-
````
|
175
|
-
<%= nav_bar :fixed => :top, :brand => "Ninety Ten" do %>
|
176
|
-
<% menu_group do %>
|
177
|
-
<%= menu_item "Home", root_path %>
|
178
|
-
<%= menu_item "About Us", about_us_path %>
|
179
|
-
<%= menu_item "Contact", contact_path %>
|
180
|
-
<% end %>
|
181
|
-
<% if current_user %>
|
182
|
-
<%= menu_item "Log Out", log_out_path %>
|
183
|
-
<% else %>
|
184
|
-
<% menu_group :pull => :right do %>
|
185
|
-
<%= menu_item "Sign Up", registration_path %>
|
186
|
-
<% form_for @user, :url => session_path(:user) do |f| -%>
|
187
|
-
<p><%= f.text_field :email %></p>
|
188
|
-
<p><%= f.password_field :password %></p>
|
189
|
-
<p><%= f.submit "Sign in" %></p>
|
190
|
-
<% end -%>
|
191
|
-
<% end %>
|
192
|
-
<% end %>
|
193
|
-
<% end %>
|
194
|
-
````
|
195
|
-
|
196
|
-
### Dropdown menus
|
197
|
-
|
198
|
-
For multi-level list options, where it makes logical sense to group menu items, or simply to save space if you have a lot of pages, you can group menu items into drop down lists like this:
|
199
|
-
|
200
|
-
````
|
201
|
-
<%= nav_bar do %>
|
202
|
-
<%= menu_item "Home", root_path %>
|
203
|
-
|
204
|
-
<%= drop_down "Products" do %>
|
205
|
-
<%= menu_item "Latest", latest_products_path %>
|
206
|
-
<%= menu_item "Top Sellers", popular_products_path %>
|
207
|
-
<%= drop_down_divider %>
|
208
|
-
<%= menu_item "Discount Items", discounted_products_path %>
|
209
|
-
<% end %>
|
210
|
-
|
211
|
-
<%= menu_item "About Us", about_us_path %>
|
212
|
-
<%= menu_item "Contact", contact_path %>
|
213
|
-
<% end %>
|
214
|
-
````
|
215
|
-
|
216
|
-
### Dividers
|
217
|
-
|
218
|
-
Dividers are just vertical bars that visually separate logically disparate groups of menu items
|
219
|
-
|
220
|
-
````
|
221
|
-
<%= nav_bar :fixed => :bottom do %>
|
222
|
-
<%= menu_item "Home", root_path %>
|
223
|
-
<%= menu_item "About Us", about_us_path %>
|
224
|
-
<%= menu_item "Contact", contact_path %>
|
225
|
-
|
226
|
-
<%= menu_divider %>
|
227
|
-
|
228
|
-
<%= menu_item "Edit Profile", edit_user_path(current_user) %>
|
229
|
-
<%= menu_item "Account Settings", edit_user_account_path(current_user, @account) %>
|
230
|
-
<%= menu_item "Log Out", log_out_path %>
|
231
|
-
<% end %>
|
232
|
-
````
|
233
|
-
|
234
|
-
### Forms in navbar
|
235
|
-
|
236
|
-
At the moment - this is just a how to...
|
237
|
-
|
238
|
-
You need to add this class to the form itself (Different form builders do this in different ways - please check out the relevant docs)
|
239
|
-
|
240
|
-
````css
|
241
|
-
.navbar-form
|
242
|
-
````
|
243
|
-
To pull the form left or right, add either of these classes:
|
244
|
-
````css
|
245
|
-
.pull-left
|
246
|
-
.pull-right
|
247
|
-
````
|
248
|
-
|
249
|
-
If you want the Bootstrap search box (I think it just rounds the corners), use:
|
250
|
-
````css
|
251
|
-
.navbar-search
|
252
|
-
````
|
253
|
-
Instead of:
|
254
|
-
````css
|
255
|
-
.navbar-form
|
256
|
-
````
|
257
|
-
|
258
|
-
To change the size of the form fields, use .span2 (or however many span widths you want) to the input itself.
|
259
|
-
|
260
|
-
### Component alignment
|
261
|
-
|
262
|
-
You can shift things to the left or the right across the nav bar. It's easiest to do this on grouped menu items:
|
263
|
-
|
264
|
-
````
|
265
|
-
<%= nav_bar :fixed => :bottom do %>
|
266
|
-
<% menu_group do %>
|
267
|
-
<%= menu_item "Home", root_path %>
|
268
|
-
<%= menu_item "About Us", about_us_path %>
|
269
|
-
<%= menu_item "Contact", contact_path %>
|
270
|
-
<% end %>
|
271
|
-
<% menu_group :pull => :right do %>
|
272
|
-
<%= menu_item "Edit Profile", edit_user_path(current_user) %>
|
273
|
-
<%= menu_item "Account Settings", edit_user_account_path(current_user, @account) %>
|
274
|
-
<%= menu_item "Log Out", log_out_path %>
|
275
|
-
<% end %>
|
276
|
-
<% end %>
|
277
|
-
````
|
278
|
-
|
279
|
-
### Text in the navbar
|
280
|
-
|
281
|
-
If you want to put regular plain text in the navbar anywhere, you do it like this:
|
282
|
-
|
283
|
-
````
|
284
|
-
<%= nav_bar :brand => "Apple" do %>
|
285
|
-
<%= menu_text "We make shiny things" %>
|
286
|
-
<%= menu_item "Home", root_path %>
|
287
|
-
<%= menu_item "About Us", about_us_path %>
|
288
|
-
<% end %>
|
289
|
-
````
|
290
|
-
It also takes the :pull option to drag it to the left or right.
|
32
|
+
The gem [bootstrap_navbar](https://github.com/krautcomputing/bootstrap_navbar) is used to generate the HTML. Please refer to the [README](https://github.com/krautcomputing/bootstrap_navbar#usage) of that gem for detailed instructions on how to generate the navbar.
|
291
33
|
|
292
34
|
## Contributing
|
293
35
|
|
294
|
-
This is my first ever published gem - so please feel free to pull it apart and fix bits that are dumb. One of my biggest problems was getting Rspec to test it properly (only just bitten the bullet and gone full TDD). Cleaning up the specs would be a good place to start.
|
295
|
-
|
296
|
-
I'm guessing also that there's a much nicer way of doing the whole thing using Rails' form_builder approach, but this was where TDD got me...
|
297
|
-
|
298
36
|
1. Fork it
|
299
37
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
300
38
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
@@ -14,11 +14,13 @@ Gem::Specification.new do |gem|
|
|
14
14
|
gem.name = "rails_bootstrap_navbar"
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = RailsBootstrapNavbar::VERSION
|
17
|
+
gem.license = 'MIT'
|
17
18
|
|
18
19
|
gem.add_development_dependency 'rake', '>= 10.0.0'
|
19
20
|
gem.add_development_dependency 'rspec', '~> 2.13'
|
20
21
|
gem.add_development_dependency 'guard-rspec', '~> 3.0'
|
22
|
+
gem.add_development_dependency 'rails', '>= 3.0.0'
|
21
23
|
|
22
|
-
gem.add_runtime_dependency '
|
24
|
+
gem.add_runtime_dependency 'bootstrap-navbar', '~> 0.0.13'
|
23
25
|
gem.add_runtime_dependency 'rails', '>= 3.0.0'
|
24
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_bootstrap_navbar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jules Copeland
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -53,19 +53,33 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.0.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.0.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bootstrap-navbar
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - ~>
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.0.
|
75
|
+
version: 0.0.13
|
62
76
|
type: :runtime
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
80
|
- - ~>
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.0.
|
82
|
+
version: 0.0.13
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rails
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -93,6 +107,7 @@ files:
|
|
93
107
|
- .travis.yml
|
94
108
|
- CHANGELOG.md
|
95
109
|
- Gemfile
|
110
|
+
- Guardfile
|
96
111
|
- LICENSE
|
97
112
|
- README.md
|
98
113
|
- Rakefile
|
@@ -100,9 +115,11 @@ files:
|
|
100
115
|
- lib/rails_bootstrap_navbar/railtie.rb
|
101
116
|
- lib/rails_bootstrap_navbar/version.rb
|
102
117
|
- rails_bootstrap_navbar.gemspec
|
118
|
+
- spec/rails_bootstrap_navbar/railtie_spec.rb
|
103
119
|
- spec/spec_helper.rb
|
104
120
|
homepage: ''
|
105
|
-
licenses:
|
121
|
+
licenses:
|
122
|
+
- MIT
|
106
123
|
metadata: {}
|
107
124
|
post_install_message:
|
108
125
|
rdoc_options: []
|
@@ -125,5 +142,6 @@ signing_key:
|
|
125
142
|
specification_version: 4
|
126
143
|
summary: Generate Bootstrap Navbars in Rails views
|
127
144
|
test_files:
|
145
|
+
- spec/rails_bootstrap_navbar/railtie_spec.rb
|
128
146
|
- spec/spec_helper.rb
|
129
147
|
has_rdoc:
|