middleman-bootstrap-navbar 0.0.3 → 0.0.4

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: d6cc10d2d6d36697f3c8cc98f25cebf6d108a235
4
- data.tar.gz: 8739a03d6aa19792f58c5273abded7a0b596b9ab
3
+ metadata.gz: aeec9fcceeb262b91949e635a1216241e3530cb2
4
+ data.tar.gz: 2fbb33bfd63bfcb8d31fefcf85f20978972ce145
5
5
  SHA512:
6
- metadata.gz: 5404bce3d0fbbe7aaf47c19b6bdcac8c061218b5ea0e6c14a5d4f569bdefcfd80fd439d65d1fde7ac35ba44aabba2f277bd5ceaf5e5a170e50000cfc4a5a8ce1
7
- data.tar.gz: 4625390a7f4bfda5ddb6955cb1247c91eb37f20f00a2f6bd0f203b02bc88340e24e42ec4b24142be793cf090cf7475e4eedd9ab034a8de1785abd4f7fb533764
6
+ metadata.gz: 2df6d5384fef5d9aebb5f22a4ac104c008d8f790e7eb9439e71246ef0910d265b92acd19193a92645532b2750cccc6d63fca03dbc429830ab7b52d588bb7000d
7
+ data.tar.gz: 40301735855e89eb8daa4a189bc6c4ac825fb68081371033d4c0eb4befda5dd1a9fd7adec39900fc6e6c474a6a18806789f2432e4e6e0b538139a83d503c7b8b
data/README.md CHANGED
@@ -21,6 +21,10 @@ Or install it yourself as:
21
21
 
22
22
  $ gem install middleman-bootstrap-navbar
23
23
 
24
+ ## Requirements
25
+
26
+ Bootstrap >= 2.0 should be available in your app, at least the CSS. Include at least the dropdown and responsive JS files if you want those features.
27
+
24
28
  ## Usage
25
29
 
26
30
  Activate in `config.rb` in your Middleman app:
@@ -51,7 +55,11 @@ Then generate your navbar:
51
55
  = menu_item "Log In", log_in_path
