bootstrap-rails-engine 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,24 @@
1
+ # See http://help.github.com/ignore-files/ for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile ~/.gitignore_global
6
+
7
+ # Ignore bundler config
8
+ /.bundle
9
+
10
+ # Ignore the default SQLite database.
11
+ /db/*.sqlite3
12
+
13
+ # Ignore all logfiles and tempfiles.
14
+ /log/*.log
15
+ /tmp
16
+ /public/assets/
17
+ /config/secret_settings.yml
18
+
19
+ *.log
20
+ .DS_Store
21
+ .sass-cache/
22
+ *.bak
23
+ *~
24
+ *.swp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in bootstrap-rails-engine.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ Copyright (c) 2012 Yen-Ju Chen
2
+ Copyright (c) 2012 Kenn Ejima (jquery-rails-cdn)
3
+
4
+ MIT License
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ "Software"), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # Twitter Bootstrap for Rails 3
2
+ Make [Twitter Bootstrap](http://twitter.github.com/bootstrap) into Rails Engine. [Bootstrap-datepicker](https://github.com/eternicode/bootstrap-datepicker) is also included.
3
+
4
+ ## Version
5
+ Bootstrap 2.1.0
6
+ Bootstrap-datepicker
7
+
8
+ ## Rails 3.1 or later
9
+ Include Gemfile,
10
+
11
+ gem 'bootstrap-rails-engine'
12
+
13
+ Add stylesheets into application.css
14
+
15
+ *= require bootstrap/bootstrap
16
+ *= require bootstrap/bootstrap-responsive
17
+
18
+ Add javascripts into application.js
19
+
20
+ //= require bootstrap/bootstrap
21
+
22
+ ## CDN
23
+
24
+ This gem supports cdn the same as [jquery-rails-cdn](https://github.com/yjchen/jquery-rails-cdn). In the application layout, add
25
+
26
+ = bootstrap_javascript_include_tag :default
27
+
28
+ and
29
+
30
+ = bootstrap_stylesheet_include_tag :default
31
+
32
+ then remove corresponding lines in application.js and application.css.
33
+
34
+ ## License
35
+
36
+ Copyright (c) 2012 Yen-Ju Chen
37
+
38
+ MIT License
39
+
40
+ Permission is hereby granted, free of charge, to any person obtaining
41
+ a copy of this software and associated documentation files (the
42
+ "Software"), to deal in the Software without restriction, including
43
+ without limitation the rights to use, copy, modify, merge, publish,
44
+ distribute, sublicense, and/or sell copies of the Software, and to
45
+ permit persons to whom the Software is furnished to do so, subject to
46
+ the following conditions:
47
+
48
+ The above copyright notice and this permission notice shall be
49
+ included in all copies or substantial portions of the Software.
50
+
51
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
52
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
53
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
54
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
55
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
56
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
57
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require 'bundler/gem_tasks'
4
+ Bundler::GemHelper.install_tasks
5
+
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/bootstrap-rails-engine/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = "bootstrap-rails-engine"
6
+ gem.version = BootstrapRailsEngine::Rails::VERSION
7
+ gem.platform = Gem::Platform::RUBY
8
+ gem.authors = ["Yen-Ju Chen"]
9
+ gem.email = ["yjchenx@gmail.com"]
10
+ gem.homepage = "https://github.com/yjchen/bootstrap-rails-engine"
11
+ gem.description = %q{Twitter Bootstrap for Rails 3}
12
+ gem.summary = gem.description
13
+
14
+ gem.files = `git ls-files`.split("\n")
15
+ gem.require_paths = ["lib"]
16
+
17
+ gem.add_dependency "railties", ">= 3.0"
18
+ gem.add_development_dependency "bundler", ">= 1.0"
19
+ gem.add_development_dependency "rake"
20
+ end
21
+
@@ -0,0 +1,6 @@
1
+ module BootstrapRailsEngine
2
+ module Rails
3
+ VERSION = "1.1.0"
4
+ TWITTER_BOOTSTRAP = "2.1.0"
5
+ end
6
+ end
@@ -0,0 +1,54 @@
1
+ module BootstrapRailsEngine
2
+ module ActionViewExtensions
3
+ OFFLINE = (::Rails.env.development? or ::Rails.env.test?)
4
+
5
+ CDNS = {
6
+ :bootstrap_js => {
7
+ :default => "//netdna.bootstrapcdn.com/twitter-bootstrap/2.1.0/js/bootstrap.min.js"
8
+ },
9
+ :bootstrap_css => {
10
+ :default => "//netdna.bootstrapcdn.com/twitter-bootstrap/2.1.0/css/bootstrap.min.css"
11
+ },
12
+ }
13
+
14
+ def bootstrap_javascript_url(name, options = {})
15
+ return CDNS[:bootstrap_js][name]
16
+ end
17
+
18
+ def bootstrap_stylesheet_url(name, options = {})
19
+ return CDNS[:bootstrap_css][name]
20
+ end
21
+
22
+ # to be used with bootstrap-rails-engine gem
23
+ def bootstrap_javascript_include_tag(name, options = {})
24
+ if OFFLINE and !options[:force]
25
+ return javascript_include_tag('bootstrap/bootstrap')
26
+ else
27
+ # Bootstrap do not offer way to check existing
28
+ [ javascript_include_tag(bootstrap_javascript_url(name, options)),
29
+ ].join("\n").html_safe
30
+ end
31
+ end
32
+
33
+ def bootstrap_stylesheet_include_tag(name, options = {})
34
+ if OFFLINE and !options[:force]
35
+ return stylesheet_link_tag('bootstrap/bootstrap')
36
+ else
37
+ # Bootstrap do not offer way to check existing
38
+ [ stylesheet_link_tag(bootstrap_stylesheet_url(name, options)),
39
+ ].join("\n").html_safe
40
+ end
41
+ end
42
+ end
43
+
44
+
45
+ class Engine < ::Rails::Engine
46
+
47
+ initializer 'bootstrap-rails-engine.action_view' do |app|
48
+ ActiveSupport.on_load(:action_view) do
49
+ include BootstrapRailsEngine::ActionViewExtensions
50
+ end
51
+ end
52
+ end
53
+ end
54
+