forked from lleger/Rails-3-jQuery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.rb
62 lines (53 loc) · 2.38 KB
/
jquery.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
# This template installs the new jQuery drivers, removes
# the old prototype drivers, and installs an initializer
# which provides a jquery javscript expansion
# and overrides the :defaults expansion
# Written by: Logan Leger, [email protected]
# http://github.com/lleger/Rails-3-jQuery
# Deleting old prototype drivers
# Do this first so that you don't delete the new jQuery rails one below
inside('public/javascripts') do
FileUtils.rm_rf %w(controls.js dragdrop.js effects.js prototype.js rails.js)
end
#disable ssl verification since it fails miserably on windows
#OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
# Downloading latest jQuery.min
get "http://code.jquery.com/jquery-latest.min.js", "public/javascripts/jquery.js"
# Downloading latest jQuery drivers
get "https://raw.github.com/rails/jquery-ujs/master/src/rails.js", "public/javascripts/rails.js"
# Overriding default expansion
if yes?("Override :defaults and setup :jquery expansion?")
initializer 'jquery.rb', <<-CODE
# Switch the javascript_include_tag :defaults to
# use jQuery instead of the default prototype helpers.
# Also setup a :jquery expansion, just for good measure.
# Written by: Logan Leger, [email protected]
# http://github.com/lleger/Rails-3-jQuery
ActionView::Helpers::AssetTagHelper.register_javascript_expansion :jquery => ['jquery', 'rails']
ActiveSupport.on_load(:action_view) do
ActiveSupport.on_load(:after_initialize) do
ActionView::Helpers::AssetTagHelper::register_javascript_expansion :defaults => ['jquery', 'rails']
end
end
CODE
elsif yes?("Override :defaults only?")
initializer 'jquery.rb', <<-CODE
# Switch the javascript_include_tag :defaults to
# use jQuery instead of the default prototype helpers.
# Written by: Logan Leger, [email protected]
# https://github.com/lleger/Rails-3-jQuery
ActiveSupport.on_load(:action_view) do
ActiveSupport.on_load(:after_initialize) do
ActionView::Helpers::AssetTagHelper::register_javascript_expansion :defaults => ['jquery', 'rails']
end
end
CODE
elsif yes?("Setup :jquery expansion only?")
initializer 'jquery.rb', <<-CODE
# Setup a :jquery expansion, just for good measure.
# Written by: Logan Leger, [email protected]
# https://github.com/lleger/Rails-3-jQuery
ActionView::Helpers::AssetTagHelper.register_javascript_expansion :jquery => ['jquery', 'rails']
CODE
end