virgo-gadgeteer 0.2.4 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 4
2
+ :patch: 6
3
3
  :major: 0
4
4
  :minor: 2
@@ -1,8 +1,8 @@
1
1
  /*! Copyright (c) 2009 Virgo Systems Kft. (http://virgo.hu)
2
2
  * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
3
3
  *
4
- * Version: 1.0.2
5
- * Requires opensocial-jQuery 0.5+
4
+ * Version: 0.2.6
5
+ * Requires opensocial-jQuery 1.0+
6
6
  */
7
7
 
8
8
  (function($) {
@@ -27,27 +27,54 @@ $.gadgeteer = function(callback, options) {
27
27
  }
28
28
 
29
29
  if (!options.noAjaxForms) {
30
+ // Making sure submit input element values are submitted
31
+ $('form input[type=submit]').livequery('click', function(e) {
32
+ $(this).parents('form:eq(0)').data('submitClicked', $(this));
33
+ });
30
34
  // All forms will submit through an ajax call
31
35
  $('form').livequery('submit', function(e) {
32
36
  e.preventDefault();
33
37
  var form = $(this);
34
38
  var action = form.attr('action');
35
39
  var target = form.hasClass('silent') ? null : $.gadgeteer.defaultTarget;
40
+ var params = [$.param(form.formToArray()), $.param($.gadgeteer.viewer.osParams()), $.param($.gadgeteer.owner.osParams())];
41
+ var submit = form.data('submitClicked');
42
+ if (submit) {
43
+ if (submit.attr('name')) {
44
+ var param = {};
45
+ param[submit.attr('name')] = submit.val();
46
+ params.push($.param(param));
47
+ }
48
+ if ($.gadgeteer.options.submitSendingMessage) {
49
+ submit.data('oldValue', submit.val());
50
+ submit.val($.gadgeteer.options.submitSendingMessage).get(0).disabled = true;
51
+ }
52
+ form.data('submitClicked', null);
53
+ }
54
+ action = $.gadgeteer.expandUri(action);
36
55
  $.ajax({
37
56
  url: action.charAt(0) == '/' ? $.gadgeteer.host + action : action,
38
57
  type: form.attr('method') || 'GET',
39
- data: [$.param(form.formToArray()), $.param($.gadgeteer.viewer.osParams()), $.param($.gadgeteer.owner.osParams())].join("&"),
58
+ data: params.join("&"),
40
59
  dataType: 'html',
41
- auth: 'SIGNED',
42
- target: target
60
+ oauth: 'signed',
61
+ target: target,
62
+ complete: function(request, status) {
63
+ if (submit) {
64
+ var oldValue = submit.data('oldValue');
65
+ if (oldValue) {
66
+ submit.val(oldValue).get(0).disabled = false;
67
+ submit.data('oldValue', null);
68
+ }
69
+ }
70
+ }
43
71
  });
44
72
  });
45
73
  }
46
74
 
47
75
  // Setup ajax event callbacks
48
76
  $(document).ajaxSend(function(e, request, settings) {
49
- if (settings.target) {
50
- // TODO: make this customizable by `loading` callback in options
77
+ if (settings.target && $.gadgeteer.options.loadingMessage) {
51
78
  $(settings.target).append($.gadgeteer.loadingElem());
52
79
  }
53
80
  }).ajaxSuccess(function(e, request, settings) {
@@ -61,26 +88,30 @@ $.gadgeteer = function(callback, options) {
61
88
  // Do another adjustHeight in 250ms just to be sure
62
89
  setTimeout(function() {$(window).adjustHeight();}, 250);
63
90
  }).ajaxError(function(e, request, settings, exception) {
64
- console.log(request, settings, exception);
65
- if (settings.target) {
91
+ if (settings.target && request.status.toString().charAt(0) != '3') {
66
92
  var html = request.responseText;
67
93
  $(settings.target).html(html);
94
+ // !iframe
95
+ $(window).adjustHeight();
96
+ // Do another adjustHeight in 250ms just to be sure
97
+ setTimeout(function() {$(window).adjustHeight();}, 250);
68
98
  }
69
- // !iframe
70
- $(window).adjustHeight();
71
- // Do another adjustHeight in 250ms just to be sure
72
- setTimeout(function() {$(window).adjustHeight();}, 250);
73
99
  }).ajaxComplete(function(e, request, settings) {
74
100
  if (request.status.toString().charAt(0) == '3') {
75
101
  var href = request.getResponseHeader('Location') || request.getResponseHeader('location');
76
102
  // hackish way to determine if we have an array (depends on the fact that the real href must be longer than 1 char)
77
103
  if (!href.charAt) href = href[0];
104
+ href = $.gadgeteer.expandUri(href);
105
+ var params = '';
106
+ if (settings.auth == 'signed' || !$.gadgeteer.options.dontAddOsParams) {
107
+ params = $.param($.gadgeteer.viewer.osParams()) + '&' + $.param($.gadgeteer.owner.osParams())
108
+ }
78
109
  $.ajax({
79
110
  url: href.charAt(0) == '/' ? $.gadgeteer.host + href : href,
80
111
  type: 'GET',
81
- data: $.param($.gadgeteer.viewer.osParams()) + '&' + $.param($.gadgeteer.owner.osParams()),
112
+ data: params,
82
113
  dataType: 'html',
83
- auth: settings.auth,
114
+ oauth: settings.auth,
84
115
  target: settings.target
85
116
  });
86
117
  }
@@ -88,12 +119,14 @@ $.gadgeteer = function(callback, options) {
88
119
 
89
120
  // Wait for everything to load then call the callback
90
121
  setTimeout(function() {
91
- if ($.gadgeteer.viewer && $.gadgeteer.owner) {
122
+ if ($.gadgeteer.viewer && $.gadgeteer.owner && $.gadgeteer.data && $.gadgeteer.owner.data) {
92
123
  // Navigate away if params tell so
93
124
  var params = gadgets.views.getParams();
94
125
  var navTo = params.navigateTo;
95
126
  if (navTo) {
96
- $.gadgeteer.simpleRequest(navTo, params.signedNavigate);
127
+ // Tell the callback that we're navigating away
128
+ callback(true);
129
+ $.gadgeteer.simpleRequest(navTo, {signed: params.signedNavigate});
97
130
  } else {
98
131
  callback();
99
132
  }
@@ -106,11 +139,49 @@ $.gadgeteer = function(callback, options) {
106
139
  // Get information about the viewer and owner
107
140
  $.getData('/people/@viewer/@self', function(data, status) {
108
141
  $.gadgeteer.viewer = data[0];
109
- $.gadgeteer.viewer.osParams = function() {return $.gadgeteer._osParams.call($.gadgeteer.viewer, 'viewer')};
142
+ $.gadgeteer.viewer.osParams = function() {
143
+ return $.gadgeteer._osParams.call($.gadgeteer.viewer, 'viewer')
144
+ };
145
+ $.getData('/appdata/@viewer', function(data, status) {
146
+ for (var id in data) {
147
+ data = data[id];
148
+ break;
149
+ }
150
+ $.gadgeteer.data = $.gadgeteer.viewer.data = function(key, value, cb) {
151
+ if (value === undefined) {
152
+ return data[key];
153
+ } else {
154
+ data[key] = value;
155
+ var params = {};
156
+ params[key] = value;
157
+ $.postData('/appdata/@viewer', params, cb);
158
+ return value;
159
+ }
160
+ };
161
+ });
110
162
  });
111
163
  $.getData('/people/@owner/@self', function(data, status) {
112
164
  $.gadgeteer.owner = data[0];
113
- $.gadgeteer.owner.osParams = function() {return $.gadgeteer._osParams.call($.gadgeteer.owner, 'owner')};
165
+ $.gadgeteer.owner.osParams = function() {
166
+ return $.gadgeteer._osParams.call($.gadgeteer.owner, 'owner');
167
+ };
168
+ $.getData('/appdata/@owner', function(data, status) {
169
+ for (var id in data) {
170
+ data = data[id];
171
+ break;
172
+ }
173
+ $.gadgeteer.owner.data = function(key, value, cb) {
174
+ if (value === undefined) {
175
+ return data[key];
176
+ } else {
177
+ data[key] = value;
178
+ var params = {};
179
+ params[key] = value;
180
+ $.postData('/appdata/@owner', params, cb);
181
+ return value;
182
+ }
183
+ };
184
+ });
114
185
  });
115
186
  }
116
187
  }
@@ -130,29 +201,48 @@ $.extend($.gadgeteer, {
130
201
  loadingElem: function() {
131
202
  if ($.gadgeteer.LOADING_ELEM) return $.gadgeteer.LOADING_ELEM;
132
203
 
133
- // TODO: make this customizable
134
204
  var loading = $('#loading');
135
205
  if (loading.length < 1) {
136
- loading = $('<div id="loading">Az oldal tölt <span class="ellipses">…</span></div>');
206
+ loading = $('<div id="loading">'+$.gadgeteer.options.loadingMessage+'</div>');
137
207
  }
138
208
  return $.gadgeteer.LOADING_ELEM = loading;
139
209
  },
140
210
 
141
- simpleRequest: function(href, signed) {
211
+ expandUri: function(uri) {
212
+ if (!$.gadgeteer.options.dontExpand) {
213
+ if ($.gadgeteer.viewer) {
214
+ uri = uri.replace(/(?:(\/)|{)viewer(?:}|([\/\?#]|$))/g, '$1'+$.gadgeteer.viewer.id.replace(/\./g, '-')+'$2');
215
+ }
216
+ if ($.gadgeteer.owner) {
217
+ uri = uri.replace(/(?:(\/)|{)owner(?:}|([\/\?#]|$))/g, '$1'+$.gadgeteer.owner.id.replace(/\./g, '-')+'$2');
218
+ }
219
+ }
220
+ return uri;
221
+ },
222
+
223
+ simpleRequest: function(href, options) {
142
224
  var params = {}
143
- if (href.indexOf('os_viewer_id') == -1) params.os_viewer_id = $.gadgeteer.viewer.id;
144
- if (href.indexOf('os_owner_id') == -1) params.os_owner_id = $.gadgeteer.owner.id;
145
- if (signed) {
225
+ if (options === undefined) options = {};
226
+ if (options.addProfileIds) {
227
+ if (href.indexOf('os_viewer_id') == -1) params.os_viewer_id = $.gadgeteer.viewer.id;
228
+ if (href.indexOf('os_owner_id') == -1) params.os_owner_id = $.gadgeteer.owner.id;
229
+ }
230
+ if (options.signed) {
146
231
  params = $.extend(false, params, $.gadgeteer.viewer.osParams(), $.gadgeteer.owner.osParams());
147
232
  }
148
- $.ajax({
149
- type: 'GET',
150
- data: $.param(params),
151
- url: href.charAt(0) == '/' ? $.gadgeteer.host + href : href,
152
- dataType: 'html',
153
- auth: signed && 'SIGNED',
154
- target: $($.gadgeteer.defaultTarget)
155
- });
233
+ href = $.gadgeteer.expandUri(href);
234
+ options = $.extend(
235
+ { // defaults
236
+ type: 'GET',
237
+ dataType: 'html'
238
+ }, options, { // force options
239
+ data: $.param(params),
240
+ url: href.charAt(0) == '/' ? $.gadgeteer.host + href : href,
241
+ oauth: options.signed && 'signed',
242
+ target: options.target === undefined ? $($.gadgeteer.defaultTarget) : options.target
243
+ }
244
+ );
245
+ $.ajax(options);
156
246
  },
157
247
 
158
248
  regularRequest: function(e) {
@@ -177,24 +267,28 @@ $.extend($.gadgeteer, {
177
267
  var params = {};
178
268
  var method = link.hasClass('post') ? 'post' : link.hasClass('put') ? 'put' : link.hasClass('delete') ? 'delete' : 'get';
179
269
  if (method != 'get') params._method = method;
180
- if (link.hasClass('signed'))
270
+ if (link.hasClass('signed')) {
181
271
  params = $.extend(false, params, $.gadgeteer.viewer.osParams(), $.gadgeteer.owner.osParams());
182
- else
272
+ } else if (!$.gadgeteer.options.dontAddOsParams) {
183
273
  params = $.extend(false, params, {os_viewer_id: $.gadgeteer.viewer.id, os_owner_id: $.gadgeteer.owner.id});
274
+ }
184
275
 
185
276
  var target = link.hasClass('silent') ? null : $.gadgeteer.defaultTarget;
277
+ href = $.gadgeteer.expandUri(href);
186
278
  $.ajax({
187
279
  type: method == 'get' ? 'GET' : 'POST',
188
280
  url: href,
189
281
  data: params,
190
282
  dataType: target ? 'html' : null,
191
- auth: link.hasClass('signed') ? 'SIGNED' : null,
283
+ oauth: link.hasClass('signed') ? 'signed' : null,
192
284
  target: target
193
285
  });
194
286
  },
195
287
 
196
288
  navigateRequest: function(view, params, ownerId, e) {
197
- e.preventDefault();
289
+ if (e !== undefined) {
290
+ e.preventDefault();
291
+ }
198
292
  view = gadgets.views.getSupportedViews()[view];
199
293
  gadgets.views.requestNavigateTo(view, params, ownerId);
200
294
  },
@@ -1,5 +1,5 @@
1
1
  /**
2
- * opensocial-jquery 0.5.1
2
+ * opensocial-jquery 1.0.1
3
3
  * http://code.google.com/p/opensocial-jquery/
4
4
  *
5
5
  * Enhancing of jQuery.ajax with JSDeferred
@@ -2555,6 +2555,12 @@ var jsc = now();
2555
2555
 
2556
2556
  jQuery.extend({
2557
2557
  get: function( url, data, callback, type ) {
2558
+ var off = url.indexOf(" ");
2559
+ if ( off >= 0 ) {
2560
+ var oauth = url.slice(off + 1, url.length);
2561
+ url = url.slice(0, off);
2562
+ }
2563
+
2558
2564
  // shift arguments if data argument was ommited
2559
2565
  if ( jQuery.isFunction( data ) ) {
2560
2566
  callback = data;
@@ -2566,7 +2572,8 @@ jQuery.extend({
2566
2572
  url: url,
2567
2573
  data: data,
2568
2574
  success: callback,
2569
- dataType: type
2575
+ dataType: type,
2576
+ oauth: oauth
2570
2577
  });
2571
2578
  },
2572
2579
 
@@ -2579,6 +2586,12 @@ jQuery.extend({
2579
2586
  },
2580
2587
 
2581
2588
  post: function( url, data, callback, type ) {
2589
+ var off = url.indexOf(" ");
2590
+ if ( off >= 0 ) {
2591
+ var oauth = url.slice(off + 1, url.length);
2592
+ url = url.slice(0, off);
2593
+ }
2594
+
2582
2595
  if ( jQuery.isFunction( data ) ) {
2583
2596
  callback = data;
2584
2597
  data = {};
@@ -2589,7 +2602,8 @@ jQuery.extend({
2589
2602
  url: url,
2590
2603
  data: data,
2591
2604
  success: callback,
2592
- dataType: type
2605
+ dataType: type,
2606
+ oauth: oauth
2593
2607
  });
2594
2608
  },
2595
2609
 
@@ -2745,9 +2759,6 @@ jQuery.extend({
2745
2759
  xhr.open(type, s.url, s.async, s.username, s.password);
2746
2760
  else
2747
2761
  xhr.open(type, s.url, s.async);
2748
-
2749
- if( s.auth && jQuery.isFunction(xhr.setAuthorizationType) )
2750
- xhr.setAuthorizationType(s.auth);
2751
2762
 
2752
2763
  // Need an extra try/catch for cross domain requests in Firefox 3
2753
2764
  try {
@@ -2855,7 +2866,7 @@ jQuery.extend({
2855
2866
  // Send the data
2856
2867
  try {
2857
2868
  // xhr.send(s.data);
2858
- xhr.send(s.data, s.dataType);
2869
+ xhr.send(s.data, s);
2859
2870
 
2860
2871
  } catch(e) {
2861
2872
  jQuery.handleError(s, xhr, null, e);
@@ -3731,6 +3742,7 @@ jQuery.each([ "Height", "Width" ], function(i, name){
3731
3742
  orkut: /orkut/.test(synd),
3732
3743
  hi5: /hi5/.test(synd),
3733
3744
  myspace: /msappspace/.test(location.host),
3745
+ goohome: /goohome/.test(synd),
3734
3746
  sandbox: /sandbox/.test(synd) ||
3735
3747
  /sandbox/.test(parent) ||
3736
3748
  /sandbox/.test(location.host) ||
@@ -3749,9 +3761,8 @@ jQuery.each([ "Height", "Width" ], function(i, name){
3749
3761
  * Preference
3750
3762
  */
3751
3763
 
3752
- var prefs = new gadgets.Prefs();
3753
-
3754
3764
  $.pref = function(key, value) {
3765
+ var prefs = new gadgets.Prefs();
3755
3766
  var pairs = key;
3756
3767
 
3757
3768
  if (key.constructor === String)
@@ -3781,6 +3792,10 @@ jQuery.each([ "Height", "Width" ], function(i, name){
3781
3792
  return v.replace(/%7C/g, '|')
3782
3793
  });
3783
3794
  };
3795
+
3796
+ $.msg = function(key) {
3797
+ return new gadgets.Prefs().getMsg(key);
3798
+ };
3784
3799
 
3785
3800
  /**
3786
3801
  * Window
@@ -3794,7 +3809,9 @@ jQuery.each([ "Height", "Width" ], function(i, name){
3794
3809
 
3795
3810
  $.fn.adjustHeight = function(height) {
3796
3811
  if (this[0] === window)
3797
- gadgets.window.adjustHeight(height);
3812
+ setTimeout(function() {
3813
+ gadgets.window.adjustHeight(height);
3814
+ }, 0);
3798
3815
  return this;
3799
3816
  };
3800
3817
 
@@ -3833,7 +3850,96 @@ jQuery.each([ "Height", "Width" ], function(i, name){
3833
3850
  }
3834
3851
  return names;
3835
3852
  };
3836
-
3853
+
3854
+ /**
3855
+ * Flash
3856
+ */
3857
+ if (gadgets.flash) {
3858
+
3859
+ $.flash = {
3860
+ version: gadgets.flash.getMajorVersion()
3861
+ };
3862
+
3863
+ $.fn.flash = function(url, data) {
3864
+ data = $.extend(true, {}, data);
3865
+ for (var key in data)
3866
+ if (key.toLowerCase() == 'flashvars' && data[key] && typeof(data[key]) != 'string')
3867
+ data[key] = jQuery.param(data[key]);
3868
+ return this.each(function() {
3869
+ gadgets.flash.embedFlash(url, this, $.flash.version, data);
3870
+ });
3871
+ };
3872
+
3873
+ }
3874
+
3875
+ /**
3876
+ * MiniMessage
3877
+ */
3878
+ if (gadgets.MiniMessage) {
3879
+
3880
+ $.fn.minimessage = function(fn) {
3881
+ return this.each(function(i, n) {
3882
+ if (n.parentNode)
3883
+ n.parentNode.removeChild(n);
3884
+ new gadgets.MiniMessage()
3885
+ .createDismissibleMessage(n, function() {
3886
+ return (fn || function() {}).apply(n) !== false;
3887
+ });
3888
+ });
3889
+ };
3890
+
3891
+ } // if (gadgets.MiniMessage) {
3892
+
3893
+ /**
3894
+ * Tabs
3895
+ */
3896
+ if (gadgets.TabSet) {
3897
+
3898
+ $.fn.tabs = function(fn) {
3899
+ return this.each(function() {
3900
+ var tabset = new gadgets.TabSet(null, null, this);
3901
+ tabset.alignTabs('left');
3902
+ $('ul', this)
3903
+ .find('li a')
3904
+ .each(function(i) {
3905
+ var content = $('#' + this.href.split('#')[1]).get(0);
3906
+ tabset.addTab($(this).html(), {
3907
+ tooltip: this.title,
3908
+ contentContainer: content,
3909
+ callback: function () {
3910
+ if (fn) fn.apply(content, [i, content]);
3911
+ }
3912
+ });
3913
+ })
3914
+ .end()
3915
+ .remove();
3916
+ });
3917
+ };
3918
+
3919
+ } // if (gadgets.TabSet) {
3920
+
3921
+ /**
3922
+ * PubSub
3923
+ */
3924
+ if (gadgets.pubsub) {
3925
+
3926
+ $.pub = function(channel, data) {
3927
+ gadgets.pubsub.publish(channel, data);
3928
+ };
3929
+
3930
+ $.sub = function(channel, fn) {
3931
+ gadgets.pubsub.subscribe(channel, fn);
3932
+ };
3933
+
3934
+ } // if (gadgets.pubsub) {
3935
+
3936
+ /**
3937
+ * Skins
3938
+ */
3939
+ if (gadgets.skins) {
3940
+
3941
+ } // if (gadgets.skins) {
3942
+
3837
3943
  })(jQuery);
3838
3944
  (function($) {
3839
3945
 
@@ -3855,8 +3961,9 @@ jQuery.each([ "Height", "Width" ], function(i, name){
3855
3961
  this.responseHeaders = {};
3856
3962
  },
3857
3963
 
3858
- send: function(data, dataType) {
3964
+ send: function(data, s) {
3859
3965
  var self = this;
3966
+ var dataType = s.dataType;
3860
3967
 
3861
3968
  var opt_params = [];
3862
3969
  opt_params[gadgets.io.RequestParameters.METHOD] = self.type;
@@ -3865,13 +3972,14 @@ jQuery.each([ "Height", "Width" ], function(i, name){
3865
3972
  dataType === 'xml' && gadgets.io.ContentType.DOM ||
3866
3973
  dataType === 'feed' && gadgets.io.ContentType.FEED ||
3867
3974
  gadgets.io.ContentType.TEXT;
3868
- if (this.authorizationType)
3869
- opt_params[gadgets.io.RequestParameters.AUTHORIZATION] = gadgets.io.AuthorizationType[this.authorizationType.toUpperCase()];
3870
-
3871
3975
 
3872
3976
  if (data)
3873
3977
  opt_params[gadgets.io.RequestParameters.POST_DATA] = data;
3874
3978
 
3979
+ if (s.oauth == 'signed')
3980
+ opt_params[gadgets.io.RequestParameters.AUTHORIZATION] =
3981
+ gadgets.io.AuthorizationType.SIGNED;
3982
+
3875
3983
  if (dataType == 'feed')
3876
3984
  opt_params['NUM_ENTRIES'] = 10;
3877
3985
 
@@ -3918,7 +4026,7 @@ jQuery.each([ "Height", "Width" ], function(i, name){
3918
4026
  } else {
3919
4027
  self.status = res.rc;
3920
4028
  //self.statusText = 'OK';
3921
- self.responseHeaders = res.headers;
4029
+ self.responseHeaders = res.headers || {};
3922
4030
  self.responseText = res.text;
3923
4031
 
3924
4032
  if (dataType == 'xml')
@@ -3946,11 +4054,6 @@ jQuery.each([ "Height", "Width" ], function(i, name){
3946
4054
 
3947
4055
  getResponseHeader: function(header) {
3948
4056
  return this.responseHeaders[header];
3949
- },
3950
-
3951
- // set authentication type
3952
- setAuthorizationType: function(auth) {
3953
- this.authorizationType = auth;
3954
4057
  }
3955
4058
  };
3956
4059
 
@@ -3971,6 +4074,10 @@ jQuery.each([ "Height", "Width" ], function(i, name){
3971
4074
  return jQuery.get(url, data, callback, 'feed');
3972
4075
  };
3973
4076
 
4077
+ $.proxy = function(url) {
4078
+ return gadgets.io.getProxyUrl(url);
4079
+ };
4080
+
3974
4081
  })(jQuery);
3975
4082
  (function($) {
3976
4083
 
@@ -3980,9 +4087,14 @@ jQuery.each([ "Height", "Width" ], function(i, name){
3980
4087
  /**
3981
4088
  * Environment
3982
4089
  */
4090
+ if (opensocial) {
4091
+
4092
+ $(function() {
4093
+ $.container.domain = opensocial.getEnvironment().getDomain();
4094
+ });
4095
+
4096
+ } // if (opensocial) {
3983
4097
 
3984
- $.container.domain = opensocial.getEnvironment().getDomain();
3985
-
3986
4098
  /**
3987
4099
  * DataRequest
3988
4100
  */
@@ -4001,7 +4113,10 @@ jQuery.each([ "Height", "Width" ], function(i, name){
4001
4113
  '@owner': 'OWNER',
4002
4114
  '@self': 'SELF',
4003
4115
  '@friends': 'FRIENDS',
4004
- '@all': 'ALL'
4116
+ '@all': 'ALL',
4117
+ '@me/@friends': 'VIEWER_FRIENDS',
4118
+ '@viewer/@friends': 'VIEWER_FRIENDS',
4119
+ '@owner/@friends': 'OWNER_FRIENDS'
4005
4120
  };
4006
4121
 
4007
4122
  var filter = {
@@ -4133,7 +4248,7 @@ jQuery.each([ "Height", "Width" ], function(i, name){
4133
4248
 
4134
4249
  $.extend($._xhr.getPeople.prototype, $._xhr.prototype, {
4135
4250
 
4136
- send: function(data, dataType) {
4251
+ send: function(data) {
4137
4252
  var self = this, query = parseUrl(self.url);
4138
4253
 
4139
4254
  var idspec = identify(query);
@@ -4233,7 +4348,7 @@ jQuery.each([ "Height", "Width" ], function(i, name){
4233
4348
 
4234
4349
  $.extend($._xhr.getAppData.prototype, $._xhr.prototype, {
4235
4350
 
4236
- send: function(data, dataType) {
4351
+ send: function(data) {
4237
4352
  var self = this, query = parseUrl(self.url);
4238
4353
 
4239
4354
  var idspec = identify(query);
@@ -4286,7 +4401,7 @@ jQuery.each([ "Height", "Width" ], function(i, name){
4286
4401
 
4287
4402
  $.extend($._xhr.postAppData.prototype, $._xhr.prototype, {
4288
4403
 
4289
- send: function(data, dataType) {
4404
+ send: function(data) {
4290
4405
  var self = this, query = parseUrl(self.url);
4291
4406
 
4292
4407
  var idspec = identify(query);
@@ -4322,4 +4437,159 @@ jQuery.each([ "Height", "Width" ], function(i, name){
4322
4437
 
4323
4438
  $.ajaxSettings.xhr.addRoute('POST', '/appdata/', $._xhr.postAppData);
4324
4439
 
4440
+ /**
4441
+ * getActivity
4442
+ */
4443
+ if (opensocial) {
4444
+
4445
+ $._xhr.getActivity = function() {
4446
+ this.initialize();
4447
+ };
4448
+
4449
+ $.extend($._xhr.getActivity.prototype, $._xhr.prototype, {
4450
+
4451
+ send: function(data) {
4452
+ var self = this, query = parseUrl(self.url);
4453
+
4454
+ var idspec = identify(query);
4455
+
4456
+ var req = opensocial.newDataRequest();
4457
+ req.add(req.newFetchActivitiesRequest(idspec), 'data');
4458
+ req.send(function(res) {
4459
+ self.readyState = 4; // DONE
4460
+
4461
+ var error = errorify(res);
4462
+ if (error) {
4463
+ self.status = error.status;
4464
+ self.statusText = error.statusText;
4465
+ self.responseText = error.reason;
4466
+
4467
+ } else {
4468
+ var item = res.get('data');
4469
+ var collection = item.getData();
4470
+
4471
+ var activities = $.map(collection.asArray(), function(activity) {
4472
+ return objectify(activity);
4473
+ });
4474
+ activities.startIndex = 0; // collection.getOffset();
4475
+ activities.itemsPerPage = 20;
4476
+ activities.totalResults = collection.getTotalSize();
4477
+
4478
+ self.status = code['ok'];
4479
+ self.statusText = 'ok';
4480
+ self.responseData = activities;
4481
+ }
4482
+ });
4483
+ }
4484
+
4485
+ });
4486
+
4487
+ $.ajaxSettings.xhr.addRoute('GET', '/activities/', $._xhr.getActivity);
4488
+
4489
+ } // if (opensocial) {
4490
+
4491
+ /**
4492
+ * postActivity
4493
+ */
4494
+ if (opensocial) {
4495
+
4496
+ $._xhr.postActivity = function() {
4497
+ this.initialize();
4498
+ };
4499
+
4500
+ $.extend($._xhr.postActivity.prototype, $._xhr.prototype, {
4501
+
4502
+ send: function(data) {
4503
+ var self = this;
4504
+
4505
+ data.mediaItems = $.map(data.mediaItems || [], function(mediaItem) {
4506
+ return opensocial.newMediaItem(
4507
+ mediaItem[opensocial.MediaItem.Field.MIME_TYPE], // mimeType
4508
+ mediaItem[opensocial.MediaItem.Field.URL], // url
4509
+ mediaItem // opt_params
4510
+ );
4511
+ });
4512
+
4513
+ opensocial.requestCreateActivity(
4514
+ opensocial.newActivity(data),
4515
+ opensocial.CreateActivityPriority.HIGH,
4516
+ function(res) {
4517
+ self.readyState = 4; // DONE
4518
+
4519
+ var error = errorify(
4520
+ new opensocial.DataResponse({ data: res }, res.hadError())
4521
+ );
4522
+ if (error) {
4523
+ self.status = error.status;
4524
+ self.statusText = error.statusText;
4525
+ self.responseText = error.reason;
4526
+ } else {
4527
+ self.status = code['ok'];
4528
+ self.statusText = 'ok';
4529
+ self.responseData = res.getData() || {};
4530
+ }
4531
+ });
4532
+ }
4533
+
4534
+ });
4535
+
4536
+ $.ajaxSettings.xhr.addRoute('POST', '/activities/', $._xhr.postActivity);
4537
+
4538
+ } // if (opensocial) {
4539
+
4540
+ /**
4541
+ * postMessage
4542
+ */
4543
+ if (opensocial) {
4544
+
4545
+ $._xhr.postMessage = function() {
4546
+ this.initialize();
4547
+ };
4548
+
4549
+ $.extend($._xhr.postMessage.prototype, $._xhr.prototype, {
4550
+
4551
+ send: function(data) {
4552
+ var self = this;
4553
+
4554
+ var recipients = data.recipients;
4555
+ if (typeof(recipients) == 'string')
4556
+ recipients = recipients.split(',');
4557
+ recipients = $.map(recipients, function(recipient) {
4558
+ return selector[recipient] || recipient;
4559
+ });
4560
+ if (recipients.length <= 1)
4561
+ recipients = recipients[0];
4562
+
4563
+ var message = opensocial.newMessage(
4564
+ data[opensocial.Message.Field.BODY],
4565
+ data
4566
+ );
4567
+
4568
+ opensocial.requestSendMessage(
4569
+ recipients,
4570
+ message,
4571
+ function(res) {
4572
+ self.readyState = 4; // DONE
4573
+
4574
+ var error = errorify(
4575
+ new opensocial.DataResponse({ data: res }, res.hadError())
4576
+ );
4577
+ if (error) {
4578
+ self.status = error.status;
4579
+ self.statusText = error.statusText;
4580
+ self.responseText = error.reason;
4581
+ } else {
4582
+ self.status = code['ok'];
4583
+ self.statusText = 'ok';
4584
+ self.responseData = res.getData() || {};
4585
+ }
4586
+ });
4587
+ }
4588
+
4589
+ });
4590
+
4591
+ $.ajaxSettings.xhr.addRoute('POST', '/messages/', $._xhr.postMessage);
4592
+
4593
+ } // if (opensocial) {
4594
+
4325
4595
  })(jQuery);
@@ -30,6 +30,7 @@ module Gadgeteer
30
30
  end
31
31
 
32
32
  class SecretMissingError < StandardError; end
33
+ class VerificationFailedError < StandardError; end
33
34
 
34
35
  module ViewHelpers
35
36
  def gadget_content_tag(view = nil, &block)
@@ -77,12 +78,12 @@ module Gadgeteer
77
78
  # return the token secret and the consumer secret
78
79
  [nil, secret]
79
80
  end
80
- pass = signature.verify
81
+ signature.verify || raise(VerificationFailedError, "Signature verification failed")
81
82
  end
82
83
 
83
84
  def verify_signature
84
85
  verify_signature!
85
- rescue OAuth::Signature::UnknownSignatureMethod, SecretMissingError
86
+ rescue OAuth::Signature::UnknownSignatureMethod, SecretMissingError, VerificationFailedError
86
87
  false
87
88
  end
88
89
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: virgo-gadgeteer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laszlo Bacsi
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-20 00:00:00 -07:00
12
+ date: 2009-04-26 00:00:00 -07:00
13
13
  default_executable: gadgeteer
14
14
  dependencies: []
15
15