bootstrap_help 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +41 -0
- data/Rakefile +1 -0
- data/bootstrap_help.gemspec +27 -0
- data/lib/bootstrap_help.rb +8 -0
- data/lib/bootstrap_help/nav_helpers.rb +60 -0
- data/lib/bootstrap_help/railtie.rb +7 -0
- data/lib/bootstrap_help/version.rb +3 -0
- data/spec/bootstrap_helper/nav_helper_spec.rb +53 -0
- data/spec/spec_helper.rb +1 -0
- metadata +128 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a78583ac96350dc0cacde6ccc112ab5fe60f5eb9
|
4
|
+
data.tar.gz: 9740021cdcb456c8de06868f9235be530fa440a9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f451d062c0be2f351fb9f51c6e00abd103f40f1397fbf7fa70894bfaec0325023f4a8a5e84852b2a9848bf25039d3d33aaba3809a53644914c0ec9ff9db58149
|
7
|
+
data.tar.gz: 559f63bf403b3f8ba363cb1ca75f372ba7829e2b7f23e92ef608d6cfb566503f125523a1bcfdc13f3d07b30a7fc6e22033eda880be0f13a0526ded456b2840f5
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Josh Klina
|
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,41 @@
|
|
1
|
+
# BootstrapHelp
|
2
|
+
|
3
|
+
Bootstrap Help is a collection of Rails Helper methods that help build Bootstrap's HTML components.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'bootstrap_help'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install bootstrap_help
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
### Nav Helper
|
22
|
+
|
23
|
+
The Nav Helper helps you quickly build a fixed navigation bar in Bootstrap. For example:
|
24
|
+
|
25
|
+
`
|
26
|
+
= main_nav(brand: "My Awesome Company") do
|
27
|
+
= dropdown_menu "My Menu" do
|
28
|
+
= dropdown_item "Link1", "#"
|
29
|
+
= dropdown_item "Link2", "#"
|
30
|
+
= dropdown_item "Link3", "#"
|
31
|
+
= dropdown_divider
|
32
|
+
= dropdown_item "Link4", "#"
|
33
|
+
`
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
1. Fork it
|
38
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
39
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
40
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
41
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bootstrap_help/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bootstrap_help"
|
8
|
+
spec.version = BootstrapHelp::VERSION
|
9
|
+
spec.authors = ["Josh Klina"]
|
10
|
+
spec.email = ["joshua.klina@gmail.com"]
|
11
|
+
spec.description = %q{Helper methods for generating Twitter Bootstrap markup}
|
12
|
+
spec.summary = %q{Twitter Bootstrap makeup generators}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
|
25
|
+
spec.add_dependency('log4r', '>= 1.0.5')
|
26
|
+
spec.add_dependency('rails', '~> 4.0')
|
27
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module BootstrapHelp
|
2
|
+
module NavHelpers
|
3
|
+
include ActionView::Helpers::TagHelper
|
4
|
+
include ActionView::Helpers::TextHelper
|
5
|
+
include ActionView::Helpers::UrlHelper
|
6
|
+
include ActionView::Context
|
7
|
+
|
8
|
+
def main_nav(args)
|
9
|
+
brand = args.fetch(:brand, '')
|
10
|
+
brand_path = args.fetch(:brand_path, '/')
|
11
|
+
|
12
|
+
content_tag :div, class: 'navbar navbar-fixed-top navbar-inverse' do
|
13
|
+
content_tag :div, class: 'navbar-inner' do
|
14
|
+
content_tag :div, class: 'container-fluid' do
|
15
|
+
concat(responsive_menu_variation)
|
16
|
+
concat(link_to(brand, brand_path, class: 'brand'))
|
17
|
+
if block_given?
|
18
|
+
concat(content_tag(:div, class: 'nav') { yield })
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
#Dropdown Menus
|
26
|
+
def dropdown_menu(menu_name)
|
27
|
+
|
28
|
+
content_tag :li, :class => "dropdown" do
|
29
|
+
dropdown_link(menu_name) +
|
30
|
+
content_tag(:ul, :class => "dropdown-menu") { yield }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
def dropdown_item(value, url)
|
36
|
+
content_tag(:li, link_to(value, url))
|
37
|
+
end
|
38
|
+
|
39
|
+
def dropdown_divider
|
40
|
+
content_tag(:li, nil, :class => "divider")
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def dropdown_link(value)
|
47
|
+
content_tag :a, href: "#", class: "dropdown-toggle", "data-toggle" => "dropdown" do
|
48
|
+
(value + content_tag(:b, nil, :class => "caret")).html_safe
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def responsive_menu_variation
|
53
|
+
content_tag :button, :class => "btn btn-navbar", "data-toggle" => "collapse", "data-target" => ".nav-collapse" do
|
54
|
+
content_tag(:span, nil, :class => "icon-bar") +
|
55
|
+
content_tag(:span, nil, :class => "icon-bar") +
|
56
|
+
content_tag(:span, nil, :class => "icon-bar")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe BootstrapHelp::NavHelpers do
|
5
|
+
let(:helpers) do
|
6
|
+
class HelpersClass
|
7
|
+
include BootstrapHelp::NavHelpers
|
8
|
+
end
|
9
|
+
HelpersClass.new
|
10
|
+
end
|
11
|
+
let(:block) { Proc.new { 'block content' } }
|
12
|
+
|
13
|
+
describe '#main_nav' do
|
14
|
+
it 'accepts a brand' do
|
15
|
+
expect(helpers.main_nav(brand: 'Brand')).to include('Brand')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'accepts a path for the brand to link to' do
|
19
|
+
expect(helpers.main_nav(brand: 'Brand', brand_path: '/mypath')).
|
20
|
+
to include('/mypath')
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'accepts a block that can add content to the nav' do
|
24
|
+
expect { |b| helpers.main_nav(brand: 'Brand', &b) }.to yield_control
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'returns a bootstrap top nav bar' do
|
28
|
+
result = "<div class=\"navbar navbar-fixed-top navbar-inverse\"><div class=\"navbar-inner\"><div class=\"container-fluid\"><button class=\"btn btn-navbar\" data-target=\".nav-collapse\" data-toggle=\"collapse\"><span class=\"icon-bar\"></span><span class=\"icon-bar\"></span><span class=\"icon-bar\"></span></button><a class=\"brand\" href=\"/\">Brand</a><div class=\"nav\">block content</div></div></div></div>"
|
29
|
+
expect(helpers.main_nav(brand: 'Brand', &block)).to eq(result)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#dropdown_menu' do
|
34
|
+
it 'returns a bootstrap dropdown menu with the provided name' do
|
35
|
+
result = "<li class=\"dropdown\"><a class=\"dropdown-toggle\" data-toggle=\"dropdown\" href=\"#\">test<b class=\"caret\"></b></a><ul class=\"dropdown-menu\">block content</ul></li>"
|
36
|
+
expect(helpers.dropdown_menu('test', &block)).to eq(result)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#dropdown_item' do
|
41
|
+
it 'returns a bootstrap dropdown item with the provided value and url' do
|
42
|
+
result = "<li><a href=\"#\">test</a></li>"
|
43
|
+
expect(helpers.dropdown_item('test', '#')).to eq(result)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#dropdown_divider' do
|
48
|
+
it 'returns a bootstrap dropdown menu divider' do
|
49
|
+
result = "<li class=\"divider\"></li>"
|
50
|
+
expect(helpers.dropdown_divider).to eq(result)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bootstrap_help'
|
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bootstrap_help
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.11
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Josh Klina
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: log4r
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.0.5
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.0.5
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '4.0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '4.0'
|
83
|
+
description: Helper methods for generating Twitter Bootstrap markup
|
84
|
+
email:
|
85
|
+
- joshua.klina@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE.txt
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- bootstrap_help.gemspec
|
96
|
+
- lib/bootstrap_help.rb
|
97
|
+
- lib/bootstrap_help/nav_helpers.rb
|
98
|
+
- lib/bootstrap_help/railtie.rb
|
99
|
+
- lib/bootstrap_help/version.rb
|
100
|
+
- spec/bootstrap_helper/nav_helper_spec.rb
|
101
|
+
- spec/spec_helper.rb
|
102
|
+
homepage: ''
|
103
|
+
licenses:
|
104
|
+
- MIT
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - '>='
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - '>='
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.0.4
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: Twitter Bootstrap makeup generators
|
126
|
+
test_files:
|
127
|
+
- spec/bootstrap_helper/nav_helper_spec.rb
|
128
|
+
- spec/spec_helper.rb
|