pusher_rails 0.1.3 → 0.1.4
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.
- data/CHANGELOG.md +4 -0
- data/pusher_rails.gemspec +1 -1
- data/vendor/assets/javascripts/backpusher.js +25 -26
- metadata +4 -4
data/CHANGELOG.md
CHANGED
data/pusher_rails.gemspec
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
// we can setup the socket_id param.
|
17
17
|
if (channel.pusher.connection) {
|
18
18
|
channel.pusher.connection.bind('connected', function() {
|
19
|
-
Backbone.pusher_socket_id = channel.pusher.socket_id;
|
19
|
+
Backbone.pusher_socket_id = channel.pusher.connection.socket_id;
|
20
20
|
});
|
21
21
|
} else {
|
22
22
|
channel.pusher.bind('pusher:connection_established', function() {
|
@@ -100,40 +100,34 @@
|
|
100
100
|
'read' : 'GET'
|
101
101
|
};
|
102
102
|
|
103
|
-
|
104
|
-
// -------------
|
105
|
-
Backbone.sync = function(method, model, success, error) {
|
103
|
+
Backbone.sync = function(method, model, options) {
|
106
104
|
var type = methodMap[method];
|
107
|
-
var modelJSON = null;
|
108
105
|
|
109
|
-
|
110
|
-
|
111
|
-
|
106
|
+
// Default JSON-request options.
|
107
|
+
var params = _.extend({
|
108
|
+
type: type,
|
109
|
+
dataType: 'json'
|
110
|
+
}, options);
|
112
111
|
|
113
112
|
if (!(model && model.url)) {
|
114
113
|
throw new Error("A 'url' property or function must be specified");
|
115
114
|
}
|
116
115
|
|
117
|
-
|
118
|
-
|
116
|
+
if (!params.url) {
|
117
|
+
params.url = _.isFunction(model.url) ? model.url() : model.url;
|
118
|
+
params.url += '?socket_id=' + Backbone.pusher_socket_id;
|
119
|
+
}
|
119
120
|
|
120
|
-
//
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
data: modelJSON,
|
126
|
-
dataType: 'json',
|
127
|
-
processData: false,
|
128
|
-
success: success,
|
129
|
-
error: error
|
130
|
-
};
|
121
|
+
// Ensure that we have the appropriate request data.
|
122
|
+
if (!params.data && model && (method == 'create' || method == 'update')) {
|
123
|
+
params.contentType = 'application/json';
|
124
|
+
params.data = JSON.stringify(model.toJSON());
|
125
|
+
}
|
131
126
|
|
132
127
|
// For older servers, emulate JSON by encoding the request into an HTML-form.
|
133
128
|
if (Backbone.emulateJSON) {
|
134
129
|
params.contentType = 'application/x-www-form-urlencoded';
|
135
|
-
params.
|
136
|
-
params.data = modelJSON ? {model : modelJSON} : {};
|
130
|
+
params.data = params.data ? {model : params.data} : {};
|
137
131
|
}
|
138
132
|
|
139
133
|
// For older servers, emulate HTTP by mimicking the HTTP method with `_method`
|
@@ -143,15 +137,20 @@
|
|
143
137
|
if (Backbone.emulateJSON) params.data._method = type;
|
144
138
|
params.type = 'POST';
|
145
139
|
params.beforeSend = function(xhr) {
|
146
|
-
xhr.setRequestHeader(
|
140
|
+
xhr.setRequestHeader('X-HTTP-Method-Override', type);
|
147
141
|
};
|
148
142
|
}
|
149
143
|
}
|
150
144
|
|
145
|
+
// Don't process data on a non-GET request.
|
146
|
+
if (params.type !== 'GET' && !Backbone.emulateJSON) {
|
147
|
+
params.processData = false;
|
148
|
+
}
|
149
|
+
|
151
150
|
// Make the request.
|
152
|
-
$.ajax(params);
|
151
|
+
return $.ajax(params);
|
153
152
|
};
|
154
153
|
|
155
154
|
// Export:
|
156
155
|
exports.Backpusher = Backpusher;
|
157
|
-
})((typeof exports !== 'undefined' ? exports : this));
|
156
|
+
})((typeof exports !== 'undefined' ? exports : this));
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pusher_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-12-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pusher
|
16
|
-
requirement: &
|
16
|
+
requirement: &70285432931700 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 0.8.4
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70285432931700
|
25
25
|
description: Adds pusher.js/backpusher.js to the asset pipeline and pusher-gem to
|
26
26
|
to your app.
|
27
27
|
email:
|