cdnjs-rails 1.0.0 → 1.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -0
- data/Gemfile.lock +5 -2
- data/LICENSE +2 -2
- data/README.md +21 -20
- data/cdnjs-rails.gemspec +1 -1
- data/lib/cdnjs-rails/view_helpers.rb +19 -7
- data/{cdnjs-rails-0.0.1.gem → pkg/cdnjs-rails-1.0.1.gem} +0 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a00f41e41e1d86d4f6a83183b67528bc170f141
|
4
|
+
data.tar.gz: 6753cce10459173ee498916aac74dd2706a93df6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba3affba817f6f736191fe091c4390c7d42676ad876c6c9271d012da68a749f1ea1dc0a5dd216efe9519d3f72a85bdee678a712acb2f2ae70e9bf2f4bb247bfe
|
7
|
+
data.tar.gz: 5cec39ff36cc74c2576b8b17724ab90df87ea654701f215e0d102741cb6d239954ef8dbdbdc8722c0b5a47fe56778e7f4394d566c906bae50a8483df3dbd63a4
|
data/CHANGELOG.md
ADDED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
|
4
|
+
cdnjs-rails (1.0.1)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -11,4 +11,7 @@ PLATFORMS
|
|
11
11
|
ruby
|
12
12
|
|
13
13
|
DEPENDENCIES
|
14
|
-
|
14
|
+
cdnjs-rails!
|
15
|
+
|
16
|
+
BUNDLED WITH
|
17
|
+
1.10.6
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c)
|
1
|
+
Copyright (c) 2015 Kenn Ejima
|
2
2
|
|
3
3
|
MIT License
|
4
4
|
|
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
19
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
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.
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -42,34 +42,45 @@ gem 'jquery-rails'
|
|
42
42
|
gem 'cdnjs-rails'
|
43
43
|
```
|
44
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:
|
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, and :windowvar matches a variable that is added to the global scope by the library. Add this to your `config/application.rb` file so that it is loaded in all environments:
|
46
46
|
|
47
47
|
```ruby
|
48
48
|
# Specify CDNJS Libraries to include in the header with fallback using an array of hashes
|
49
49
|
config.cdnjs = [
|
50
|
-
{
|
51
|
-
{
|
50
|
+
{:cdnjs => 'jquery/2.0.2/jquery.min.js', :localpath => 'jquery.js', :windowvar => 'jQuery'},
|
51
|
+
{:cdnjs => 'jqueryui/1.10.3/jquery-ui.min.js', :localpath => 'jquery-ui.min.js', :windowvar => 'jQuery.ui'}
|
52
52
|
]
|
53
53
|
```
|
54
54
|
|
55
|
+
- Remove `//= jquery` from your `application.js` file so that jQuery
|
56
|
+
does not get compiled into your application.js. Also do this for other
|
57
|
+
cdnjs libraries you want that may be in here like `//= jquery-ui.min`
|
58
|
+
|
59
|
+
- Add the following to your `config/environments/production.rb` file.
|
60
|
+
The filenames should match the local filenames for your javascript
|
61
|
+
libraries.
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
config.assets.precompile += %w( jquery.js jquery-ui.min.js )
|
65
|
+
```
|
66
|
+
|
55
67
|
- Finally add this section to your layouts file.
|
56
68
|
|
57
|
-
```
|
58
|
-
<%= cdnjs_include_tag
|
59
|
-
<%= javascript_include_tag "application" %>
|
69
|
+
```erb
|
70
|
+
<%= cdnjs_include_tag %>
|
71
|
+
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
|
60
72
|
```
|
61
73
|
|
62
74
|
- 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
75
|
|
64
|
-
```
|
76
|
+
```erb
|
65
77
|
<!DOCTYPE html>
|
66
78
|
<html>
|
67
79
|
<head>
|
68
80
|
<title>Demoapp</title>
|
69
|
-
<%= cdnjs_include_tag
|
70
|
-
<%= javascript_include_tag "application" %>
|
81
|
+
<%= cdnjs_include_tag %>
|
82
|
+
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
|
71
83
|
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
|
72
|
-
<%= javascript_include_tag "data-turbolinks-track" => true %>
|
73
84
|
<%= csrf_meta_tags %>
|
74
85
|
</head>
|
75
86
|
<body>
|
@@ -96,13 +107,3 @@ window.jQuery || document.write(unescape('%3Cscript src="/assets/jquery-ui.min.j
|
|
96
107
|
//]]>
|
97
108
|
</script>
|
98
109
|
```
|
99
|
-
|
100
|
-
=============
|
101
|
-
|
102
|
-
###Changelog
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
###Changelog
|
107
|
-
|
108
|
-
* v0.0.1: Initial release
|
data/cdnjs-rails.gemspec
CHANGED
@@ -1,20 +1,32 @@
|
|
1
1
|
module CDNJS
|
2
2
|
module ViewHelpers
|
3
|
-
def cdnjs_include_tag(cdn_vars)
|
4
|
-
|
3
|
+
def cdnjs_include_tag(cdn_vars=nil)
|
4
|
+
cdn_vars ||= Rails.application.config.cdnjs
|
5
5
|
js_string_output = Array.new
|
6
6
|
|
7
7
|
cdn_vars.each do |js_file_config|
|
8
|
+
window_var = js_file_config.fetch(:windowvar)
|
9
|
+
split_vars = window_var.split(".")
|
10
|
+
window_path = ""
|
8
11
|
|
9
|
-
|
10
|
-
|
12
|
+
split_vars.each_with_index do |val, index|
|
13
|
+
var_check = ["window"]
|
11
14
|
|
12
|
-
|
15
|
+
0.upto(index) do |i|
|
16
|
+
var_check.push split_vars[i]
|
17
|
+
end
|
18
|
+
|
19
|
+
window_path << var_check.join(".") + " && "
|
20
|
+
end
|
13
21
|
|
14
|
-
|
22
|
+
window_path.chomp!(" && ")
|
15
23
|
|
24
|
+
js_string_output << javascript_include_tag("//cdnjs.cloudflare.com/ajax/libs/#{js_file_config.fetch(:cdnjs)}")
|
25
|
+
js_string_output << javascript_tag("(#{window_path}) || document.write(unescape(\"%3Cscript src='#{asset_path(js_file_config.fetch(:localpath)).gsub('<','%3C')}' type='text/javascript'%3E%3C/script%3E\"))")
|
26
|
+
end
|
27
|
+
|
28
|
+
js_string_output.join("\n").html_safe
|
16
29
|
end
|
17
30
|
end
|
18
31
|
end
|
19
32
|
|
20
|
-
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cdnjs-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Hough
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Use the CDNJS CDN to serve files and fall back to the local version if
|
14
14
|
the CDN is unreachable.
|
@@ -20,16 +20,17 @@ extra_rdoc_files: []
|
|
20
20
|
files:
|
21
21
|
- ".DS_Store"
|
22
22
|
- ".gitignore"
|
23
|
+
- CHANGELOG.md
|
23
24
|
- Gemfile
|
24
25
|
- Gemfile.lock
|
25
26
|
- LICENSE
|
26
27
|
- README.md
|
27
28
|
- Rakefile
|
28
|
-
- cdnjs-rails-0.0.1.gem
|
29
29
|
- cdnjs-rails.gemspec
|
30
30
|
- lib/cdnjs-rails.rb
|
31
31
|
- lib/cdnjs-rails/railtie.rb
|
32
32
|
- lib/cdnjs-rails/view_helpers.rb
|
33
|
+
- pkg/cdnjs-rails-1.0.1.gem
|
33
34
|
homepage: https://github.com/chrishough/cdnjs-rails
|
34
35
|
licenses:
|
35
36
|
- GPL
|
@@ -50,7 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
51
|
version: '0'
|
51
52
|
requirements: []
|
52
53
|
rubyforge_project:
|
53
|
-
rubygems_version: 2.
|
54
|
+
rubygems_version: 2.4.5
|
54
55
|
signing_key:
|
55
56
|
specification_version: 4
|
56
57
|
summary: A gem to serve CDNJS files with fall back protection.
|