52
56
  ```
53
57
 
54
- Check out the [Twitter Bootstrap Docs](http://twitter.github.io/bootstrap/components.html#navbar) for more info.
58
+ Check out the [Twitter Bootstrap Docs](http://twitter.github.io/bootstrap/components.html#navbar) for more info. All components mentioned there should be supported, so you don't need to write any HTML by hand. If there is something missing or wrong HTML is generated, please [open an issue](https://github.com/krautcomputing/middleman-bootstrap-navbar/issues).
59
+
60
+ To see all supported options, please have a look at the [source file](https://github.com/krautcomputing/middleman-bootstrap-navbar/blob/master/lib/middleman-bootstrap-navbar/helpers.rb), it should be quite readable.
61
+
62
+ Otherwise: just trust your instincts. Want a nav bar that's fixed to the bottom? Try `nav_bar fixed: :bottom`. Want a nav bar that is static? Try `nav_bar static: :top` or `nav_bar static: :bottom`.
55
63
 
56
64
  ## Inspiration
57
65
 
@@ -1,16 +1,18 @@
1
- require 'middleman-core/extensions' unless defined?(Middleman::Extensions)
2
1
  require 'middleman-bootstrap-navbar/version'
3
- require 'middleman-bootstrap-navbar/helpers'
2
+
3
+ require 'bootstrap_navbar'
4
+ BootstrapNavbar.current_url_method = 'current_page.url'
4
5
 
5
6
  module Middleman
6
7
  module BootstrapNavbar
7
8
  class << self
8
9
  def registered(app)
9
- app.helpers Helpers
10
+ app.helpers ::BootstrapNavbar::Helpers
10
11
  end
11
12
  alias :included :registered
12
13
  end
13
14
  end
14
15
  end
15
16
 
17
+ require 'middleman-core/extensions' unless defined?(Middleman::Extensions)
16
18
  Middleman::Extensions.register :bootstrap_navbar, Middleman::BootstrapNavbar
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module BootstrapNavbar
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
  end
5
5
  end
@@ -11,8 +11,8 @@ Gem::Specification.new do |gem|
11
11
  gem.platform = Gem::Platform::RUBY
12
12
  gem.authors = ['Manuel Meurer']
13
13
  gem.email = 'manuel.meurer@gmail.com'
14
- gem.summary = 'Middleman extension to easily generate a Twitter Bootstrap navbar'
15
- gem.description = 'Middleman extension to easily generate a Twitter Bootstrap navbar'
14
+ gem.summary = 'Middleman extension to easily generate a Twitter Bootstrap style navbar'
15
+ gem.description = 'Middleman extension to easily generate a Twitter Bootstrap style navbar'
16
16
  gem.homepage = 'https://github.com/krautcomputing/middleman-bootstrap-navbar'
17
17
  gem.license = 'MIT'
18
18
 
@@ -23,8 +23,8 @@ Gem::Specification.new do |gem|
23
23
 
24
24
  gem.add_development_dependency 'rake', '>= 10.0.0'
25
25
  gem.add_development_dependency 'rspec', '~> 2.13'
26
- gem.add_development_dependency 'rspec-html-matchers', '~> 0.4.1'
27
26
  gem.add_development_dependency 'guard-rspec', '~> 3.0'
28
27
 
28
+ gem.add_runtime_dependency 'bootstrap_navbar', '~> 0.0.5'
29
29
  gem.add_runtime_dependency 'middleman-core', '>= 3.0'
30
30
  end
data/spec/spec_helper.rb CHANGED
@@ -7,18 +7,3 @@ RSpec.configure do |config|
7
7
  config.filter_run :focus
8
8
  config.order = 'random'
9
9
  end
10
-
11
- unless defined?(Padrino::Helpers)
12
- require 'vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/support_lite'
13
- require 'vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers'
14
- end
15
-
16
- module Middleman
17
- module BootstrapNavbar
18
- module Helpers
19
- include Padrino::Helpers::TagHelpers
20
- include Padrino::Helpers::AssetTagHelpers
21
- include Padrino::Helpers::OutputHelpers
22
- end
23
- end
24
- end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-bootstrap-navbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel Meurer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-27 00:00:00.000000000 Z
11
+ date: 2013-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -39,33 +39,33 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.13'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rspec-html-matchers
42
+ name: guard-rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: 0.4.1
47
+ version: '3.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: 0.4.1
54
+ version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: guard-rspec
56
+ name: bootstrap_navbar
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: '3.0'
62
- type: :development
61
+ version: 0.0.5
62
+ type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: '3.0'
68
+ version: 0.0.5
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: middleman-core
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -80,7 +80,7 @@ dependencies:
80
80
  - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.0'
83
- description: Middleman extension to easily generate a Twitter Bootstrap navbar
83
+ description: Middleman extension to easily generate a Twitter Bootstrap style navbar
84
84
  email: manuel.meurer@gmail.com
85
85
  executables: []
86
86
  extensions: []
@@ -94,10 +94,8 @@ files:
94
94
  - README.md
95
95
  - Rakefile
96
96
  - lib/middleman-bootstrap-navbar.rb
97
- - lib/middleman-bootstrap-navbar/helpers.rb
98
97
  - lib/middleman-bootstrap-navbar/version.rb
99
98
  - middleman-bootstrap-navbar.gemspec
100
- - spec/helpers_spec.rb
101
99
  - spec/spec_helper.rb
102
100
  homepage: https://github.com/krautcomputing/middleman-bootstrap-navbar
103
101
  licenses:
@@ -122,8 +120,7 @@ rubyforge_project:
122
120
  rubygems_version: 2.0.2
123
121
  signing_key:
124
122
  specification_version: 4
125
- summary: Middleman extension to easily generate a Twitter Bootstrap navbar
123
+ summary: Middleman extension to easily generate a Twitter Bootstrap style navbar
126
124
  test_files:
127
- - spec/helpers_spec.rb
128
125
  - spec/spec_helper.rb
129
126
  has_rdoc:
@@ -1,101 +0,0 @@
1
- module Middleman
2
- module BootstrapNavbar
3
- module Helpers
4
- def nav_bar(options = {}, &block)
5
- nav_bar_div options do
6
- navbar_inner_div do
7
- container_div options[:brand], options[:brand_link], options[:responsive], options[:fluid], &block
8
- end
9
- end
10
- end
11
-
12
- def menu_group(options = {}, &block)
13
- classes = %w(nav)
14
- classes << "pull-#{options[:pull]}" if options.has_key?(:pull)
15
- content_tag :ul, nil, class: classes.join(' '), &block
16
- end
17
-
18
- def menu_item(name, path = '#', options = {})
19
- content_tag :li, class: path.sub(%r(/\z), '') == current_page.url.sub(%r(/\z), '') ? 'active' : nil do
20
- link_to name, path, options
21
- end
22
- end
23
-
24
- def drop_down(name, &block)
25
- content_tag :li, class: 'dropdown' do
26
- name_and_caret = "#{name} #{content_tag :b, nil, class: 'caret'}".html_safe
27
- link_to(name_and_caret, '#', class: 'dropdown-toggle', data: { toggle: 'dropdown' }) <<
28
- content_tag(:ul, nil, class: 'dropdown-menu', &block)
29
- end
30
- end
31
-
32
- def drop_down_divider
33
- content_tag :li, nil, class: 'divider'
34
- end
35
-
36
- def drop_down_header(text)
37
- content_tag :li, text, class: 'nav-header'
38
- end
39
-
40
- def menu_divider
41
- content_tag :li, nil, class: 'divider-vertical'
42
- end
43
-
44
- def menu_text(text = nil, options = {}, &block)
45
- classes = %w(navbar-text)
46
- pull = options.delete(:pull)
47
- classes << "pull-#{pull}" if pull
48
- options[:class] = classes.join(' ')
49
- content_tag :p, text, options, &block
50
- end
51
-
52
- def brand_link(name, url = nil)
53
- link_to name, (url || '/'), class: 'brand'
54
- end
55
-
56
- private
57
-
58
- def nav_bar_div(options, &block)
59
- position = case
60
- when options.has_key?(:static)
61
- "static-#{options[:static]}"
62
- when options.has_key?(:fixed)
63
- "fixed-#{options[:fixed]}"
64
- end
65
-
66
- css_class = %w(navbar).tap do |css_class|
67
- css_class << "navbar-#{position}" if position
68
- css_class << 'navbar-inverse' if options[:inverse]
69
- end.join(' ')
70
-
71
- content_tag :div, class: css_class, &block
72
- end
73
-
74
- def navbar_inner_div(&block)
75
- content_tag :div, class: 'navbar-inner', &block
76
- end
77
-
78
- def container_div(brand, brand_link, responsive, fluid, &block)
79
- content_tag :div, class: fluid ? 'container-fluid' : 'container' do
80
- [].tap do |parts|
81
- parts << responsive_button if responsive
82
- parts << brand_link(brand, brand_link) if brand || brand_link
83
- parts << if responsive
84
- content_tag :div, nil, class: 'nav-collapse collapse', &block
85
- else
86
- capture(&block)
87
- end
88
- end.join("\n").html_safe
89
- end
90
- end
91
-
92
- def responsive_button
93
- content_tag :a, class: 'btn btn-navbar', data: { toggle: 'collapse', target: '.nav-collapse' } do
94
- (0..2).map do
95
- content_tag :span, nil, class: 'icon-bar'
96
- end.join("\n").html_safe
97
- end
98
- end
99
- end
100
- end
101
- end
data/spec/helpers_spec.rb DELETED
@@ -1,180 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Middleman::BootstrapNavbar::Helpers do
4
- subject do
5
- Class.new do
6
- extend Middleman::BootstrapNavbar::Helpers
7
- end
8
- end
9
-
10
- describe '#nav_bar' do
11
- context 'div.navbar' do
12
- context '"static" parameter' do
13
- it 'generates the correct HTML' do
14
- subject.nav_bar(static: 'top').should have_tag(:div, with: { class: 'navbar navbar-static-top' })
15
- subject.nav_bar(static: 'bottom').should have_tag(:div, with: { class: 'navbar navbar-static-bottom' })
16
- end
17
- end
18
-
19
- context '"fixed" parameter' do
20
- it 'generates the correct HTML' do
21
- subject.nav_bar(fixed: 'top').should have_tag(:div, with: { class: 'navbar navbar-fixed-top' })
22
- subject.nav_bar(fixed: 'bottom').should have_tag(:div, with: { class: 'navbar navbar-fixed-bottom' })
23
- end
24
- end
25
-
26
- context '"inverse" parameter' do
27
- it 'generates the correct HTML' do
28
- subject.nav_bar(inverse: true).should have_tag(:div, with: { class: 'navbar navbar-inverse' })
29
- end
30
- end
31
-
32
- context 'no parameters' do
33
- it 'generates the correct HTML' do
34
- subject.nav_bar.should have_tag(:div, with: { class: 'navbar' })
35
- subject.nav_bar { 'foo' }.should have_tag(:div, with: { class: 'navbar' }, content: 'foo')
36
- end
37
- end
38
- end
39
-
40
- context 'div.navbar-inner' do
41
- it 'generates the correct HTML' do
42
- subject.nav_bar.should have_tag(:div, with: { class: 'navbar-inner' })
43
- end
44
- end
45
-
46
- context 'div.container' do
47
- it 'generates the correct HTML' do
48
- subject.nav_bar.should have_tag(:div, with: { class: 'container' })
49
- end
50
- end
51
-
52
- describe 'brand and brank_link parameters' do
53
- it 'generates the correct HTML' do
54
- subject.nav_bar(brand: 'foo').should have_tag(:a, with: { href: '/', class: 'brand' }, content: 'foo')
55
- subject.nav_bar(brand: 'foo', brand_link: 'http://google.com').should have_tag(:a, with: { href: 'http://google.com', class: 'brand' }, content: 'foo')
56
- subject.nav_bar(brand_link: 'http://google.com').should have_tag(:a, with: { href: 'http://google.com', class: 'brand' })
57
- end
58
- end
59
-
60
- describe '"responsive" parameter' do
61
- it 'generates the correct HTML' do
62
- subject.nav_bar(responsive: true).should have_tag(:a, with: { class: 'btn btn-navbar', :'data-toggle' => 'collapse', :'data-target' => '.nav-collapse' }) do
63
- 3.times do
64
- with_tag :span, with: { class: 'icon-bar' }
65
- end
66
- end
67
- end
68
- end
69
-
70
- describe '"fluid" parameter' do
71
- it 'generates the correct HTML' do
72
- subject.nav_bar(fluid: true).should have_tag(:div, with: { class: 'container-fluid' })
73
- end
74
- end
75
- end
76
-
77
- describe '#menu_group' do
78
- describe '"pull" parameter' do
79
- it 'generates the correct HTML' do
80
- subject.menu_group(pull: 'right').should have_tag(:ul, with: { class: 'nav pull-right' })
81
- end
82
- end
83
-
84
- context 'no parameters' do
85
- it 'generates the correct HTML' do
86
- subject.menu_group.should have_tag(:ul, with: { class: 'nav' })
87
- subject.menu_group { 'foo' }.should have_tag(:ul, with: { class: 'nav' }, content: 'foo')
88
- end
89
- end
90
- end
91
-
92
- describe '#menu_item' do
93
- let(:current_page) { double('current_page') }
94
-
95
- before do
96
- subject.stub(:current_page).and_return(current_page)
97
- end
98
-
99
- context 'with current URL' do
100
- it 'generates the correct HTML' do
101
- current_page.stub(:url).and_return('/')
102
- subject.menu_item('foo', '/').should have_tag(:li, with: { class: 'active' }) do
103
- with_tag :a, with: { href: '/' }, content: 'foo'
104
- end
105
-
106
- current_page.stub(:url).and_return('/foo')
107
- subject.menu_item('foo', '/foo').should have_tag(:li, with: { class: 'active' }) do
108
- with_tag :a, with: { href: '/foo' }, content: 'foo'
109
- end
110
- end
111
- end
112
-
113
- context 'without current URL' do
114
- it 'generates the correct HTML' do
115
- current_page.stub(:url).and_return('/foo')
116
- subject.menu_item('foo').should have_tag(:li, without: { class: 'active' }) do
117
- with_tag :a, with: { href: '#' }, content: 'foo'
118
- end
119
- subject.menu_item('foo', '/').should have_tag(:li, without: { class: 'active' }) do
120
- with_tag :a, with: { href: '/' }, content: 'foo'
121
- end
122
- subject.menu_item('foo', '/bar').should have_tag(:li, without: { class: 'active' }) do
123
- with_tag :a, with: { href: '/bar' }, content: 'foo'
124
- end
125
-
126
- current_page.stub(:url).and_return('/')
127
- subject.menu_item('foo', '/foo').should have_tag(:li, without: { class: 'active' }) do
128
- with_tag :a, with: { href: '/foo' }, content: 'foo'
129
- end
130
- end
131
- end
132
- end
133
-
134
- describe '#drop_down' do
135
- it 'generates the correct HTML' do
136
- subject.drop_down('foo').should have_tag(:li, with: { class: 'dropdown' }) do
137
- with_tag :a, with: { href: '#', class: 'dropdown-toggle', :'data-toggle' => 'dropdown' } do
138
- with_text /foo/
139
- with_tag :b, with: { class: 'caret' }
140
- end
141
- with_tag :ul, with: { class: 'dropdown-menu' }
142
- end
143
-
144
- subject.drop_down('foo') { 'bar' }.should have_tag(:li, with: { class: 'dropdown' }) do
145
- with_tag :a, with: { href: '#', class: 'dropdown-toggle', :'data-toggle' => 'dropdown' } do
146
- with_text /foo/
147
- with_tag :b, with: { class: 'caret' }
148
- end
149
- with_tag :ul, with: { class: 'dropdown-menu' }, content: 'bar'
150
- end
151
- end
152
- end
153
-
154
- describe '#drop_down_divider' do
155
- it 'generates the correct HTML' do
156
- subject.drop_down_divider.should have_tag(:li, with: { class: 'divider' }, content: '')
157
- end
158
- end
159
-
160
- describe '#drop_down_header' do
161
- it 'generates the correct HTML' do
162
- subject.drop_down_header('foo').should have_tag(:li, with: { class: 'nav-header' }, content: 'foo')
163
- end
164
- end
165
-
166
- describe '#menu_divider' do
167
- it 'generates the correct HTML' do
168
- subject.menu_divider.should have_tag(:li, with: { class: 'divider-vertical' }, content: '')
169
- end
170
- end
171
-
172
- describe '#menu_text' do
173
- it 'generates the correct HTML' do
174
- subject.menu_text('foo').should have_tag(:p, with: { class: 'navbar-text' }, content: 'foo')
175
- subject.menu_text { 'foo' }.should have_tag(:p, with: { class: 'navbar-text' }, content: 'foo')
176
- subject.menu_text('foo', pull: 'right').should have_tag(:p, with: { class: 'navbar-text pull-right' }, content: 'foo')
177
- subject.menu_text(nil, pull: 'left') { 'foo' }.should have_tag(:p, with: { class: 'navbar-text pull-left' }, content: 'foo')
178
- end
179
- end
180
- end