twitter-bootstrap-rails 5.0.0 → 5.1.0

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.

Potentially problematic release.


This version of twitter-bootstrap-rails might be problematic. Click here for more details.

data/README.md CHANGED
@@ -1,710 +1,638 @@
1
- # Twitter Bootstrap for Rails 6, 5 and 4 Asset Pipeline
2
-
3
- Bootstrap is a toolkit from Twitter designed to kickstart development of web apps and sites. It includes base CSS and HTML for typography, forms, buttons, tables, grids, navigation, and more.
4
-
5
- twitter-bootstrap-rails project integrates Bootstrap CSS toolkit for Rails Asset Pipeline (Rails 6, Rails 5 and Rails 3.x versions are supported)
6
-
7
- [![Gem Version](https://badge.fury.io/rb/twitter-bootstrap-rails.svg)](http://badge.fury.io/rb/twitter-bootstrap-rails)
8
- [![Dependency Status](https://gemnasium.com/seyhunak/twitter-bootstrap-rails.svg?travis)](https://gemnasium.com/seyhunak/twitter-bootstrap-rails?travis)
9
- [![Code Climate](https://codeclimate.com/github/seyhunak/twitter-bootstrap-rails/badges/gpa.svg)](https://codeclimate.com/github/seyhunak/twitter-bootstrap-rails?branch=master)
10
- [![Coverage Status](https://coveralls.io/repos/seyhunak/twitter-bootstrap-rails/badge.svg?branch=master)](https://coveralls.io/repos/seyhunak/twitter-bootstrap-rails/badge.svg?branch=master)
11
- [![GitHub stars](https://img.shields.io/github/stars/seyhunak/twitter-bootstrap-rails.svg)](https://github.com/seyhunak/twitter-bootstrap-rails/stargazers)
12
- [![GitHub forks](https://img.shields.io/github/forks/seyhunak/twitter-bootstrap-rails.svg)](https://github.com/seyhunak/twitter-bootstrap-rails/network)
13
- [![GitHub issues](https://img.shields.io/github/issues/seyhunak/twitter-bootstrap-rails.svg)](https://github.com/seyhunak/twitter-bootstrap-rails/issues)
14
-
15
- [![OpenCollective](https://opencollective.com/twitter-bootstrap-rails/backers/badge.svg)](#backers)
16
- [![OpenCollective](https://opencollective.com/twitter-bootstrap-rails/sponsors/badge.svg)](#sponsors)
17
-
18
- ## Screencasts
19
- #### Installing twitter-bootstrap-rails, generators, usage and more
20
-
21
- Screencasts provided by <a href="http://railscasts.com">RailsCasts</a> (Ryan Bates)
22
-
23
- [Twitter Bootstrap Basics](http://railscasts.com/episodes/328-twitter-bootstrap-basics "Twitter Bootstrap Basics")
24
- in this episode you will learn how to include Bootstrap into Rails application with the twitter-bootstrap-rails gem.
25
-
26
- [More on Twitter Bootstrap](http://railscasts.com/episodes/329-more-on-twitter-bootstrap "More on Twitter Bootstrap")
27
- in this episode continues on the Bootstrap project showing how to display flash messages, add form validations with SimpleForm, customise layout with variables, and switch to using Sass.
28
- (Note: This episode is pro episode)
29
-
30
- ## Installing the Gem
31
-
32
- The [Twitter Bootstrap Rails gem](http://rubygems.org/gems/twitter-bootstrap-rails) can provide the Bootstrap stylesheets in two ways.
33
-
34
- The plain CSS way is how Bootstrap is provided on [the official website](http://twbs.github.io/bootstrap/).
35
-
36
- The [Less](http://lesscss.org/) way provides more customisation options, like changing theme colors and provides useful Less mixins for your code, but requires the
37
- Less gem and the Ruby Racer Javascript runtime (not available on Microsoft Windows).
38
-
39
- ### Installing the Less stylesheets
40
-
41
- To use Less stylesheets, you'll need the [less-rails gem](http://rubygems.org/gems/less-rails), and one of [JavaScript runtimes supported by CommonJS](https://github.com/cowboyd/commonjs.rb#supported-runtimes).
42
-
43
- Include these lines in the Gemfile to install the gems from [RubyGems.org](http://rubygems.org):
44
-
45
- ```ruby
46
- gem "therubyracer"
47
- gem "less-rails" #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS
48
- gem "twitter-bootstrap-rails"
49
- ```
50
-
51
- or you can install from latest build;
52
-
53
- ```ruby
54
- gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git'
55
- ```
56
-
57
- Then run `bundle install` from the command line:
58
-
59
- bundle install
60
-
61
- Then run the bootstrap generator to add Bootstrap includes into your assets:
62
-
63
- rails generate bootstrap:install less
64
-
65
- If you need to skip coffeescript replacement into app generators, use:
66
-
67
- rails generate bootstrap:install --no-coffeescript
68
-
69
- ### Installing the CSS stylesheets
70
-
71
- If you don't need to customize the stylesheets using Less, the only gem you need is the `twitter-bootstrap-rails` gem:
72
-
73
- ```ruby
74
- gem "twitter-bootstrap-rails"
75
- ```
76
-
77
- After running `bundle install`, run the generator:
78
-
79
- rails generate bootstrap:install static
80
-
81
- If your Rails server is running, make sure to restart it.
82
-
83
- ## Generating layouts and views
84
-
85
- You can run following generators to get started with Bootstrap quickly.
86
-
87
-
88
- Layout (generates Bootstrap compatible layout) - (Haml and Slim supported)
89
-
90
-
91
- Usage:
92
-
93
-
94
- rails g bootstrap:layout [LAYOUT_NAME]
95
-
96
-
97
- Themed (generates Bootstrap compatible scaffold views.) - (Haml and Slim supported)
98
-
99
-
100
- Usage:
101
-
102
-
103
- rails g bootstrap:themed [RESOURCE_NAME]
104
-
105
-
106
- Example:
107
-
108
-
109
- rails g scaffold Post title:string description:text
110
- rake db:migrate
111
- rails g bootstrap:themed Posts
112
-
113
- Notice the plural usage of the resource to generate bootstrap:themed.
114
-
115
- ## Using with Less
116
-
117
- Bootstrap was built with Preboot, an open-source pack of mixins and variables to be used in conjunction with Less, a CSS preprocessor for faster and easier web development.
118
-
119
- ## Using stylesheets with Less
120
-
121
- You have to require Bootstrap LESS (bootstrap_and_overrides.css.less) in your application.css
122
-
123
- ```css
124
- /*
125
- *= require bootstrap_and_overrides
126
- */
127
-
128
- /* Your stylesheets goes here... */
129
- ```
130
-
131
- To use individual components from bootstrap, your bootstrap_and_overrides.less could look like this:
132
-
133
- ```less
134
- // Core variables and mixins
135
- @import "twitter/bootstrap/variables.less";
136
- @import "twitter/bootstrap/mixins.less";
137
-
138
- // Reset and dependencies
139
- @import "twitter/bootstrap/normalize.less";
140
- @import "twitter/bootstrap/print.less";
141
- //@import "twitter/bootstrap/glyphicons.less"; // Excludes glyphicons
142
-
143
- // Core CSS
144
- @import "twitter/bootstrap/scaffolding.less";
145
- @import "twitter/bootstrap/type.less";
146
- @import "twitter/bootstrap/code.less";
147
- @import "twitter/bootstrap/grid.less";
148
- @import "twitter/bootstrap/tables.less";
149
- @import "twitter/bootstrap/forms.less";
150
- @import "twitter/bootstrap/buttons.less";
151
-
152
- // Components
153
- @import "twitter/bootstrap/component-animations.less";
154
- @import "twitter/bootstrap/dropdowns.less";
155
- @import "twitter/bootstrap/button-groups.less";
156
- @import "twitter/bootstrap/input-groups.less";
157
- @import "twitter/bootstrap/navs.less";
158
- @import "twitter/bootstrap/navbar.less";
159
- @import "twitter/bootstrap/breadcrumbs.less";
160
- @import "twitter/bootstrap/pagination.less";
161
- @import "twitter/bootstrap/pager.less";
162
- @import "twitter/bootstrap/labels.less";
163
- @import "twitter/bootstrap/badges.less";
164
- @import "twitter/bootstrap/jumbotron.less";
165
- @import "twitter/bootstrap/thumbnails.less";
166
- @import "twitter/bootstrap/alerts.less";
167
- @import "twitter/bootstrap/progress-bars.less";
168
- @import "twitter/bootstrap/media.less";
169
- @import "twitter/bootstrap/list-group.less";
170
- @import "twitter/bootstrap/panels.less";
171
- @import "twitter/bootstrap/responsive-embed.less";
172
- @import "twitter/bootstrap/wells.less";
173
- @import "twitter/bootstrap/close.less";
174
-
175
- // Components w/ JavaScript
176
- @import "twitter/bootstrap/modals.less";
177
- @import "twitter/bootstrap/tooltip.less";
178
- @import "twitter/bootstrap/popovers.less";
179
- @import "twitter/bootstrap/carousel.less";
180
-
181
- // Utility classes
182
- @import "twitter/bootstrap/utilities.less";
183
- @import "twitter/bootstrap/responsive-utilities.less";
184
- ```
185
-
186
- If you'd like to alter Bootstrap's own variables, or define your LESS
187
- styles inheriting Bootstrap's mixins, you can do so inside bootstrap_and_overrides.css.less:
188
-
189
-
190
- ```less
191
- @link-color: #ff0000;
192
- ```
193
-
194
- ### SASS
195
-
196
- If you are using SASS to compile your application.css (e.g. your manifest file is application.css.sass or application.css.scss) you may get this:
197
-
198
- ```
199
- Invalid CSS after "*": expected "{", was "= require twitt..."
200
- (in app/assets/stylesheets/application.css)
201
- (sass)
202
- ```
203
-
204
- If this is the case, you **must** use @import instead of `*=` in your manifest file, or don't compile your manifest with SASS.
205
-
206
- ### Icons
207
-
208
- By default, this gem (when using less generator) won't enable standard Bootstraps's Glyphicons.
209
-
210
- If you would like to restore the default Glyphicons, inside the generated `bootstrap_and_overrides.css.less` uncomment these lines:
211
-
212
- ```less
213
- // Glyphicons are not required by default, uncomment the following lines to enable them.
214
- @glyphiconsEotPath: font-url("glyphicons-halflings-regular.eot");
215
- @glyphiconsEotPath_iefix: font-url("glyphicons-halflings-regular.eot?#iefix");
216
- @glyphiconsWoffPath: font-url("glyphicons-halflings-regular.woff");
217
- @glyphiconsTtfPath: font-url("glyphicons-halflings-regular.ttf");
218
- @glyphiconsSvgPath: font-url("glyphicons-halflings-regular.svg#glyphicons_halflingsregular");
219
-
220
- @import "twitter/bootstrap/glyphicons.less";
221
- ```
222
-
223
- This gem was used to bundle the excellent [Font-Awesome](http://fortawesome.github.io/Font-Awesome/) library.
224
- However that was another maintenance effort that is not worth to do here.
225
-
226
- For Rails projects that need it there is the [font-awesome-rails gem](https://github.com/bokmann/font-awesome-rails) that
227
- provides same functionality that this gems was used to provide and it also have some other interesting features (e.g. view helpers).
228
-
229
- ## Using JavaScript
230
-
231
- Require Bootstrap JS (bootstrap.js) in your application.js
232
-
233
- ```js
234
- //= require twitter/bootstrap
235
-
236
- $(function(){
237
- /* Your JavaScript goes here... */
238
- });
239
- ```
240
-
241
- If you want to customize what is loaded, your application.js would look something like this
242
-
243
- ```js
244
- #= require jquery
245
- #= require jquery_ujs
246
- #= require twitter/bootstrap/transition
247
- #= require twitter/bootstrap/alert
248
- #= require twitter/bootstrap/modal
249
- #= require twitter/bootstrap/button
250
- #= require twitter/bootstrap/collapse
251
- ```
252
-
253
- ...and so on for each bootstrap js component.
254
-
255
- ## Using CoffeeScript (optionally)
256
-
257
- Using Bootstrap with the CoffeeScript is easy.
258
- twitter-bootstrap-rails generates a "bootstrap.js.coffee" file for you
259
- to /app/assets/javascripts/ folder.
260
-
261
- ```coffee
262
- jQuery ->
263
- $("a[rel~=popover], .has-popover").popover()
264
- $("a[rel~=tooltip], .has-tooltip").tooltip()
265
- ```
266
-
267
- ## Using Helpers
268
-
269
- ### Modal Helper
270
- You can create modals easily using the following example. The header, body, and footer all accept content_tag or plain html.
271
- The href of the button to launch the modal must match the id of the modal dialog. It also accepts a block for the header, body, and footer. If you are getting a complaint about the modal_helper unable to merge a hash it is due to this.
272
-
273
- ```erb
274
- <%= content_tag :a, "Modal", href: "#modal", class: 'btn', data: {toggle: 'modal'} %>
275
-
276
- <%= modal_dialog id: "modal",
277
- header: { show_close: true, dismiss: 'modal', title: 'Modal header' },
278
- body: { content: 'This is the body' },
279
- footer: { content: content_tag(:button, 'Save', class: 'btn') } %>
280
-
281
- ```
282
-
283
- ### Navbar Helper
284
- It should let you write things like:
285
-
286
- ```erb
287
- <%= nav_bar fixed: :top, brand: "Fashionable Clicheizr 2.0", responsive: true do %>
288
- <%= menu_group do %>
289
- <%= menu_item "Home", root_path %>
290
- <%= menu_divider %>
291
- <%= drop_down "Products" do %>
292
- <%= menu_item "Things you can't afford", expensive_products_path %>
293
- <%= menu_item "Things that won't suit you anyway", harem_pants_path %>
294
- <%= menu_item "Things you're not even cool enough to buy anyway", hipster_products_path %>
295
- <% if current_user.lives_in_hackney? %>
296
- <%= menu_item "Bikes", fixed_wheel_bikes_path %>
297
- <% end %>
298
- <% end %>
299
- <%= menu_item "About Us", about_us_path %>
300
- <%= menu_item "Contact", contact_path %>
301
- <% end %>
302
- <%= menu_group pull: :right do %>
303
- <% if current_user %>
304
- <%= menu_item "Log Out", log_out_path %>
305
- <% else %>
306
- <%= form_for @user, url: session_path(:user), html => {class: "navbar-form pull-right"} do |f| -%>
307
- <p><%= f.text_field :email %></p>
308
- <p><%= f.password_field :password %></p>
309
- <p><%= f.submit "Sign in" %></p>
310
- <% end -%>
311
- <% end %>
312
- <% end %>
313
- <% end %>
314
- ```
315
-
316
- ### Navbar scaffolding
317
-
318
- In your view file (most likely application.html.erb) to get a basic navbar set up you need to do this:
319
-
320
- ```erb
321
- <%= nav_bar %>
322
- ```
323
-
324
- Which will render:
325
-
326
- ```html
327
- <div class="navbar">
328
- <div class="container">
329
- </div>
330
- </div>
331
- ```
332
-
333
- ### Fixed navbar
334
-
335
- If you want the navbar to stick to the top of the screen, pass in the option like this:
336
-
337
- ```erb
338
- <%= nav_bar fixed: :top %>
339
- ```
340
-
341
- To render:
342
-
343
- ```html
344
- <div class="navbar navbar-fixed-top">
345
- <div class="container">
346
- </div>
347
- </div>
348
- ```
349
-
350
- ### Static navbar
351
-
352
- If you want a full-width navbar that scrolls away with the page, pass in the option like this:
353
-
354
- ```erb
355
- <%= nav_bar static: :top %>
356
- ```
357
-
358
- To render:
359
-
360
- ```html
361
- <div class="navbar navbar-static-top">
362
- <div class="container">
363
- </div>
364
- </div>
365
- ```
366
-
367
- ### Brand name
368
-
369
- Add the name of your site on the left hand edge of the navbar. By default, it will link to root_url. Passing a brand_link option will set the url to whatever you want.
370
-
371
- ```erb
372
- <%= nav_bar brand: "We're sooo web 2.0alizr", brand_link: account_dashboard_path %>
373
- ```
374
-
375
- Which will render:
376
-
377
- ```html
378
- <div class="navbar">
379
- <div class="container">
380
- <a class="navbar-brand" href="/accounts/dashboard">
381
- We're sooo web 2.0alizr
382
- </a>
383
- </div>
384
- </div>
385
- ```
386
-
387
- ### Optional responsive variation
388
-
389
- If you want the responsive version of the navbar to work (One that shrinks down on mobile devices etc.), you need to pass this option:
390
-
391
- ```erb
392
- <%= nav_bar responsive: true %>
393
- ```
394
-
395
- Which renders the html quite differently:
396
-
397
- ```html
398
- <div class="navbar">
399
- <div class="container">
400
- <!-- .navbar-toggle is used as the toggle for collapsed navbar content -->
401
- <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
402
- <span class="icon-bar"></span>
403
- <span class="icon-bar"></span>
404
- <span class="icon-bar"></span>
405
- </button>
406
- <!-- Everything in here gets hidden at 940px or less -->
407
- <div class="navbar-collapse collapse">
408
- <!-- menu items gets rendered here instead -->
409
- </div>
410
- </div>
411
- </div>
412
- ```
413
-
414
- ### Nav links
415
-
416
- This is the 'meat' of the code where you define your menu items.
417
-
418
- You can group menu items in theoretical boxes which you can apply logic to - e.g. show different collections for logged in users/logged out users, or simply right align a group.
419
-
420
- The active menu item will be inferred from the link for now.
421
-
422
- The important methods here are menu_group and menu_item.
423
-
424
- menu_group only takes one argument - :pull - this moves the group left or right when passed :left or :right.
425
-
426
- menu_item generates a link wrapped in an li tag. It takes two arguments and an options hash. The first argument is the name (the text that will appear in the menu), and the path (which defaults to "#" if left blank). The rest of the options are passed straight through to the link_to helper, so that you can add classes, ids, methods or data tags etc.
427
-
428
- ```erb
429
- <%= nav_bar fixed: :top, brand: "Ninety Ten" do %>
430
- <%= menu_group do %>
431
- <%= menu_item "Home", root_path %>
432
- <%= menu_item "About Us", about_us_path %>
433
- <%= menu_item "Contact", contact_path %>
434
- <% end %>
435
- <% if current_user %>
436
- <%= menu_item "Log Out", log_out_path %>
437
- <% else %>
438
- <%= menu_group pull: :right do %>
439
- <%= menu_item "Sign Up", registration_path %>
440
- <%= form_for @user, url: session_path(:user) do |f| -%>
441
- <p><%= f.text_field :email %></p>
442
- <p><%= f.password_field :password %></p>
443
- <p><%= f.submit "Sign in" %></p>
444
- <% end -%>
445
- <% end %>
446
- <% end %>
447
- <% end %>
448
- ```
449
-
450
- ### Dropdown menus
451
-
452
- For multi-level list options, where it makes logical sense to group menu items, or simply to save space if you have a lot of pages, you can group menu items into drop down lists like this:
453
-
454
- ```erb
455
- <%= nav_bar do %>
456
- <%= menu_item "Home", root_path %>
457
-
458
- <%= drop_down "Products" do %>
459
- <%= menu_item "Latest", latest_products_path %>
460
- <%= menu_item "Top Sellers", popular_products_path %>
461
- <%= drop_down_divider %>
462
- <%= menu_item "Discount Items", discounted_products_path %>
463
- <% end %>
464
-
465
- <%= menu_item "About Us", about_us_path %>
466
- <%= menu_item "Contact", contact_path %>
467
- <% end %>
468
- ```
469
-
470
- ### Dividers
471
-
472
- Dividers are just vertical bars that visually separate logically disparate groups of menu items
473
-
474
- ```erb
475
- <%= nav_bar fixed: :bottom do %>
476
- <%= menu_item "Home", root_path %>
477
- <%= menu_item "About Us", about_us_path %>
478
- <%= menu_item "Contact", contact_path %>
479
-
480
- <%= menu_divider %>
481
-
482
- <%= menu_item "Edit Profile", edit_user_path(current_user) %>
483
- <%= menu_item "Account Settings", edit_user_account_path(current_user, @account) %>
484
- <%= menu_item "Log Out", log_out_path %>
485
- <% end %>
486
- ```
487
-
488
- ### Forms in navbar
489
-
490
- At the moment - this is just a how to...
491
-
492
- You need to add this class to the form itself (Different form builders do this in different ways - please check out the relevant docs)
493
-
494
- ```css
495
- .navbar-form
496
- ```
497
- To pull the form left or right, add either of these classes:
498
- ```css
499
- .pull-left
500
- .pull-right
501
- ```
502
-
503
- If you want the Bootstrap search box (I think it just rounds the corners), use:
504
- ```css
505
- .navbar-search
506
- ```
507
- Instead of:
508
- ```css
509
- .navbar-form
510
- ```
511
-
512
- To change the size of the form fields, use .span2 (or however many span widths you want) to the input itself.
513
-
514
- ### Component alignment
515
-
516
- You can shift things to the left or the right across the nav bar. It's easiest to do this on grouped menu items:
517
-
518
- ```erb
519
- <%= nav_bar fixed: :bottom do %>
520
- <% menu_group do %>
521
- <%= menu_item "Home", root_path %>
522
- <%= menu_item "About Us", about_us_path %>
523
- <%= menu_item "Contact", contact_path %>
524
- <% end %>
525
- <% menu_group pull: :right do %>
526
- <%= menu_item "Edit Profile", edit_user_path(current_user) %>
527
- <%= menu_item "Account Settings", edit_user_account_path(current_user, @account) %>
528
- <%= menu_item "Log Out", log_out_path %>
529
- <% end %>
530
- <% end %>
531
- ```
532
-
533
- ### Text in the navbar
534
-
535
- If you want to put regular plain text in the navbar anywhere, you do it like this:
536
-
537
- ```erb
538
- <%= nav_bar brand: "Apple" do %>
539
- <%= menu_text "We make shiny things" %>
540
- <%= menu_item "Home", root_path %>
541
- <%= menu_item "About Us", about_us_path %>
542
- <% end %>
543
- ```
544
-
545
- It also takes the :pull option to drag it to the left or right.
546
-
547
- ### Flash helper
548
-
549
- Add flash helper `<%= bootstrap_flash %>` to your layout (built-in with layout generator).
550
- You can pass the attributes you want to add to the main div returned: `<%= bootstrap_flash(class: "extra-class", id: "your-id") %>`
551
-
552
-
553
- ### Breadcrumbs Helpers
554
-
555
- *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. For this reason if breadcrumbs-on-rails is detected in `Gemfile` gem methods will be accessible using `boostrap` prefix, i.e. `render_bootstrap_breadcrumbs` and `add_bootstrap_breadcrumb`
556
-
557
- Usually you do not need to use these breadcrumb gems since this gem provides the same functionality out of the box without the additional dependency.
558
-
559
- However if there are some `breadcrumbs-on-rails` features you need to keep you can still use them and use this gem with the prefixes explained above.
560
-
561
- Add breadcrumbs helper `<%= render_breadcrumbs %>` to your layout.
562
- You can also specify a divider for it like this: `<%= render_breadcrumbs('>') %>` (default divider is `/`).
563
- If you do not need dividers at all you can use `nil`: `<%= render_breadcrumbs(nil) %>`.
564
-
565
- Full example:
566
- ```ruby
567
-
568
- render_breadcrumbs(" / ", { class: '', item_class: '', divider_class: '', active_class: 'active' })
569
-
570
- ```
571
-
572
- ```ruby
573
- class ApplicationController
574
- add_breadcrumb :root # 'root_path' will be used as url
575
- end
576
- ```
577
-
578
- ```ruby
579
- class ExamplesController < ApplicationController
580
- add_breadcrumb :index, :examples_path
581
-
582
- def edit
583
- @example = Example.find params[:id]
584
- add_breadcrumb @example # @example.to_s as name, example_path(@example) as url
585
- add_breadcrumb :edit, edit_example_path(@example)
586
- end
587
- end
588
- ```
589
- All symbolic names translated with I18n. See [I18n Internationalization Support](#i18n-internationalization-support)
590
- section.
591
-
592
- ### Element utility helpers
593
-
594
- Badge:
595
- ```erb
596
- <%= badge(12, :warning) %> <span class="badge badge-warning">12</span>
597
- ```
598
-
599
- Label:
600
- ```erb
601
- <%= tag_label('Gut!', :success) %> <span class="label label-success">Gut!</span>
602
- ```
603
-
604
- Glyph:
605
- ```erb
606
- <%= glyph(:pencil) %> <i class="icon-pencil"></i>
607
-
608
- <%= glyph(:pencil, {tag: :span}) %> <span class="icon-pencil"></span>
609
-
610
- <%= glyph(:pencil, {class: 'foo'}) %> <i class="icon-pencil foo"></i>
611
- ```
612
-
613
- ### I18n Internationalization Support
614
- The installer creates an English translation file for you and copies it to config/locales/en.bootstrap.yml
615
-
616
-
617
- NOTE: If you are using Devise in your project, you must have a devise locale file
618
- for handling flash messages, even if those messages are blank. See https://github.com/plataformatec/devise/wiki/I18n
619
-
620
- ## Changelog
621
- Please see CHANGELOG.md for more details
622
-
623
- ## Contributors & Patches & Forks
624
- Please see CONTRIBUTERS.md for contributors list
625
-
626
- ## About Me
627
- Senior Software Developer Istanbul / Turkey
628
- seyhunak [at] gmail com
629
-
630
- ## Hire Me
631
- [![Hire Me !](https://img.shields.io/badge/Hire%20Me-for%20your%20project%20on%20PPH-red?s?style=social&logo=ios&logoColor=blue&labelColor=black&color=blue)](http://pph.me/seyhunak)
632
-
633
- ## Thanks
634
- Bootstrap and all twitter-bootstrap-rails contributors
635
- http://twbs.github.io/bootstrap
636
-
637
- ## Backers
638
- Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/twitter-bootstrap-rails#backer)]
639
-
640
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/0/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/0/avatar.svg"></a>
641
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/1/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/1/avatar.svg"></a>
642
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/2/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/2/avatar.svg"></a>
643
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/3/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/3/avatar.svg"></a>
644
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/4/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/4/avatar.svg"></a>
645
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/5/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/5/avatar.svg"></a>
646
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/6/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/6/avatar.svg"></a>
647
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/7/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/7/avatar.svg"></a>
648
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/8/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/8/avatar.svg"></a>
649
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/9/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/9/avatar.svg"></a>
650
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/10/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/10/avatar.svg"></a>
651
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/11/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/11/avatar.svg"></a>
652
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/12/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/12/avatar.svg"></a>
653
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/13/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/13/avatar.svg"></a>
654
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/14/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/14/avatar.svg"></a>
655
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/15/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/15/avatar.svg"></a>
656
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/16/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/16/avatar.svg"></a>
657
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/17/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/17/avatar.svg"></a>
658
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/18/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/18/avatar.svg"></a>
659
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/19/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/19/avatar.svg"></a>
660
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/20/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/20/avatar.svg"></a>
661
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/21/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/21/avatar.svg"></a>
662
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/22/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/22/avatar.svg"></a>
663
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/23/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/23/avatar.svg"></a>
664
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/24/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/24/avatar.svg"></a>
665
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/25/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/25/avatar.svg"></a>
666
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/26/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/26/avatar.svg"></a>
667
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/27/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/27/avatar.svg"></a>
668
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/28/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/28/avatar.svg"></a>
669
- <a href="https://opencollective.com/twitter-bootstrap-rails/backer/29/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/backer/29/avatar.svg"></a>
670
-
671
- ## Sponsors
672
- Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/twitter-bootstrap-rails#sponsor)]
673
-
674
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/0/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/0/avatar.svg"></a>
675
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/1/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/1/avatar.svg"></a>
676
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/2/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/2/avatar.svg"></a>
677
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/3/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/3/avatar.svg"></a>
678
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/4/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/4/avatar.svg"></a>
679
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/5/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/5/avatar.svg"></a>
680
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/6/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/6/avatar.svg"></a>
681
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/7/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/7/avatar.svg"></a>
682
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/8/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/8/avatar.svg"></a>
683
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/9/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/9/avatar.svg"></a>
684
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/10/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/10/avatar.svg"></a>
685
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/11/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/11/avatar.svg"></a>
686
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/12/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/12/avatar.svg"></a>
687
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/13/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/13/avatar.svg"></a>
688
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/14/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/14/avatar.svg"></a>
689
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/15/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/15/avatar.svg"></a>
690
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/16/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/16/avatar.svg"></a>
691
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/17/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/17/avatar.svg"></a>
692
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/18/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/18/avatar.svg"></a>
693
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/19/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/19/avatar.svg"></a>
694
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/20/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/20/avatar.svg"></a>
695
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/21/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/21/avatar.svg"></a>
696
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/22/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/22/avatar.svg"></a>
697
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/23/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/23/avatar.svg"></a>
698
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/24/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/24/avatar.svg"></a>
699
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/25/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/25/avatar.svg"></a>
700
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/26/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/26/avatar.svg"></a>
701
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/27/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/27/avatar.svg"></a>
702
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/28/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/28/avatar.svg"></a>
703
- <a href="https://opencollective.com/twitter-bootstrap-rails/sponsor/29/website" target="_blank"><img src="https://opencollective.com/twitter-bootstrap-rails/sponsor/29/avatar.svg"></a>
704
-
705
- ## License
706
- Copyright (c) 2017 (since 2012) by Seyhun Akyürek
707
-
708
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
709
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
710
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ # twitter-bootstrap-rails
2
+
3
+ Bootstrap is a toolkit from Twitter designed to kickstart development of web apps and sites. It includes base CSS and HTML for typography, forms, buttons, tables, grids, navigation, and more.
4
+
5
+ twitter-bootstrap-rails project integrates Bootstrap CSS toolkit for Rails Asset Pipeline (Rails 8, Rails 7, Rails 6, Rails 5 and Rails 4.x versions are supported)
6
+
7
+ [![Gem Version](https://badge.fury.io/rb/twitter-bootstrap-rails.svg)](http://badge.fury.io/rb/twitter-bootstrap-rails)
8
+ [![Dependency Status](https://gemnasium.com/seyhunak/twitter-bootstrap-rails.svg?travis)](https://gemnasium.com/seyhunak/twitter-bootstrap-rails?travis)
9
+ [![Code Climate](https://codeclimate.com/github/seyhunak/twitter-bootstrap-rails/badges/gpa.svg)](https://codeclimate.com/github/seyhunak/twitter-bootstrap-rails?branch=master)
10
+ [![Coverage Status](https://coveralls.io/repos/seyhunak/twitter-bootstrap-rails/badge.svg?branch=master)](https://coveralls.io/repos/seyhunak/twitter-bootstrap-rails/badge.svg?branch=master)
11
+ [![GitHub stars](https://img.shields.io/github/stars/seyhunak/twitter-bootstrap-rails.svg)](https://github.com/seyhunak/twitter-bootstrap-rails/stargazers)
12
+ [![GitHub forks](https://img.shields.io/github/forks/seyhunak/twitter-bootstrap-rails.svg)](https://github.com/seyhunak/twitter-bootstrap-rails/network)
13
+ [![GitHub issues](https://img.shields.io/github/issues/seyhunak/twitter-bootstrap-rails.svg)](https://github.com/seyhunak/twitter-bootstrap-rails/issues)
14
+
15
+ [![OpenCollective](https://opencollective.com/twitter-bootstrap-rails/backers/badge.svg)](#backers)
16
+ [![OpenCollective](https://opencollective.com/twitter-bootstrap-rails/sponsors/badge.svg)](#sponsors)
17
+
18
+ ## Screencasts
19
+ #### Installing twitter-bootstrap-rails, generators, usage and more
20
+
21
+ Screencasts provided by <a href="http://railscasts.com">RailsCasts</a> (Ryan Bates)
22
+
23
+ [Twitter Bootstrap Basics](http://railscasts.com/episodes/328-twitter-bootstrap-basics "Twitter Bootstrap Basics")
24
+ in this episode you will learn how to include Bootstrap into Rails application with the twitter-bootstrap-rails gem.
25
+
26
+ [More on Twitter Bootstrap](http://railscasts.com/episodes/329-more-on-twitter-bootstrap "More on Twitter Bootstrap")
27
+ in this episode continues on the Bootstrap project showing how to display flash messages, add form validations with SimpleForm, customise layout with variables, and switch to using Sass.
28
+ (Note: This episode is pro episode)
29
+
30
+ ## Installing the Gem
31
+
32
+ The [Twitter Bootstrap Rails gem](http://rubygems.org/gems/twitter-bootstrap-rails) can provide the Bootstrap stylesheets in two ways.
33
+
34
+ The plain CSS way is how Bootstrap is provided on [the official website](http://twbs.github.io/bootstrap/).
35
+
36
+ The [Less](http://lesscss.org/) way provides more customisation options, like changing theme colors and provides useful Less mixins for your code, but requires the
37
+ Less gem and the Ruby Racer Javascript runtime (not available on Microsoft Windows).
38
+
39
+ ### Installing the Less stylesheets
40
+
41
+ To use Less stylesheets, you'll need the [less-rails gem](http://rubygems.org/gems/less-rails), and one of [JavaScript runtimes supported by CommonJS](https://github.com/cowboyd/commonjs.rb#supported-runtimes).
42
+
43
+ Include these lines in the Gemfile to install the gems from [RubyGems.org](http://rubygems.org):
44
+
45
+ ```ruby
46
+ gem "therubyracer"
47
+ gem "less-rails" #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS
48
+ gem "twitter-bootstrap-rails"
49
+ ```
50
+
51
+ or you can install from latest build;
52
+
53
+ ```ruby
54
+ gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git'
55
+ ```
56
+
57
+ Then run `bundle install` from the command line:
58
+
59
+ bundle install
60
+
61
+ Then run the bootstrap generator to add Bootstrap includes into your assets:
62
+
63
+ rails generate bootstrap:install less
64
+
65
+ If you need to skip coffeescript replacement into app generators, use:
66
+
67
+ rails generate bootstrap:install --no-coffeescript
68
+
69
+ ### Installing the CSS stylesheets
70
+
71
+ If you don't need to customize the stylesheets using Less, the only gem you need is the `twitter-bootstrap-rails` gem:
72
+
73
+ ```ruby
74
+ gem "twitter-bootstrap-rails"
75
+ ```
76
+
77
+ After running `bundle install`, run the generator:
78
+
79
+ rails generate bootstrap:install static
80
+
81
+ If your Rails server is running, make sure to restart it.
82
+
83
+ ## Generating layouts and views
84
+
85
+ You can run following generators to get started with Bootstrap quickly.
86
+
87
+
88
+ Layout (generates Bootstrap compatible layout) - (Haml and Slim supported)
89
+
90
+
91
+ Usage:
92
+
93
+
94
+ rails g bootstrap:layout [LAYOUT_NAME]
95
+
96
+
97
+ Themed (generates Bootstrap compatible scaffold views.) - (Haml and Slim supported)
98
+
99
+
100
+ Usage:
101
+
102
+
103
+ rails g bootstrap:themed [RESOURCE_NAME]
104
+
105
+
106
+ Example:
107
+
108
+
109
+ rails g scaffold Post title:string description:text
110
+ rake db:migrate
111
+ rails g bootstrap:themed Posts
112
+
113
+ Notice the plural usage of the resource to generate bootstrap:themed.
114
+
115
+ ## Using with Less
116
+
117
+ Bootstrap was built with Preboot, an open-source pack of mixins and variables to be used in conjunction with Less, a CSS preprocessor for faster and easier web development.
118
+
119
+ ## Using stylesheets with Less
120
+
121
+ You have to require Bootstrap LESS (bootstrap_and_overrides.css.less) in your application.css
122
+
123
+ ```css
124
+ /*
125
+ *= require bootstrap_and_overrides
126
+ */
127
+
128
+ /* Your stylesheets goes here... */
129
+ ```
130
+
131
+ To use individual components from bootstrap, your bootstrap_and_overrides.less could look like this:
132
+
133
+ ```less
134
+ // Core variables and mixins
135
+ @import "twitter/bootstrap/variables.less";
136
+ @import "twitter/bootstrap/mixins.less";
137
+
138
+ // Reset and dependencies
139
+ @import "twitter/bootstrap/normalize.less";
140
+ @import "twitter/bootstrap/print.less";
141
+ //@import "twitter/bootstrap/glyphicons.less"; // Excludes glyphicons
142
+
143
+ // Core CSS
144
+ @import "twitter/bootstrap/scaffolding.less";
145
+ @import "twitter/bootstrap/type.less";
146
+ @import "twitter/bootstrap/code.less";
147
+ @import "twitter/bootstrap/grid.less";
148
+ @import "twitter/bootstrap/tables.less";
149
+ @import "twitter/bootstrap/forms.less";
150
+ @import "twitter/bootstrap/buttons.less";
151
+
152
+ // Components
153
+ @import "twitter/bootstrap/component-animations.less";
154
+ @import "twitter/bootstrap/dropdowns.less";
155
+ @import "twitter/bootstrap/button-groups.less";
156
+ @import "twitter/bootstrap/input-groups.less";
157
+ @import "twitter/bootstrap/navs.less";
158
+ @import "twitter/bootstrap/navbar.less";
159
+ @import "twitter/bootstrap/breadcrumbs.less";
160
+ @import "twitter/bootstrap/pagination.less";
161
+ @import "twitter/bootstrap/pager.less";
162
+ @import "twitter/bootstrap/labels.less";
163
+ @import "twitter/bootstrap/badges.less";
164
+ @import "twitter/bootstrap/jumbotron.less";
165
+ @import "twitter/bootstrap/thumbnails.less";
166
+ @import "twitter/bootstrap/alerts.less";
167
+ @import "twitter/bootstrap/progress-bars.less";
168
+ @import "twitter/bootstrap/media.less";
169
+ @import "twitter/bootstrap/list-group.less";
170
+ @import "twitter/bootstrap/panels.less";
171
+ @import "twitter/bootstrap/responsive-embed.less";
172
+ @import "twitter/bootstrap/wells.less";
173
+ @import "twitter/bootstrap/close.less";
174
+
175
+ // Components w/ JavaScript
176
+ @import "twitter/bootstrap/modals.less";
177
+ @import "twitter/bootstrap/tooltip.less";
178
+ @import "twitter/bootstrap/popovers.less";
179
+ @import "twitter/bootstrap/carousel.less";
180
+
181
+ // Utility classes
182
+ @import "twitter/bootstrap/utilities.less";
183
+ @import "twitter/bootstrap/responsive-utilities.less";
184
+ ```
185
+
186
+ If you'd like to alter Bootstrap's own variables, or define your LESS
187
+ styles inheriting Bootstrap's mixins, you can do so inside bootstrap_and_overrides.css.less:
188
+
189
+
190
+ ```less
191
+ @link-color: #ff0000;
192
+ ```
193
+
194
+ ### SASS
195
+
196
+ If you are using SASS to compile your application.css (e.g. your manifest file is application.css.sass or application.css.scss) you may get this:
197
+
198
+ ```
199
+ Invalid CSS after "*": expected "{", was "= require twitt..."
200
+ (in app/assets/stylesheets/application.css)
201
+ (sass)
202
+ ```
203
+
204
+ If this is the case, you **must** use @import instead of `*=` in your manifest file, or don't compile your manifest with SASS.
205
+
206
+ ### Icons
207
+
208
+ By default, this gem (when using less generator) won't enable standard Bootstraps's Glyphicons.
209
+
210
+ If you would like to restore the default Glyphicons, inside the generated `bootstrap_and_overrides.css.less` uncomment these lines:
211
+
212
+ ```less
213
+ // Glyphicons are not required by default, uncomment the following lines to enable them.
214
+ @glyphiconsEotPath: font-url("glyphicons-halflings-regular.eot");
215
+ @glyphiconsEotPath_iefix: font-url("glyphicons-halflings-regular.eot?#iefix");
216
+ @glyphiconsWoffPath: font-url("glyphicons-halflings-regular.woff");
217
+ @glyphiconsTtfPath: font-url("glyphicons-halflings-regular.ttf");
218
+ @glyphiconsSvgPath: font-url("glyphicons-halflings-regular.svg#glyphicons_halflingsregular");
219
+
220
+ @import "twitter/bootstrap/glyphicons.less";
221
+ ```
222
+
223
+ This gem was used to bundle the excellent [Font-Awesome](http://fortawesome.github.io/Font-Awesome/) library.
224
+ However that was another maintenance effort that is not worth to do here.
225
+
226
+ For Rails projects that need it there is the [font-awesome-rails gem](https://github.com/bokmann/font-awesome-rails) that
227
+ provides same functionality that this gems was used to provide and it also have some other interesting features (e.g. view helpers).
228
+
229
+ ## Using JavaScript
230
+
231
+ Require Bootstrap JS (bootstrap.js) in your application.js
232
+
233
+ ```js
234
+ //= require twitter/bootstrap
235
+
236
+ $(function(){
237
+ /* Your JavaScript goes here... */
238
+ });
239
+ ```
240
+
241
+ If you want to customize what is loaded, your application.js would look something like this
242
+
243
+ ```js
244
+ #= require jquery
245
+ #= require jquery_ujs
246
+ #= require twitter/bootstrap/transition
247
+ #= require twitter/bootstrap/alert
248
+ #= require twitter/bootstrap/modal
249
+ #= require twitter/bootstrap/button
250
+ #= require twitter/bootstrap/collapse
251
+ ```
252
+
253
+ ...and so on for each bootstrap js component.
254
+
255
+ ## Using CoffeeScript (optionally)
256
+
257
+ Using Bootstrap with the CoffeeScript is easy.
258
+ twitter-bootstrap-rails generates a "bootstrap.js.coffee" file for you
259
+ to /app/assets/javascripts/ folder.
260
+
261
+ ```coffee
262
+ jQuery ->
263
+ $("a[rel~=popover], .has-popover").popover()
264
+ $("a[rel~=tooltip], .has-tooltip").tooltip()
265
+ ```
266
+
267
+ ## Using Helpers
268
+
269
+ ### Modal Helper
270
+ You can create modals easily using the following example. The header, body, and footer all accept content_tag or plain html.
271
+ The href of the button to launch the modal must match the id of the modal dialog. It also accepts a block for the header, body, and footer. If you are getting a complaint about the modal_helper unable to merge a hash it is due to this.
272
+
273
+ ```erb
274
+ <%= content_tag :a, "Modal", href: "#modal", class: 'btn', data: {toggle: 'modal'} %>
275
+ <%= modal_dialog id: "modal",
276
+ header: { show_close: true, dismiss: 'modal', title: 'Modal header' },
277
+ body: { content: 'This is the body' },
278
+ footer: { content: content_tag(:button, 'Save', class: 'btn') } %>
279
+ ```
280
+
281
+ ### Navbar Helper
282
+ It should let you write things like:
283
+
284
+ ```erb
285
+ <%= nav_bar fixed: :top, brand: "Fashionable Clicheizr 2.0", responsive: true do %>
286
+ <%= menu_group do %>
287
+ <%= menu_item "Home", root_path %>
288
+ <%= menu_divider %>
289
+ <%= drop_down "Products" do %>
290
+ <%= menu_item "Things you can't afford", expensive_products_path %>
291
+ <%= menu_item "Things that won't suit you anyway", harem_pants_path %>
292
+ <%= menu_item "Things you're not even cool enough to buy anyway", hipster_products_path %>
293
+ <% if current_user.lives_in_hackney? %>
294
+ <%= menu_item "Bikes", fixed_wheel_bikes_path %>
295
+ <% end %>
296
+ <% end %>
297
+ <%= menu_item "About Us", about_us_path %>
298
+ <%= menu_item "Contact", contact_path %>
299
+ <% end %>
300
+ <%= menu_group pull: :right do %>
301
+ <% if current_user %>
302
+ <%= menu_item "Log Out", log_out_path %>
303
+ <% else %>
304
+ <%= form_for @user, url: session_path(:user), html => {class: "navbar-form pull-right"} do |f| -%>
305
+ <p><%= f.text_field :email %></p>
306
+ <p><%= f.password_field :password %></p>
307
+ <p><%= f.submit "Sign in" %></p>
308
+ <% end -%>
309
+ <% end %>
310
+ <% end %>
311
+ <% end %>
312
+ ```
313
+
314
+ ### Navbar scaffolding
315
+
316
+ In your view file (most likely application.html.erb) to get a basic navbar set up you need to do this:
317
+
318
+ ```erb
319
+ <%= nav_bar %>
320
+ ```
321
+
322
+ Which will render:
323
+
324
+ ```html
325
+ <div class="navbar">
326
+ <div class="container">
327
+ </div>
328
+ </div>
329
+ ```
330
+
331
+ ### Fixed navbar
332
+
333
+ If you want the navbar to stick to the top of the screen, pass in the option like this:
334
+
335
+ ```erb
336
+ <%= nav_bar fixed: :top %>
337
+ ```
338
+
339
+ To render:
340
+
341
+ ```html
342
+ <div class="navbar navbar-fixed-top">
343
+ <div class="container">
344
+ </div>
345
+ </div>
346
+ ```
347
+
348
+ ### Static navbar
349
+
350
+ If you want a full-width navbar that scrolls away with the page, pass in the option like this:
351
+
352
+ ```erb
353
+ <%= nav_bar static: :top %>
354
+ ```
355
+
356
+ To render:
357
+
358
+ ```html
359
+ <div class="navbar navbar-static-top">
360
+ <div class="container">
361
+ </div>
362
+ </div>
363
+ ```
364
+
365
+ ### Brand name
366
+
367
+ Add the name of your site on the left hand edge of the navbar. By default, it will link to root_url. Passing a brand_link option will set the url to whatever you want.
368
+
369
+ ```erb
370
+ <%= nav_bar brand: "We're sooo web 2.0alizr", brand_link: account_dashboard_path %>
371
+ ```
372
+
373
+ Which will render:
374
+
375
+ ```html
376
+ <div class="navbar">
377
+ <div class="container">
378
+ <a class="navbar-brand" href="/accounts/dashboard">
379
+ We're sooo web 2.0alizr
380
+ </a>
381
+ </div>
382
+ </div>
383
+ ```
384
+
385
+ ### Optional responsive variation
386
+
387
+ If you want the responsive version of the navbar to work (One that shrinks down on mobile devices etc.), you need to pass this option:
388
+
389
+ ```erb
390
+ <%= nav_bar responsive: true %>
391
+ ```
392
+
393
+ Which renders the html quite differently:
394
+
395
+ ```html
396
+ <div class="navbar">
397
+ <div class="container">
398
+ <!-- .navbar-toggle is used as the toggle for collapsed navbar content -->
399
+ <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
400
+ <span class="icon-bar"></span>
401
+ <span class="icon-bar"></span>
402
+ <span class="icon-bar"></span>
403
+ </button>
404
+ <!-- Everything in here gets hidden at 940px or less -->
405
+ <div class="navbar-collapse collapse">
406
+ <!-- menu items gets rendered here instead -->
407
+ </div>
408
+ </div>
409
+ </div>
410
+ ```
411
+
412
+ ### Nav links
413
+
414
+ This is the 'meat' of the code where you define your menu items.
415
+
416
+ You can group menu items in theoretical boxes which you can apply logic to - e.g. show different collections for logged in users/logged out users, or simply right align a group.
417
+
418
+ The active menu item will be inferred from the link for now.
419
+
420
+ The important methods here are menu_group and menu_item.
421
+
422
+ menu_group only takes one argument - :pull - this moves the group left or right when passed :left or :right.
423
+
424
+ menu_item generates a link wrapped in an li tag. It takes two arguments and an options hash. The first argument is the name (the text that will appear in the menu), and the path (which defaults to "#" if left blank). The rest of the options are passed straight through to the link_to helper, so that you can add classes, ids, methods or data tags etc.
425
+
426
+ ```erb
427
+ <%= nav_bar fixed: :top, brand: "Ninety Ten" do %>
428
+ <%= menu_group do %>
429
+ <%= menu_item "Home", root_path %>
430
+ <%= menu_item "About Us", about_us_path %>
431
+ <%= menu_item "Contact", contact_path %>
432
+ <% end %>
433
+ <% if current_user %>
434
+ <%= menu_item "Log Out", log_out_path %>
435
+ <% else %>
436
+ <%= menu_group pull: :right do %>
437
+ <%= menu_item "Sign Up", registration_path %>
438
+ <%= form_for @user, url: session_path(:user) do |f| -%>
439
+ <p><%= f.text_field :email %></p>
440
+ <p><%= f.password_field :password %></p>
441
+ <p><%= f.submit "Sign in" %></p>
442
+ <% end -%>
443
+ <% end %>
444
+ <% end %>
445
+ <% end %>
446
+ ```
447
+
448
+ ### Dropdown menus
449
+
450
+ For multi-level list options, where it makes logical sense to group menu items, or simply to save space if you have a lot of pages, you can group menu items into drop down lists like this:
451
+
452
+ ```erb
453
+ <%= nav_bar do %>
454
+ <%= menu_item "Home", root_path %>
455
+ <%= drop_down "Products" do %>
456
+ <%= menu_item "Latest", latest_products_path %>
457
+ <%= menu_item "Top Sellers", popular_products_path %>
458
+ <%= drop_down_divider %>
459
+ <%= menu_item "Discount Items", discounted_products_path %>
460
+ <% end %>
461
+ <%= menu_item "About Us", about_us_path %>
462
+ <%= menu_item "Contact", contact_path %>
463
+ <% end %>
464
+ ```
465
+
466
+ ### Dividers
467
+
468
+ Dividers are just vertical bars that visually separate logically disparate groups of menu items
469
+
470
+ ```erb
471
+ <%= nav_bar fixed: :bottom do %>
472
+ <%= menu_item "Home", root_path %>
473
+ <%= menu_item "About Us", about_us_path %>
474
+ <%= menu_item "Contact", contact_path %>
475
+ <%= menu_divider %>
476
+ <%= menu_item "Edit Profile", edit_user_path(current_user) %>
477
+ <%= menu_item "Account Settings", edit_user_account_path(current_user, @account) %>
478
+ <%= menu_item "Log Out", log_out_path %>
479
+ <% end %>
480
+ ```
481
+
482
+ ### Forms in navbar
483
+
484
+ At the moment - this is just a how to...
485
+
486
+ You need to add this class to the form itself (Different form builders do this in different ways - please check out the relevant docs)
487
+
488
+ ```css
489
+ .navbar-form
490
+ ```
491
+ To pull the form left or right, add either of these classes:
492
+ ```css
493
+ .pull-left
494
+ .pull-right
495
+ ```
496
+
497
+ If you want the Bootstrap search box (I think it just rounds the corners), use:
498
+ ```css
499
+ .navbar-search
500
+ ```
501
+ Instead of:
502
+ ```css
503
+ .navbar-form
504
+ ```
505
+
506
+ To change the size of the form fields, use .span2 (or however many span widths you want) to the input itself.
507
+
508
+ ### Component alignment
509
+
510
+ You can shift things to the left or the right across the nav bar. It's easiest to do this on grouped menu items:
511
+
512
+ ```erb
513
+ <%= nav_bar fixed: :bottom do %>
514
+ <% menu_group do %>
515
+ <%= menu_item "Home", root_path %>
516
+ <%= menu_item "About Us", about_us_path %>
517
+ <%= menu_item "Contact", contact_path %>
518
+ <% end %>
519
+ <% menu_group pull: :right do %>
520
+ <%= menu_item "Edit Profile", edit_user_path(current_user) %>
521
+ <%= menu_item "Account Settings", edit_user_account_path(current_user, @account) %>
522
+ <%= menu_item "Log Out", log_out_path %>
523
+ <% end %>
524
+ <% end %>
525
+ ```
526
+
527
+ ### Text in the navbar
528
+
529
+ If you want to put regular plain text in the navbar anywhere, you do it like this:
530
+
531
+ ```erb
532
+ <%= nav_bar brand: "Apple" do %>
533
+ <%= menu_text "We make shiny things" %>
534
+ <%= menu_item "Home", root_path %>
535
+ <%= menu_item "About Us", about_us_path %>
536
+ <% end %>
537
+ ```
538
+
539
+ It also takes the :pull option to drag it to the left or right.
540
+
541
+ ### Flash helper
542
+
543
+ Add flash helper `<%= bootstrap_flash %>` to your layout (built-in with layout generator).
544
+ You can pass the attributes you want to add to the main div returned: `<%= bootstrap_flash(class: "extra-class", id: "your-id") %>`
545
+
546
+
547
+ ### Breadcrumbs Helpers
548
+
549
+ *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. For this reason if breadcrumbs-on-rails is detected in `Gemfile` gem methods will be accessible using `boostrap` prefix, i.e. `render_bootstrap_breadcrumbs` and `add_bootstrap_breadcrumb`
550
+
551
+ Usually you do not need to use these breadcrumb gems since this gem provides the same functionality out of the box without the additional dependency.
552
+
553
+ However if there are some `breadcrumbs-on-rails` features you need to keep you can still use them and use this gem with the prefixes explained above.
554
+
555
+ Add breadcrumbs helper `<%= render_breadcrumbs %>` to your layout.
556
+ You can also specify a divider for it like this: `<%= render_breadcrumbs('>') %>` (default divider is `/`).
557
+ If you do not need dividers at all you can use `nil`: `<%= render_breadcrumbs(nil) %>`.
558
+
559
+ Full example:
560
+ ```ruby
561
+
562
+ render_breadcrumbs(" / ", { class: '', item_class: '', divider_class: '', active_class: 'active' })
563
+
564
+ ```
565
+
566
+ ```ruby
567
+ class ApplicationController
568
+ add_breadcrumb :root # 'root_path' will be used as url
569
+ end
570
+ ```
571
+
572
+ ```ruby
573
+ class ExamplesController < ApplicationController
574
+ add_breadcrumb :index, :examples_path
575
+
576
+ def edit
577
+ @example = Example.find params[:id]
578
+ add_breadcrumb @example # @example.to_s as name, example_path(@example) as url
579
+ add_breadcrumb :edit, edit_example_path(@example)
580
+ end
581
+ end
582
+ ```
583
+ All symbolic names translated with I18n. See [I18n Internationalization Support](#i18n-internationalization-support)
584
+ section.
585
+
586
+ ### Element utility helpers
587
+
588
+ Badge:
589
+ ```erb
590
+ <%= badge(12, :warning) %> <span class="badge badge-warning">12</span>
591
+ ```
592
+
593
+ Label:
594
+ ```erb
595
+ <%= tag_label('Good!', :success) %> <span class="label label-success">Good!</span>
596
+ ```
597
+
598
+ Glyph:
599
+ ```erb
600
+ <%= glyph(:pencil) %> <i class="icon-pencil"></i>
601
+ <%= glyph(:pencil, {tag: :span}) %> <span class="icon-pencil"></span>
602
+ <%= glyph(:pencil, {class: 'foo'}) %> <i class="icon-pencil foo"></i>
603
+ ```
604
+
605
+ ### I18n Internationalization Support
606
+ The installer creates an English translation file for you and copies it to config/locales/en.bootstrap.yml
607
+
608
+
609
+ NOTE: If you are using Devise in your project, you must have a devise locale file
610
+ for handling flash messages, even if those messages are blank. See https://github.com/plataformatec/devise/wiki/I18n
611
+
612
+ ## Changelog
613
+ Please see CHANGELOG.md for more details
614
+
615
+ ## Contributors & Patches & Forks
616
+ Please see CONTRIBUTERS.md for contributors list
617
+
618
+ ## About Me
619
+ Senior Software Developer Istanbul / Turkey
620
+ seyhunak [at] gmail com
621
+
622
+ ## Hire Me
623
+ [![Hire Me !](https://img.shields.io/badge/Hire%20Me-for%20your%20project%20on%20PPH-red?s?style=social&logo=ios&logoColor=blue&labelColor=black&color=blue)](http://pph.me/seyhunak)
624
+
625
+ ## Thanks
626
+ Bootstrap and all twitter-bootstrap-rails contributors
627
+ http://twbs.github.io/bootstrap
628
+
629
+ ## Backers
630
+ Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/twitter-bootstrap-rails#backer)]
631
+
632
+ ## License
633
+ Copyright (c) 2025 (since 2012) by Seyhun Akyürek
634
+
635
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
636
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
637
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
638
+