Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Move jquery, jquery-ui and jquery-ujs version strings to a more acces…

…sible place.

On production sites, it's nice to use an offsite CDN to serve
jquery.js, and there's a nice technique for seamlessly falling back to
the local bundled jquery.js if the CDN is unavailable:

http://weblogs.asp.net/jgalloway/archive/2010/01/21/using-cdn-hosted-jquery-with-a-local-fall-back-copy.aspx.

To ensure that the CDN jquery.js version matches that bundled with
jquery-rails, it's necessary to programatically access the bundled
version number. This commit allows users to do the following, by
ensuring that the jquery version is no longer hidden away in the
install generator:

    = javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/#{Jquery::Rails::JQUERY_VERSION}/jquery.min.js"
    :javascript
      if (typeof jQuery == 'undefined') {
        document.write(unescape(#{URI.escape(javascript_include_tag('jquery')).to_json}));
      }
  • Loading branch information...
commit 5445a937f62c2f39edd4fe1fbd1e76e5f77ef071 1 parent 9205e3e
Steve Purcell authored
11 lib/generators/jquery/install/install_generator.rb
@@ -3,11 +3,8 @@
3 3 module Jquery
4 4 module Generators
5 5 class InstallGenerator < ::Rails::Generators::Base
6   - @@jquery_version = "1.6.1"
7   - @@jquery_ui_version = "1.8.12"
8   - @@jquery_ujs_version = "dad6982dc592686677e6845e681233c40d2ead27"
9 6
10   - desc "This generator installs jQuery #{@@jquery_version}, jQuery-ujs, and (optionally) jQuery UI #{@@jquery_ui_version}"
  7 + desc "This generator installs jQuery #{Jquery::Rails::JQUERY_VERSION}, jQuery-ujs, and (optionally) jQuery UI #{Jquery::Rails::JQUERY_UI_VERSION}"
11 8 class_option :ui, :type => :boolean, :default => false, :desc => "Include jQueryUI"
12 9 source_root File.expand_path('../../../../../vendor/assets/javascripts', __FILE__)
13 10
@@ -18,21 +15,21 @@ def remove_prototype
18 15 end
19 16
20 17 def copy_jquery
21   - say_status("copying", "jQuery (#{@@jquery_version})", :green)
  18 + say_status("copying", "jQuery (#{Jquery::Rails::JQUERY_VERSION})", :green)
22 19 copy_file "jquery.js", "public/javascripts/jquery.js"
23 20 copy_file "jquery.min.js", "public/javascripts/jquery.min.js"
24 21 end
25 22
26 23 def copy_jquery_ui
27 24 if options.ui?
28   - say_status("copying", "jQuery UI (#{@@jquery_ui_version})", :green)
  25 + say_status("copying", "jQuery UI (#{Jquery::Rails::JQUERY_UI_VERSION})", :green)
29 26 copy_file "jquery-ui.js", "public/javascripts/jquery-ui.js"
30 27 copy_file "jquery-ui.min.js", "public/javascripts/jquery-ui.min.js"
31 28 end
32 29 end
33 30
34 31 def copy_ujs_driver
35   - say_status("copying", "jQuery UJS adapter (#{@@jquery_ujs_version[0..5]})", :green)
  32 + say_status("copying", "jQuery UJS adapter (#{Jquery::Rails::JQUERY_UJS_VERSION[0..5]})", :green)
36 33 remove_file "public/javascripts/rails.js"
37 34 copy_file "jquery_ujs.js", "public/javascripts/jquery_ujs.js"
38 35 end
1  lib/jquery/rails.rb
@@ -7,5 +7,6 @@ module Rails
7 7 else
8 8 require 'jquery/rails/engine'
9 9 end
  10 + require 'jquery/rails/version'
10 11 end
11 12 end
3  lib/jquery/rails/version.rb
... ... @@ -1,5 +1,8 @@
1 1 module Jquery
2 2 module Rails
3 3 VERSION = "1.0.9"
  4 + JQUERY_VERSION = "1.6.1"
  5 + JQUERY_UI_VERSION = "1.8.12"
  6 + JQUERY_UJS_VERSION = "dad6982dc592686677e6845e681233c40d2ead27"
4 7 end
5 8 end

0 comments on commit 5445a93

Please sign in to comment.
Something went wrong with that request. Please try again.