middleman-bootstrap-navbar 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ee9034c89d0970d28c0ddd6c63a508c4e8e53f5e
4
+ data.tar.gz: 1a3e61fa563c21eeaaeec78d96a56584aac27588
5
+ SHA512:
6
+ metadata.gz: 5fe1edeae657b6ea6974caedb74633a453e6d65930c111759cdf69f6dd5ea1b6a418e04edb523320195bf331fc909af119bc28f8bef14893bec000b93ef51da5
7
+ data.tar.gz: ea2e3519f877a8d5a98497d252dc265cf31d3b91a401e899f66e524f9f671b093356bdaeb801dc08da03cd0b2edb674c473f666caf4e76db3f7bcb83deaad3e8
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org/'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 kraut computing UG (haftungsbeschränkt)
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Middleman Bootstrap Navbar
2
+
3
+ Inspiration: https://github.com/julescopeland/Rails-Bootstrap-Navbar
@@ -0,0 +1 @@
1
+ require 'middleman_bootstrap_navbar'
@@ -0,0 +1,15 @@
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
@@ -0,0 +1,122 @@
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
@@ -0,0 +1,5 @@
1
+ module Middleman
2
+ module BootstrapNavbar
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ require 'middleman_bootstrap_navbar/version'
7
+
8
+ Gem::Specification.new do |gem|
9
+ gem.name = 'middleman-bootstrap-navbar'
10
+ gem.version = Middleman::BootstrapNavbar::VERSION
11
+ gem.platform = Gem::Platform::RUBY
12
+ gem.authors = ['Manuel Meurer']
13
+ gem.email = 'manuel.meurer@gmail.com'
14
+ gem.summary = 'Middleman Bootstrap Navbar'
15
+ gem.description = 'Middleman Bootstrap Navbar'
16
+ gem.homepage = ''
17
+ gem.license = 'MIT'
18
+
19
+ gem.files = `git ls-files`.split($/)
20
+ gem.executables = gem.files.grep(%r(^bin/)).map { |f| File.basename(f) }
21
+ gem.test_files = gem.files.grep(%r(^(test|spec|features)/))
22
+ gem.require_paths = ['lib']
23
+
24
+ gem.add_runtime_dependency 'middleman-core', '>= 3.0'
25
+ end
@@ -0,0 +1,16 @@
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
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: middleman-bootstrap-navbar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Manuel Meurer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-05-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: middleman-core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ description: Middleman Bootstrap Navbar
28
+ email: manuel.meurer@gmail.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - Gemfile
34
+ - LICENSE.txt
35
+ - README.md
36
+ - lib/middleman-bootstrap-navbar.rb
37
+ - lib/middleman_bootstrap_navbar.rb
38
+ - lib/middleman_bootstrap_navbar/helpers.rb
39
+ - lib/middleman_bootstrap_navbar/version.rb
40
+ - middleman-bootstrap-navbar.gemspec
41
+ - middleman_bootstrap_navbar.rb
42
+ homepage: ''
43
+ licenses:
44
+ - MIT
45
+ metadata: {}
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubyforge_project:
62
+ rubygems_version: 2.0.2
63
+ signing_key:
64
+ specification_version: 4
65
+ summary: Middleman Bootstrap Navbar
66
+ test_files: []