Skip to content

Commit

Permalink
Support schemeless URL for Google CDN.
Browse files Browse the repository at this point in the history
  • Loading branch information
kenn committed Apr 23, 2012
1 parent 794025e commit 220761c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ On top of that, if you're using asset pipeline, you may have noticed that the ma
* Updating your js code won't evict the entire cache in browsers - your code changes more often than jQuery upgrades, right?
* `rake assets:precompile` takes less peak memory usage.

Changelog:

* v0.1.0: Added :google_schemeless for sites that support both ssl / non-ssl
* v0.0.1: Initial release

## Installation

Add this line to your application's Gemfile:
Expand All @@ -44,7 +49,15 @@ Then in layout:
= javascript_include_tag 'application'
```

Note that valid CDN symbols are `:google`, `:google_ssl`, `:microsoft` and `:jquery`.
Note that valid CDN symbols are:

```ruby
:google
:google_ssl
:google_schemeless
:microsoft
:jquery
```

It will generate the following on production:

Expand Down
10 changes: 6 additions & 4 deletions lib/jquery-rails-cdn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@

module Jquery::Rails::Cdn
module ActionViewExtensions
JQUERY_VERSION = Jquery::Rails::JQUERY_VERSION
OFFLINE = (Rails.env.development? or Rails.env.test?)
URL = {
:google => "http://ajax.googleapis.com/ajax/libs/jquery/#{Jquery::Rails::JQUERY_VERSION}/jquery.min.js",
:google_ssl => "https://ajax.googleapis.com/ajax/libs/jquery/#{Jquery::Rails::JQUERY_VERSION}/jquery.min.js",
:microsoft => "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-#{Jquery::Rails::JQUERY_VERSION}.min.js",
:jquery => "http://code.jquery.com/jquery-#{Jquery::Rails::JQUERY_VERSION}.min.js"
:google => "http://ajax.googleapis.com/ajax/libs/jquery/#{JQUERY_VERSION}/jquery.min.js",
:google_ssl => "https://ajax.googleapis.com/ajax/libs/jquery/#{JQUERY_VERSION}/jquery.min.js",
:google_schemeless => "//ajax.googleapis.com/ajax/libs/jquery/#{JQUERY_VERSION}/jquery.min.js",
:microsoft => "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-#{JQUERY_VERSION}.min.js",
:jquery => "http://code.jquery.com/jquery-#{JQUERY_VERSION}.min.js"
}

def jquery_url(name, options = {})
Expand Down
2 changes: 1 addition & 1 deletion lib/jquery-rails-cdn/version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Jquery
module Rails
module Cdn
VERSION = "0.0.1"
VERSION = "0.1.0"
end
end
end

0 comments on commit 220761c

Please sign in to comment.