social_stream 0.22.1 → 0.23.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/base/app/assets/javascripts/activities.js.erb +0 -85
  2. data/base/app/assets/javascripts/social_stream.comments.js +63 -0
  3. data/base/app/assets/javascripts/social_stream.objects.js +23 -0
  4. data/base/app/assets/javascripts/social_stream.timeline.js +37 -10
  5. data/base/app/assets/javascripts/social_stream.wall.js.erb +135 -118
  6. data/base/app/assets/stylesheets/cheesecake.css.scss +6 -3
  7. data/base/app/models/activity_object.rb +18 -0
  8. data/base/app/models/activity_object_property.rb +5 -0
  9. data/base/app/views/activities/_new.html.erb +1 -1
  10. data/base/app/views/activities/_wall.html.erb +1 -1
  11. data/base/app/views/cheesecake/_cheesecake.html.erb +44 -10
  12. data/base/app/views/cheesecake/_index.html.erb +18 -130
  13. data/base/app/views/cheesecake/_sector_form.html.erb +176 -17
  14. data/base/app/views/comments/_new.html.erb +0 -14
  15. data/base/app/views/objects/_show.html.erb +6 -0
  16. data/base/app/views/toolbar/_home.html.erb +1 -1
  17. data/base/app/views/toolbar/_messages.html.erb +1 -1
  18. data/base/app/views/toolbar/_profile.html.erb +1 -1
  19. data/base/config/locales/es.yml +7 -0
  20. data/base/db/migrate/20120302215722_activity_object_properties.rb +24 -0
  21. data/base/lib/social_stream/ability/base.rb +2 -2
  22. data/base/lib/social_stream/base/version.rb +1 -1
  23. data/documents/app/assets/javascripts/social_stream-documents.js +5 -1
  24. data/documents/app/models/document.rb +4 -3
  25. data/documents/app/models/picture.rb +4 -0
  26. data/documents/lib/social_stream/documents/version.rb +1 -1
  27. data/documents/social_stream-documents.gemspec +1 -1
  28. data/events/app/assets/images/poster.png +0 -0
  29. data/events/app/assets/javascripts/social_stream-events.js +7 -0
  30. data/events/app/assets/javascripts/social_stream.events.poster.js +21 -0
  31. data/events/app/assets/stylesheets/events.css.scss +25 -0
  32. data/events/app/helpers/events_helper.rb +9 -0
  33. data/events/app/models/activity_object_property/poster.rb +2 -0
  34. data/events/app/models/event.rb +18 -0
  35. data/events/app/views/events/_event.html.erb +39 -27
  36. data/events/app/views/events/_form_poster.html.erb +8 -0
  37. data/events/app/views/events/edit.js.erb +5 -0
  38. data/events/config/locales/en.yml +2 -0
  39. data/events/config/locales/es.yml +2 -0
  40. data/events/lib/social_stream-events.rb +2 -1
  41. data/events/lib/social_stream/events/engine.rb +6 -0
  42. data/events/lib/social_stream/events/models/document.rb +26 -0
  43. data/events/lib/social_stream/events/version.rb +1 -1
  44. data/events/social_stream-events.gemspec +1 -1
  45. data/lib/social_stream/version.rb +1 -1
  46. data/linkser/lib/social_stream/linkser/version.rb +1 -1
  47. data/linkser/social_stream-linkser.gemspec +1 -1
  48. data/presence/app/assets/images/games/ter/classic_aspa.png +0 -0
  49. data/presence/app/assets/images/games/ter/classic_board.png +0 -0
  50. data/presence/app/assets/images/games/ter/classic_circle.png +0 -0
  51. data/presence/app/assets/images/games/ter/modern_aspa.png +0 -0
  52. data/presence/app/assets/images/games/ter/modern_board.png +0 -0
  53. data/presence/app/assets/images/games/ter/modern_circle.png +0 -0
  54. data/presence/app/assets/javascripts/jquery.ui.chatbox.sstreampresence.js +34 -3
  55. data/presence/app/assets/javascripts/presence.js.erb +4 -0
  56. data/presence/app/assets/javascripts/{xmpp_client_management.js.erb → presence_XmppClient.js.erb} +417 -49
  57. data/presence/app/assets/javascripts/{chat_audio.js.erb → presence_audio.js.erb} +0 -0
  58. data/presence/app/assets/javascripts/presence_game.js.erb +76 -0
  59. data/presence/app/assets/javascripts/presence_game_ter.js.erb +384 -0
  60. data/presence/app/assets/javascripts/presence_notifications.js +191 -0
  61. data/presence/app/assets/javascripts/{chat_parser.js → presence_parser.js} +0 -0
  62. data/presence/app/assets/javascripts/{chat_persistence.js → presence_persistence.js} +84 -70
  63. data/presence/app/assets/javascripts/{store.js → presence_store.js} +0 -0
  64. data/presence/app/assets/javascripts/{chat_interface_manager.js.erb → presence_uiManager.js.erb} +42 -132
  65. data/presence/app/assets/javascripts/{chat_utilities.js → presence_utilities.js} +10 -34
  66. data/presence/app/assets/javascripts/{videochat.js.erb → presence_videochat.js.erb} +4 -24
  67. data/presence/app/assets/javascripts/{chat_window_manager.js → presence_windowManager.js} +275 -217
  68. data/presence/app/assets/javascripts/social_stream-presence.js +0 -2
  69. data/presence/app/assets/stylesheets/chat.css.scss +12 -1
  70. data/presence/app/views/chat/_contacts.html.erb +5 -5
  71. data/presence/app/views/chat/_index.html.erb +10 -2
  72. data/presence/config/locales/en.yml +9 -1
  73. data/presence/config/locales/es.yml +9 -1
  74. data/presence/ejabberd/ejabberd_files.zip +0 -0
  75. data/presence/ejabberd/ejabberd_scripts/emanagement +132 -2
  76. data/presence/ejabberd/installer.sh +1 -0
  77. data/presence/ejabberd/mod_muc_admin/mod_muc_admin.beam +0 -0
  78. data/presence/ejabberd/mod_muc_admin/mod_muc_admin.erl +871 -0
  79. data/presence/ejabberd/mod_sspresence/mod_sspresence.beam +0 -0
  80. data/presence/lib/social_stream/presence/models/buddy_manager.rb +32 -26
  81. data/presence/lib/social_stream/presence/models/group_manager.rb +12 -2
  82. data/presence/lib/social_stream/presence/version.rb +1 -1
  83. data/presence/lib/social_stream/presence/xmpp_server_order.rb +2 -2
  84. data/presence/social_stream-presence.gemspec +1 -1
  85. data/presence/vendor/assets/javascripts/strophe.muc.js +1 -1
  86. data/social_stream.gemspec +5 -5
  87. metadata +63 -41
  88. data/events/app/assets/javascripts/0_init.js +0 -4
