├── .gitignore
├── .rspec
├── .travis.yml
├── CHANGELOG.md
├── Gemfile
├── Gemfile.lock
├── MIT-LICENSE
├── README.md
├── Rakefile
├── app
├── helpers
│ ├── badge_helper.rb
│ ├── bootstrap_flash_helper.rb
│ ├── bootstrap_viewport_meta_helper.rb
│ ├── glyph_helper.rb
│ ├── modal_helper.rb
│ ├── nav_helper.rb
│ ├── twitter_breadcrumbs_helper.rb
│ └── url_helper.rb
└── views
│ └── bootstrap_sass_extras
│ └── _breadcrumbs.html.erb
├── bootstrap-sass-extras.gemspec
├── lib
├── bootstrap-sass-extras.rb
├── bootstrap-sass-extras
│ ├── breadcrumbs.rb
│ ├── engine.rb
│ └── version.rb
└── generators
│ └── bootstrap
│ ├── install
│ ├── install_generator.rb
│ └── templates
│ │ └── en.bootstrap.yml
│ ├── layout
│ ├── layout_generator.rb
│ └── templates
│ │ ├── layout.html.erb
│ │ ├── layout.html.haml
│ │ └── layout.html.slim
│ ├── partial
│ ├── partial_generator.rb
│ └── templates
│ │ ├── _login.html.erb
│ │ └── _navbar.html.erb
│ └── themed
│ ├── templates
│ ├── _form.html.erb
│ ├── _form.html.haml
│ ├── _form.html.slim
│ ├── edit.html.erb
│ ├── edit.html.haml
│ ├── edit.html.slim
│ ├── index.html.erb
│ ├── index.html.haml
│ ├── index.html.slim
│ ├── new.html.erb
│ ├── new.html.haml
│ ├── new.html.slim
│ ├── show.html.erb
│ ├── show.html.haml
│ ├── show.html.slim
│ └── simple_form
│ │ ├── _form.html.erb
│ │ ├── _form.html.haml
│ │ └── _form.html.slim
│ └── themed_generator.rb
├── script
└── rails
└── spec
├── dummy
├── README.rdoc
├── Rakefile
├── app
│ ├── assets
│ │ ├── config
│ │ │ └── manifest.js
│ │ ├── images
│ │ │ └── .keep
│ │ ├── javascripts
│ │ │ └── application.js
│ │ └── stylesheets
│ │ │ └── application.css
│ ├── controllers
│ │ ├── application_controller.rb
│ │ └── concerns
│ │ │ └── .keep
│ ├── helpers
│ │ └── application_helper.rb
│ ├── mailers
│ │ └── .keep
│ ├── models
│ │ ├── .keep
│ │ └── concerns
│ │ │ └── .keep
│ └── views
│ │ ├── application
│ │ └── _custom_breadcrumbs.html.erb
│ │ └── layouts
│ │ └── application.html.erb
├── bin
│ ├── bundle
│ ├── rails
│ ├── rake
│ └── setup
├── config.ru
├── config
│ ├── application.rb
│ ├── boot.rb
│ ├── database.yml
│ ├── environment.rb
│ ├── environments
│ │ ├── development.rb
│ │ ├── production.rb
│ │ └── test.rb
│ ├── initializers
│ │ ├── assets.rb
│ │ ├── backtrace_silencers.rb
│ │ ├── cookies_serializer.rb
│ │ ├── filter_parameter_logging.rb
│ │ ├── inflections.rb
│ │ ├── mime_types.rb
│ │ ├── session_store.rb
│ │ └── wrap_parameters.rb
│ ├── locales
│ │ └── en.yml
│ ├── routes.rb
│ └── secrets.yml
├── lib
│ └── assets
│ │ └── .keep
├── log
│ └── .keep
└── public
│ ├── 404.html
│ ├── 422.html
│ ├── 500.html
│ └── favicon.ico
├── helpers
├── badge_helper_spec.rb
├── bootstrap_flash_helper_spec.rb
├── bootstrap_viewport_meta_helper_spec.rb
├── button_to_helper_spec.rb
├── glyph_helper_spec.rb
├── nav_helper_spec.rb
└── twitter_breadcrumbs_helper_spec.rb
└── spec_helper.rb
/.gitignore:
--------------------------------------------------------------------------------
1 | .bundle/
2 | log/*.log
3 | pkg/
4 | spec/dummy/db/*.sqlite3
5 | spec/dummy/log/*.log
6 | spec/dummy/tmp/
7 | spec/dummy/.sass-cache
8 | .DS_Store
--------------------------------------------------------------------------------
/.rspec:
--------------------------------------------------------------------------------
1 | --color
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: ruby
2 | cache: bundler
3 | sudo: false
4 | rvm:
5 | - 2.5.7
6 | - 2.6.5
7 | before_install:
8 | - gem update --system
9 | - bundle update --bundler
10 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## Release 0.1.0
4 |
5 | - Avoid dangerous calling of methods [@dlackty][]
6 | - Fix Travis CI [@dlackty][]
7 | - Add nav_to option to force active state [@sharshenov][]
8 | - use `before_action` over `before_filter` [@cantonic][]
9 | - Treat space-separated class names the same as arrays of class names in
10 | button_to_with_bootstrap [@marcp][]
11 | - Freeze ALERT_TYPES_MAP to save allocations
12 |
13 | ## Release 0.0.7
14 |
15 | - Added the ability to specify a custom view path for breadcrumbs [@fredwu][]
16 | - Put locale arg for String#pluralize in the view templates [@kayhide][]
17 | - Fix .haml themed template show.html.haml [@mskubenich][]
18 | - Augment button_to to generate the `btn` Bootstrap class. [@lowjoel][]
19 | - Given the nav helper, generate the appropriate Bootstrap tabs markup.
20 | [@lowjoel][]
21 | - Allow pills and tabs to be used in the same manner. [@lowjoel][]
22 |
23 | ## Release 0.0.6
24 |
25 | - Update to bootstrap 3.0
26 | - Add a `badge(badge_count)` helper by [@pdobb][]
27 | - Clean up codes by [@pdobb][]
28 |
29 | ## Release 0.0.5
30 |
31 | - Adjust bootstrap_flash to match bootstrap alerts by [@jonwaghorn][]
32 | - Rails Form Helper for Bootstrap META tag by [@dabit][]
33 |
34 | ## Release 0.0.4
35 |
36 | - Fix BreadCrumbs Helper
37 |
38 | ## Release 0.0.3
39 |
40 | - Add glyph, model and breadcrumbs helpers
41 | - Update templates
42 |
43 | ## Release 0.0.2
44 |
45 | - Add layout and views generators
46 |
47 | ## Release 0.0.1
48 |
49 | - Initial version
50 |
51 | [@lowjoel]: https://github.com/lowjoel
52 | [@mskubenich]: https://github.com/mskubenich
53 | [@kayhide]: https://github.com/kayhide
54 | [@fredwu]: https://github.com/fredwu
55 | [@jonwaghorn]: https://github.com/jonwaghorn
56 | [@pdobb]: https://github.com/pdobb
57 | [@dabit]: https://github.com/dabit
58 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source "http://rubygems.org"
2 |
3 | # Declare your gem's dependencies in bootstrap-sass-extras.gemspec.
4 | # Bundler will treat runtime dependencies like base dependencies, and
5 | # development dependencies will be added by default to the :development group.
6 | gemspec
7 |
8 | # gem 'byebug'
9 | gem 'pry'
10 |
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | PATH
2 | remote: .
3 | specs:
4 | bootstrap-sass-extras (0.1.0)
5 | rails (>= 3.1.0)
6 |
7 | GEM
8 | remote: http://rubygems.org/
9 | specs:
10 | actioncable (6.1.3.2)
11 | actionpack (= 6.1.3.2)
12 | activesupport (= 6.1.3.2)
13 | nio4r (~> 2.0)
14 | websocket-driver (>= 0.6.1)
15 | actionmailbox (6.1.3.2)
16 | actionpack (= 6.1.3.2)
17 | activejob (= 6.1.3.2)
18 | activerecord (= 6.1.3.2)
19 | activestorage (= 6.1.3.2)
20 | activesupport (= 6.1.3.2)
21 | mail (>= 2.7.1)
22 | actionmailer (6.1.3.2)
23 | actionpack (= 6.1.3.2)
24 | actionview (= 6.1.3.2)
25 | activejob (= 6.1.3.2)
26 | activesupport (= 6.1.3.2)
27 | mail (~> 2.5, >= 2.5.4)
28 | rails-dom-testing (~> 2.0)
29 | actionpack (6.1.3.2)
30 | actionview (= 6.1.3.2)
31 | activesupport (= 6.1.3.2)
32 | rack (~> 2.0, >= 2.0.9)
33 | rack-test (>= 0.6.3)
34 | rails-dom-testing (~> 2.0)
35 | rails-html-sanitizer (~> 1.0, >= 1.2.0)
36 | actiontext (6.1.3.2)
37 | actionpack (= 6.1.3.2)
38 | activerecord (= 6.1.3.2)
39 | activestorage (= 6.1.3.2)
40 | activesupport (= 6.1.3.2)
41 | nokogiri (>= 1.8.5)
42 | actionview (6.1.3.2)
43 | activesupport (= 6.1.3.2)
44 | builder (~> 3.1)
45 | erubi (~> 1.4)
46 | rails-dom-testing (~> 2.0)
47 | rails-html-sanitizer (~> 1.1, >= 1.2.0)
48 | activejob (6.1.3.2)
49 | activesupport (= 6.1.3.2)
50 | globalid (>= 0.3.6)
51 | activemodel (6.1.3.2)
52 | activesupport (= 6.1.3.2)
53 | activerecord (6.1.3.2)
54 | activemodel (= 6.1.3.2)
55 | activesupport (= 6.1.3.2)
56 | activestorage (6.1.3.2)
57 | actionpack (= 6.1.3.2)
58 | activejob (= 6.1.3.2)
59 | activerecord (= 6.1.3.2)
60 | activesupport (= 6.1.3.2)
61 | marcel (~> 1.0.0)
62 | mini_mime (~> 1.0.2)
63 | activesupport (6.1.3.2)
64 | concurrent-ruby (~> 1.0, >= 1.0.2)
65 | i18n (>= 1.6, < 2)
66 | minitest (>= 5.1)
67 | tzinfo (~> 2.0)
68 | zeitwerk (~> 2.3)
69 | builder (3.2.4)
70 | coderay (1.1.2)
71 | concurrent-ruby (1.1.8)
72 | crass (1.0.6)
73 | diff-lcs (1.3)
74 | erubi (1.10.0)
75 | globalid (0.4.2)
76 | activesupport (>= 4.2.0)
77 | i18n (1.8.10)
78 | concurrent-ruby (~> 1.0)
79 | loofah (2.18.0)
80 | crass (~> 1.0.2)
81 | nokogiri (>= 1.5.9)
82 | mail (2.7.1)
83 | mini_mime (>= 0.1.1)
84 | marcel (1.0.1)
85 | method_source (0.9.2)
86 | mini_mime (1.0.3)
87 | mini_portile2 (2.8.0)
88 | minitest (5.14.4)
89 | nio4r (2.5.7)
90 | nokogiri (1.13.6)
91 | mini_portile2 (~> 2.8.0)
92 | racc (~> 1.4)
93 | pry (0.12.2)
94 | coderay (~> 1.1.0)
95 | method_source (~> 0.9.0)
96 | racc (1.6.0)
97 | rack (2.2.3)
98 | rack-test (1.1.0)
99 | rack (>= 1.0, < 3)
100 | rails (6.1.3.2)
101 | actioncable (= 6.1.3.2)
102 | actionmailbox (= 6.1.3.2)
103 | actionmailer (= 6.1.3.2)
104 | actionpack (= 6.1.3.2)
105 | actiontext (= 6.1.3.2)
106 | actionview (= 6.1.3.2)
107 | activejob (= 6.1.3.2)
108 | activemodel (= 6.1.3.2)
109 | activerecord (= 6.1.3.2)
110 | activestorage (= 6.1.3.2)
111 | activesupport (= 6.1.3.2)
112 | bundler (>= 1.15.0)
113 | railties (= 6.1.3.2)
114 | sprockets-rails (>= 2.0.0)
115 | rails-dom-testing (2.0.3)
116 | activesupport (>= 4.2.0)
117 | nokogiri (>= 1.6)
118 | rails-html-sanitizer (1.4.3)
119 | loofah (~> 2.3)
120 | railties (6.1.3.2)
121 | actionpack (= 6.1.3.2)
122 | activesupport (= 6.1.3.2)
123 | method_source
124 | rake (>= 0.8.7)
125 | thor (~> 1.0)
126 | rake (13.0.3)
127 | rspec-core (3.8.2)
128 | rspec-support (~> 3.8.0)
129 | rspec-expectations (3.8.4)
130 | diff-lcs (>= 1.2.0, < 2.0)
131 | rspec-support (~> 3.8.0)
132 | rspec-mocks (3.8.1)
133 | diff-lcs (>= 1.2.0, < 2.0)
134 | rspec-support (~> 3.8.0)
135 | rspec-rails (3.8.2)
136 | actionpack (>= 3.0)
137 | activesupport (>= 3.0)
138 | railties (>= 3.0)
139 | rspec-core (~> 3.8.0)
140 | rspec-expectations (~> 3.8.0)
141 | rspec-mocks (~> 3.8.0)
142 | rspec-support (~> 3.8.0)
143 | rspec-support (3.8.2)
144 | sprockets (4.0.2)
145 | concurrent-ruby (~> 1.0)
146 | rack (> 1, < 3)
147 | sprockets-rails (3.2.2)
148 | actionpack (>= 4.0)
149 | activesupport (>= 4.0)
150 | sprockets (>= 3.0.0)
151 | sqlite3 (1.4.1)
152 | thor (1.1.0)
153 | tzinfo (2.0.4)
154 | concurrent-ruby (~> 1.0)
155 | websocket-driver (0.7.3)
156 | websocket-extensions (>= 0.1.0)
157 | websocket-extensions (0.1.5)
158 | zeitwerk (2.4.2)
159 |
160 | PLATFORMS
161 | ruby
162 |
163 | DEPENDENCIES
164 | bootstrap-sass-extras!
165 | pry
166 | rspec-rails
167 | sqlite3
168 |
169 | BUNDLED WITH
170 | 1.17.2
171 |
--------------------------------------------------------------------------------
/MIT-LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2013 Doabit
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the
5 | "Software"), to deal in the Software without restriction, including
6 | without limitation the rights to use, copy, modify, merge, publish,
7 | distribute, sublicense, and/or sell copies of the Software, and to
8 | permit persons to whom the Software is furnished to do so, subject to
9 | the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be
12 | included in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Bootstrap::Sass::Extras
2 |
3 | [bootstrap-sass][1] extras, idea and codes from [twitter-bootstrap-rails][2]
4 |
5 | [1]: https://github.com/thomas-mcdonald/bootstrap-sass
6 | [2]: https://github.com/seyhunak/twitter-bootstrap-rails
7 |
8 | [](https://travis-ci.org/doabit/bootstrap-sass-extras)
9 |
10 | ## Note
11 |
12 | From version 0.0.6, only support bootstrap 3. If you want to use bootstrap 2, please use version 0.0.5.
13 |
14 | ## Installation
15 |
16 | Add this line to your application's Gemfile:
17 |
18 | gem 'bootstrap-sass-extras'
19 |
20 | And then execute:
21 |
22 | $ bundle
23 |
24 | Or install it yourself as:
25 |
26 | $ gem install bootstrap-sass-extras
27 |
28 | ## Generating locale, layouts and views
29 |
30 | You can run following generators to get started with Twitter Bootstrap quickly.
31 |
32 | Generate locale
33 |
34 |
35 | Usage:
36 |
37 | ```ruby
38 | rails g bootstrap:install
39 | ```
40 |
41 | Layout (generates Twitter Bootstrap compatible layout) - (Haml and Slim supported)
42 |
43 |
44 | Usage:
45 |
46 | ```ruby
47 | rails g bootstrap:layout [LAYOUT_NAME] [*fixed or fluid]
48 | ```
49 |
50 | Example of a fixed layout:
51 |
52 | ```ruby
53 | rails g bootstrap:layout application fixed
54 | ```
55 |
56 | Example of a responsive layout:
57 |
58 | ```ruby
59 | rails g bootstrap:layout application fluid
60 | ```
61 |
62 | Themed (generates Twitter Bootstrap compatible scaffold views.) - (Haml and Slim supported)
63 |
64 |
65 | Usage:
66 |
67 | ```ruby
68 | rails g bootstrap:themed [RESOURCE_NAME]
69 | ```
70 |
71 | Example:
72 |
73 | ```ruby
74 | rails g scaffold Post title:string description:text
75 | rake db:migrate
76 | rails g bootstrap:themed Posts
77 | ```
78 |
79 | Notice the plural usage of the resource to generate bootstrap:themed.
80 |
81 | ## Using Helpers
82 |
83 | ### Viewport Meta Helper
84 | Add the viewport meta helper `<%= viewport_meta_tag %>` to your layout
85 | (built-in with layout generator) to render the required meta tag for Bootstrap:
86 |
87 | ```html
88 |
89 | ```
90 |
91 | You can change the content value by passing a hash as an argument:
92 |
93 | ```erb
94 | <%= viewport_meta_tag(:maximum_scale => "1.0") %>
95 | ```
96 |
97 | Renders:
98 |
99 | ```html
100 |
101 | ```
102 |
103 | ### Flash helper
104 | Add flash helper `<%= bootstrap_flash %>` to your layout (built-in with layout generator)
105 |
106 | ### Modal Helper
107 | You can create modals easily using the following example. The header, body, and footer all accept content_tag or plain html.
108 | The href of the button to launch the modal must match the id of the modal dialog.
109 |
110 | ```erb
111 | <%= modal_toggle 'Modal', dialog: '#modal'%>
112 | <%= modal_dialog :id => "modal",
113 | :header => { :show_close => true, :title => 'Modal header' },
114 | :body => 'This is the body',
115 | :footer => content_tag(:button, 'Save', :class => 'btn btn-primary')
116 | %>
117 | ```
118 |
119 | ### Breadcrumbs Helpers
120 |
121 | *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.
122 | You do not need to use these breadcrumb gems since this gem provides the same functionality out of the box without the additional dependency.
123 |
124 | ```ruby
125 | class ApplicationController
126 | add_breadcrumb :index, :root_path
127 | end
128 | ```
129 |
130 | ```ruby
131 | class ExamplesController < ApplicationController
132 | add_breadcrumb :index, :examples_path
133 |
134 | def index
135 | end
136 |
137 | def show
138 | @example = Example.find params[:id]
139 | add_breadcrumb @example.name, example_path(@example)
140 | add_breadcrumb :show, example_path(@example)
141 | end
142 | end
143 | ```
144 |
145 | Finally, add the `<%= render_breadcrumbs %>` helper to your layout.
146 |
147 | You can wrap the breadcrumbs in an HTML element by using the block form like this:
148 |
149 | ```erb
150 | <%= render_breadcrumbs do |breadcrumbs| %>
151 | <%= content_tag(:div, breadcrumbs, class: "container") %>
152 | <% end %>
153 |
154 | # =>
155 | #
156 | #
157 | #
...
158 | #
...
159 | #
160 | #
161 | ```
162 |
163 | You can also optionally specify which custom view partial you would like to use for rendering the breadcrumbs:
164 |
165 | ```erb
166 | <%= render_breadcrumbs partial: 'path/to/custom/breadcrumbs' %>
167 | ```
168 |
169 | There are also a few interface methods available for working with the internal breadcrumbs hashes. The following methods are available in controllers and views.
170 |
171 | ```ruby
172 | # Given previously added breadcrumbs:
173 |
174 | breadcrumbs?
175 | # => true
176 |
177 | breadcrumb_names
178 | # => ["example", "show"]
179 | ```
180 |
181 | The following method is available to controllers only.
182 |
183 | ```ruby
184 | clear_breadcrumbs
185 | # => nil
186 | ```
187 |
188 | ### Nav Helper
189 |
190 | To render the Bootstrap example:
191 |
192 | ```html
193 |
15 | <%- end -%>
16 | <%% end %>
17 |
--------------------------------------------------------------------------------
/lib/generators/bootstrap/themed/templates/simple_form/_form.html.haml:
--------------------------------------------------------------------------------
1 | = simple_form_for @<%= resource_name %>, html: { class: 'form-horizontal' }, wrapper: :horizontal_form, wrapper_mappings: { check_boxes: :horizontal_radio_and_checkboxes, radio_buttons: :horizontal_radio_and_checkboxes, file: :horizontal_file_input, boolean: :horizontal_boolean } do |f|
2 | <%- columns.each do |column| -%>
3 | = f.input :<%= column.name %>
4 | <%- end -%>
5 | <%- if ::SimpleForm::FormBuilder.instance_methods.include?(:wrapped_button) -%>
6 | = f.button :wrapped, cancel: <%= controller_routing_path %>_path
7 | <%- else -%>
8 | .form-group
9 | .col-sm-offset-3.col-sm-9
10 | = f.submit nil, class: 'btn btn-primary'
11 | = link_to t('.cancel', default: t("helpers.links.cancel")), <%= controller_routing_path %>_path, class: 'btn btn-default'
12 | <%- end -%>
13 |
--------------------------------------------------------------------------------
/lib/generators/bootstrap/themed/templates/simple_form/_form.html.slim:
--------------------------------------------------------------------------------
1 | = simple_form_for @<%= resource_name %>, html: { class: "form-horizontal" }, wrapper: :horizontal_form, wrapper_mappings: { check_boxes: :horizontal_radio_and_checkboxes, radio_buttons: :horizontal_radio_and_checkboxes, file: :horizontal_file_input, boolean: :horizontal_boolean } do |f|
2 | <%- columns.each do |column| -%>
3 | = f.input :<%= column.name %>
4 | <%- end -%>
5 | <%- if ::SimpleForm::FormBuilder.instance_methods.include?(:wrapped_button) -%>
6 | = f.button :wrapped, cancel: <%= controller_routing_path %>_path
7 | <%- else -%>
8 | .form-group
9 | .col-sm-offset-3.col-sm-9
10 | = f.submit nil, class: 'btn btn-primary'
11 | = link_to t('.cancel', default: t("helpers.links.cancel")), <%= controller_routing_path %>_path, class: 'btn btn-default'
12 | <%- end -%>
13 |
--------------------------------------------------------------------------------
/lib/generators/bootstrap/themed/themed_generator.rb:
--------------------------------------------------------------------------------
1 | require 'rails/generators'
2 | require 'rails/generators/generated_attribute'
3 |
4 | module Bootstrap
5 | module Generators
6 | class ThemedGenerator < ::Rails::Generators::Base
7 | source_root File.expand_path('../templates', __FILE__)
8 | argument :controller_path, :type => :string
9 | argument :model_name, :type => :string, :required => false
10 | argument :layout, :type => :string, :default => "application",
11 | :banner => "Specify application layout"
12 |
13 | class_option :excluded_columns, :type => :array, :required => false
14 |
15 | def initialize(args, *options)
16 | super(args, *options)
17 | initialize_views_variables
18 | end
19 |
20 | def copy_views
21 | generate_views
22 | end
23 |
24 | protected
25 |
26 | def initialize_views_variables
27 | @base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(controller_path)
28 | @controller_routing_path = @controller_file_path.gsub(/\//, '_')
29 | @model_name = @controller_class_nesting + "::#{@base_name.singularize.camelize}" unless @model_name
30 | @model_name = @model_name.camelize
31 | end
32 |
33 | def controller_routing_path
34 | @controller_routing_path
35 | end
36 |
37 | def singular_controller_routing_path
38 | @controller_routing_path.singularize
39 | end
40 |
41 | def model_name
42 | @model_name
43 | end
44 |
45 | def plural_model_name
46 | @model_name.pluralize
47 | end
48 |
49 | def resource_name
50 | @model_name.demodulize.underscore
51 | end
52 |
53 | def plural_resource_name
54 | resource_name.pluralize
55 | end
56 |
57 | def columns
58 | retrieve_columns.reject {|c| excluded?(c.name) }.map do |c|
59 | new_attribute(c.name, c.type.to_s)
60 | end
61 | end
62 |
63 | def excluded_columns_names
64 | %w[id _id created_at updated_at]
65 | end
66 |
67 | def excluded_columns_pattern
68 | [
69 | /.*_checksum/,
70 | /.*_count/,
71 | ]
72 | end
73 |
74 | def excluded_columns
75 | options['excluded_columns']||[]
76 | end
77 |
78 | def excluded?(name)
79 | excluded_columns_names.include?(name) ||
80 | excluded_columns_pattern.any? {|p| name =~ p } ||
81 | excluded_columns.include?(name)
82 | end
83 |
84 | def retrieve_columns
85 | if defined?(ActiveRecord) == "constant" && ActiveRecord.class == Module
86 | rescue_block ActiveRecord::StatementInvalid do
87 | @model_name.constantize.columns
88 | end
89 | else
90 | rescue_block do
91 | @model_name.constantize.fields.map {|c| c[1] }
92 | end
93 | end
94 | end
95 |
96 | def new_attribute(name, type)
97 | ::Rails::Generators::GeneratedAttribute.new(name, type)
98 | end
99 |
100 | def rescue_block(exception=Exception)
101 | yield if block_given?
102 | rescue exception => e
103 | say e.message, :red
104 | exit
105 | end
106 |
107 | def extract_modules(name)
108 | modules = name.include?('/') ? name.split('/') : name.split('::')
109 | name = modules.pop
110 | path = modules.map { |m| m.underscore }
111 | file_path = (path + [name.underscore]).join('/')
112 | nesting = modules.map { |m| m.camelize }.join('::')
113 | [name, path, file_path, nesting, modules.size]
114 | end
115 |
116 | def generate_views
117 | options.engine == generate_erb(selected_views)
118 | end
119 |
120 | def selected_views
121 | {
122 | "index.html.#{ext}" => File.join('app/views', @controller_file_path, "index.html.#{ext}"),
123 | "new.html.#{ext}" => File.join('app/views', @controller_file_path, "new.html.#{ext}"),
124 | "edit.html.#{ext}" => File.join('app/views', @controller_file_path, "edit.html.#{ext}"),
125 | "#{form_builder}_form.html.#{ext}" => File.join('app/views', @controller_file_path, "_form.html.#{ext}"),
126 | "show.html.#{ext}" => File.join('app/views', @controller_file_path, "show.html.#{ext}")
127 | }
128 | end
129 |
130 | def generate_erb(views)
131 | views.each do |template_name, output_path|
132 | template template_name, output_path
133 | end
134 | end
135 |
136 | def ext
137 | ::Rails.application.config.generators.options[:rails][:template_engine] || :erb
138 | end
139 |
140 | def form_builder
141 | defined?(::SimpleForm) ? 'simple_form/' : ''
142 | end
143 | end
144 | end
145 | end
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------
/script/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3 |
4 | ENGINE_ROOT = File.expand_path('../..', __FILE__)
5 | ENGINE_PATH = File.expand_path('../../lib/bootstrap-sass-extras/engine', __FILE__)
6 |
7 | require 'rails/all'
8 | require 'rails/engine/commands'
9 |
--------------------------------------------------------------------------------
/spec/dummy/README.rdoc:
--------------------------------------------------------------------------------
1 | == README
2 |
3 | This README would normally document whatever steps are necessary to get the
4 | application up and running.
5 |
6 | Things you may want to cover:
7 |
8 | * Ruby version
9 |
10 | * System dependencies
11 |
12 | * Configuration
13 |
14 | * Database creation
15 |
16 | * Database initialization
17 |
18 | * How to run the test suite
19 |
20 | * Services (job queues, cache servers, search engines, etc.)
21 |
22 | * Deployment instructions
23 |
24 | * ...
25 |
26 |
27 | Please feel free to use a different markup language if you do not plan to run
28 | rake doc:app.
29 |
--------------------------------------------------------------------------------
/spec/dummy/Rakefile:
--------------------------------------------------------------------------------
1 | # Add your own tasks in files placed in lib/tasks ending in .rake,
2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3 |
4 | require File.expand_path('../config/application', __FILE__)
5 |
6 | Rails.application.load_tasks
7 |
--------------------------------------------------------------------------------
/spec/dummy/app/assets/config/manifest.js:
--------------------------------------------------------------------------------
1 | //= link_tree ../images
2 | //= link_directory ../javascripts .js
3 | //= link_directory ../stylesheets .css
--------------------------------------------------------------------------------
/spec/dummy/app/assets/images/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/doabit/bootstrap-sass-extras/5db21def780a8d14b537ef8db0b3d34da881257a/spec/dummy/app/assets/images/.keep
--------------------------------------------------------------------------------
/spec/dummy/app/assets/javascripts/application.js:
--------------------------------------------------------------------------------
1 | // This is a manifest file that'll be compiled into application.js, which will include all the files
2 | // listed below.
3 | //
4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5 | // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6 | //
7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8 | // compiled file.
9 | //
10 | // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11 | // about supported directives.
12 | //
13 | //= require_tree .
14 |
--------------------------------------------------------------------------------
/spec/dummy/app/assets/stylesheets/application.css:
--------------------------------------------------------------------------------
1 | /*
2 | * This is a manifest file that'll be compiled into application.css, which will include all the files
3 | * listed below.
4 | *
5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6 | * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7 | *
8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9 | * compiled file so the styles you add here take precedence over styles defined in any styles
10 | * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11 | * file per style scope.
12 | *
13 | *= require_tree .
14 | *= require_self
15 | */
16 |
--------------------------------------------------------------------------------
/spec/dummy/app/controllers/application_controller.rb:
--------------------------------------------------------------------------------
1 | class ApplicationController < ActionController::Base
2 | # Prevent CSRF attacks by raising an exception.
3 | # For APIs, you may want to use :null_session instead.
4 | protect_from_forgery with: :exception
5 | end
6 |
--------------------------------------------------------------------------------
/spec/dummy/app/controllers/concerns/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/doabit/bootstrap-sass-extras/5db21def780a8d14b537ef8db0b3d34da881257a/spec/dummy/app/controllers/concerns/.keep
--------------------------------------------------------------------------------
/spec/dummy/app/helpers/application_helper.rb:
--------------------------------------------------------------------------------
1 | module ApplicationHelper
2 | end
3 |
--------------------------------------------------------------------------------
/spec/dummy/app/mailers/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/doabit/bootstrap-sass-extras/5db21def780a8d14b537ef8db0b3d34da881257a/spec/dummy/app/mailers/.keep
--------------------------------------------------------------------------------
/spec/dummy/app/models/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/doabit/bootstrap-sass-extras/5db21def780a8d14b537ef8db0b3d34da881257a/spec/dummy/app/models/.keep
--------------------------------------------------------------------------------
/spec/dummy/app/models/concerns/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/doabit/bootstrap-sass-extras/5db21def780a8d14b537ef8db0b3d34da881257a/spec/dummy/app/models/concerns/.keep
--------------------------------------------------------------------------------
/spec/dummy/app/views/application/_custom_breadcrumbs.html.erb:
--------------------------------------------------------------------------------
1 | Custom Breadcrumbs Loaded
2 |
--------------------------------------------------------------------------------
/spec/dummy/app/views/layouts/application.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Dummy
5 | <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6 | <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7 | <%= csrf_meta_tags %>
8 |
9 |
10 |
11 | <%= yield %>
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/spec/dummy/bin/bundle:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3 | load Gem.bin_path('bundler', 'bundle')
4 |
--------------------------------------------------------------------------------
/spec/dummy/bin/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | APP_PATH = File.expand_path('../../config/application', __FILE__)
3 | require_relative '../config/boot'
4 | require 'rails/commands'
5 |
--------------------------------------------------------------------------------
/spec/dummy/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require_relative '../config/boot'
3 | require 'rake'
4 | Rake.application.run
5 |
--------------------------------------------------------------------------------
/spec/dummy/bin/setup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'pathname'
3 |
4 | # path to your application root.
5 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6 |
7 | Dir.chdir APP_ROOT do
8 | # This script is a starting point to setup your application.
9 | # Add necessary setup steps to this file:
10 |
11 | puts "== Installing dependencies =="
12 | system "gem install bundler --conservative"
13 | system "bundle check || bundle install"
14 |
15 | # puts "\n== Copying sample files =="
16 | # unless File.exist?("config/database.yml")
17 | # system "cp config/database.yml.sample config/database.yml"
18 | # end
19 |
20 | puts "\n== Preparing database =="
21 | system "bin/rake db:setup"
22 |
23 | puts "\n== Removing old logs and tempfiles =="
24 | system "rm -f log/*"
25 | system "rm -rf tmp/cache"
26 |
27 | puts "\n== Restarting application server =="
28 | system "touch tmp/restart.txt"
29 | end
30 |
--------------------------------------------------------------------------------
/spec/dummy/config.ru:
--------------------------------------------------------------------------------
1 | # This file is used by Rack-based servers to start the application.
2 |
3 | require ::File.expand_path('../config/environment', __FILE__)
4 | run Rails.application
5 |
--------------------------------------------------------------------------------
/spec/dummy/config/application.rb:
--------------------------------------------------------------------------------
1 | require File.expand_path('../boot', __FILE__)
2 |
3 | # Pick the frameworks you want:
4 | require "active_record/railtie"
5 | require "action_controller/railtie"
6 | require "action_mailer/railtie"
7 | require "action_view/railtie"
8 | require "sprockets/railtie"
9 | # require "rails/test_unit/railtie"
10 |
11 | Bundler.require(*Rails.groups)
12 | require "bootstrap-sass-extras"
13 |
14 | module Dummy
15 | class Application < Rails::Application
16 | # Settings in config/environments/* take precedence over those specified here.
17 | # Application configuration should go into files in config/initializers
18 | # -- all .rb files in that directory are automatically loaded.
19 |
20 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
21 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
22 | # config.time_zone = 'Central Time (US & Canada)'
23 |
24 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
25 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
26 | # config.i18n.default_locale = :de
27 | end
28 | end
29 |
30 |
--------------------------------------------------------------------------------
/spec/dummy/config/boot.rb:
--------------------------------------------------------------------------------
1 | # Set up gems listed in the Gemfile.
2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3 |
4 | require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5 | $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
6 |
--------------------------------------------------------------------------------
/spec/dummy/config/database.yml:
--------------------------------------------------------------------------------
1 | # SQLite version 3.x
2 | # gem install sqlite3
3 | #
4 | # Ensure the SQLite 3 gem is defined in your Gemfile
5 | # gem 'sqlite3'
6 | #
7 | default: &default
8 | adapter: sqlite3
9 | pool: 5
10 | timeout: 5000
11 |
12 | development:
13 | <<: *default
14 | database: db/development.sqlite3
15 |
16 | # Warning: The database defined as "test" will be erased and
17 | # re-generated from your development database when you run "rake".
18 | # Do not set this db to the same as development or production.
19 | test:
20 | <<: *default
21 | database: db/test.sqlite3
22 |
23 | production:
24 | <<: *default
25 | database: db/production.sqlite3
26 |
--------------------------------------------------------------------------------
/spec/dummy/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the Rails application.
2 | require File.expand_path('../application', __FILE__)
3 |
4 | # Initialize the Rails application.
5 | Rails.application.initialize!
6 |
--------------------------------------------------------------------------------
/spec/dummy/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # In the development environment your application's code is reloaded on
5 | # every request. This slows down response time but is perfect for development
6 | # since you don't have to restart the web server when you make code changes.
7 | config.cache_classes = false
8 |
9 | # Do not eager load code on boot.
10 | config.eager_load = false
11 |
12 | # Show full error reports and disable caching.
13 | config.consider_all_requests_local = true
14 | config.action_controller.perform_caching = false
15 |
16 | # Don't care if the mailer can't send.
17 | config.action_mailer.raise_delivery_errors = false
18 |
19 | # Print deprecation notices to the Rails logger.
20 | config.active_support.deprecation = :log
21 |
22 | # Raise an error on page load if there are pending migrations.
23 | config.active_record.migration_error = :page_load
24 |
25 | # Debug mode disables concatenation and preprocessing of assets.
26 | # This option may cause significant delays in view rendering with a large
27 | # number of complex assets.
28 | config.assets.debug = true
29 |
30 | # Asset digests allow you to set far-future HTTP expiration dates on all assets,
31 | # yet still be able to expire them through the digest params.
32 | config.assets.digest = true
33 |
34 | # Adds additional error checking when serving assets at runtime.
35 | # Checks for improperly declared sprockets dependencies.
36 | # Raises helpful error messages.
37 | config.assets.raise_runtime_errors = true
38 |
39 | # Raises error for missing translations
40 | # config.action_view.raise_on_missing_translations = true
41 | end
42 |
--------------------------------------------------------------------------------
/spec/dummy/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # Code is not reloaded between requests.
5 | config.cache_classes = true
6 |
7 | # Eager load code on boot. This eager loads most of Rails and
8 | # your application in memory, allowing both threaded web servers
9 | # and those relying on copy on write to perform better.
10 | # Rake tasks automatically ignore this option for performance.
11 | config.eager_load = true
12 |
13 | # Full error reports are disabled and caching is turned on.
14 | config.consider_all_requests_local = false
15 | config.action_controller.perform_caching = true
16 |
17 | # Enable Rack::Cache to put a simple HTTP cache in front of your application
18 | # Add `rack-cache` to your Gemfile before enabling this.
19 | # For large-scale production use, consider using a caching reverse proxy like
20 | # NGINX, varnish or squid.
21 | # config.action_dispatch.rack_cache = true
22 |
23 | # Disable serving static files from the `/public` folder by default since
24 | # Apache or NGINX already handles this.
25 | config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
26 |
27 | # Compress JavaScripts and CSS.
28 | config.assets.js_compressor = :uglifier
29 | # config.assets.css_compressor = :sass
30 |
31 | # Do not fallback to assets pipeline if a precompiled asset is missed.
32 | config.assets.compile = false
33 |
34 | # Asset digests allow you to set far-future HTTP expiration dates on all assets,
35 | # yet still be able to expire them through the digest params.
36 | config.assets.digest = true
37 |
38 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
39 |
40 | # Specifies the header that your server uses for sending files.
41 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
42 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
43 |
44 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
45 | # config.force_ssl = true
46 |
47 | # Use the lowest log level to ensure availability of diagnostic information
48 | # when problems arise.
49 | config.log_level = :debug
50 |
51 | # Prepend all log lines with the following tags.
52 | # config.log_tags = [ :subdomain, :uuid ]
53 |
54 | # Use a different logger for distributed setups.
55 | # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
56 |
57 | # Use a different cache store in production.
58 | # config.cache_store = :mem_cache_store
59 |
60 | # Enable serving of images, stylesheets, and JavaScripts from an asset server.
61 | # config.action_controller.asset_host = 'http://assets.example.com'
62 |
63 | # Ignore bad email addresses and do not raise email delivery errors.
64 | # Set this to true and configure the email server for immediate delivery to raise delivery errors.
65 | # config.action_mailer.raise_delivery_errors = false
66 |
67 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
68 | # the I18n.default_locale when a translation cannot be found).
69 | config.i18n.fallbacks = true
70 |
71 | # Send deprecation notices to registered listeners.
72 | config.active_support.deprecation = :notify
73 |
74 | # Use default logging formatter so that PID and timestamp are not suppressed.
75 | config.log_formatter = ::Logger::Formatter.new
76 |
77 | # Do not dump schema after migrations.
78 | config.active_record.dump_schema_after_migration = false
79 | end
80 |
--------------------------------------------------------------------------------
/spec/dummy/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # The test environment is used exclusively to run your application's
5 | # test suite. You never need to work with it otherwise. Remember that
6 | # your test database is "scratch space" for the test suite and is wiped
7 | # and recreated between test runs. Don't rely on the data there!
8 | config.cache_classes = true
9 |
10 | # Do not eager load code on boot. This avoids loading your whole application
11 | # just for the purpose of running a single test. If you are using a tool that
12 | # preloads Rails for running tests, you may have to set it to true.
13 | config.eager_load = false
14 |
15 | # Configure static file server for tests with Cache-Control for performance.
16 | config.serve_static_files = true
17 | config.static_cache_control = 'public, max-age=3600'
18 |
19 | # Show full error reports and disable caching.
20 | config.consider_all_requests_local = true
21 | config.action_controller.perform_caching = false
22 |
23 | # Raise exceptions instead of rendering exception templates.
24 | config.action_dispatch.show_exceptions = false
25 |
26 | # Disable request forgery protection in test environment.
27 | config.action_controller.allow_forgery_protection = false
28 |
29 | # Tell Action Mailer not to deliver emails to the real world.
30 | # The :test delivery method accumulates sent emails in the
31 | # ActionMailer::Base.deliveries array.
32 | config.action_mailer.delivery_method = :test
33 |
34 | # Randomize the order test cases are executed.
35 | config.active_support.test_order = :random
36 |
37 | # Print deprecation notices to the stderr.
38 | config.active_support.deprecation = :stderr
39 |
40 | # Raises error for missing translations
41 | # config.action_view.raise_on_missing_translations = true
42 | end
43 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/assets.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Version of your assets, change this if you want to expire all your assets.
4 | Rails.application.config.assets.version = '1.0'
5 |
6 | # Add additional assets to the asset load path
7 | # Rails.application.config.assets.paths << Emoji.images_path
8 |
9 | # Precompile additional assets.
10 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
11 | # Rails.application.config.assets.precompile += %w( search.js )
12 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5 |
6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7 | # Rails.backtrace_cleaner.remove_silencers!
8 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/cookies_serializer.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | Rails.application.config.action_dispatch.cookies_serializer = :json
4 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/filter_parameter_logging.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Configure sensitive parameters which will be filtered from the log file.
4 | Rails.application.config.filter_parameters += [:password]
5 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new inflection rules using the following format. Inflections
4 | # are locale specific, and you may define rules for as many different
5 | # locales as you wish. All of these examples are active by default:
6 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
7 | # inflect.plural /^(ox)$/i, '\1en'
8 | # inflect.singular /^(ox)en/i, '\1'
9 | # inflect.irregular 'person', 'people'
10 | # inflect.uncountable %w( fish sheep )
11 | # end
12 |
13 | # These inflection rules are supported but not enabled by default:
14 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
15 | # inflect.acronym 'RESTful'
16 | # end
17 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new mime types for use in respond_to blocks:
4 | # Mime::Type.register "text/richtext", :rtf
5 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/session_store.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | Rails.application.config.session_store :cookie_store, key: '_dummy_session'
4 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/wrap_parameters.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # This file contains settings for ActionController::ParamsWrapper which
4 | # is enabled by default.
5 |
6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7 | ActiveSupport.on_load(:action_controller) do
8 | wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9 | end
10 |
11 | # To enable root element in JSON for ActiveRecord objects.
12 | # ActiveSupport.on_load(:active_record) do
13 | # self.include_root_in_json = true
14 | # end
15 |
--------------------------------------------------------------------------------
/spec/dummy/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Files in the config/locales directory are used for internationalization
2 | # and are automatically loaded by Rails. If you want to use locales other
3 | # than English, add the necessary files in this directory.
4 | #
5 | # To use the locales, use `I18n.t`:
6 | #
7 | # I18n.t 'hello'
8 | #
9 | # In views, this is aliased to just `t`:
10 | #
11 | # <%= t('hello') %>
12 | #
13 | # To use a different locale, set it with `I18n.locale`:
14 | #
15 | # I18n.locale = :es
16 | #
17 | # This would use the information in config/locales/es.yml.
18 | #
19 | # To learn more, please read the Rails Internationalization guide
20 | # available at http://guides.rubyonrails.org/i18n.html.
21 |
22 | en:
23 | hello: "Hello world"
24 |
--------------------------------------------------------------------------------
/spec/dummy/config/routes.rb:
--------------------------------------------------------------------------------
1 | Rails.application.routes.draw do
2 | # The priority is based upon order of creation: first created -> highest priority.
3 | # See how all your routes lay out with "rake routes".
4 |
5 | # You can have the root of your site routed with "root"
6 | # root 'welcome#index'
7 |
8 | # Example of regular route:
9 | # get 'products/:id' => 'catalog#view'
10 |
11 | # Example of named route that can be invoked with purchase_url(id: product.id)
12 | # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
13 |
14 | # Example resource route (maps HTTP verbs to controller actions automatically):
15 | # resources :products
16 |
17 | # Example resource route with options:
18 | # resources :products do
19 | # member do
20 | # get 'short'
21 | # post 'toggle'
22 | # end
23 | #
24 | # collection do
25 | # get 'sold'
26 | # end
27 | # end
28 |
29 | # Example resource route with sub-resources:
30 | # resources :products do
31 | # resources :comments, :sales
32 | # resource :seller
33 | # end
34 |
35 | # Example resource route with more complex sub-resources:
36 | # resources :products do
37 | # resources :comments
38 | # resources :sales do
39 | # get 'recent', on: :collection
40 | # end
41 | # end
42 |
43 | # Example resource route with concerns:
44 | # concern :toggleable do
45 | # post 'toggle'
46 | # end
47 | # resources :posts, concerns: :toggleable
48 | # resources :photos, concerns: :toggleable
49 |
50 | # Example resource route within a namespace:
51 | # namespace :admin do
52 | # # Directs /admin/products/* to Admin::ProductsController
53 | # # (app/controllers/admin/products_controller.rb)
54 | # resources :products
55 | # end
56 | end
57 |
--------------------------------------------------------------------------------
/spec/dummy/config/secrets.yml:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Your secret key is used for verifying the integrity of signed cookies.
4 | # If you change this key, all old signed cookies will become invalid!
5 |
6 | # Make sure the secret is at least 30 characters and all random,
7 | # no regular words or you'll be exposed to dictionary attacks.
8 | # You can use `rake secret` to generate a secure secret key.
9 |
10 | # Make sure the secrets in this file are kept private
11 | # if you're sharing your code publicly.
12 |
13 | development:
14 | secret_key_base: 1f96354bc7d211a7bd76f7958567bb5ae4fcaf38f3105110992420894be80520e0692cee0a0f935ff70549daa1de86db1005987109bc16ce695525498fd9b76d
15 |
16 | test:
17 | secret_key_base: fc4fdf113a91c7fc74a58c9d2f1b5b4328a8be5e95a57d45a019735f2882663eee098b1d59752e72843759a8e8adcf4b502196a479cd2ef1edfa0b8d6661e0fa
18 |
19 | # Do not keep production secrets in the repository,
20 | # instead read values from the environment.
21 | production:
22 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
23 |
--------------------------------------------------------------------------------
/spec/dummy/lib/assets/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/doabit/bootstrap-sass-extras/5db21def780a8d14b537ef8db0b3d34da881257a/spec/dummy/lib/assets/.keep
--------------------------------------------------------------------------------
/spec/dummy/log/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/doabit/bootstrap-sass-extras/5db21def780a8d14b537ef8db0b3d34da881257a/spec/dummy/log/.keep
--------------------------------------------------------------------------------
/spec/dummy/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The page you were looking for doesn't exist (404)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The page you were looking for doesn't exist.
62 |
You may have mistyped the address or the page may have moved.
63 |
64 |
If you are the application owner check the logs for more information.
If you are the application owner check the logs for more information.
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/spec/dummy/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/doabit/bootstrap-sass-extras/5db21def780a8d14b537ef8db0b3d34da881257a/spec/dummy/public/favicon.ico
--------------------------------------------------------------------------------
/spec/helpers/badge_helper_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe BadgeHelper, :type => :helper do
4 | describe "#badge" do
5 | let(:html) { %(%i) }
6 |
7 | it "returns proper output for badge count" do
8 | badge(0).should == html % 0
9 | badge(2).should == html % 2
10 | end
11 |
12 | it "returns nil for nil badge count" do
13 | badge(nil).should be_nil
14 | end
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/helpers/bootstrap_flash_helper_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe BootstrapFlashHelper, :type => :helper do
4 | describe "#bootstrap_flash" do
5 | let(:html) { %(
%s
) }
6 |
7 | def flash_test(input, output)
8 | allow(self).to receive(:flash).and_return(input)
9 | bootstrap_flash.should == html % output.to_a.flatten
10 | end
11 |
12 | it "returns alert-warning when sent a :warning message" do
13 | message = "Update Warning!"
14 | flash_test({ warning: message }, { warning: message })
15 | end
16 |
17 | it "returns alert-success when sent a :notice message" do
18 | message = "Update Success!"
19 | flash_test({ notice: message }, { success: message })
20 | end
21 |
22 | it "returns alert-danger when sent an :error message" do
23 | message = "Update Failed!"
24 | flash_test({ error: message }, { danger: message })
25 | end
26 |
27 | it "returns alert-danger when sent an :alert message" do
28 | message = "Update Alert!"
29 | flash_test({ alert: message }, { danger: message })
30 | end
31 |
32 | it "returns alert-info when sent a info message" do
33 | message = "Update Information!"
34 | flash_test({ info: message }, { info: message })
35 | end
36 |
37 | it "returns custom type when sent an unknown message" do
38 | message = "Update Unknown!"
39 | flash_test({ undefined: message }, { undefined: message })
40 | end
41 |
42 | it "properly handles string types" do
43 | message = "String to Symbol Test."
44 | flash_test({ "info" => message }, { info: message })
45 | end
46 |
47 | it "returns nil when sent a blank message" do
48 | allow(self).to receive(:flash).and_return(notice: "")
49 | bootstrap_flash.should be_nil
50 | end
51 |
52 | it "returns nil when message doesn't have an implicit conversion to String" do
53 | allow(self).to receive(:flash).and_return(notice: true)
54 | bootstrap_flash.should be_nil
55 | end
56 | end
57 | end
58 |
--------------------------------------------------------------------------------
/spec/helpers/bootstrap_viewport_meta_helper_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe BootstrapViewportMetaHelper, :type => :helper do
4 | describe :bootstrap_viewport_meta do
5 | context "no arguments" do
6 | it "should return the default viewport meta tag" do
7 | viewport_meta_tag.should ==""
8 | end
9 | end
10 |
11 | context "with arguments" do
12 | it "should return the viewport meta tag with the specified options" do
13 | viewport_meta_tag(initial_scale: "2.0").should ==""
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/spec/helpers/button_to_helper_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe UrlHelper, :type => :helper do
4 | describe "#button_to" do
5 | def pattern(label, class_)
6 | Regexp.new(Regexp.escape(html % [class_, label]))
7 | end
8 |
9 | let(:html) { %() }
10 |
11 | it "emits proper classes to style buttons" do
12 | button_to("Test", "/test").should =~ pattern("Test", "btn-default")
13 | end
14 |
15 | it "does not emit a default if a button type is specified" do
16 | button_to("Test", "/test", class: 'btn-danger').should =~ pattern("Test", "btn-danger")
17 | end
18 |
19 | it "does not emit a default if a button type is specified in a space-separated class" do
20 | button_to("Test", "/test", class: 'xyz btn-primary').should =~ pattern("Test", "xyz btn-primary")
21 | end
22 |
23 | context "with arrays of classes" do
24 | it "does not emit a default if a button type is specified as one of an array of classes" do
25 | button_to("Test", "/test", class: ['xyz', 'btn-primary']).should =~ pattern("Test", "xyz btn-primary")
26 | end
27 |
28 | it "does not emit a default if a button type is specified within a space-separated class" do
29 | button_to("Test", "/test", class: ['xyz btn-primary']).should =~ pattern("Test", "xyz btn-primary")
30 | end
31 | end
32 | end
33 | end
34 |
--------------------------------------------------------------------------------
/spec/helpers/glyph_helper_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe GlyphHelper, :type => :helper do
4 | describe "#glyph" do
5 | let(:html) { %() }
6 |
7 | it "returns proper output for one glyphicon" do
8 | glyph(:test).should == html % "test"
9 | end
10 |
11 | it "returns proper output for more than one glyphicon" do
12 | glyph(:test1, :test2).should == "#{html % "test1"}#{html % "test2"}"
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/spec/helpers/nav_helper_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe NavHelper, :type => :helper do
4 | describe "#tabs" do
5 | before do
6 | def self.current_page?(path)
7 | path == '/'
8 | end
9 | end
10 |
11 | let(:html) {
12 | <<-TABS.strip_heredoc
13 |
17 | TABS
18 | }
19 |
20 | it "generates the correct link" do
21 | (nav do
22 | concat "\n "
23 | concat (nav_to 'Name', '/')
24 | concat "\n "
25 | concat (nav_to '/profile' do
26 | 'Profile'
27 | end)
28 | concat "\n"
29 | end + "\n").should == html
30 | end
31 |
32 | context "when a type of navigation is specified" do
33 | let(:html) { '
' }
34 |
35 | it "generates the correct link" do
36 | (nav class: 'nav-pills').should == html
37 | end
38 | end
39 |
40 | context "when the navigation type helper is used" do
41 | let(:html) { '
' }
42 |
43 | it "generates the correct link" do
44 | (tabs).should == html
45 | end
46 | end
47 |
48 | context "when a stacked nav is used" do
49 | let(:html) { '
' }
50 |
51 | it "generates the correct link" do
52 | (pills class: 'nav-stacked').should == html
53 | end
54 | end
55 |
56 | context "when nav tab_class given" do
57 | let(:html) {
58 | <<-TABS.strip_heredoc
59 |