middleman-bootstrap-navbar 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +7 -0
- data/Guardfile +6 -0
- data/README.md +56 -1
- data/lib/middleman-bootstrap-navbar.rb +16 -1
- data/lib/middleman-bootstrap-navbar/helpers.rb +114 -0
- data/lib/{middleman_bootstrap_navbar → middleman-bootstrap-navbar}/version.rb +1 -1
- data/middleman-bootstrap-navbar.gemspec +8 -4
- data/spec/helpers_spec.rb +180 -0
- data/spec/spec_helper.rb +9 -0
- metadata +58 -10
- data/lib/middleman_bootstrap_navbar.rb +0 -15
- data/lib/middleman_bootstrap_navbar/helpers.rb +0 -122
- data/middleman_bootstrap_navbar.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1394a06043afd936ee6992313e020ad936111252
|
4
|
+
data.tar.gz: ec9156a62efa7028869b158797b2ae8feabe658f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0943ef20efe0e7c10ed6d9b999ef5a2dbfc248bb20becca3d723b701a86a3523a021133b4c1587f12052f5cb925b0d1eea5f868f6da4e7b760c0e961e88cdadb
|
7
|
+
data.tar.gz: 11a8235f81dbb8a9fddc5c0464f1997dcc0782a14bb0e895a981a4b1ec7271b54530f2dc25992753fe6deb8e81683abb3b82e9781abbf5913a07f44104a2c77f
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Gemfile.lock
|
data/.travis.yml
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
guard :rspec, all_after_pass: true, all_on_start: true do
|
2
|
+
watch(%r(^spec/.+_spec\.rb$))
|
3
|
+
watch(%r(^lib/(.+)\.rb$)) { |m| "spec/#{m[1].sub(%r(\Amiddleman-bootstrap-navbar/), '')}_spec.rb" }
|
4
|
+
watch('spec/spec_helper.rb') { 'spec' }
|
5
|
+
watch(%r(^spec/support/(.+)\.rb$)) { 'spec' }
|
6
|
+
end
|
data/README.md
CHANGED
@@ -1,3 +1,58 @@
|
|
1
1
|
# Middleman Bootstrap Navbar
|
2
2
|
|
3
|
-
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/middleman-bootstrap-navbar.png)](http://badge.fury.io/rb/middleman-bootstrap-navbar)
|
4
|
+
[![Build Status](https://secure.travis-ci.org/krautcomputing/middleman-bootstrap-navbar.png)](http://travis-ci.org/krautcomputing/middleman-bootstrap-navbar)
|
5
|
+
[![Dependency Status](https://gemnasium.com/krautcomputing/middleman-bootstrap-navbar.png)](https://gemnasium.com/krautcomputing/middleman-bootstrap-navbar)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/krautcomputing/middleman-bootstrap-navbar.png)](https://codeclimate.com/github/krautcomputing/middleman-bootstrap-navbar)
|
7
|
+
|
8
|
+
[Middleman](http://middlemanapp.com/) extension to easily generate a [Twitter Bootstrap navbar](http://twitter.github.io/bootstrap/components.html#navbar)
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
gem 'middleman-bootstrap-navbar'
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install middleman-bootstrap-navbar
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
= nav_bar fixed: :top, brand: "My great app", responsive: true do
|
28
|
+
= menu_group do
|
29
|
+
= menu_item "Home", root_path
|
30
|
+
= menu_divider
|
31
|
+
= drop_down "Stuff" do
|
32
|
+
= menu_item "One", one_path
|
33
|
+
= menu_item "Two", two_path
|
34
|
+
= menu_item "Three", three_path
|
35
|
+
- if current_user.admin?
|
36
|
+
= menu_item "Admin", admin_path
|
37
|
+
= menu_item "About Us", about_us_path
|
38
|
+
= menu_item "Contact", contact_path
|
39
|
+
= menu_group pull: :right do
|
40
|
+
- if current_user
|
41
|
+
= menu_item "Log Out", log_out_path
|
42
|
+
- else
|
43
|
+
= menu_item "Log In", log_in_path
|
44
|
+
```
|
45
|
+
|
46
|
+
Check out the [Twitter Bootstrap Docs](http://twitter.github.io/bootstrap/components.html#navbar) for more info.
|
47
|
+
|
48
|
+
## Inspiration
|
49
|
+
|
50
|
+
https://github.com/julescopeland/Rails-Bootstrap-Navbar
|
51
|
+
|
52
|
+
## Contributing
|
53
|
+
|
54
|
+
1. Fork it
|
55
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
56
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
57
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
58
|
+
5. Create new Pull Request
|
@@ -1 +1,16 @@
|
|
1
|
-
require '
|
1
|
+
require 'middleman-core/extensions' unless defined?(Middleman::Extensions)
|
2
|
+
require 'middleman-bootstrap-navbar/version'
|
3
|
+
require 'middleman-bootstrap-navbar/helpers'
|
4
|
+
|
5
|
+
module Middleman
|
6
|
+
module BootstrapNavbar
|
7
|
+
class << self
|
8
|
+
def registered(app)
|
9
|
+
app.helpers Helpers
|
10
|
+
end
|
11
|
+
alias :included :registered
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
Middleman::Extensions.register :bootstrap_navbar, Middleman::BootstrapNavbar
|
@@ -0,0 +1,114 @@
|
|
1
|
+
unless defined?(Padrino::Helpers)
|
2
|
+
require 'vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/support_lite'
|
3
|
+
require 'vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers'
|
4
|
+
end
|
5
|
+
|
6
|
+
module Middleman
|
7
|
+
module BootstrapNavbar
|
8
|
+
module Helpers
|
9
|
+
include Padrino::Helpers::TagHelpers
|
10
|
+
include Padrino::Helpers::AssetTagHelpers
|
11
|
+
include Padrino::Helpers::OutputHelpers
|
12
|
+
|
13
|
+
def nav_bar(options = {}, &block)
|
14
|
+
nav_bar_div options do
|
15
|
+
navbar_inner_div do
|
16
|
+
container_div options[:brand], options[:brand_link], options[:responsive], options[:fluid], &block
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def menu_group(options = {}, &block)
|
22
|
+
classes = %w(nav)
|
23
|
+
classes << "pull-#{options[:pull]}" if options.has_key?(:pull)
|
24
|
+
content = block_given? ? capture(&block) : nil
|
25
|
+
content_tag :ul, content, class: classes.join(' ')
|
26
|
+
end
|
27
|
+
|
28
|
+
def menu_item(name, path = '#', options = {})
|
29
|
+
content_tag :li, class: path.sub(%r(/\z), '') == current_page.url.sub(%r(/\z), '') ? 'active' : nil do
|
30
|
+
link_to name, path, options
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def drop_down(name, &block)
|
35
|
+
content_tag :li, class: 'dropdown' do
|
36
|
+
name_and_caret = "#{name} #{content_tag :b, nil, class: 'caret'}".html_safe
|
37
|
+
content = block_given? ? capture(&block) : nil
|
38
|
+
link_to(name_and_caret, '#', class: 'dropdown-toggle', data: { toggle: 'dropdown' }) <<
|
39
|
+
content_tag(:ul, content, class: 'dropdown-menu')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def drop_down_divider
|
44
|
+
content_tag :li, nil, class: 'divider'
|
45
|
+
end
|
46
|
+
|
47
|
+
def drop_down_header(text)
|
48
|
+
content_tag :li, text, class: 'nav-header'
|
49
|
+
end
|
50
|
+
|
51
|
+
def menu_divider
|
52
|
+
content_tag :li, nil, class: 'divider-vertical'
|
53
|
+
end
|
54
|
+
|
55
|
+
def menu_text(text = nil, options = {}, &block)
|
56
|
+
classes = %w(navbar-text)
|
57
|
+
pull = options.delete(:pull)
|
58
|
+
classes << "pull-#{pull}" if pull
|
59
|
+
options[:class] = classes.join(' ')
|
60
|
+
content = text || capture(&block) || nil
|
61
|
+
content_tag :p, content, options
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def nav_bar_div(options, &block)
|
67
|
+
position = case
|
68
|
+
when options.has_key?(:static)
|
69
|
+
"static-#{options[:static]}"
|
70
|
+
when options.has_key?(:fixed)
|
71
|
+
"fixed-#{options[:fixed]}"
|
72
|
+
end
|
73
|
+
|
74
|
+
css_class = %w(navbar).tap do |css_class|
|
75
|
+
css_class << "navbar-#{position}" if position
|
76
|
+
css_class << 'navbar-inverse' if options[:inverse]
|
77
|
+
end.join(' ')
|
78
|
+
|
79
|
+
content_tag :div, class: css_class, &block
|
80
|
+
end
|
81
|
+
|
82
|
+
def navbar_inner_div(&block)
|
83
|
+
content_tag :div, class: 'navbar-inner', &block
|
84
|
+
end
|
85
|
+
|
86
|
+
def container_div(brand, brand_link, responsive, fluid, &block)
|
87
|
+
content_tag :div, class: fluid ? 'container-fluid' : 'container' do
|
88
|
+
content = block_given? ? capture(&block) : nil
|
89
|
+
[].tap do |parts|
|
90
|
+
parts << responsive_button if responsive
|
91
|
+
parts << brand_link(brand, brand_link) if brand || brand_link
|
92
|
+
parts << if responsive
|
93
|
+
content_tag :div, content, class: 'nav-collapse collapse'
|
94
|
+
else
|
95
|
+
content
|
96
|
+
end
|
97
|
+
end.join("\n").html_safe
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def brand_link(name, url)
|
102
|
+
link_to name, (url || '/'), class: 'brand'
|
103
|
+
end
|
104
|
+
|
105
|
+
def responsive_button
|
106
|
+
content_tag :a, class: 'btn btn-navbar', data: { toggle: 'collapse', target: '.nav-collapse' } do
|
107
|
+
(0..2).map do
|
108
|
+
content_tag :span, nil, class: 'icon-bar'
|
109
|
+
end.join("\n").html_safe
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
lib = File.expand_path('../lib', __FILE__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
|
6
|
-
require '
|
6
|
+
require 'middleman-bootstrap-navbar/version'
|
7
7
|
|
8
8
|
Gem::Specification.new do |gem|
|
9
9
|
gem.name = 'middleman-bootstrap-navbar'
|
@@ -11,9 +11,9 @@ 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 Bootstrap
|
15
|
-
gem.description = 'Middleman Bootstrap
|
16
|
-
gem.homepage = ''
|
14
|
+
gem.summary = 'Middleman extension to easily generate a Twitter Bootstrap navbar'
|
15
|
+
gem.description = 'Middleman extension to easily generate a Twitter Bootstrap navbar'
|
16
|
+
gem.homepage = 'https://github.com/krautcomputing/middleman-bootstrap-navbar'
|
17
17
|
gem.license = 'MIT'
|
18
18
|
|
19
19
|
gem.files = `git ls-files`.split($/)
|
@@ -21,5 +21,9 @@ Gem::Specification.new do |gem|
|
|
21
21
|
gem.test_files = gem.files.grep(%r(^(test|spec|features)/))
|
22
22
|
gem.require_paths = ['lib']
|
23
23
|
|
24
|
+
gem.add_development_dependency 'rspec', '~> 2.13'
|
25
|
+
gem.add_development_dependency 'rspec-html-matchers', '~> 0.4.1'
|
26
|
+
gem.add_development_dependency 'guard-rspec', '~> 3.0'
|
27
|
+
|
24
28
|
gem.add_runtime_dependency 'middleman-core', '>= 3.0'
|
25
29
|
end
|
@@ -0,0 +1,180 @@
|
|
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
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'middleman-bootstrap-navbar'
|
2
|
+
require 'rspec-html-matchers'
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
6
|
+
config.run_all_when_everything_filtered = true
|
7
|
+
config.filter_run :focus
|
8
|
+
config.order = 'random'
|
9
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-bootstrap-navbar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
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-
|
11
|
+
date: 2013-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec-html-matchers
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.4.1
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.4.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: guard-rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
13
55
|
- !ruby/object:Gem::Dependency
|
14
56
|
name: middleman-core
|
15
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -24,22 +66,25 @@ dependencies:
|
|
24
66
|
- - '>='
|
25
67
|
- !ruby/object:Gem::Version
|
26
68
|
version: '3.0'
|
27
|
-
description: Middleman Bootstrap
|
69
|
+
description: Middleman extension to easily generate a Twitter Bootstrap navbar
|
28
70
|
email: manuel.meurer@gmail.com
|
29
71
|
executables: []
|
30
72
|
extensions: []
|
31
73
|
extra_rdoc_files: []
|
32
74
|
files:
|
75
|
+
- .gitignore
|
76
|
+
- .travis.yml
|
33
77
|
- Gemfile
|
78
|
+
- Guardfile
|
34
79
|
- LICENSE.txt
|
35
80
|
- README.md
|
36
81
|
- lib/middleman-bootstrap-navbar.rb
|
37
|
-
- lib/
|
38
|
-
- lib/
|
39
|
-
- lib/middleman_bootstrap_navbar/version.rb
|
82
|
+
- lib/middleman-bootstrap-navbar/helpers.rb
|
83
|
+
- lib/middleman-bootstrap-navbar/version.rb
|
40
84
|
- middleman-bootstrap-navbar.gemspec
|
41
|
-
-
|
42
|
-
|
85
|
+
- spec/helpers_spec.rb
|
86
|
+
- spec/spec_helper.rb
|
87
|
+
homepage: https://github.com/krautcomputing/middleman-bootstrap-navbar
|
43
88
|
licenses:
|
44
89
|
- MIT
|
45
90
|
metadata: {}
|
@@ -62,5 +107,8 @@ rubyforge_project:
|
|
62
107
|
rubygems_version: 2.0.2
|
63
108
|
signing_key:
|
64
109
|
specification_version: 4
|
65
|
-
summary: Middleman Bootstrap
|
66
|
-
test_files:
|
110
|
+
summary: Middleman extension to easily generate a Twitter Bootstrap navbar
|
111
|
+
test_files:
|
112
|
+
- spec/helpers_spec.rb
|
113
|
+
- spec/spec_helper.rb
|
114
|
+
has_rdoc:
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'middleman_bootstrap_navbar/version'
|
2
|
-
require 'middleman_bootstrap_navbar/helpers'
|
3
|
-
|
4
|
-
module Middleman
|
5
|
-
module BootstrapNavbar
|
6
|
-
class << self
|
7
|
-
def registered(app)
|
8
|
-
app.helpers Helpers
|
9
|
-
end
|
10
|
-
alias :included :registered
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
::Middleman::Extensions.register :bootstrap_navbar, Middleman::BootstrapNavbar
|
@@ -1,122 +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[:pull].present?
|
15
|
-
content_tag :ul, class: classes.join(' '), &block
|
16
|
-
end
|
17
|
-
|
18
|
-
def menu_item(name, path = '#', *args)
|
19
|
-
options = args.extract_options!
|
20
|
-
content_tag :li, class: path.sub(%r(/\z), '') == current_page.url.sub(%r(/\z), '') ? 'active' : nil do
|
21
|
-
link_to name, path, options
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def drop_down(name)
|
26
|
-
content_tag :li, class: 'dropdown' do
|
27
|
-
drop_down_link(name) + drop_down_list {yield}
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def drop_down_divider
|
32
|
-
content_tag :li, '', class: 'divider'
|
33
|
-
end
|
34
|
-
|
35
|
-
def drop_down_header(text)
|
36
|
-
content_tag :li, text, class: 'nav-header'
|
37
|
-
end
|
38
|
-
|
39
|
-
def menu_divider
|
40
|
-
content_tag :li, '', class: 'divider-vertical'
|
41
|
-
end
|
42
|
-
|
43
|
-
def menu_text(text = nil, options = {}, &block)
|
44
|
-
pull = options.delete(:pull)
|
45
|
-
pull_class = pull.present? ? "pull-#{pull}" : nil
|
46
|
-
[pull_class, 'navbar-text'].each do |klass|
|
47
|
-
options[:class] = [options[:class], klass].compact.join(' ')
|
48
|
-
end
|
49
|
-
content_tag :p, options do
|
50
|
-
text || yield
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
private
|
55
|
-
|
56
|
-
def nav_bar_div(options, &block)
|
57
|
-
position = "static-#{options[:static]}" if options[:static]
|
58
|
-
position = "fixed-#{options[:fixed]}" if options[:fixed]
|
59
|
-
inverse = (options[:inverse].present? && options[:inverse] == true) ? true : false
|
60
|
-
|
61
|
-
content_tag :div, class: nav_bar_css_class(position, inverse) do
|
62
|
-
yield
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def navbar_inner_div(&block)
|
67
|
-
content_tag :div, class: 'navbar-inner' do
|
68
|
-
yield
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def container_div(brand, brand_link, responsive, fluid, &block)
|
73
|
-
content_tag :div, class: fluid ? 'container-flud' : 'container' do
|
74
|
-
container_div_with_block brand, brand_link, responsive, &block
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def container_div_with_block(brand, brand_link, responsive, &block)
|
79
|
-
output = []
|
80
|
-
output << responsive_button if responsive
|
81
|
-
output << brand_link(brand, brand_link) if brand.present? || brand_link.present?
|
82
|
-
output << (responsive ? responsive_div(&block) : capture(&block))
|
83
|
-
output.join("\n").html_safe
|
84
|
-
end
|
85
|
-
|
86
|
-
def nav_bar_css_class(position, inverse = false)
|
87
|
-
css_class = %w(navbar)
|
88
|
-
css_class << "navbar-#{position}" if position.present?
|
89
|
-
css_class << 'navbar-inverse' if inverse
|
90
|
-
css_class.join(' ')
|
91
|
-
end
|
92
|
-
|
93
|
-
def brand_link(name, url = nil, &block)
|
94
|
-
link_to *[name, url || '/'].compact, class: 'brand', &block
|
95
|
-
end
|
96
|
-
|
97
|
-
def responsive_button
|
98
|
-
%(<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
99
|
-
<span class="icon-bar"></span>
|
100
|
-
<span class="icon-bar"></span>
|
101
|
-
<span class="icon-bar"></span>
|
102
|
-
</a>)
|
103
|
-
end
|
104
|
-
|
105
|
-
def responsive_div(&block)
|
106
|
-
content_tag(:div, class: 'nav-collapse collapse', &block)
|
107
|
-
end
|
108
|
-
|
109
|
-
def name_and_caret(name)
|
110
|
-
"#{name} #{content_tag(:b, class: 'caret'){}}".html_safe
|
111
|
-
end
|
112
|
-
|
113
|
-
def drop_down_link(name)
|
114
|
-
link_to(name_and_caret(name), '#', class: 'dropdown-toggle', 'data-toggle' => 'dropdown')
|
115
|
-
end
|
116
|
-
|
117
|
-
def drop_down_list(&block)
|
118
|
-
content_tag :ul, class: 'dropdown-menu', &block
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module MyFeature
|
2
|
-
class << self
|
3
|
-
def registered(app)
|
4
|
-
app.helpers HelperMethods
|
5
|
-
end
|
6
|
-
alias :included :registered
|
7
|
-
end
|
8
|
-
|
9
|
-
module HelperMethods
|
10
|
-
def make_a_link(url, text)
|
11
|
-
"<a href='#{url}'>#{text}</a>"
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
::Middleman::Extensions.register :middleman_bootstrap_navbar, Middleman::BootstrapNavbar
|