bootstrap-sass-extras 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/Gemfile +4 -1
- data/Gemfile.lock +18 -4
- data/README.md +91 -37
- data/app/helpers/badge_helper.rb +13 -0
- data/app/helpers/bootstrap_flash_helper.rb +17 -15
- data/app/helpers/glyph_helper.rb +10 -7
- data/app/helpers/modal_helper.rb +19 -15
- data/app/helpers/twitter_breadcrumbs_helper.rb +3 -2
- data/app/views/bootstrap_sass_extras/_breadcrumbs.html.erb +6 -0
- data/bootstrap-sass-extras.gemspec +1 -0
- data/lib/bootstrap-sass-extras/breadcrumbs.rb +26 -9
- data/lib/bootstrap-sass-extras/engine.rb +1 -0
- data/lib/bootstrap-sass-extras/version.rb +1 -1
- data/lib/generators/bootstrap/install/templates/en.bootstrap.yml +1 -0
- data/lib/generators/bootstrap/layout/layout_generator.rb +1 -4
- data/lib/generators/bootstrap/layout/templates/layout.html.erb +32 -50
- data/lib/generators/bootstrap/layout/templates/layout.html.haml +20 -38
- data/lib/generators/bootstrap/layout/templates/layout.html.slim +20 -39
- data/lib/generators/bootstrap/themed/templates/_form.html.erb +10 -8
- data/lib/generators/bootstrap/themed/templates/_form.html.haml +8 -7
- data/lib/generators/bootstrap/themed/templates/_form.html.slim +8 -8
- data/lib/generators/bootstrap/themed/templates/index.html.erb +12 -10
- data/lib/generators/bootstrap/themed/templates/index.html.haml +8 -4
- data/lib/generators/bootstrap/themed/templates/index.html.slim +11 -9
- data/lib/generators/bootstrap/themed/templates/new.html.slim +1 -1
- data/lib/generators/bootstrap/themed/templates/show.html.erb +12 -10
- data/lib/generators/bootstrap/themed/templates/show.html.haml +13 -12
- data/lib/generators/bootstrap/themed/templates/show.html.slim +11 -10
- data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.erb +9 -7
- data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.haml +5 -4
- data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.slim +5 -5
- data/spec/dummy/db/schema.rb +16 -0
- data/spec/helpers/badge_helper_spec.rb +16 -0
- data/spec/helpers/bootstrap_flash_helper_spec.rb +54 -39
- data/spec/helpers/glyph_helper_spec.rb +15 -0
- data/spec/helpers/twitter_breadcrumbs_helper_spec.rb +153 -0
- metadata +13 -5
- data/app/views/twitter-bootstrap/_breadcrumbs.html.erb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2fd823951114762be02d3bb4b0402cf542e6124
|
4
|
+
data.tar.gz: 6e25e239409425d864a4eb541f793ba0c2889080
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cf7c080d826188a1efaa4126a6d9b1552acc418336d8400da337b45738075973db00470a43fb68797be2148cecb18eb607992bed4ff35ea0c8e4727f45f7501
|
7
|
+
data.tar.gz: be5b543f525861c238c60285dc6322764c1f052917894e78eef8d64edd324013fd2004c5db61da9e985d993bcc051a029164dbdd2fa98cee1725beecd48f2aaa
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
##
|
3
|
+
## Release 0.0.6
|
4
|
+
|
5
|
+
* Update to bootstrap 3.0
|
6
|
+
* Add a `badge(badge_count)` helper by [@pdobb][]
|
7
|
+
* Clean up codes by [@pdobb][]
|
4
8
|
|
5
9
|
## Release 0.0.5
|
6
10
|
|
@@ -26,4 +30,5 @@
|
|
26
30
|
|
27
31
|
|
28
32
|
[@jonwaghorn]: https://github.com/jonwaghorn
|
33
|
+
[@pdobb]: https://github.com/pdobb
|
29
34
|
[@dabit]: https://github.com/dabit
|
data/Gemfile
CHANGED
@@ -3,4 +3,7 @@ source "http://rubygems.org"
|
|
3
3
|
# Declare your gem's dependencies in bootstrap-sass-extras.gemspec.
|
4
4
|
# Bundler will treat runtime dependencies like base dependencies, and
|
5
5
|
# development dependencies will be added by default to the :development group.
|
6
|
-
gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem 'byebug'
|
9
|
+
gem 'pry'
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bootstrap-sass-extras (0.0.
|
4
|
+
bootstrap-sass-extras (0.0.6)
|
5
5
|
rails (>= 3.1.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -34,8 +34,14 @@ GEM
|
|
34
34
|
activesupport (3.2.13)
|
35
35
|
i18n (= 0.6.1)
|
36
36
|
multi_json (~> 1.0)
|
37
|
-
arel (3.0.
|
37
|
+
arel (3.0.3)
|
38
38
|
builder (3.0.4)
|
39
|
+
byebug (2.5.0)
|
40
|
+
columnize (~> 0.3.6)
|
41
|
+
debugger-linecache (~> 1.2.0)
|
42
|
+
coderay (1.1.0)
|
43
|
+
columnize (0.3.6)
|
44
|
+
debugger-linecache (1.2.0)
|
39
45
|
diff-lcs (1.1.3)
|
40
46
|
erubis (2.7.0)
|
41
47
|
hike (1.2.1)
|
@@ -45,9 +51,14 @@ GEM
|
|
45
51
|
mail (2.5.4)
|
46
52
|
mime-types (~> 1.16)
|
47
53
|
treetop (~> 1.4.8)
|
48
|
-
|
54
|
+
method_source (0.8.2)
|
55
|
+
mime-types (1.25.1)
|
49
56
|
multi_json (1.7.2)
|
50
57
|
polyglot (0.3.3)
|
58
|
+
pry (0.9.12.4)
|
59
|
+
coderay (~> 1.0)
|
60
|
+
method_source (~> 0.8)
|
61
|
+
slop (~> 3.4)
|
51
62
|
rack (1.4.5)
|
52
63
|
rack-cache (1.2)
|
53
64
|
rack (>= 0.4)
|
@@ -84,6 +95,7 @@ GEM
|
|
84
95
|
rspec-core (~> 2.12.0)
|
85
96
|
rspec-expectations (~> 2.12.0)
|
86
97
|
rspec-mocks (~> 2.12.0)
|
98
|
+
slop (3.4.7)
|
87
99
|
sprockets (2.2.2)
|
88
100
|
hike (~> 1.2)
|
89
101
|
multi_json (~> 1.0)
|
@@ -95,12 +107,14 @@ GEM
|
|
95
107
|
treetop (1.4.15)
|
96
108
|
polyglot
|
97
109
|
polyglot (>= 0.3.1)
|
98
|
-
tzinfo (0.3.
|
110
|
+
tzinfo (0.3.38)
|
99
111
|
|
100
112
|
PLATFORMS
|
101
113
|
ruby
|
102
114
|
|
103
115
|
DEPENDENCIES
|
104
116
|
bootstrap-sass-extras!
|
117
|
+
byebug
|
118
|
+
pry
|
105
119
|
rspec-rails
|
106
120
|
sqlite3
|
data/README.md
CHANGED
@@ -5,6 +5,10 @@
|
|
5
5
|
[1]: https://github.com/thomas-mcdonald/bootstrap-sass
|
6
6
|
[2]: https://github.com/seyhunak/twitter-bootstrap-rails
|
7
7
|
|
8
|
+
## Note
|
9
|
+
|
10
|
+
From version 0.0.6, only support bootstrap 3. If you want to use bootstrap 2, please use version 0.0.5.
|
11
|
+
|
8
12
|
## Installation
|
9
13
|
|
10
14
|
Add this line to your application's Gemfile:
|
@@ -28,46 +32,47 @@ Generate locale
|
|
28
32
|
|
29
33
|
Usage:
|
30
34
|
|
31
|
-
|
32
|
-
|
33
|
-
|
35
|
+
```ruby
|
36
|
+
rails g bootstrap:install
|
37
|
+
```
|
34
38
|
|
35
39
|
Layout (generates Twitter Bootstrap compatible layout) - (Haml and Slim supported)
|
36
40
|
|
37
41
|
|
38
42
|
Usage:
|
39
43
|
|
40
|
-
|
41
|
-
|
42
|
-
|
44
|
+
```ruby
|
45
|
+
rails g bootstrap:layout [LAYOUT_NAME] [*fixed or fluid]
|
46
|
+
```
|
43
47
|
|
44
48
|
Example of a fixed layout:
|
45
49
|
|
46
|
-
|
47
|
-
|
48
|
-
|
50
|
+
```ruby
|
51
|
+
rails g bootstrap:layout application fixed
|
52
|
+
```
|
49
53
|
|
50
54
|
Example of a responsive layout:
|
51
55
|
|
52
|
-
|
53
|
-
|
54
|
-
|
56
|
+
```ruby
|
57
|
+
rails g bootstrap:layout application fluid
|
58
|
+
```
|
55
59
|
|
56
60
|
Themed (generates Twitter Bootstrap compatible scaffold views.) - (Haml and Slim supported)
|
57
61
|
|
58
62
|
|
59
63
|
Usage:
|
60
64
|
|
61
|
-
|
62
|
-
|
63
|
-
|
65
|
+
```ruby
|
66
|
+
rails g bootstrap:themed [RESOURCE_NAME]
|
67
|
+
```
|
64
68
|
|
65
69
|
Example:
|
66
70
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
+
```ruby
|
72
|
+
rails g scaffold Post title:string description:text
|
73
|
+
rake db:migrate
|
74
|
+
rails g bootstrap:themed Posts
|
75
|
+
```
|
71
76
|
|
72
77
|
Notice the plural usage of the resource to generate bootstrap:themed.
|
73
78
|
|
@@ -77,30 +82,36 @@ Notice the plural usage of the resource to generate bootstrap:themed.
|
|
77
82
|
Add the viewport meta helper `<%= viewport_meta_tag %>` to your layout
|
78
83
|
(built-in with layout generator) to render the required meta tag for Bootstrap:
|
79
84
|
|
80
|
-
|
85
|
+
```html
|
86
|
+
<meta content="width=device-width,initial-scale=1.0" name="viewport" />
|
87
|
+
```
|
81
88
|
|
82
89
|
You can change the content value by passing a hash as an argument:
|
83
90
|
|
84
|
-
|
91
|
+
```erb
|
92
|
+
<%= viewport_meta_tag(:maximum_scale => "1.0") %>
|
93
|
+
```
|
85
94
|
|
86
95
|
Renders:
|
87
96
|
|
88
|
-
|
97
|
+
```html
|
98
|
+
<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0" name="viewport" />
|
99
|
+
```
|
89
100
|
|
90
101
|
### Flash helper
|
91
102
|
Add flash helper `<%= bootstrap_flash %>` to your layout (built-in with layout generator)
|
92
103
|
|
93
104
|
### Modal Helper
|
94
105
|
You can create modals easily using the following example. The header, body, and footer all accept content_tag or plain html.
|
95
|
-
The href of the button to launch the modal must
|
96
|
-
|
97
|
-
```ruby
|
98
|
-
<%= content_tag :a, "Modal", :href => "#modal", :class => 'btn', :data => {:toggle => modal'} %>
|
106
|
+
The href of the button to launch the modal must match the id of the modal dialog.
|
99
107
|
|
108
|
+
```erb
|
109
|
+
<%= modal_toggle 'Modal', dialog: '#modal'%>
|
100
110
|
<%= modal_dialog :id => "modal",
|
101
|
-
:header => { :show_close => true, :
|
102
|
-
|
103
|
-
|
111
|
+
:header => { :show_close => true, :title => 'Modal header' },
|
112
|
+
:body => 'This is the body',
|
113
|
+
:footer => content_tag(:button, 'Save', :class => 'btn btn-primary')
|
114
|
+
%>
|
104
115
|
```
|
105
116
|
|
106
117
|
### Breadcrumbs Helpers
|
@@ -108,8 +119,6 @@ The href of the button to launch the modal must matche the id of the modal dialo
|
|
108
119
|
*Notice* If your application is using [breadcrumbs-on-rails](https://github.com/weppos/breadcrumbs_on_rails) you will have a namespace collision with the add_breadcrumb method.
|
109
120
|
You do not need to use these breadcrumb gems since this gem provides the same functionality out of the box without the additional dependency.
|
110
121
|
|
111
|
-
Add breadcrumbs helper `<%= render_breadcrumbs %>` to your layout.
|
112
|
-
|
113
122
|
```ruby
|
114
123
|
class ApplicationController
|
115
124
|
add_breadcrumb :index, :root_path
|
@@ -126,18 +135,63 @@ class ExamplesController < ApplicationController
|
|
126
135
|
def show
|
127
136
|
@example = Example.find params[:id]
|
128
137
|
add_breadcrumb @example.name, example_path(@example)
|
129
|
-
|
138
|
+
add_breadcrumb :show, example_path(@example)
|
130
139
|
end
|
131
140
|
end
|
132
141
|
```
|
133
142
|
|
134
|
-
|
143
|
+
Finally, add the `<%= render_breadcrumbs %>` helper to your layout.
|
144
|
+
|
145
|
+
You can wrap the breadcrumbs in an HTML element by using the block form like this:
|
146
|
+
|
147
|
+
```erb
|
148
|
+
<%= render_breadcrumbs do |breadcrumbs| %>
|
149
|
+
<%= content_tag(:div, breadcrumbs, class: "container") %>
|
150
|
+
<% end %>
|
151
|
+
|
152
|
+
# =>
|
153
|
+
# <div class="container">
|
154
|
+
# <ol class="breadcrumb">
|
155
|
+
# <li> ... </li>
|
156
|
+
# <li class="active"> ... </li>
|
157
|
+
# </ol>
|
158
|
+
# </div>
|
159
|
+
```
|
160
|
+
|
161
|
+
There are also a few interface methods available for working with the internal breadcrumbs hashes. The following methods are available in controllers and views.
|
162
|
+
|
163
|
+
```ruby
|
164
|
+
# Given previously added breadcrumbs:
|
165
|
+
|
166
|
+
breadcrumbs?
|
167
|
+
# => true
|
168
|
+
|
169
|
+
breadcrumb_names
|
170
|
+
# => ["example", "show"]
|
171
|
+
```
|
172
|
+
|
173
|
+
The following method is available to controllers only.
|
135
174
|
|
136
175
|
```ruby
|
137
|
-
|
138
|
-
# =>
|
139
|
-
|
140
|
-
|
176
|
+
clear_breadcrumbs
|
177
|
+
# => nil
|
178
|
+
```
|
179
|
+
|
180
|
+
### Glyph Helper
|
181
|
+
|
182
|
+
```erb
|
183
|
+
<%= glyph(:star) %>
|
184
|
+
# => <span class="glyphicon glyphicon-star"></span>
|
185
|
+
|
186
|
+
<%= glyph(:star, :paperclip) %>
|
187
|
+
# => <span class="glyphicon glyphicon-star"></span><span class="glyphicon glyphicon-paperclip"></span>
|
188
|
+
```
|
189
|
+
|
190
|
+
### Badge Helper
|
191
|
+
|
192
|
+
```erb
|
193
|
+
<%= badge(2) %>
|
194
|
+
# => <span class="badge">2</span>
|
141
195
|
```
|
142
196
|
|
143
197
|
## Contributing
|
@@ -1,23 +1,25 @@
|
|
1
1
|
module BootstrapFlashHelper
|
2
|
-
|
2
|
+
ALERT_TYPES_MAP = {
|
3
|
+
notice: :success,
|
4
|
+
alert: :danger,
|
5
|
+
error: :danger,
|
6
|
+
info: :info,
|
7
|
+
warning: :warning
|
8
|
+
}
|
3
9
|
|
4
10
|
def bootstrap_flash
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
next unless ALERT_TYPES.include?(type)
|
11
|
-
output += flash_container(type, message)
|
12
|
-
end
|
13
|
-
|
14
|
-
raw(output)
|
11
|
+
safe_join(flash.each_with_object([]) do |(type, message), messages|
|
12
|
+
next if message.blank? || !message.respond_to?(:to_str)
|
13
|
+
type = ALERT_TYPES_MAP.fetch(type.to_sym, type)
|
14
|
+
messages << flash_container(type, message)
|
15
|
+
end, "\n").presence
|
15
16
|
end
|
16
17
|
|
17
18
|
def flash_container(type, message)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
content_tag :div, class: "alert alert-#{type} alert-dismissable" do
|
20
|
+
button_tag type: "button", class: "close", data: { dismiss: "alert" } do
|
21
|
+
"×".html_safe
|
22
|
+
end.safe_concat(message)
|
23
|
+
end
|
22
24
|
end
|
23
25
|
end
|
data/app/helpers/glyph_helper.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
module GlyphHelper
|
2
2
|
# ==== Examples
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
3
|
+
#
|
4
|
+
# glyph(:search)
|
5
|
+
# => <span class="glyphicon glyphicon-search"></span>
|
6
|
+
# glyph(:search, :paperclip)
|
7
|
+
# => <span class="glyphicon glyphicon-search"></span><span class="glyphicon glyphicon-paperclip"></span>
|
7
8
|
|
8
|
-
def glyph(*
|
9
|
-
|
9
|
+
def glyph(*glyphicon_names)
|
10
|
+
safe_join(glyphicon_names.map do |name|
|
11
|
+
content_tag :span, nil, class: "glyphicon glyphicon-#{name.to_s.parameterize}"
|
12
|
+
end, "")
|
10
13
|
end
|
11
|
-
end
|
14
|
+
end
|
data/app/helpers/modal_helper.rb
CHANGED
@@ -2,21 +2,26 @@ module ModalHelper
|
|
2
2
|
|
3
3
|
#modals have a header, a body, a footer for options.
|
4
4
|
def modal_dialog(options = {}, &block)
|
5
|
-
content_tag :div, :id => options[:id], :class => "
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
content_tag :div, :id => options[:id], :class => "modal fade", :role => "dialog" do
|
6
|
+
content_tag :div, class: 'modal-dialog' do
|
7
|
+
content_tag :div, class: 'modal-content' do
|
8
|
+
modal_header(options[:header]) +
|
9
|
+
modal_body(options[:body]) +
|
10
|
+
modal_footer(options[:footer])
|
11
|
+
end
|
12
|
+
end
|
9
13
|
end
|
10
14
|
end
|
11
15
|
|
12
16
|
def modal_header(options = {}, &block)
|
17
|
+
dismiss = options.delete(:dismiss) || 'modal'
|
13
18
|
content_tag :div, :class => 'modal-header' do
|
14
|
-
if options[:show_close]
|
15
|
-
close_button(
|
16
|
-
content_tag(:
|
19
|
+
if options[:show_close]
|
20
|
+
close_button(dismiss) +
|
21
|
+
content_tag(:h4, options[:title], :class => 'modal-title', &block)
|
17
22
|
else
|
18
|
-
content_tag(:
|
19
|
-
end
|
23
|
+
content_tag(:h4, options[:title], :class => 'modal-title', &block)
|
24
|
+
end
|
20
25
|
end
|
21
26
|
end
|
22
27
|
|
@@ -29,26 +34,25 @@ module ModalHelper
|
|
29
34
|
end
|
30
35
|
|
31
36
|
def close_button(dismiss)
|
32
|
-
|
33
|
-
raw("<button class=\"close\" data-dismiss=\"#{dismiss}\">×</button>")
|
37
|
+
content_tag :button, "×".html_safe, :class => "close", "data-dismiss" => "#{dismiss}", "aria-hidden" => "true"
|
34
38
|
end
|
35
39
|
|
36
40
|
def modal_toggle(content_or_options = nil, options = {}, &block)
|
37
41
|
if block_given?
|
38
42
|
options = content_or_options if content_or_options.is_a?(Hash)
|
39
|
-
default_options = { :class => 'btn', "data-toggle" => "modal", "
|
43
|
+
default_options = { :class => 'btn', "data-toggle" => "modal", "data-target" => options.delete[:dialog] }.merge(options)
|
40
44
|
|
41
45
|
content_tag :a, nil, default_options, true, &block
|
42
46
|
else
|
43
|
-
default_options = { :class => 'btn', "data-toggle" => "modal", "
|
47
|
+
default_options = { :class => 'btn', "data-toggle" => "modal", "data-target" => options.delete(:dialog) }.merge(options)
|
44
48
|
content_tag :a, content_or_options, default_options, true
|
45
49
|
end
|
46
50
|
end
|
47
51
|
|
48
52
|
def modal_cancel_button content, options = {}
|
49
|
-
default_options = { :class => "btn
|
53
|
+
default_options = { :class => "btn btn-default", :data => { dismiss: "modal" } }
|
50
54
|
|
51
|
-
content_tag_string
|
55
|
+
content_tag_string :button, content, default_options.merge(options)
|
52
56
|
end
|
53
57
|
|
54
58
|
end
|