jquery-ui-rails-cdn 0.1.0

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.
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
19
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
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,104 @@
1
+ # jquery-ui-rails-cdn
2
+
3
+ Add CDN support to
4
+
5
+ * [jquery-ui-rails](https://github.com/joliss/jquery-ui-rails).
6
+
7
+ Serving javascripts and stylesheets from a publicly available [CDN](http://en.wikipedia.org/wiki/Content_Delivery_Network) has clear benefits:
8
+
9
+ * **Speed**: Users will be able to download jQuery UI from the closest physical location.
10
+ * **Caching**: CDN is used so widely that potentially your users may not need to download jQuery UI and others at all.
11
+ * **Parallelism**: Browsers have a limitation on how many connections can be made to a single host. Using CDN for jQuery UI offloads a big one.
12
+
13
+ ## Features
14
+
15
+ This gem offers the following features:
16
+
17
+ * Supports multiple CDN. (Google, Microsoft and jqueryui.com)
18
+ * jQuery and jQuery-UI version is automatically detected via jquery-rails.
19
+ * Automatically fallback to jquery-rails' bundled jQuery when:
20
+ * You're on a development environment so that you can work offline.
21
+ * The CDN is down or unavailable.
22
+
23
+ On top of that, if you're using asset pipeline, you may have noticed that the major chunks of the code in `application.js` is jQuery. Implications of externalizing jQuery from `application.js` are:
24
+
25
+ * Updating your js code won't evict the entire cache in browsers - your code changes more often than jQuery upgrades, right?
26
+ * `rake assets:precompile` takes less peak memory usage.
27
+
28
+ Changelog:
29
+
30
+ * v0.2.2: Remove Bootstrap and Angular.js to their own rails engine.
31
+ * v0.2.1: Add Angular.js
32
+ * v0.2.0: Update to match original codes and update bootstrap to 2.1.0
33
+ * v0.1.2: Added bootstrap.
34
+ * v0.1.1: Added jQuery-UI
35
+ * v0.1.0: Added `:google_schemeless` for sites that support both ssl / non-ssl
36
+ * v0.0.1: Initial release
37
+
38
+ ## Installation
39
+
40
+ Add this line to your application's Gemfile:
41
+
42
+ ```ruby
43
+ gem 'jquery-rails-cdn'
44
+ ```
45
+
46
+ ## Usage
47
+
48
+ This gem adds these methods to generate a script tag to the jQuery on a CDN of your preference:
49
+ `jquery_include_tag` and `jquery_url`
50
+ `jQuery_ui_include_tag` and `jquery_ui_url`
51
+
52
+ If you're using asset pipeline with Rails 3.1+, first remove `//= require jquery` and `//= require jquery-ui` from `application.js`.
53
+
54
+ Then in layout:
55
+
56
+ ```ruby
57
+ = jquery_include_tag :google
58
+ = jquery_ui_include_tag :google
59
+ = javascript_include_tag 'application'
60
+ ```
61
+
62
+ Note that valid CDN symbols for jQuery and jQuery-UI are:
63
+
64
+ ```ruby
65
+ :google
66
+ :microsoft
67
+ :jquery
68
+ :yandex
69
+ ```
70
+
71
+ Note that valid CDN symbols for bootstrap are:
72
+
73
+ ```ruby
74
+ :default
75
+ ```
76
+
77
+ It will generate the following for jQuery and similarly for jQuery-UI on production:
78
+
79
+ ```html
80
+ <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
81
+ <script type="text/javascript">
82
+ //<![CDATA[
83
+ window.jQuery || document.write(unescape('%3Cscript src="/assets/jquery-86b29a215ef746103e2469f095a4df9e.js" type="text/javascript">%3C/script>'))
84
+ //]]>
85
+ </script>
86
+ ```
87
+
88
+ on development:
89
+
90
+ ```html
91
+ <script src="/assets/jquery.js?body=1" type="text/javascript"></script>
92
+ ```
93
+
94
+ If you want to check the production URL, you can pass `:force => true` as an option.
95
+
96
+ ```ruby
97
+ jquery_include_tag :google, :force => true
98
+ ```
99
+
100
+ To fallback to rails assets when CDN is not available, add `jquery.js` and `jquery-ui.js` in `config/environments/production.rb`
101
+
102
+ ```ruby
103
+ config.assets.precompile += %w( jquery.js jquery-ui.js )
104
+ ```
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env rake
2
+ require 'rake'
3
+ require 'bundler/setup'
4
+ require 'bundler/gem_tasks'
5
+ require 'rdoc/task'
6
+
7
+ desc 'Generate documentation for the timeline_fu plugin.'
8
+ Rake::RDocTask.new(:rdoc) do |rdoc|
9
+ rdoc.rdoc_dir = 'rdoc'
10
+ rdoc.title = 'jQuery-ui.cdn'
11
+ rdoc.options << '--line-numbers' << '--inline-source'
12
+ rdoc.rdoc_files.include('README*')
13
+ rdoc.rdoc_files.include('lib/**/*.rb')
14
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/jquery-ui-rails-cdn/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Mikhail Pobolovets"]
6
+ gem.email = ["styx.mp@gmail.com"]
7
+ gem.description = %q{Add CDN support to jquery-ui-rails}
8
+ gem.summary = %q{Add CDN support to jquery-ui-rails}
9
+ gem.homepage = "https://github.com/styx/jquery-ui-rails-cdn"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "jquery-ui-rails-cdn"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Jquery::Ui::Rails::Cdn::VERSION
17
+
18
+ gem.add_runtime_dependency "jquery-ui-rails"
19
+ end
@@ -0,0 +1,36 @@
1
+ require 'jquery-ui-rails'
2
+ require 'jquery-rails-cdn/version'
3
+
4
+ module Jquery::Ui::Rails::Cdn
5
+ module ActionViewExtensions
6
+ JQUERY_UI_VERSION = Jquery::Ui::Rails::JQUERY_UI_VERSION
7
+ OFFLINE = (Rails.env.development? or Rails.env.test?)
8
+
9
+ URL = {
10
+ :google => "//ajax.googleapis.com/ajax/libs/jqueryui/#{JQUERY_UI_VERSION}/jquery-ui.min.js",
11
+ :microsoft => "//ajax.aspnetcdn.com/ajax/jquery.ui/#{JQUERY_UI_VERSION}/jquery-ui.min.js",
12
+ :jquery => "http://code.jquery.com/ui/#{JQUERY_UI_VERSION}/jquery-ui.min.js",
13
+ :yandex => "//yandex.st/jquery-ui/#{JQUERY_UI_VERSION}/jquery-ui.min.js"
14
+ }
15
+
16
+ def jquery_ui_url(name, options = {})
17
+ return URL[name]
18
+ end
19
+
20
+ def jquery_ui_include_tag(name, options = {})
21
+ return javascript_include_tag(:'jquery-ui') if OFFLINE and !options[:force]
22
+
23
+ [ javascript_include_tag(jquery_ui_url(name, options)),
24
+ javascript_tag("window.jQuery.ui || document.write(unescape('#{javascript_include_tag(:'jquery-ui').gsub('<','%3C')}'))")
25
+ ].join("\n").html_safe
26
+ end
27
+ end
28
+
29
+ class Railtie < Rails::Railtie
30
+ initializer 'jquery_ui_rails_cdn.action_view' do |app|
31
+ ActiveSupport.on_load(:action_view) do
32
+ include Jquery::Ui::Rails::Cdn::ActionViewExtensions
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,9 @@
1
+ module Jquery
2
+ module Ui
3
+ module Rails
4
+ module Cdn
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jquery-ui-rails-cdn
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Mikhail Pobolovets
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-01 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: jquery-ui-rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: Add CDN support to jquery-ui-rails
31
+ email:
32
+ - styx.mp@gmail.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - Gemfile
39
+ - LICENSE
40
+ - README.md
41
+ - Rakefile
42
+ - jquery-ui-rails-cdn.gemspec
43
+ - lib/jquery-ui-rails-cdn.rb
44
+ - lib/jquery-ui-rails-cdn/version.rb
45
+ homepage: https://github.com/styx/jquery-ui-rails-cdn
46
+ licenses: []
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubyforge_project:
65
+ rubygems_version: 1.8.24
66
+ signing_key:
67
+ specification_version: 3
68
+ summary: Add CDN support to jquery-ui-rails
69
+ test_files: []