cdnjs-rails 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/.DS_Store +0 -0
  3. data/Gemfile +3 -0
  4. data/Gemfile.lock +14 -0
  5. data/LICENSE +22 -0
  6. data/README.md +108 -0
  7. data/Rakefile +2 -0
  8. data/cdnjs-rails.gemspec +18 -0
  9. data/demoapp/.bundle/config +4 -0
  10. data/demoapp/.gitignore +58 -0
  11. data/demoapp/.ruby-version +1 -0
  12. data/demoapp/Gemfile +47 -0
  13. data/demoapp/Gemfile.lock +121 -0
  14. data/demoapp/README.rdoc +28 -0
  15. data/demoapp/Rakefile +6 -0
  16. data/demoapp/app/assets/javascripts/application.js +14 -0
  17. data/demoapp/app/assets/javascripts/home.js.coffee +3 -0
  18. data/demoapp/app/assets/stylesheets/application.css +13 -0
  19. data/demoapp/app/assets/stylesheets/home.css.scss +3 -0
  20. data/demoapp/app/controllers/application_controller.rb +5 -0
  21. data/demoapp/app/controllers/concerns/.keep +0 -0
  22. data/demoapp/app/controllers/home_controller.rb +4 -0
  23. data/demoapp/app/helpers/application_helper.rb +2 -0
  24. data/demoapp/app/helpers/home_helper.rb +2 -0
  25. data/demoapp/app/mailers/.keep +0 -0
  26. data/demoapp/app/models/.keep +0 -0
  27. data/demoapp/app/models/concerns/.keep +0 -0
  28. data/demoapp/app/views/home/index.html.erb +1 -0
  29. data/demoapp/app/views/layouts/application.html.erb +16 -0
  30. data/demoapp/bin/bundle +3 -0
  31. data/demoapp/bin/rails +4 -0
  32. data/demoapp/bin/rake +4 -0
  33. data/demoapp/config.ru +4 -0
  34. data/demoapp/config/application.rb +36 -0
  35. data/demoapp/config/boot.rb +4 -0
  36. data/demoapp/config/database.yml +25 -0
  37. data/demoapp/config/environment.rb +5 -0
  38. data/demoapp/config/environments/development.rb +29 -0
  39. data/demoapp/config/environments/production.rb +80 -0
  40. data/demoapp/config/environments/test.rb +36 -0
  41. data/demoapp/config/initializers/backtrace_silencers.rb +7 -0
  42. data/demoapp/config/initializers/filter_parameter_logging.rb +4 -0
  43. data/demoapp/config/initializers/inflections.rb +16 -0
  44. data/demoapp/config/initializers/mime_types.rb +5 -0
  45. data/demoapp/config/initializers/secret_token.rb +12 -0
  46. data/demoapp/config/initializers/session_store.rb +3 -0
  47. data/demoapp/config/initializers/wrap_parameters.rb +14 -0
  48. data/demoapp/config/locales/en.yml +23 -0
  49. data/demoapp/config/routes.rb +52 -0
  50. data/demoapp/db/schema.rb +16 -0
  51. data/demoapp/db/seeds.rb +7 -0
  52. data/demoapp/lib/assets/.keep +0 -0
  53. data/demoapp/lib/tasks/.keep +0 -0
  54. data/demoapp/log/.keep +0 -0
  55. data/demoapp/public/404.html +58 -0
  56. data/demoapp/public/422.html +58 -0
  57. data/demoapp/public/500.html +57 -0
  58. data/demoapp/public/favicon.ico +0 -0
  59. data/demoapp/public/robots.txt +5 -0
  60. data/demoapp/test.rb +24 -0
  61. data/demoapp/vendor/assets/javascripts/.keep +0 -0
  62. data/demoapp/vendor/assets/javascripts/jquery/jquery-ui.min.js +12 -0
  63. data/demoapp/vendor/assets/javascripts/jquery/jquery.min.js +6 -0
  64. data/demoapp/vendor/assets/stylesheets/.keep +0 -0
  65. data/lib/.DS_Store +0 -0
  66. data/lib/cdnjs-rails.rb +2 -0
  67. data/lib/cdnjs-rails/railtie.rb +6 -0
  68. data/lib/cdnjs-rails/view_helpers.rb +20 -0
  69. metadata +112 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8c92a0e42cbfd9d9772112a66c36c17be8d98d39