@@ -0,0 +1,76 @@
1
+ ////////////////////
2
+ //Multiplayer Games Core based on XMPP
3
+ ////////////////////
4
+
5
+ PRESENCE.GAME = (function(P,$,undefined){
6
+
7
+ //Gamecore variables
8
+ var connection = null;
9
+ iqStanzaID['gameRequest'] = "gameRequestID";
10
+
11
+ var init = function(myConnection){
12
+ connection = myconnection;
13
+ };
14
+
15
+
16
+ var sendIQStanzaToRequestGame = function (slug,players,options){
17
+
18
+ if (slug in contactsInfo) {
19
+ var jid=slug+"@"+contactsInfo[slug].domain+"/"+contactsInfo[slug].resource;
20
+
21
+ var iq = $iq({to: jid, type: "get", id: iqStanzaID['gameRequest']})
22
+ .c("query", {xmlns: "urn:ietf:params:xml:ns:xmpp-stanzas"})
23
+ .c("game", {name: "gameName"})
24
+ .c("players", {})
25
+ .c("player1").t("player1value").up()
26
+ .c("player2").t("player2value").up()
27
+ .c("options", {})
28
+ .c("options1").t("options1value").up()
29
+ .c("options2").t("options2value").up()
30
+ strophe_connection.sendIQ(iq);
31
+ }
32
+ };
33
+
34
+ //Getters
35
+ var getDummy = function(){
36
+ return param;
37
+ };
38
+
39
+
40
+ return {
41
+ init: init,
42
+ sendIQStanzaToRequestGame: sendIQStanzaToRequestGame,
43
+ getDummy: getDummy
44
+ };
45
+
46
+ }) (PRESENCE, jQuery);
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+ ////////////////////
63
+ //Interface Events
64
+ ////////////////////
65
+ var global;
66
+
67
+ function play(){
68
+ $(".chat-gamesthick").css("display","block");
69
+ }
70
+
71
+ function pickGamesButton(uiElement){
72
+ var slug = $(uiElement.element).attr("id");
73
+ //clickGamesButton(slug);
74
+ log("clickGamesButton(slug)" + slug)
75
+ }
76
+
@@ -0,0 +1,384 @@
1
+ ////////////////////
2
+ //Tres en Raya
3
+ ////////////////////
4
+
5
+ PRESENCE.GAME.TER = (function(P,$,undefined){
6
+
7
+ //Game core
8
+ var core = P.GAME
9
+
10
+ //Game variables
11
+ var players = null;
12
+ var player = null;
13
+ var currentPlayer = null;
14
+ var options = null;
15
+ function action(player,square) {
16
+ this.player = player;
17
+ this.square = square;
18
+ }
19
+ var playing=true;
20
+
21
+ //Html Divs
22
+ var divID = null;
23
+ var containerDivId = 'tresEnRayaContainerDivID';
24
+ var messageDivId = 'tresEnRayaMessageDivID';
25
+
26
+ //Boardgame
27
+ var board = [];
28
+ var boardDimension = null;
29
+ var squareDimension = null;
30
+ var middleSquareDimension = null;
31
+
32
+ var init = function(myPlayers,myPlayer,myOptions,myDivID){
33
+ if (!validateParams(myPlayers,myPlayer,myOptions,myDivID)){
34
+ showMessage("Invalid parameters");
35
+ return;
36
+ }
37
+ players = myPlayers;
38
+ player = myPlayer;
39
+ options = settingOptions(myOptions);
40
+ divID = myDivID;
41
+ drawBoard();
42
+ settingBoard();
43
+ setBoardEvents();
44
+ currentPlayer = players[0];
45
+ if(player==currentPlayer){
46
+ showMessage("You start!")
47
+ } else {
48
+ showMessage(currentPlayer + " starts!")
49
+ }
50
+ };
51
+
52
+ var validateParams = function(myPlayers,myPlayer,myOptions,myDivID){
53
+
54
+ if ((typeof myPlayers=="undefined")||(typeof myPlayer=="undefined")||(typeof myOptions=="undefined")||(typeof myDivID=="undefined")){
55
+ return false;
56
+ }
57
+
58
+ //Check if myPlayers is an Array
59
+ if (myPlayers.constructor.toString().indexOf("Array") == -1){
60
+ return false;
61
+ }
62
+
63
+ //2 players at least
64
+ if(myPlayers.lenght < 2){
65
+ return false;
66
+ }
67
+
68
+ //Check if myOptions is an Array
69
+ if (myOptions.constructor.toString().indexOf("Array") == -1){
70
+ return false;
71
+ }
72
+
73
+ //Check that myPlayer is contained on myPlayers
74
+ if(myPlayers.indexOf(myPlayer)==-1){
75
+ return false;
76
+ }
77
+
78
+ return true;
79
+ }
80
+
81
+ var settingOptions = function(myOptions){
82
+
83
+ if (!('theme' in myOptions)){
84
+ myOptions['theme'] = "Modern"
85
+ }
86
+
87
+ if (!('rounds' in myOptions)){
88
+ myOptions['rounds'] = "1"
89
+ }
90
+
91
+ //Apply default options for non specified opts.
92
+ return myOptions;
93
+ };
94
+
95
+ var drawBoard = function(){
96
+ var containerDiv = document.createElement('div');
97
+ containerDiv.setAttribute('id', containerDivId);
98
+ containerDiv.setAttribute('class', 'tresEnRayaContainerDivClass');
99
+ $("#" + divID).append(containerDiv);
100
+
101
+ var messageDiv = document.createElement('div');
102
+ messageDiv.setAttribute('id', messageDivId);
103
+ $(messageDiv).addClass('tresEnRayaMessageDivClass')
104
+ $(messageDiv).addClass('tresEnRayaMessageTheme' + options['theme'])
105
+ $("#" + divID).append(messageDiv);
106
+
107
+ var p = document.createElement('p');
108
+ p.setAttribute('id', messageDivId + "p");
109
+ $(p).addClass('tresEnRayaMessagePTheme' + options['theme'])
110
+ $("#" + messageDivId).append(p);
111
+
112
+
113
+ //Adjust dimensions
114
+ var parentWidth = $("#" + divID).width();
115
+ var parentHeight = $("#" + divID).height();
116
+ var maxDimension = 300;
117
+ var minDimension = 100;
118
+
119
+ var dimension = Math.min(parentWidth,parentHeight,maxDimension)
120
+ boardDimension = Math.max(dimension,minDimension)
121
+
122
+ $("#" + containerDivId).height(boardDimension)
123
+ $("#" + containerDivId).width(boardDimension);
124
+
125
+ //Apply Theme
126
+ $("#" + containerDivId).addClass('tresEnRayaContainerTheme' + options['theme'])
127
+ };
128
+
129
+ var settingBoard = function(){
130
+ squareDimension = boardDimension/3;
131
+ middleSquareDimension = squareDimension/2;
132
+ //board[squareID] = [x,y,ElementInSquare {0=none,1=circle,2=aspa}]
133
+ board[0] = [middleSquareDimension,middleSquareDimension,0]
134
+ board[1] = [middleSquareDimension+squareDimension,middleSquareDimension,0]
135
+ board[2] = [boardDimension-middleSquareDimension,middleSquareDimension,0]
136
+ board[3] = [middleSquareDimension,middleSquareDimension+squareDimension,0]
137
+ board[4] = [middleSquareDimension+squareDimension,middleSquareDimension+squareDimension,0]
138
+ board[5] = [boardDimension-middleSquareDimension,middleSquareDimension+squareDimension,0]
139
+ board[6] = [middleSquareDimension,boardDimension-middleSquareDimension,0]
140
+ board[7] = [middleSquareDimension+squareDimension,boardDimension-middleSquareDimension,0]
141
+ board[8] = [boardDimension-middleSquareDimension,boardDimension-middleSquareDimension,0]
142
+ };
143
+
144
+ var setBoardEvents = function(){
145
+ $("#" + containerDivId).click(function (event) {
146
+
147
+ var offsetX = event.pageX - $("#" + containerDivId).offset().left
148
+ var offsetY = event.pageY - $("#" + containerDivId).offset().top
149
+
150
+ if($(event.target).is('img')){
151
+ return;
152
+ }
153
+
154
+ if(currentPlayer!=player){
155
+ //return;
156
+ }
157
+ square = getSquare(offsetX,offsetY)
158
+ var actionNew = new action(currentPlayer,square);
159
+ processAction(actionNew)
160
+ });
161
+ };
162
+
163
+ var getSquare = function(x,y){
164
+ for(var i=0; i<board.length; i++){
165
+ if((Math.abs(x-board[i][0])<middleSquareDimension)&&(Math.abs(y-board[i][1])<middleSquareDimension)){
166
+ return i;
167
+ }
168
+ }
169
+ return 0;
170
+ }
171
+
172
+
173
+ var processAction = function(action){
174
+
175
+ if(playing==false){
176
+ return;
177
+ }
178
+
179
+ //Check if the action is legal
180
+ if(!checkAction(action)){
181
+ showMessage("Ilegal action");
182
+ return false;
183
+ }
184
+
185
+ if(player==currentPlayer){
186
+ //Notify action
187
+ sendAction(action);
188
+ }
189
+
190
+
191
+ //Update logic
192
+ updateLogic(action);
193
+
194
+ //Update interface
195
+ updateInterface(action);
196
+
197
+ //Check for winner
198
+ var winner = checkWinner()
199
+ if(winner!=null){
200
+ if(winner!="finish"){
201
+ if(player==winner){
202
+ showMessage("You have won the game")
203
+ } else {
204
+ showMessage(winner + " has won the game")
205
+ }
206
+ } else {
207
+ showMessage("Finished game");
208
+ }
209
+ finishGame();
210
+ return
211
+ }
212
+
213
+ nextTurn();
214
+ }
215
+
216
+
217
+ var showMessage = function(msg){
218
+ $("#" + messageDivId + "p").html(msg)
219
+ }
220
+
221
+ var finishGame = function(){
222
+ playing = false;
223
+ }
224
+
225
+ var checkAction = function(action){
226
+ if(board[action.square][2]!=0){
227
+ return false;
228
+ }
229
+
230
+ return true;
231
+ }
232
+
233
+ var updateLogic = function(action){
234
+ board[action.square][2]=players.indexOf(action.player)+1;
235
+ }
236
+
237
+ var updateInterface = function(action){
238
+ var img = document.createElement('img');
239
+
240
+ if(action.player==players[0]){
241
+ var figure = "circle";
242
+ } else {
243
+ var figure = "aspa";
244
+ }
245
+
246
+ $(img).attr("src","themes/" + options['theme'].toLowerCase() + "_" + figure + ".png");
247
+
248
+ $("#" + containerDivId).append(img);
249
+ $(img).addClass('tresEnRayaImgTheme' + options['theme'])
250
+ $(img).width(squareDimension*0.8)
251
+ $(img).height(squareDimension*0.8)
252
+ var x = $("#" + containerDivId).offset().left
253
+ var y = $("#" + containerDivId).offset().top
254
+ $(img).css("top",y+board[action.square][1]-middleSquareDimension*0.8)
255
+ $(img).css("left",x+board[action.square][0]-middleSquareDimension*0.8)
256
+ return;
257
+ }
258
+
259
+ var sendAction = function(action){
260
+ //Notify action to other players
261
+ //[...]
262
+ return;
263
+ }
264
+
265
+ var onActionReceived = function(action){
266
+ processAction(action);
267
+ return;
268
+ }
269
+
270
+ //Return winner's name if exists and null if dont exits.
271
+ //Return "finish" when the game is blocked.
272
+ var checkWinner = function(){
273
+
274
+ //Check for finish game without winner.
275
+ var finish=true;
276
+ for(var i=0; i<board.length; i++){
277
+ if(board[i][2]==0){
278
+ finish = false;
279
+ break;
280
+ }
281
+ }
282
+ if(finish){
283
+ return "finish";
284
+ }
285
+
286
+ //Check winner
287
+ //Check if exists three squares with the same symbol consecutively
288
+
289
+ //Check horizontal
290
+ if((board[0][2]==board[1][2])&&(board[1][2]==board[2][2])&&(board[2][2]!=0)){
291
+ return players[board[0][2]-1];
292
+ }
293
+ if((board[3][2]==board[4][2])&&(board[4][2]==board[5][2])&&(board[5][2]!=0)){
294
+ return players[board[3][2]-1];
295
+ }
296
+ if((board[6][2]==board[7][2])&&(board[7][2]==board[8][2])&&(board[8][2]!=0)){
297
+ return players[board[6][2]-1];
298
+ }
299
+
300
+ //Check vertical
301
+ if((board[0][2]==board[3][2])&&(board[3][2]==board[6][2])&&(board[6][2]!=0)){
302
+ return players[board[0][2]-1];
303
+ }
304
+ if((board[1][2]==board[4][2])&&(board[4][2]==board[7][2])&&(board[7][2]!=0)){
305
+ return players[board[1][2]-1];
306
+ }
307
+ if((board[2][2]==board[5][2])&&(board[5][2]==board[8][2])&&(board[8][2]!=0)){
308
+ return players[board[2][2]-1];
309
+ }
310
+
311
+ //Check diagonals
312
+ if((board[0][2]==board[4][2])&&(board[4][2]==board[8][2])&&(board[8][2]!=0)){
313
+ return players[board[0][2]-1];
314
+ }
315
+ if((board[6][2]==board[4][2])&&(board[4][2]==board[2][2])&&(board[2][2]!=0)){
316
+ return players[board[6][2]-1];
317
+ }
318
+
319
+ return null;
320
+ }
321
+
322
+ var nextTurn = function(){
323
+ var playersQuantity = players.length;
324
+ var indexActualPlayer = players.indexOf(currentPlayer);
325
+ if(indexActualPlayer==(playersQuantity-1)){
326
+ currentPlayer=players[0];
327
+ } else {
328
+ currentPlayer=players[indexActualPlayer+1];
329
+ }
330
+ if(player==currentPlayer){
331
+ showMessage("Is your turn!")
332
+ } else {
333
+ showMessage(currentPlayer + " turn")
334
+ }
335
+ }
336
+
337
+ var getRandomPlayer = function(){
338
+ var playersQuantity = players.length;
339
+ var randomIndex = Math.round(Math.random()*(players.length-1))
340
+ return players[randomIndex]
341
+ }
342
+
343
+ //Getters
344
+ var getPlayers = function(){
345
+ return players;
346
+ }
347
+
348
+ var getOptions = function(){
349
+ return options;
350
+ }
351
+
352
+ var getDummy = function(){
353
+ return core;
354
+ }
355
+
356
+
357
+ return {
358
+ init: init,
359
+ getDummy: getDummy,
360
+ onActionReceived: onActionReceived
361
+ };
362
+
363
+ }) (PRESENCE, jQuery);
364
+
365
+
366
+
367
+
368
+
369
+
370
+
371
+
372
+ ////////////////////
373
+ //Interface Events
374
+ ////////////////////
375
+ function play(){
376
+ $(".chat-gamesthick").css("display","block");
377
+ }
378
+
379
+ function pickGamesButton(uiElement){
380
+ var slug = $(uiElement.element).attr("id");
381
+ //clickGamesButton(slug);
382
+ log("clickGamesButton(slug)" + slug)
383
+ }
384
+