├── .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 | [![Build Status](https://travis-ci.org/doabit/bootstrap-sass-extras.png?branch=master)](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 | # 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 | 198 | ``` 199 | 200 | In your views: 201 | 202 | ```erb 203 | <%= nav do %> 204 | <%= nav_to('Home', root_path) %> 205 | <%= nav_to(profile_path) do %> 206 | Profile 207 | <% end %> 208 | <%= nav_to('Messages', controller: users, action: :messages) %> 209 | <%= nav_to('Forced active state', some_path, active: true) %> 210 | <% end %> 211 | ``` 212 | 213 | The `tabs` helper declares that a tab component is being used. Alternatively, the `pills` helper can 214 | be used in the same manner. Other classes can be specified in the `class` hash argument, the `nav` 215 | class need not be specified. 216 | 217 | The `nav_to` helper accepts the same methods that the `link_to` helper accepts, but also 218 | automatically applies the `active` class to the active link. 219 | 220 | ### Glyph Helper 221 | 222 | ```erb 223 | <%= glyph(:star) %> 224 | # => 225 | 226 | <%= glyph(:star, :paperclip) %> 227 | # => 228 | ``` 229 | 230 | ### Badge Helper 231 | 232 | ```erb 233 | <%= badge(2) %> 234 | # => 2 235 | ``` 236 | 237 | ## Contributing 238 | 239 | 1. Fork it 240 | 2. Create your feature branch (`git checkout -b my-new-feature`) 241 | 3. Commit your changes (`git commit -am 'Add some feature'`) 242 | 4. Push to the branch (`git push origin my-new-feature`) 243 | 5. Create new Pull Request 244 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'bundler/gem_tasks' 3 | require 'rspec/core/rake_task' 4 | 5 | desc "Run all examples" 6 | RSpec::Core::RakeTask.new(:spec) do |t| 7 | #t.rspec_path = 'bin/rspec' 8 | t.rspec_opts = %w[--color] 9 | end 10 | 11 | task :default => [:spec] -------------------------------------------------------------------------------- /app/helpers/badge_helper.rb: -------------------------------------------------------------------------------- 1 | module BadgeHelper 2 | # ==== Examples 3 | # 4 | # badge(2) 5 | # => 2 6 | # badge(nil) 7 | # => nil 8 | 9 | def badge(count) 10 | return unless count 11 | content_tag(:span, count, class: "badge") 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /app/helpers/bootstrap_flash_helper.rb: -------------------------------------------------------------------------------- 1 | module BootstrapFlashHelper 2 | ALERT_TYPES_MAP = { 3 | notice: :success, 4 | alert: :danger, 5 | error: :danger, 6 | info: :info, 7 | warning: :warning 8 | }.freeze 9 | 10 | def bootstrap_flash 11 | safe_join(flash.each_with_object([]) do |(type, message), messages| 12 | next if message.blank? || !message.respond_to?(:to_str) 13 | type = ALERT_TYPES_MAP.fetch(type.to_sym, type) 14 | messages << flash_container(type, message) 15 | end, "\n").presence 16 | end 17 | 18 | def flash_container(type, message) 19 | content_tag :div, class: "alert alert-#{type} alert-dismissable" do 20 | button_tag type: "button", class: "close", data: { dismiss: "alert" } do 21 | "×".html_safe 22 | end.safe_concat(message) 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /app/helpers/bootstrap_viewport_meta_helper.rb: -------------------------------------------------------------------------------- 1 | module BootstrapViewportMetaHelper 2 | # 3 | # Creates the meta tag for Bootstrap with the specified parameters: 4 | # 5 | # <%= viewport_meta_tag %> 6 | # 7 | # Renders: 8 | # 9 | # 10 | # 11 | # You can change the content value by passing a hash as an argument: 12 | # 13 | # <%= viewport_meta_tag(:maximum_scale => "1.0") %> 14 | # 15 | # Renders: 16 | # 17 | # 18 | # 19 | def viewport_meta_tag(*args) 20 | options = { 21 | width: "device-width", 22 | initial_scale: "1.0" }.merge(args[0] || {}) 23 | 24 | content = options.collect {|key,value| "#{key.to_s.dasherize}=#{value}"}.join(",") 25 | raw(tag(:meta, name: "viewport", content: content)) 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /app/helpers/glyph_helper.rb: -------------------------------------------------------------------------------- 1 | module GlyphHelper 2 | # ==== Examples 3 | # 4 | # glyph(:search) 5 | # => 6 | # glyph(:search, :paperclip) 7 | # => 8 | 9 | def glyph(*glyphicon_names) 10 | safe_join(glyphicon_names.map do |name| 11 | content_tag :span, nil, class: "glyphicon glyphicon-#{name.to_s.parameterize}" 12 | end, "") 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /app/helpers/modal_helper.rb: -------------------------------------------------------------------------------- 1 | module ModalHelper 2 | 3 | #modals have a header, a body, a footer for options. 4 | def modal_dialog(options = {}, &block) 5 | content_tag :div, :id => options[:id], :class => "modal fade", :role => "dialog" do 6 | content_tag :div, class: 'modal-dialog' do 7 | content_tag :div, class: 'modal-content' do 8 | modal_header(options[:header]) + 9 | modal_body(options[:body]) + 10 | modal_footer(options[:footer]) 11 | end 12 | end 13 | end 14 | end 15 | 16 | def modal_header(options = {}, &block) 17 | dismiss = options.delete(:dismiss) || 'modal' 18 | content_tag :div, :class => 'modal-header' do 19 | if options[:show_close] 20 | close_button(dismiss) + 21 | content_tag(:h4, options[:title], :class => 'modal-title', &block) 22 | else 23 | content_tag(:h4, options[:title], :class => 'modal-title', &block) 24 | end 25 | end 26 | end 27 | 28 | def modal_body(options = {}, &block) 29 | content_tag :div, options, :class => 'modal-body', &block 30 | end 31 | 32 | def modal_footer(options = {}, &block) 33 | content_tag :div, options, :class => 'modal-footer', &block 34 | end 35 | 36 | def close_button(dismiss) 37 | content_tag :button, "×".html_safe, :class => "close", "data-dismiss" => "#{dismiss}", "aria-hidden" => "true" 38 | end 39 | 40 | def modal_toggle(content_or_options = nil, options = {}, &block) 41 | if block_given? 42 | options = content_or_options if content_or_options.is_a?(Hash) 43 | default_options = { :class => 'btn', "data-toggle" => "modal", "data-target" => options.delete[:dialog] }.merge(options) 44 | 45 | content_tag :a, nil, default_options, true, &block 46 | else 47 | default_options = { :class => 'btn', "data-toggle" => "modal", "data-target" => options.delete(:dialog) }.merge(options) 48 | content_tag :a, content_or_options, default_options, true 49 | end 50 | end 51 | 52 | def modal_cancel_button content, options = {} 53 | default_options = { :class => "btn btn-default", :data => { dismiss: "modal" } } 54 | 55 | content_tag_string :button, content, default_options.merge(options) 56 | end 57 | 58 | end 59 | 60 | -------------------------------------------------------------------------------- /app/helpers/nav_helper.rb: -------------------------------------------------------------------------------- 1 | module NavHelper 2 | NAV_CLASS = 'nav'.freeze 3 | NAV_TABS_CLASS = 'nav-tabs'.freeze 4 | NAV_PILLS_CLASS = 'nav-pills'.freeze 5 | NAV_CLASSES = [NAV_TABS_CLASS, NAV_PILLS_CLASS] 6 | 7 | def nav(options = {}, type = NAV_TABS_CLASS, &block) 8 | options, type = {}, options unless options.is_a?(Hash) 9 | options[:class] ||= [] 10 | options[:class] = [*options[:class]] 11 | options[:class].unshift(NAV_CLASS) unless options[:class].include?(NAV_CLASS) 12 | options[:class] << type unless NAV_CLASSES.any? { |c| options[:class].include?(c) } 13 | 14 | content_or_options_with_block = options if block_given? 15 | content_tag(:ul, content_or_options_with_block, options, &block) 16 | end 17 | alias_method(:tabs, :nav) 18 | 19 | def pills(*args, &block) 20 | nav(*args, NAV_PILLS_CLASS, &block) 21 | end 22 | 23 | def nav_to(name = nil, options = nil, html_options = nil, &block) 24 | if block_given? 25 | url_options, html_options = name, options 26 | else 27 | url_options = options 28 | end 29 | 30 | url_options ||= {} 31 | 32 | active = html_options.try(:delete, :active) 33 | active = current_page?(url_options) if active.nil? 34 | tab_class = active ? 'active' : nil 35 | 36 | content_tag(:li, role: 'presentation', class: tab_class) do 37 | link_to(name, options, html_options, &block) 38 | end 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /app/helpers/twitter_breadcrumbs_helper.rb: -------------------------------------------------------------------------------- 1 | module TwitterBreadcrumbsHelper 2 | def render_breadcrumbs(options = {}, &block) 3 | return unless breadcrumbs? 4 | content = render(options[:partial] || 'bootstrap_sass_extras/breadcrumbs') 5 | if block_given? 6 | capture(content, &block) 7 | else 8 | content 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /app/helpers/url_helper.rb: -------------------------------------------------------------------------------- 1 | module UrlHelper 2 | BUTTON_CLASSES = ['btn-default', 'btn-primary', 'btn-success', 'btn-info', 'btn-warning', 3 | 'btn-danger', 'btn-link'].freeze 4 | 5 | def self.included(class_) 6 | class_.class_eval do 7 | def button_to(*args, &proc) 8 | args << nil if args.length < 2 9 | args << {} if args.length < 3 10 | button_to_with_bootstrap(*args, &proc) 11 | super(*args, &proc) 12 | end 13 | end 14 | end 15 | 16 | def button_to_with_bootstrap(name = nil, options = nil, html_options = {}, &block) 17 | html_options[:class] ||= [] 18 | html_options[:class] = [*html_options[:class]] 19 | 20 | # Expand space-separated class strings so that each has its own spot in the class array 21 | html_options[:class] = html_options[:class].map { |c| c.split }.flatten 22 | 23 | html_options[:class].unshift('btn') unless html_options[:class].include?('btn') 24 | if html_options[:class].select { |cls| UrlHelper::BUTTON_CLASSES.include?(cls) }.empty? 25 | html_options[:class] << 'btn-default' 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /app/views/bootstrap_sass_extras/_breadcrumbs.html.erb: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /bootstrap-sass-extras.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'bootstrap-sass-extras/version' 5 | 6 | Gem::Specification.new do |gem| 7 | gem.name = "bootstrap-sass-extras" 8 | gem.version = BootstrapSassExtras::VERSION 9 | gem.authors = ["doabit"] 10 | gem.email = ["doinsist@gmail.com"] 11 | gem.description = %q{bootstrap-sass extras.} 12 | gem.summary = %q{bootstrap-sass extras.} 13 | gem.homepage = "https://github.com/doabit/bootstrap-sass-extras" 14 | 15 | gem.files = `git ls-files`.split($/) 16 | gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } 17 | gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) 18 | gem.require_paths = ["lib"] 19 | 20 | gem.add_dependency "rails", ">= 3.1.0" 21 | 22 | gem.add_development_dependency "rspec-rails" 23 | gem.add_development_dependency "sqlite3" 24 | end 25 | -------------------------------------------------------------------------------- /lib/bootstrap-sass-extras.rb: -------------------------------------------------------------------------------- 1 | module BootstrapSassExtras 2 | require "bootstrap-sass-extras/engine" 3 | end 4 | -------------------------------------------------------------------------------- /lib/bootstrap-sass-extras/breadcrumbs.rb: -------------------------------------------------------------------------------- 1 | module BootstrapSassExtras 2 | module BreadCrumbs 3 | def self.included(base) 4 | base.extend(ClassMethods) 5 | base.helper_method :breadcrumbs?, 6 | :breadcrumb_names, 7 | :last_breadcrumb_name 8 | end 9 | 10 | module ClassMethods 11 | def add_breadcrumb(name, url, options = {}) 12 | class_name = self.name 13 | before_action options do |controller| 14 | if name.is_a?(Symbol) 15 | name = controller.send :translate_breadcrumb, name, class_name 16 | end 17 | controller.send :add_breadcrumb, name, url 18 | end 19 | end 20 | end 21 | 22 | protected 23 | 24 | def add_breadcrumb(name, url = '', options = {}) 25 | @breadcrumbs ||= [] 26 | name = translate_breadcrumb(name, self.class.name) if name.is_a?(Symbol) 27 | url = send(url) if url.is_a?(Symbol) 28 | @breadcrumbs << { name: name, url: url, options: options } 29 | end 30 | 31 | def translate_breadcrumb(name, class_name) 32 | scope = [:breadcrumbs] 33 | namespace = class_name.underscore.split('/') 34 | namespace.last.sub!('_controller', '') 35 | scope << namespace 36 | 37 | I18n.t name, scope: scope 38 | end 39 | 40 | def clear_breadcrumbs 41 | @breadcrumbs = nil 42 | end 43 | 44 | def breadcrumbs? 45 | Array(@breadcrumbs).any? 46 | end 47 | 48 | def breadcrumb_names 49 | Array(@breadcrumbs).map { |breadcrumb| breadcrumb[:name] } 50 | end 51 | 52 | def last_breadcrumb_name 53 | return unless crumb = Array(@breadcrumbs).last 54 | crumb[:name] 55 | end 56 | end 57 | end 58 | -------------------------------------------------------------------------------- /lib/bootstrap-sass-extras/engine.rb: -------------------------------------------------------------------------------- 1 | require File.dirname(__FILE__) + '/breadcrumbs.rb' 2 | module BootstrapSassExtras 3 | class Engine < ::Rails::Engine 4 | initializer 'bootstrap-sass-extras.setup_helpers' do |app| 5 | app.config.to_prepare do 6 | ActionController::Base.send :helper, BootstrapFlashHelper 7 | ActionController::Base.send :helper, BootstrapViewportMetaHelper 8 | ActionController::Base.send :helper, GlyphHelper 9 | ActionController::Base.send :helper, BadgeHelper 10 | ActionController::Base.send :helper, ModalHelper 11 | ActionController::Base.send :helper, NavHelper 12 | ActionController::Base.send :helper, TwitterBreadcrumbsHelper 13 | ActionController::Base.send :helper, UrlHelper 14 | ActionController::Base.send :include, BootstrapSassExtras::BreadCrumbs 15 | end 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /lib/bootstrap-sass-extras/version.rb: -------------------------------------------------------------------------------- 1 | module BootstrapSassExtras 2 | VERSION = "0.1.0" 3 | end 4 | -------------------------------------------------------------------------------- /lib/generators/bootstrap/install/install_generator.rb: -------------------------------------------------------------------------------- 1 | require 'rails/generators' 2 | 3 | module Bootstrap 4 | module Generators 5 | class InstallGenerator < ::Rails::Generators::Base 6 | 7 | source_root File.expand_path("../templates", __FILE__) 8 | desc "This generator installs Twitter Bootstrap locale" 9 | 10 | def add_locale 11 | if File.exist?("config/locales/en.bootstrap.yml") 12 | localez = File.read("config/locales/en.bootstrap.yml") 13 | insert_into_file "config/locales/en.bootstrap.yml", localez, :after => "en\n" 14 | else 15 | copy_file "en.bootstrap.yml", "config/locales/en.bootstrap.yml" 16 | end 17 | end 18 | 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /lib/generators/bootstrap/install/templates/en.bootstrap.yml: -------------------------------------------------------------------------------- 1 | # Sample localization file for English. Add more files in this directory for other locales. 2 | # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. 3 | 4 | en: 5 | helpers: 6 | actions: "Actions" 7 | links: 8 | back: "Back" 9 | cancel: "Cancel" 10 | confirm: "Are you sure?" 11 | destroy: "Delete" 12 | new: "New" 13 | edit: "Edit" 14 | show: "Show" 15 | titles: 16 | edit: "Edit" 17 | save: "Save" 18 | new: "New" 19 | delete: "Delete" 20 | -------------------------------------------------------------------------------- /lib/generators/bootstrap/layout/layout_generator.rb: -------------------------------------------------------------------------------- 1 | require 'rails/generators' 2 | 3 | module Bootstrap 4 | module Generators 5 | class LayoutGenerator < ::Rails::Generators::Base 6 | source_root File.expand_path("../templates", __FILE__) 7 | desc "This generator generates layout file with navigation." 8 | argument :layout_name, :type => :string, :default => "application" 9 | 10 | attr_reader :app_name 11 | 12 | def generate_layout 13 | app = ::Rails.application 14 | @app_name = app.class.to_s.split("::").first 15 | ext = app.config.generators.options[:rails][:template_engine] || :erb 16 | template "layout.html.#{ext}", "app/views/layouts/#{layout_name}.html.#{ext}" 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /lib/generators/bootstrap/layout/templates/layout.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | <%%= viewport_meta_tag %> 7 | <%%= content_for?(:title) ? yield(:title) : "<%= app_name %>" %> 8 | <%%= csrf_meta_tags %> 9 | 10 | 11 | 15 | 16 | <%%= stylesheet_link_tag "application", media: "all" %> 17 | 18 | 19 | 20 | <%%= favicon_link_tag 'apple-touch-icon-144x144-precomposed.png', rel: 'apple-touch-icon-precomposed', type: 'image/png', sizes: '144x144' %> 21 | 22 | 23 | 24 | <%%= favicon_link_tag 'apple-touch-icon-114x114-precomposed.png', rel: 'apple-touch-icon-precomposed', type: 'image/png', sizes: '114x114' %> 25 | 26 | 27 | 28 | <%%= favicon_link_tag 'apple-touch-icon-72x72-precomposed.png', rel: 'apple-touch-icon-precomposed', type: 'image/png', sizes: '72x72' %> 29 | 30 | 31 | 32 | <%%= favicon_link_tag 'apple-touch-icon-precomposed.png', rel: 'apple-touch-icon-precomposed', type: 'image/png' %> 33 | 34 | 35 | 36 | <%%= favicon_link_tag 'favicon.ico', rel: 'shortcut icon' %> 37 | <%%= javascript_include_tag "application" %> 38 | 39 | 40 | 41 | 64 | 65 |
66 |
67 |
68 | <%%= bootstrap_flash %> 69 | <%%= yield %> 70 |
71 |
72 | 81 |
82 |
83 | 84 | 87 | 88 |
89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /lib/generators/bootstrap/layout/templates/layout.html.haml: -------------------------------------------------------------------------------- 1 | !!! 5 2 | %html(lang="en") 3 | %head 4 | %meta(charset="utf-8") 5 | %meta(http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1") 6 | = viewport_meta_tag 7 | %title= content_for?(:title) ? yield(:title) : "<%= app_name %>" 8 | = csrf_meta_tags 9 | / Le HTML5 shim, for IE6-8 support of HTML elements 10 | /[if lt IE 9] 11 | = javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.1/html5shiv.js" 12 | = javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/respond.js/1.3.0/respond.js" 13 | = stylesheet_link_tag "application", media: "all" 14 | = favicon_link_tag 'apple-touch-icon-144x144-precomposed.png', rel: 'apple-touch-icon-precomposed', type: 'image/png', sizes: '144x144' 15 | = favicon_link_tag 'apple-touch-icon-114x114-precomposed.png', rel: 'apple-touch-icon-precomposed', type: 'image/png', sizes: '114x114' 16 | = favicon_link_tag 'apple-touch-icon-72x72-precomposed.png', rel: 'apple-touch-icon-precomposed', type: 'image/png', sizes: '72x72' 17 | = favicon_link_tag 'apple-touch-icon-precomposed.png', rel: 'apple-touch-icon-precomposed', type: 'image/png' 18 | = favicon_link_tag 'favicon.ico', rel: 'shortcut icon' 19 | = javascript_include_tag "application" 20 | 21 | %body 22 | %nav.navbar.navbar-default.navbar-fixed-top(role="navigation") 23 | .container 24 | .navbar-header 25 | %button.navbar-toggle(type="button" data-toggle="collapse" data-target=".navbar-responsive-collapse") 26 | %span.icon-bar 27 | %span.icon-bar 28 | %span.icon-bar 29 | %a.navbar-brand(href="#") <%= app_name %> 30 | .navbar-collapse.collapse.navbar-responsive-collapse 31 | %ul.nav.navbar-nav 32 | %li.active= link_to "Link 1", "#" 33 | %li= link_to "Link 2", "#" 34 | %li= link_to "Link 3", "#" 35 | %li= link_to "Link 3", "#" 36 | 37 | .container 38 | .row 39 | .col-md-9 40 | = bootstrap_flash 41 | = yield 42 | .col-md-3 43 | .well.sidebar-nav 44 | %h3 Sidebar 45 | %ul.nav.nav-list 46 | %li.nav-header Sidebar 47 | %li= link_to "Link 1", "#" 48 | %li= link_to "Link 2", "#" 49 | %li= link_to "Link 3", "#" 50 | %footer 51 | %p © Company <%= Date.today.year %> 52 | -------------------------------------------------------------------------------- /lib/generators/bootstrap/layout/templates/layout.html.slim: -------------------------------------------------------------------------------- 1 | doctype html 2 | html lang="en" 3 | head 4 | meta charset="utf-8" 5 | meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" 6 | = viewport_meta_tag 7 | title= content_for?(:title) ? yield(:title) : "<%= app_name %>" 8 | = csrf_meta_tags 9 | 10 | /! Le HTML5 shim, for IE6-8 support of HTML elements 11 | /[if lt IE 9] 12 | = javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.1/html5shiv.js" 13 | = javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/respond.js/1.3.0/respond.js" 14 | = stylesheet_link_tag "application", media: "all" 15 | = favicon_link_tag 'apple-touch-icon-144x144-precomposed.png', rel: 'apple-touch-icon-precomposed', type: 'image/png', sizes: '144x144' 16 | = favicon_link_tag 'apple-touch-icon-114x114-precomposed.png', rel: 'apple-touch-icon-precomposed', type: 'image/png', sizes: '114x114' 17 | = favicon_link_tag 'apple-touch-icon-72x72-precomposed.png', rel: 'apple-touch-icon-precomposed', type: 'image/png', sizes: '72x72' 18 | = favicon_link_tag 'apple-touch-icon-precomposed.png', rel: 'apple-touch-icon-precomposed', type: 'image/png' 19 | = favicon_link_tag 'favicon.ico', rel: 'shortcut icon' 20 | = javascript_include_tag "application" 21 | 22 | body 23 | nav.navbar.navbar-default.navbar-fixed-top role="navigation" 24 | .container 25 | .navbar-header 26 | button.navbar-toggle type="button" data-toggle="collapse" data-target=".navbar-responsive-collapse" 27 | span.icon-bar 28 | span.icon-bar 29 | span.icon-bar 30 | a.navbar-brand href="#" <%= app_name %> 31 | .navbar-collapse.collapse.navbar-responsive-collapse 32 | ul.nav.navbar-nav 33 | li.active= link_to "Link 1", "#" 34 | li= link_to "Link 2", "#" 35 | li= link_to "Link 3", "#" 36 | 37 | .container 38 | .row 39 | .col-md-9 40 | = bootstrap_flash 41 | = yield 42 | .col-md-3 43 | .well.sidebar-nav 44 | h3 Sidebar 45 | ul.nav.nav-list 46 | li.nav-header Sidebar 47 | li= link_to "Link 1", "#" 48 | li= link_to "Link 2", "#" 49 | li= link_to "Link 3", "#" 50 | 51 | footer 52 | p © Company <%= Date.today.year %> 53 | -------------------------------------------------------------------------------- /lib/generators/bootstrap/partial/partial_generator.rb: -------------------------------------------------------------------------------- 1 | require 'rails/generators' 2 | 3 | module Bootstrap 4 | module Generators 5 | class PartialGenerator < ::Rails::Generators::Base 6 | source_root File.expand_path("../templates", __FILE__) 7 | desc "This generator generates bootstrap HTML partials" 8 | argument :component_name, :type => :string, :default => "application", 9 | :banner => "navbar, navbar-devise, carousel" 10 | 11 | attr_reader :app_name 12 | 13 | def generate_partial 14 | app = ::Rails.application 15 | ext = app.config.generators.options[:rails][:template_engine] || :erb 16 | copy_file "_#{component_name}.html.#{ext}", "app/views/shared/_#{component_name}.html.#{ext}" 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /lib/generators/bootstrap/partial/templates/_login.html.erb: -------------------------------------------------------------------------------- 1 |

Sign in

2 | 3 | <%= form_for(resource, as: resource_name, url: session_path(resource_name), html: { class: 'form-horizontal' }) do |f| %> 4 |
5 | <%= f.label :email, class: 'control-label' %> 6 |
7 | <%= f.email_field :email %> 8 |
9 |
10 |
11 | <%= f.label :password, class: 'control-label' %> 12 |
13 | <%= f.password_field :password %> 14 |
15 |
16 | 17 | <% if devise_mapping.rememberable? -%> 18 |
19 | <%= f.label :remember_me, class: 'control-label' %> 20 | <%= f.check_box :remember_me %> 21 |
22 | <% end -%> 23 | 24 |
25 | <%= f.submit "Sign in", class: 'btn' %> 26 |
27 | <% end %> 28 | 29 | <%= render partial: "devise/shared/links" %> 30 | -------------------------------------------------------------------------------- /lib/generators/bootstrap/partial/templates/_navbar.html.erb: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /lib/generators/bootstrap/themed/templates/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%%= form_for @<%= resource_name %>, html: { class: 'form-horizontal' } do |f| %> 2 | <%- columns.each do |column| -%> 3 |
4 | <%%= f.label :<%= column.name %>, class: 'control-label col-md-2' %> 5 |
6 | <%%= f.<%= column.field_type %> :<%= column.name %>, class: '<%= column.field_type %> form-control' %> 7 |
8 |
9 | <%- end -%> 10 | 11 |
12 |
13 | <%%= f.submit nil, class: 'btn btn-primary' %> 14 | <%%= link_to t('.cancel', default: t("helpers.links.cancel")), 15 | <%= controller_routing_path %>_path, class: 'btn btn-default' %> 16 |
17 |
18 | <%% end %> 19 | -------------------------------------------------------------------------------- /lib/generators/bootstrap/themed/templates/_form.html.haml: -------------------------------------------------------------------------------- 1 | = form_for @<%= resource_name %>, html: { class: 'form-horizontal' } do |f| 2 | <%- columns.each do |column| -%> 3 | .form-group 4 | = f.label :<%= column.name %>, class: 'control-label col-md-2' 5 | .col-md-10 6 | = f.<%= column.field_type %> :<%= column.name %>, class: '<%= column.field_type %> form-control' 7 | <%- end -%> 8 | .form-group 9 | .col-md-offset-2.col-md-10 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' -------------------------------------------------------------------------------- /lib/generators/bootstrap/themed/templates/_form.html.slim: -------------------------------------------------------------------------------- 1 | = form_for @<%= resource_name %>, html: { class: "form-horizontal" } do |f| 2 | <%- columns.each do |column| -%> 3 | .form-group 4 | = f.label :<%= column.name %>, class: 'control-label col-md-2' 5 | .col-md-10 6 | = f.<%= column.field_type %> :<%= column.name %>, class: '<%= column.field_type %> form-control' 7 | <%- end -%> 8 | .form-group 9 | .col-md-offset-2.col-md-10 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 | -------------------------------------------------------------------------------- /lib/generators/bootstrap/themed/templates/edit.html.erb: -------------------------------------------------------------------------------- 1 | <%%- model_class = <%= resource_name.classify %> -%> 2 | 5 | <%%= render partial: 'form' %> 6 | -------------------------------------------------------------------------------- /lib/generators/bootstrap/themed/templates/edit.html.haml: -------------------------------------------------------------------------------- 1 | - model_class = <%= resource_name.classify %> 2 | .page-header 3 | %h1=t '.title', default: [:'helpers.titles.edit', 'Edit %{model}'], model: model_class.model_name.human.titleize 4 | = render partial: "form" 5 | -------------------------------------------------------------------------------- /lib/generators/bootstrap/themed/templates/edit.html.slim: -------------------------------------------------------------------------------- 1 | - model_class = <%= resource_name.classify %> 2 | div class="page-header" 3 | h1=t '.title', default: [:'helpers.titles.edit', 'Edit %{model}'], model: model_class.model_name.human.titleize 4 | = render partial: "form" 5 | -------------------------------------------------------------------------------- /lib/generators/bootstrap/themed/templates/index.html.erb: -------------------------------------------------------------------------------- 1 | <%%- model_class = <%= resource_name.classify %> -%> 2 | 5 | 6 | 7 | 8 | 9 | <%- columns.each do |column| -%> 10 | 11 | <%- end -%> 12 | 13 | 14 | 15 | 16 | 17 | <%% @<%= plural_resource_name %>.each do |<%= resource_name %>| %> 18 | 19 | 20 | <%- columns.each do |column| -%> 21 | 22 | <%- end -%> 23 | 24 | 35 | 36 | <%% end %> 37 | 38 |
<%%= model_class.human_attribute_name(:id) %><%%= model_class.human_attribute_name(:<%= column.name %>) %><%%= model_class.human_attribute_name(:created_at) %><%%=t '.actions', default: t("helpers.actions") %>
<%%= <%= resource_name %>.id %><%%= <%= resource_name %>.<%= column.name %> %><%%=l <%= resource_name %>.created_at, format: :long %> 25 | <%%= link_to <%= singular_controller_routing_path %>_path(<%= resource_name %>), class: 'btn btn-xs', title: "#{ t('.show', default: t('helpers.links.show')) }" do %> 26 | <%%= glyph 'info-sign' %> 27 | <%%- end -%> 28 | <%%= link_to edit_<%= singular_controller_routing_path %>_path(<%= resource_name %>), class: 'btn btn-xs', title: "#{ t('.edit', default: t('helpers.links.edit')) }" do %> 29 | <%%= glyph 'pencil' %> 30 | <%%- end -%> 31 | <%%= link_to <%= singular_controller_routing_path %>_path(<%= resource_name %>), method: :delete, data: { confirm: t('.confirm', default: t("helpers.links.confirm", default: 'Are you sure?')) }, class: 'btn btn-xs', title: "#{ t('.destroy', default: t('helpers.links.destroy')) }" do %> 32 | <%%= glyph 'remove' %> 33 | <%%- end -%> 34 |
39 | 40 | <%%= link_to t('.new', default: t("helpers.links.new")), 41 | new_<%= singular_controller_routing_path %>_path, 42 | class: 'btn btn-primary' %> 43 | -------------------------------------------------------------------------------- /lib/generators/bootstrap/themed/templates/index.html.haml: -------------------------------------------------------------------------------- 1 | - model_class = <%= resource_name.classify %> 2 | .page-header 3 | %h1=t '.title', default: model_class.model_name.human.pluralize.titleize 4 | %table.table.table-striped 5 | %thead 6 | %tr 7 | %th= model_class.human_attribute_name(:id) 8 | <%- columns.each do |column| -%> 9 | %th= model_class.human_attribute_name(:<%= column.name %>) 10 | <%- end -%> 11 | %th= model_class.human_attribute_name(:created_at) 12 | %th=t '.actions', default: t("helpers.actions") 13 | %tbody 14 | - @<%= plural_resource_name %>.each do |<%= resource_name %>| 15 | %tr 16 | %td= <%= resource_name %>.id 17 | <%- columns.each do |column| -%> 18 | %td= <%= resource_name %>.<%= column.name %> 19 | <%- end -%> 20 | %td=l <%= resource_name %>.created_at, format: :long 21 | %td 22 | = link_to <%= singular_controller_routing_path %>_path(<%= resource_name %>), class: 'btn btn-xs', title: "#{ t('.show', default: t('helpers.links.show')) }" do 23 | = glyph 'info-sign' 24 | = link_to edit_<%= singular_controller_routing_path %>_path(<%= resource_name %>), class: 'btn btn-xs', title: "#{ t('.edit', default: t('helpers.links.edit')) }" do 25 | = glyph 'pencil' 26 | = link_to <%= singular_controller_routing_path %>_path(<%= resource_name %>), method: :delete, data: { confirm: t('.confirm', default: t("helpers.links.confirm", default: 'Are you sure?')) }, class: 'btn btn-xs', title: "#{ t('.destroy', default: t('helpers.links.destroy')) }" do 27 | = glyph 'remove' 28 | 29 | = link_to t('.new', default: t("helpers.links.new")), new_<%= singular_controller_routing_path %>_path, class: 'btn btn-primary' 30 | -------------------------------------------------------------------------------- /lib/generators/bootstrap/themed/templates/index.html.slim: -------------------------------------------------------------------------------- 1 | - model_class = <%= resource_name.classify %> 2 | .page-header 3 | h1=t '.title', default: model_class.model_name.human.pluralize.titleize 4 | table.table.table-striped 5 | thead 6 | tr 7 | th= model_class.human_attribute_name(:id) 8 | <%- columns.each do |column| -%> 9 | th= model_class.human_attribute_name(:<%= column.name %>) 10 | <%- end -%> 11 | th= model_class.human_attribute_name(:created_at) 12 | th=t '.actions', default: t("helpers.actions") 13 | tbody 14 | - @<%= plural_resource_name %>.each do |<%= resource_name %>| 15 | tr 16 | td= <%= resource_name %>.id 17 | <%- columns.each do |column| -%> 18 | td= <%= resource_name %>.<%= column.name %> 19 | <%- end -%> 20 | td=l <%= resource_name %>.created_at, format: :long 21 | td 22 | = link_to <%= singular_controller_routing_path %>_path(<%= resource_name %>), class: 'btn btn-xs', title: "#{ t('.show', default: t('helpers.links.show')) }" do 23 | = glyph 'info-sign' 24 | = link_to edit_<%= singular_controller_routing_path %>_path(<%= resource_name %>), class: 'btn btn-xs', title: "#{ t('.edit', default: t('helpers.links.edit')) }" do 25 | = glyph 'pencil' 26 | = link_to <%= singular_controller_routing_path %>_path(<%= resource_name %>), method: :delete, data: { confirm: t('.confirm', default: t("helpers.links.confirm", default: 'Are you sure?')) }, class: 'btn btn-xs', title: "#{ t('.destroy', default: t('helpers.links.destroy')) }" do 27 | = glyph 'remove' 28 | 29 | = link_to t('.new', default: t("helpers.links.new")), new_<%= singular_controller_routing_path %>_path, class: 'btn btn-primary' -------------------------------------------------------------------------------- /lib/generators/bootstrap/themed/templates/new.html.erb: -------------------------------------------------------------------------------- 1 | <%%- model_class = <%= resource_name.classify %> -%> 2 | 5 | <%%= render partial: 'form' %> 6 | -------------------------------------------------------------------------------- /lib/generators/bootstrap/themed/templates/new.html.haml: -------------------------------------------------------------------------------- 1 | - model_class = <%= resource_name.classify %> 2 | .page-header 3 | %h1=t '.title', default: [:'helpers.titles.new', 'New %{model}'], model: model_class.model_name.human.titleize 4 | = render partial: "form" 5 | -------------------------------------------------------------------------------- /lib/generators/bootstrap/themed/templates/new.html.slim: -------------------------------------------------------------------------------- 1 | - model_class = <%= resource_name.classify %> 2 | .page-header 3 | h1=t '.title', default: [:'helpers.titles.new', 'New %{model}'], model: model_class.model_name.human.titleize 4 | = render partial: "form" 5 | -------------------------------------------------------------------------------- /lib/generators/bootstrap/themed/templates/show.html.erb: -------------------------------------------------------------------------------- 1 | <%%- model_class = <%= resource_name.classify %> -%> 2 | 5 | 6 |
7 |
8 | <%- columns.each do |column| -%> 9 |
<%%= model_class.human_attribute_name(:<%= column.name %>) %>
10 |
<%%= @<%= resource_name %>.<%= column.name %> %>
11 | <%- end -%> 12 |
13 |
14 | 15 |
16 | <%%= link_to t('.back', default: t("helpers.links.back")), 17 | <%= controller_routing_path %>_path, class: 'btn btn-default' %> 18 | <%%= link_to t('.edit', default: t("helpers.links.edit")), 19 | edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), class: 'btn btn-default' %> 20 | <%%= link_to t('.destroy', default: t("helpers.links.destroy")), 21 | <%= singular_controller_routing_path %>_path(@<%= resource_name %>), 22 | method: 'delete', 23 | data: { confirm: t('.confirm', default: t("helpers.links.confirm", default: 'Are you sure?')) }, 24 | class: 'btn btn-danger' %> 25 |
-------------------------------------------------------------------------------- /lib/generators/bootstrap/themed/templates/show.html.haml: -------------------------------------------------------------------------------- 1 | - model_class = <%= resource_name.classify %> 2 | .page-header 3 | %h1=t '.title', default: model_class.model_name.human.titleize 4 | .fieldset 5 | %dl 6 | <%- columns.each do |column| -%> 7 | %dt.label.label-default= model_class.human_attribute_name(:<%= column.name %>) 8 | %dd 9 | %pre.prettyprint= @<%= resource_name %>.<%= column.name %> 10 | <%- end -%> 11 | 12 | .form-group 13 | = link_to t('.back', default: t("helpers.links.back")), <%= controller_routing_path %>_path, class: 'btn btn-default' 14 | = link_to t('.edit', default: t("helpers.links.edit")), edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), class: 'btn btn-default' 15 | = link_to t('.destroy', default: t("helpers.links.destroy")), <%= singular_controller_routing_path %>_path(@<%= resource_name %>), method: "delete", data: { confirm: t('.confirm', default: t("helpers.links.confirm", default: 'Are you sure?')) }, class: 'btn btn-danger' -------------------------------------------------------------------------------- /lib/generators/bootstrap/themed/templates/show.html.slim: -------------------------------------------------------------------------------- 1 | - model_class = <%= resource_name.classify %> 2 | div class="page-header" 3 | h1=t '.title', default: model_class.model_name.human.titleize 4 | 5 | .fieldset 6 | dl 7 | <%- columns.each do |column| -%> 8 | dt.label.label-default= model_class.human_attribute_name(:<%= column.name %>) 9 | dd 10 | pre.prettyprint= @<%= resource_name %>.<%= column.name %> 11 | <%- end -%> 12 | 13 | .form-group 14 | = link_to t('.back', default: t("helpers.links.back")), <%= controller_routing_path %>_path, class: 'btn btn-default' 15 | ' 16 | = link_to t('.edit', default: t("helpers.links.edit")), edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), class: 'btn btn-default' 17 | ' 18 | = link_to t('.destroy', default: t("helpers.links.destroy")), <%= singular_controller_routing_path %>_path(@<%= resource_name %>), method: "delete", data: { confirm: t('.confirm', default: t("helpers.links.confirm", default: 'Are you sure?')) }, class: 'btn btn-danger' -------------------------------------------------------------------------------- /lib/generators/bootstrap/themed/templates/simple_form/_form.html.erb: -------------------------------------------------------------------------------- 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 |
9 |
10 | <%%= f.button :submit, class: 'btn-primary' %> 11 | <%%= link_to t('.cancel', default: t("helpers.links.cancel")), 12 | <%= controller_routing_path %>_path, class: 'btn btn-default' %> 13 |
14 |
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.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /spec/dummy/public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The change you wanted was rejected.

62 |

Maybe you tried to change something you didn't have access to.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /spec/dummy/public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

We're sorry, but something went wrong.

62 |
63 |

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 | 63 | TABS 64 | } 65 | 66 | it "generates the correct tabs" do 67 | (nav do 68 | concat "\n " 69 | concat (nav_to 'Name', '/', active: false) 70 | concat "\n " 71 | concat (nav_to '/profile', active: true do 72 | 'Profile' 73 | end) 74 | concat "\n" 75 | end + "\n").should == html 76 | end 77 | end 78 | end 79 | end 80 | -------------------------------------------------------------------------------- /spec/helpers/twitter_breadcrumbs_helper_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe TwitterBreadcrumbsHelper, :type => :helper do 4 | describe "given one breadcrumb" do 5 | before do 6 | controller.send(:add_breadcrumb, "Name", "URL") 7 | end 8 | 9 | describe "#render_breadcrumbs" do 10 | let(:html) { 11 | <<-BREADCRUMBS.strip_heredoc 12 | 15 | BREADCRUMBS 16 | } 17 | 18 | it "returns bootstrap-style breadcrumbs html" do 19 | helper.render_breadcrumbs.should == html 20 | end 21 | 22 | describe "given a block" do 23 | it "returns breadcrumbs wrapped in the captured block" do 24 | helper.render_breadcrumbs do |crumbs| 25 | helper.content_tag(:div, crumbs) 26 | end.should == "
#{html}
" 27 | end 28 | end 29 | end 30 | 31 | describe "#breadcrumbs?" do 32 | it "returns true" do 33 | helper.breadcrumbs?.should be_truthy 34 | end 35 | end 36 | 37 | describe "#breadcrumb_names" do 38 | it "returns an array of breadcrumb names" do 39 | helper.breadcrumb_names.should == ["Name"] 40 | controller.send(:breadcrumb_names).should == ["Name"] 41 | end 42 | end 43 | 44 | describe "#last_breadcrumb_name" do 45 | it "returns a breadcrumb name" do 46 | helper.last_breadcrumb_name.should == "Name" 47 | controller.send(:last_breadcrumb_name).should == "Name" 48 | end 49 | end 50 | 51 | describe "#clear_breadcrumbs" do 52 | it "empties all existing breadcrumbs" do 53 | helper.breadcrumbs?.should be_truthy 54 | controller.send(:clear_breadcrumbs) 55 | helper.breadcrumbs?.should be_falsey 56 | end 57 | end 58 | end 59 | 60 | describe "given two breadcrumbs" do 61 | before do 62 | controller.send(:add_breadcrumb, "Name1", "URL1") 63 | controller.send(:add_breadcrumb, "Name2", "URL2") 64 | end 65 | 66 | describe "#render_breadcrumbs" do 67 | let(:html) { 68 | <<-BREADCRUMBS.strip_heredoc 69 | 73 | BREADCRUMBS 74 | } 75 | 76 | it "returns bootstrap-style breadcrumbs html" do 77 | helper.render_breadcrumbs.should == html 78 | end 79 | 80 | describe "given a block" do 81 | it "returns breadcrumbs wrapped in the captured block" do 82 | helper.render_breadcrumbs do |crumbs| 83 | helper.content_tag(:div, crumbs) 84 | end.should == "
#{html}
" 85 | end 86 | end 87 | 88 | describe "custom breadcrumbs view" do 89 | let(:html) { "Custom Breadcrumbs Loaded\n" } 90 | 91 | it "returns the custom breadcrumbs view content" do 92 | helper.render_breadcrumbs(partial: 'application/custom_breadcrumbs').should == html 93 | end 94 | end 95 | end 96 | 97 | describe "#breadcrumbs?" do 98 | it "returns true" do 99 | helper.breadcrumbs?.should be_truthy 100 | controller.send(:breadcrumbs?).should be_truthy 101 | end 102 | end 103 | 104 | describe "#breadcrumb_names" do 105 | it "returns an array of breadcrumb names" do 106 | helper.breadcrumb_names.should == ["Name1", "Name2"] 107 | controller.send(:breadcrumb_names).should == ["Name1", "Name2"] 108 | end 109 | end 110 | 111 | describe "#last_breadcrumb_name" do 112 | it "returns a breadcrumb name" do 113 | helper.last_breadcrumb_name.should == "Name2" 114 | controller.send(:last_breadcrumb_name).should == "Name2" 115 | end 116 | end 117 | 118 | describe "#clear_breadcrumbs" do 119 | it "empties all existing breadcrumbs" do 120 | helper.breadcrumbs?.should be_truthy 121 | controller.send(:clear_breadcrumbs) 122 | helper.breadcrumbs?.should be_falsey 123 | end 124 | end 125 | end 126 | 127 | describe "given no breadcrumbs" do 128 | describe "#render_breadcrumbs" do 129 | it "returns nil" do 130 | helper.render_breadcrumbs.should be_nil 131 | end 132 | 133 | describe "given a block" do 134 | it "returns nil" do 135 | helper.render_breadcrumbs { |crumbs| "No #{crumbs} here!" }.should be_nil 136 | end 137 | end 138 | end 139 | 140 | describe "#breadcrumbs?" do 141 | it "returns false" do 142 | helper.breadcrumbs?.should be_falsey 143 | controller.send(:breadcrumbs?).should be_falsey 144 | end 145 | end 146 | 147 | describe "#breadcrumb_names" do 148 | it "returns an empty array" do 149 | helper.breadcrumb_names.should == [] 150 | controller.send(:breadcrumb_names).should == [] 151 | end 152 | end 153 | 154 | describe "#last_breadcrumb_name" do 155 | it "returns nil" do 156 | helper.last_breadcrumb_name.should be_nil 157 | controller.send(:last_breadcrumb_name).should be_nil 158 | end 159 | end 160 | end 161 | end 162 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | ENV["RAILS_ENV"] ||= 'test' 2 | require File.expand_path("../dummy/config/environment", __FILE__) 3 | require 'rspec/rails' 4 | # require 'rspec/autorun' 5 | 6 | RSpec.configure do |config| 7 | config.fixture_path = "#{::Rails.root}/spec/fixtures" 8 | config.use_transactional_fixtures = true 9 | end --------------------------------------------------------------------------------