4
+ data.tar.gz: ea068b58b24500ee51c8b8e8598d7131b37e7994
5
+ SHA512:
6
+ metadata.gz: 039acde0034b1f11924b5dfdef37fdf0172740334856931024b2fc870867ca5f58106dbe1f1f766e4a439190ae6134811f8449a288f1627772d97550a3f23d9a
7
+ data.tar.gz: b86cd64ea1d271a4eede0de7ed2e6ebe6cf102046636502cfd415357c32e64b99ae3ee569cc836293044e751c7013067478da0099e8877391f0535255ce91b0f
Binary file
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,14 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ jquery-rails-google-cdn (0.0.2)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+
10
+ PLATFORMS
11
+ ruby
12
+
13
+ DEPENDENCIES
14
+ jquery-rails-google-cdn!
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Kenn Ejima
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,108 @@
1
+ Serving js files from a publicly available [CDN](http://en.wikipedia.org/wiki/Content_Delivery_Network) has clear benefits:
2
+
3
+ * **Speed**: Users will be able to download file from the closest physical location.
4
+ * **Caching**: CDN is used so widely that potentially your users may not need to download files at all.
5
+ * **Parallelism**: Browsers have a limitation on how many connections can be made to a single host. Using a CDN for file offloads a big one.
6
+
7
+ =============
8
+
9
+ ### Features
10
+
11
+ This gem offers the following features:
12
+
13
+ * Supports [cdnjs.com](http://cdnjs.com/)
14
+ * All libraries and versions are set in your application.rb file
15
+ * Automatically fallback to local files stored in your vendor directory:
16
+ * You're on a development environment, so that you can work offline.
17
+ * The CDN is down or unreachable.
18
+
19
+ On top of that, if you're using asset pipeline, you may have noticed that the major chunks of the code in combined `application.js` is jQuery. Implications of externalizing js files from `application.js` are:
20
+
21
+ * Updating your JS code won't evict the entire cache in browsers.
22
+ * Cached jQuery in the client browsers will survive deployments.
23
+ * Your code changes more often than jQuery upgrades, right?
24
+ * `rake assets:precompile` will run faster and use less memory.
25
+
26
+ =============
27
+
28
+ ### Installation
29
+
30
+ If you're using the asset pipeline with Rails 3.1+,
31
+
32
+ - Start by removing `//= require jquery`, `//= require jquery-ujs`, and other includes where applicable from your `application.js` file.
33
+
34
+ If you're using the asset pipeline with Rails 4+,
35
+
36
+ - Create a vendor directory `mkdir vendor/assets/javascripts/` for each library you would like to include, or only if you see fit
37
+ - Download the version of the library you want to use from the [cdnjs.com](http://cdnjs.com/) and save the file to this directory. The file should look something like `jquery.min.js`.
38
+ - Verify you have removed jquery-rails gem, it is not needed. Only include this gem reference.:
39
+
40
+ ```ruby
41
+ # gem 'jquery-rails'
42
+ gem 'cdnjs-rails'
43
+ ```
44
+
45
+ - In the supplied demo app, we are including 2 libraries `jquery` and `jquery-ui` where `cdnjs` is the name of the partial path on [cdnjs.com](http://cdnjs.com/) and `localpath` matches the folder path in your local application i.e. vendor directory:
46
+
47
+ ```ruby
48
+ # Specify CDNJS Libraries to include in the header with fallback using an array of hashes
49
+ config.cdnjs = [
50
+ {'cdnjs' => 'jquery/2.0.2/jquery.min.js', 'localpath' => 'jquery/jquery.min.js'},
51
+ {'cdnjs' => 'jqueryui/1.10.3/jquery-ui.min.js','localpath' => 'jquery/jquery-ui.min.js'}
52
+ ]
53
+ ```
54
+
55
+ - Finally add this section to your layouts file.
56
+
57
+ ```html
58
+ <%= cdnjs_include_tag Rails.application.config.cdnjs %>
59
+ <%= javascript_include_tag "application" %>
60
+ ```
61
+
62
+ - Please verify you do not have a duplicate `application` js include as this can cause issues with libraries down the road like ember. Here is an example layout of a rails 4 application:
63
+
64
+ ```html
65
+ <!DOCTYPE html>
66
+ <html>
67
+ <head>
68
+ <title>Demoapp</title>
69
+ <%= cdnjs_include_tag Rails.application.config.cdnjs %>
70
+ <%= javascript_include_tag "application" %>
71
+ <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
72
+ <%= javascript_include_tag "data-turbolinks-track" => true %>
73
+ <%= csrf_meta_tags %>
74
+ </head>
75
+ <body>
76
+
77
+ <%= yield %>
78
+
79
+ </body>
80
+ </html>
81
+ ```
82
+
83
+ The gem will generate the following across all modes production, testing, and development:
84
+
85
+ ```html
86
+ <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
87
+ <script>
88
+ //<![CDATA[
89
+ window.jQuery || document.write(unescape('%3Cscript src="/assets/jquery/jquery.min.js?body=1">%3C/script>'))
90
+ //]]>
91
+ </script>
92
+ <script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
93
+ <script>
94
+ //<![CDATA[
95
+ window.jQuery || document.write(unescape('%3Cscript src="/assets/jquery/jquery-ui.min.js?body=1">%3C/script>'))
96
+ //]]>
97
+ </script>
98
+ ```
99
+
100
+ =============
101
+
102
+ ###Changelog
103
+
104
+
105
+
106
+ ###Changelog
107
+
108
+ * v0.0.1: Initial release
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ Gem::Specification.new do |s|
3
+
4
+ s.authors = ["Chris Hough"]
5
+ s.email = ["founders@noconformity.com"]
6
+ s.description = %q{Use the CDNJS CDN to serve files and fall back to the local version if the CDN is unreachable.}
7
+ s.summary = %q{A gem to serve CDNJS files with fall back protection.}
8
+ s.homepage = "https://github.com/chrishough/cdnjs-rails"
9
+
10
+ s.files = `git ls-files`.split("\n")
11
+ s.require_paths = ["lib"]
12
+
13
+ s.name = "cdnjs-rails"
14
+ s.licenses = "GPL"
15
+ s.version = '0.0.1'
16
+
17
+ end
18
+
@@ -0,0 +1,4 @@
1
+ ---
2
+ BUNDLE_PATH: .bundle
3
+ BUNDLE_BIN: .bundle/binstubs
4
+ BUNDLE_DISABLE_SHARED_GEMS: '1'
@@ -0,0 +1,58 @@
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 specific config files
8
+ .bundle/*
9
+ !.bundle/config
10
+ .chef
11
+ .vagrant
12
+
13
+ # Ignore the default SQLite database.
14
+ /db/*.sqlite3
15
+
16
+ # Ignore all logfiles and tempfiles.
17
+ /log/*.log
18
+ /tmp
19
+
20
+ # APPLICATION #
21
+ ###################
22
+ *.com
23
+ *.class
24
+ *.dll
25
+ *.exe
26
+ *.o
27
+ *.so
28
+
29
+ # Packages #
30
+ ############
31
+ # it's better to unpack these files and commit the raw source
32
+ # git has its own built in compression methods
33
+ *.7z
34
+ *.dmg
35
+ *.gz
36
+ *.iso
37
+ *.jar
38
+ *.rar
39
+ *.tar
40
+ *.zip
41
+
42
+ # Logs and databases #
43
+ ######################
44
+ *.log
45
+ *.sql
46
+ *.sqlite
47
+
48
+ # OS generated files #
49
+ ######################
50
+ *.DS_Store
51
+ .DS_Store?
52
+ ._*
53
+ .Spotlight-V100
54
+ .Trashes
55
+ Icon?
56
+ ehthumbs.db
57
+ Thumbs.db
58
+
@@ -0,0 +1 @@
1
+ 2.0.0-p0
@@ -0,0 +1,47 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
4
+ gem 'rails', '4.0.0.rc1'
5
+
6
+ # Use sqlite3 as the database for Active Record
7
+ gem 'sqlite3'
8
+
9
+ # Use SCSS for stylesheets
10
+ gem 'sass-rails', '~> 4.0.0.rc1'
11
+
12
+ # Use Uglifier as compressor for JavaScript assets
13
+ gem 'uglifier', '>= 1.3.0'
14
+
15
+ # Use CoffeeScript for .js.coffee assets and views
16
+ gem 'coffee-rails', '~> 4.0.0'
17
+
18
+ # See https://github.com/sstephenson/execjs#readme for more supported runtimes
19
+ # gem 'therubyracer', platforms: :ruby
20
+
21
+ # Use jquery as the JavaScript library
22
+ # gem 'jquery-rails'
23
+ gem 'cdnjs-rails'
24
+ # gem 'cdnjs-rails', path: '../'
25
+
26
+ # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
27
+ gem 'turbolinks'
28
+
29
+ # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
30
+ gem 'jbuilder', '~> 1.0.1'
31
+
32
+ group :doc do
33
+ # bundle exec rake doc:rails generates the API under doc/api.
34
+ gem 'sdoc', require: false
35
+ end
36
+
37
+ # Use ActiveModel has_secure_password
38
+ # gem 'bcrypt-ruby', '~> 3.0.0'
39
+
40
+ # Use unicorn as the app server
41
+ # gem 'unicorn'
42
+
43
+ # Use Capistrano for deployment
44
+ # gem 'capistrano', group: :development
45
+
46
+ # Use debugger
47
+ # gem 'debugger', group: [:development, :test]
@@ -0,0 +1,121 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ cdnjs-rails (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actionmailer (4.0.0.rc1)
10
+ actionpack (= 4.0.0.rc1)
11
+ mail (~> 2.5.3)
12
+ actionpack (4.0.0.rc1)
13
+ activesupport (= 4.0.0.rc1)
14
+ builder (~> 3.1.0)
15
+ erubis (~> 2.7.0)
16
+ rack (~> 1.5.2)
17
+ rack-test (~> 0.6.2)
18
+ activemodel (4.0.0.rc1)
19
+ activesupport (= 4.0.0.rc1)
20
+ builder (~> 3.1.0)
21
+ activerecord (4.0.0.rc1)
22
+ activemodel (= 4.0.0.rc1)
23
+ activerecord-deprecated_finders (~> 1.0.2)
24
+ activesupport (= 4.0.0.rc1)
25
+ arel (~> 4.0.0)
26
+ activerecord-deprecated_finders (1.0.3)
27
+ activesupport (4.0.0.rc1)
28
+ i18n (~> 0.6, >= 0.6.4)
29
+ minitest (~> 4.2)
30
+ multi_json (~> 1.3)
31
+ thread_safe (~> 0.1)
32
+ tzinfo (~> 0.3.37)
33
+ arel (4.0.0)
34
+ atomic (1.1.9)
35
+ builder (3.1.4)
36
+ coffee-rails (4.0.0)
37
+ coffee-script (>= 2.2.0)
38
+ railties (>= 4.0.0.beta, < 5.0)
39
+ coffee-script (2.2.0)
40
+ coffee-script-source
41
+ execjs
42
+ coffee-script-source (1.6.2)
43
+ erubis (2.7.0)
44
+ execjs (1.4.0)
45
+ multi_json (~> 1.0)
46
+ hike (1.2.3)
47
+ i18n (0.6.4)
48
+ jbuilder (1.0.2)
49
+ activesupport (>= 3.0.0)
50
+ json (1.8.0)
51
+ mail (2.5.4)
52
+ mime-types (~> 1.16)
53
+ treetop (~> 1.4.8)
54
+ mime-types (1.23)
55
+ minitest (4.7.4)
56
+ multi_json (1.7.6)
57
+ polyglot (0.3.3)
58
+ rack (1.5.2)
59
+ rack-test (0.6.2)
60
+ rack (>= 1.0)
61
+ rails (4.0.0.rc1)
62
+ actionmailer (= 4.0.0.rc1)
63
+ actionpack (= 4.0.0.rc1)
64
+ activerecord (= 4.0.0.rc1)
65
+ activesupport (= 4.0.0.rc1)
66
+ bundler (>= 1.3.0, < 2.0)
67
+ railties (= 4.0.0.rc1)
68
+ sprockets-rails (~> 2.0.0.rc4)
69
+ railties (4.0.0.rc1)
70
+ actionpack (= 4.0.0.rc1)
71
+ activesupport (= 4.0.0.rc1)
72
+ rake (>= 0.8.7)
73
+ thor (>= 0.18.1, < 2.0)
74
+ rake (10.0.4)
75
+ rdoc (3.12.2)
76
+ json (~> 1.4)
77
+ sass (3.2.9)
78
+ sass-rails (4.0.0.rc2)
79
+ railties (>= 4.0.0.beta, < 5.0)
80
+ sass (>= 3.1.10)
81
+ sprockets-rails (~> 2.0.0)
82
+ sdoc (0.3.20)
83
+ json (>= 1.1.3)
84
+ rdoc (~> 3.10)
85
+ sprockets (2.10.0)
86
+ hike (~> 1.2)
87
+ multi_json (~> 1.0)
88
+ rack (~> 1.0)
89
+ tilt (~> 1.1, != 1.3.0)
90
+ sprockets-rails (2.0.0)
91
+ actionpack (>= 3.0)
92
+ activesupport (>= 3.0)
93
+ sprockets (~> 2.8)
94
+ sqlite3 (1.3.7)
95
+ thor (0.18.1)
96
+ thread_safe (0.1.0)
97
+ atomic
98
+ tilt (1.4.1)
99
+ treetop (1.4.14)
100
+ polyglot
101
+ polyglot (>= 0.3.1)
102
+ turbolinks (1.2.0)
103
+ coffee-rails
104
+ tzinfo (0.3.37)
105
+ uglifier (2.1.1)
106
+ execjs (>= 0.3.0)
107
+ multi_json (~> 1.0, >= 1.0.2)
108
+
109
+ PLATFORMS
110
+ ruby
111
+
112
+ DEPENDENCIES
113
+ cdnjs-rails!
114
+ coffee-rails (~> 4.0.0)
115
+ jbuilder (~> 1.0.1)
116
+ rails (= 4.0.0.rc1)
117
+ sass-rails (~> 4.0.0.rc1)
118
+ sdoc
119
+ sqlite3
120
+ turbolinks
121
+ uglifier (>= 1.3.0)
@@ -0,0 +1,28 @@
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
+ <tt>rake doc:app</tt>.