rocky 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
@@ -14,7 +14,7 @@ module Rocky
|
|
14
14
|
|
15
15
|
def inject_middleware
|
16
16
|
inject_into_file "app/assets/javascripts/application.js", :after => "//= require jquery_ujs" do
|
17
|
-
"\n//= require underscore\n//= require backbone\n//= require middleware\n//= require application/#{application_name.underscore}"
|
17
|
+
"\n//= require underscore\n//= require backbone\n//= require xdomain\n//= require middleware\n//= require application/#{application_name.underscore}"
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
data/lib/rocky/version.rb
CHANGED
@@ -0,0 +1,75 @@
|
|
1
|
+
/**
|
2
|
+
* jQuery.ajax mid - CROSS DOMAIN AJAX
|
3
|
+
* ---
|
4
|
+
* @author James Padolsey (http://james.padolsey.com)
|
5
|
+
* @version 0.11
|
6
|
+
* @updated 12-JAN-10
|
7
|
+
* ---
|
8
|
+
* Note: Read the README!
|
9
|
+
* ---
|
10
|
+
* @info http://james.padolsey.com/javascript/cross-domain-requests-with-jquery/
|
11
|
+
*/
|
12
|
+
|
13
|
+
jQuery.ajax = (function(_ajax){
|
14
|
+
|
15
|
+
var protocol = location.protocol,
|
16
|
+
hostname = location.hostname,
|
17
|
+
exRegex = RegExp(protocol + '//' + hostname),
|
18
|
+
YQL = 'http' + (/^https/.test(protocol)?'s':'') + '://query.yahooapis.com/v1/public/yql?callback=?',
|
19
|
+
query = 'select * from html where url="{URL}" and xpath="*"';
|
20
|
+
|
21
|
+
function isExternal(url) {
|
22
|
+
return !exRegex.test(url) && /:\/\//.test(url);
|
23
|
+
}
|
24
|
+
|
25
|
+
return function(o) {
|
26
|
+
|
27
|
+
var url = o.url;
|
28
|
+
|
29
|
+
if ( /get/i.test(o.type) && !/json/i.test(o.dataType) && isExternal(url) ) {
|
30
|
+
|
31
|
+
// Manipulate options so that JSONP-x request is made to YQL
|
32
|
+
|
33
|
+
o.url = YQL;
|
34
|
+
o.dataType = 'json';
|
35
|
+
|
36
|
+
o.data = {
|
37
|
+
q: query.replace(
|
38
|
+
'{URL}',
|
39
|
+
url + (o.data ?
|
40
|
+
(/\?/.test(url) ? '&' : '?') + jQuery.param(o.data)
|
41
|
+
: '')
|
42
|
+
),
|
43
|
+
format: 'xml'
|
44
|
+
};
|
45
|
+
|
46
|
+
// Since it's a JSONP request
|
47
|
+
// complete === success
|
48
|
+
if (!o.success && o.complete) {
|
49
|
+
o.success = o.complete;
|
50
|
+
delete o.complete;
|
51
|
+
}
|
52
|
+
|
53
|
+
o.success = (function(_success){
|
54
|
+
return function(data) {
|
55
|
+
|
56
|
+
if (_success) {
|
57
|
+
// Fake XHR callback.
|
58
|
+
_success.call(this, {
|
59
|
+
responseText: (data.results[0] || '')
|
60
|
+
// YQL screws with <script>s
|
61
|
+
// Get rid of them
|
62
|
+
.replace(/<script[^>]+?\/>|<script(.|\s)*?\/script>/gi, '')
|
63
|
+
}, 'success');
|
64
|
+
}
|
65
|
+
|
66
|
+
};
|
67
|
+
})(o.success);
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
return _ajax.apply(this, arguments);
|
72
|
+
|
73
|
+
};
|
74
|
+
|
75
|
+
})(jQuery.ajax);
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rocky
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: coffee-script
|
@@ -75,6 +75,7 @@ files:
|
|
75
75
|
- vendor/assets/javascripts/middleware/component/modal.js.coffee
|
76
76
|
- vendor/assets/javascripts/middleware/component/puppet.js.coffee
|
77
77
|
- vendor/assets/javascripts/underscore.js
|
78
|
+
- vendor/assets/javascripts/xdomain.js
|
78
79
|
- vendor/assets/javascripts/backbone.js
|
79
80
|
- vendor/assets/javascripts/middleware.js.coffee
|
80
81
|
- Rakefile
|