social_stream-presence 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/chat_interface_manager.js.erb +104 -15
- data/app/assets/javascripts/chat_utilities.js +126 -0
- data/app/assets/javascripts/chat_window_manager.js +1 -1
- data/app/assets/javascripts/xmpp_client_management.js.erb +3 -27
- data/app/controllers/xmpp_controller.rb +2 -5
- data/app/views/chat/_contacts.html.erb +3 -3
- data/app/views/chat/_settings.html.erb +4 -8
- data/app/views/xmpp/active_users.html.erb +10 -10
- data/config/locales/en.yml +5 -1
- data/config/locales/es.yml +6 -1
- data/config/routes.rb +1 -4
- data/lib/social_stream-presence.rb +8 -1
- data/lib/social_stream/presence/engine.rb +8 -6
- data/lib/social_stream/presence/version.rb +1 -1
- data/lib/social_stream/views/settings/presence.rb +20 -0
- data/vendor/assets/javascripts/jquery.ui.chatbox.js +22 -13
- metadata +4 -5
- data/app/views/xmpp/index.html +0 -18
- data/app/views/xmpp/test.html.erb +0 -11
@@ -1,6 +1,9 @@
|
|
1
1
|
////////////////////
|
2
2
|
//Hash table
|
3
3
|
////////////////////
|
4
|
+
|
5
|
+
//Keys: Xmpp status
|
6
|
+
//Value: Social Stream Status
|
4
7
|
var statusIcons = new Array();
|
5
8
|
statusIcons[''] = "available";
|
6
9
|
statusIcons['chat'] = "available";
|
@@ -63,29 +66,55 @@ function setUserFunctions(){
|
|
63
66
|
$(".dropdown dt a").click(function(event) {
|
64
67
|
event.preventDefault();
|
65
68
|
$(".dropdown dd ul").toggle();
|
69
|
+
|
70
|
+
if($(".dropdown dd ul").is(":visible")){
|
71
|
+
setStatusWidgetTitle("default");
|
72
|
+
} else {
|
73
|
+
setStatusWidgetTitle(userStatus);
|
74
|
+
}
|
75
|
+
|
76
|
+
restartAwayTimer(false);
|
77
|
+
|
66
78
|
});
|
67
79
|
|
68
80
|
$(".dropdown dd ul li a.option").click(function(event) {
|
69
81
|
event.preventDefault();
|
70
|
-
|
71
|
-
$(".dropdown dt a span").html(text);
|
72
|
-
userStatus = getSelectedValue("status");
|
82
|
+
userStatus = $(this).find("span.value").html();
|
73
83
|
sendStatus(userStatus);
|
74
84
|
$(".dropdown dd ul").hide();
|
75
85
|
});
|
76
86
|
|
77
|
-
|
78
|
-
function getSelectedValue(id) {
|
79
|
-
return $("#" + id).find("dt a span.value").html();
|
80
|
-
}
|
81
87
|
|
82
88
|
$(document).bind('click', function(e) {
|
83
89
|
var $clicked = $(e.target);
|
84
90
|
if (! $clicked.parents().hasClass("dropdown")){
|
85
91
|
//Click outside the select...
|
86
92
|
$(".dropdown dd ul").hide();
|
93
|
+
setStatusWidgetTitle(userStatus);
|
87
94
|
}
|
88
95
|
});
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
function setStatusWidgetTitle(status){
|
100
|
+
|
101
|
+
if ($(".dropdown dt a span").length == 0){
|
102
|
+
return;
|
103
|
+
}
|
104
|
+
|
105
|
+
if (status in statusIcons) {
|
106
|
+
|
107
|
+
if ($("#" + statusIcons[status]).length == 0){
|
108
|
+
return;
|
109
|
+
}
|
110
|
+
var text = $("#" + statusIcons[status]).html();
|
111
|
+
$(".dropdown dt a span").html(text);
|
112
|
+
|
113
|
+
} else if(status=="default"){
|
114
|
+
var defaultTitle = '<%=I18n.t('chat.status.choose')%>'
|
115
|
+
$(".dropdown dt a span").html(defaultTitle);
|
116
|
+
}
|
117
|
+
|
89
118
|
}
|
90
119
|
|
91
120
|
|
@@ -96,21 +125,32 @@ function setUserFunctions(){
|
|
96
125
|
function awayTimerFunction(){
|
97
126
|
awayCounter++;
|
98
127
|
if (awayCounter > (awayTime/awayTimerPeriod)){
|
99
|
-
|
100
|
-
|
128
|
+
if (userStatus != "dnd") {
|
129
|
+
userStatus = "away";
|
130
|
+
sendStatus(userStatus);
|
131
|
+
}
|
101
132
|
clearTimeout(awayTimer);
|
102
|
-
} else {
|
103
|
-
userStatus = "chat";
|
104
133
|
}
|
105
134
|
}
|
106
135
|
|
107
|
-
function
|
136
|
+
function autochangeStatusOnUserAway(){
|
108
137
|
if (userStatus == "away"){
|
109
|
-
|
110
|
-
|
111
|
-
|
138
|
+
userStatus = "chat";
|
139
|
+
sendStatus(userStatus);
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
function restartAwayTimer(autochangeStatus){
|
144
|
+
|
145
|
+
if (awayCounter > (awayTime/awayTimerPeriod)){
|
112
146
|
awayTimer = setInterval("awayTimerFunction()", awayTimerPeriod);
|
147
|
+
|
148
|
+
if(autochangeStatus){
|
149
|
+
autochangeStatusOnUserAway();
|
150
|
+
}
|
113
151
|
}
|
152
|
+
|
153
|
+
awayCounter = 0;
|
114
154
|
}
|
115
155
|
|
116
156
|
|
@@ -144,6 +184,7 @@ function updateChatWindow(){
|
|
144
184
|
$(".tooltip").hide() //Prevent tooltips
|
145
185
|
$("#chat_partial").html(data);
|
146
186
|
if (userConnected) {
|
187
|
+
setStatusWidgetTitle(userStatus);
|
147
188
|
$(".user_presence a[title]").tooltip();
|
148
189
|
setUserFunctions();
|
149
190
|
}
|
@@ -194,4 +235,52 @@ function getAllConnectedSlugs(){
|
|
194
235
|
}
|
195
236
|
});
|
196
237
|
return connectedSlugs
|
238
|
+
}
|
239
|
+
|
240
|
+
|
241
|
+
////////////////////
|
242
|
+
//Insert received message in chatbox
|
243
|
+
////////////////////
|
244
|
+
|
245
|
+
function putReceivedMessageOnChatWindow(from_jid,from_slug,body,msgID){
|
246
|
+
|
247
|
+
//Antiflood control
|
248
|
+
if (antifloodControl(from_jid,from_slug,body,msgID)){
|
249
|
+
return;
|
250
|
+
}
|
251
|
+
|
252
|
+
//Check for from_slug name and connectionBox visibility
|
253
|
+
if (typeof($('div.user_presence[slug=' + from_slug + ']').attr('name')) == 'undefined') {
|
254
|
+
//No connectionBox for this user!
|
255
|
+
var from_name = from_slug;
|
256
|
+
refreshChatWindow();
|
257
|
+
} else {
|
258
|
+
showConnectionBoxFromSlug(from_slug);
|
259
|
+
var from_name = $('div.user_presence[slug=' + from_slug + ']').attr('name');
|
260
|
+
}
|
261
|
+
|
262
|
+
|
263
|
+
//Create or toggle from_slug's chatBox.
|
264
|
+
if (createChatBox(from_slug, from_name, from_jid, user_name, user_jid)) {
|
265
|
+
} else {
|
266
|
+
window[getChatVariableFromSlug(from_slug)].chatbox("option", "boxManager").toggleBox(true);
|
267
|
+
}
|
268
|
+
|
269
|
+
//Parse content before show it.
|
270
|
+
var content = getParsedContent(Strophe.getText(body), false)
|
271
|
+
|
272
|
+
//Show message to chatBox.
|
273
|
+
$("#" + from_slug).chatbox("option", "boxManager").addMsg(from_name, content);
|
274
|
+
|
275
|
+
//Rotate chatBoxes priority.
|
276
|
+
rotatePriority(from_slug);
|
277
|
+
|
278
|
+
//Check for start blinkTitle.
|
279
|
+
blinkTitleOnMessage(from_name);
|
280
|
+
|
281
|
+
//Check for play sound
|
282
|
+
if (mustPlaySoundForChatWindow(window[getChatVariableFromSlug(from_slug)])) {
|
283
|
+
playSound("onMessageAudio");
|
284
|
+
}
|
285
|
+
|
197
286
|
}
|
@@ -64,6 +64,132 @@ function blinkTitleOnMessage(username){
|
|
64
64
|
}
|
65
65
|
|
66
66
|
|
67
|
+
|
68
|
+
////////////////////
|
69
|
+
//Antiflood
|
70
|
+
////////////////////
|
71
|
+
|
72
|
+
var lastMessageTimes = new Array();
|
73
|
+
//lastMessageTimes['from_slug'] = ["timeOfLastMessage",["msgID1","msgID2"]];
|
74
|
+
|
75
|
+
var timeBetweenMessages = 500; //mseconds
|
76
|
+
|
77
|
+
//Return true when detects a text storm and control the text flood:
|
78
|
+
//timeBetweenMessages is the minimum time that must elapse between the messages of the same contact.
|
79
|
+
function antifloodControl(from_jid,from_slug,body,msgID) {
|
80
|
+
|
81
|
+
if( from_slug in lastMessageTimes){
|
82
|
+
|
83
|
+
} else {
|
84
|
+
lastMessageTimes[from_slug] = [,[]];
|
85
|
+
}
|
86
|
+
|
87
|
+
if (msgID==null){
|
88
|
+
msgID = generateMessageID();
|
89
|
+
}
|
90
|
+
|
91
|
+
var lastMessageTime = lastMessageTimes[from_slug][0];
|
92
|
+
|
93
|
+
var t = (new Date()).getTime();
|
94
|
+
if(t - lastMessageTime < timeBetweenMessages) {
|
95
|
+
//Flood detected
|
96
|
+
return retryToShowMessage(from_jid,from_slug,body,msgID);
|
97
|
+
}
|
98
|
+
|
99
|
+
//Check if is the first message of this user to be send.
|
100
|
+
//var messageQueue = lastMessageTimes[from_slug][1];
|
101
|
+
|
102
|
+
if (lastMessageTimes[from_slug][1].length>0){
|
103
|
+
if((lastMessageTimes[from_slug][1])[0]==msgID){
|
104
|
+
//Message is the first on the queue: Show it and remove from the queue
|
105
|
+
lastMessageTimes[from_slug][1].splice(0,1);
|
106
|
+
} else {
|
107
|
+
//Message is not the first on the queue
|
108
|
+
return retryToShowMessage(from_jid,from_slug,body,msgID);
|
109
|
+
}
|
110
|
+
}
|
111
|
+
|
112
|
+
//Message can be send
|
113
|
+
lastMessageTimes[from_slug][0] = t;
|
114
|
+
return false;
|
115
|
+
};
|
116
|
+
|
117
|
+
|
118
|
+
var rootMessageID=1;
|
119
|
+
function generateMessageID(){
|
120
|
+
return (++rootMessageID);
|
121
|
+
}
|
122
|
+
|
123
|
+
|
124
|
+
function retryToShowMessage(from_jid,from_slug,body,msgID){
|
125
|
+
//Enque the message if isn't in the queue
|
126
|
+
if (lastMessageTimes[from_slug][1].indexOf(msgID)==-1){
|
127
|
+
lastMessageTimes[from_slug][1].push(msgID);
|
128
|
+
}
|
129
|
+
|
130
|
+
setTimeout(function(){putReceivedMessageOnChatWindow(from_jid,from_slug,body,msgID)}, timeBetweenMessages);
|
131
|
+
return true;
|
132
|
+
}
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
////////////////////
|
139
|
+
//Controlflood
|
140
|
+
////////////////////
|
141
|
+
var timeBetweenOwnMessages = 500; //mseconds
|
142
|
+
var lastMessageSentTime=null;
|
143
|
+
|
144
|
+
function floodControl() {
|
145
|
+
var t = (new Date()).getTime();
|
146
|
+
|
147
|
+
if(lastMessageSentTime==null){
|
148
|
+
lastMessageSentTime = t;
|
149
|
+
return true;
|
150
|
+
}
|
151
|
+
|
152
|
+
if (t - lastMessageSentTime < timeBetweenOwnMessages) {
|
153
|
+
return false;
|
154
|
+
} else {
|
155
|
+
lastMessageSentTime = t;
|
156
|
+
return true;
|
157
|
+
}
|
158
|
+
};
|
159
|
+
|
160
|
+
|
161
|
+
function initControlFlood(){
|
162
|
+
$(".ui-chatbox-input-box")
|
163
|
+
}
|
164
|
+
|
165
|
+
|
166
|
+
////////////////////
|
167
|
+
//Bounce chatbox control
|
168
|
+
////////////////////
|
169
|
+
var lastBounceTimes = new Array();
|
170
|
+
var timeBetweenBounces = 5000; //mseconds
|
171
|
+
|
172
|
+
function mustBounceBoxForChatWindow(jqueryUIChatbox){
|
173
|
+
var from_slug = $($(jqueryUIChatbox.elem.uiChatbox).find(".ui-chatbox-content").children()[0]).attr("id")
|
174
|
+
|
175
|
+
var t = (new Date()).getTime();
|
176
|
+
|
177
|
+
if(!(from_slug in lastBounceTimes)){
|
178
|
+
lastBounceTimes[from_slug] = t;
|
179
|
+
return true;
|
180
|
+
}
|
181
|
+
|
182
|
+
var lastBounceTime = lastBounceTimes[from_slug];
|
183
|
+
|
184
|
+
if (t - lastBounceTime < timeBetweenBounces) {
|
185
|
+
return false;
|
186
|
+
} else {
|
187
|
+
lastBounceTimes[from_slug] = t;
|
188
|
+
return true;
|
189
|
+
}
|
190
|
+
|
191
|
+
}
|
192
|
+
|
67
193
|
////////////////////
|
68
194
|
//Next features...
|
69
195
|
////////////////////
|
@@ -52,7 +52,7 @@ function createChatBox(guest_slug,guest_name,guest_jid,user_name,user_jid){
|
|
52
52
|
},
|
53
53
|
|
54
54
|
messageSent : function(id, user, msg) {
|
55
|
-
|
55
|
+
rotatePriority(guest_slug);
|
56
56
|
$("#" + guest_slug).chatbox("option", "boxManager").addMsg(id, getParsedContent(msg,true));
|
57
57
|
sendChatMessage(user_jid,guest_jid,msg);
|
58
58
|
}});
|
@@ -181,36 +181,11 @@ function onMessage(msg) {
|
|
181
181
|
var elems = msg.getElementsByTagName('body');
|
182
182
|
|
183
183
|
if (type == "chat" && elems.length > 0) {
|
184
|
-
|
185
184
|
var body = elems[0];
|
186
185
|
var from_slug = from.split("@")[0];
|
187
|
-
var from_name = $("#" + from_slug).attr("name");
|
188
186
|
var from_jid = from_slug + "@" + domain;
|
189
187
|
|
190
|
-
|
191
|
-
if (typeof ($('div.user_presence[slug=' + from_slug + ']').attr('name')) == 'undefined') {
|
192
|
-
//No connectionBox for this user!
|
193
|
-
var from_name = from_slug;
|
194
|
-
refreshChatWindow();
|
195
|
-
} else {
|
196
|
-
showConnectionBoxFromSlug(from_slug);
|
197
|
-
var from_name = $('div.user_presence[slug=' + from_slug + ']').attr('name');
|
198
|
-
}
|
199
|
-
|
200
|
-
if (createChatBox(from_slug,from_name,from_jid,user_name,user_jid)) {
|
201
|
-
} else {
|
202
|
-
window[getChatVariableFromSlug(from_slug)].chatbox("option", "boxManager").toggleBox(true);
|
203
|
-
}
|
204
|
-
|
205
|
-
var content = getParsedContent(Strophe.getText(body),false)
|
206
|
-
//Send message to chatBox and post-message functions.
|
207
|
-
$("#" + from_slug).chatbox("option", "boxManager").addMsg(from_name, content);
|
208
|
-
rotatePriority(from_slug);
|
209
|
-
blinkTitleOnMessage(from_name);
|
210
|
-
if (mustPlaySoundForChatWindow(window[getChatVariableFromSlug(from_slug)])){
|
211
|
-
playSound("onMessageAudio");
|
212
|
-
}
|
213
|
-
|
188
|
+
putReceivedMessageOnChatWindow(from_jid,from_slug,body,null)
|
214
189
|
}
|
215
190
|
|
216
191
|
// we must return true to keep the handler alive.
|
@@ -283,7 +258,7 @@ function sendChatMessage(from,to,text){
|
|
283
258
|
body.t(text);
|
284
259
|
var message = $msg({to: to, from: from, type: 'chat'}).cnode(body.tree());
|
285
260
|
connection.send(message.tree());
|
286
|
-
|
261
|
+
restartAwayTimer(false);
|
287
262
|
return true;
|
288
263
|
}
|
289
264
|
|
@@ -300,5 +275,6 @@ function sendStatus(status){
|
|
300
275
|
.c('show')
|
301
276
|
.t(status);
|
302
277
|
connection.send(pres.tree());
|
278
|
+
setStatusWidgetTitle(status);
|
303
279
|
}
|
304
280
|
}
|
@@ -172,15 +172,12 @@ class XmppController < ApplicationController
|
|
172
172
|
redirect_to :controller => :settings, :action => :index
|
173
173
|
end
|
174
174
|
|
175
|
-
|
175
|
+
|
176
|
+
#Test Method
|
176
177
|
def active_users
|
177
178
|
@users = User.find_all_by_connected(true)
|
178
179
|
@all_users = User.all
|
179
180
|
end
|
180
|
-
|
181
|
-
def test
|
182
|
-
#puts "TEST"
|
183
|
-
end
|
184
181
|
|
185
182
|
|
186
183
|
private
|
@@ -12,9 +12,9 @@
|
|
12
12
|
<dt><a href=""><span><%=t('chat.status.choose')%></span></a></dt>
|
13
13
|
<dd>
|
14
14
|
<ul>
|
15
|
-
<li><a href="#" class="option"><img class="flag" src="assets/status/available.png" alt=""/> <%=t('chat.status.available')%> <span class="value">chat</span></a></li>
|
16
|
-
<li><a href="#" class="option"><img class="flag" src="assets/status/away.png" alt=""/> <%=t('chat.status.away')%> <span class="value">away</span></a></li>
|
17
|
-
<li><a href="#" class="option"><img class="flag" src="assets/status/dnd.png" alt=""/> <%=t('chat.status.dnd')%> <span class="value">dnd</span></a></li>
|
15
|
+
<li><a id="available" href="#" class="option"><img class="flag" src="assets/status/available.png" alt=""/> <%=t('chat.status.available')%> <span class="value">chat</span></a></li>
|
16
|
+
<li><a id="away" href="#" class="option"><img class="flag" src="assets/status/away.png" alt=""/> <%=t('chat.status.away')%> <span class="value">away</span></a></li>
|
17
|
+
<li><a id="dnd" href="#" class="option"><img class="flag" src="assets/status/dnd.png" alt=""/> <%=t('chat.status.dnd')%> <span class="value">dnd</span></a></li>
|
18
18
|
</ul>
|
19
19
|
</dd>
|
20
20
|
</div>
|
@@ -1,9 +1,7 @@
|
|
1
|
-
<% if current_user and current_subject and current_user==current_subject %>
|
2
|
-
|
3
1
|
<div class="block" id="chat_settings">
|
4
2
|
<div class="header">
|
5
3
|
<div class="header_text">
|
6
|
-
|
4
|
+
<%=t('chat.title')%>
|
7
5
|
</div>
|
8
6
|
<div class="header_icon_right">
|
9
7
|
<%= link_to (image_tag('btn/edit.png')), "javascript:showSettings(\"chat_settings\");" %>
|
@@ -11,7 +9,7 @@
|
|
11
9
|
</div>
|
12
10
|
<div id="chat_settings_briefing" class="settings_briefing content">
|
13
11
|
<div class="form_row">
|
14
|
-
|
12
|
+
<%=t('chat.settings.title')%>
|
15
13
|
</div>
|
16
14
|
</div>
|
17
15
|
<div class="content settings_content" id="chat_settings_content" style="display:none;">
|
@@ -23,16 +21,14 @@
|
|
23
21
|
<div class="form_sub_row">
|
24
22
|
<% checked = current_user.chat_enabled %>
|
25
23
|
<%= check_box_tag 'enable_chat', true, checked %>
|
26
|
-
<%= label_tag(:enable_chat,
|
24
|
+
<%= label_tag(:enable_chat, t('chat.settings.checkbox')) %>
|
27
25
|
</div>
|
28
26
|
<div class="actions center">
|
29
27
|
<%= hidden_field_tag :settings_section, :chat %>
|
30
|
-
<%= submit_tag
|
28
|
+
<%= submit_tag t('chat.settings.update'), :class => "button" %>
|
31
29
|
</div>
|
32
30
|
</div>
|
33
31
|
</ul>
|
34
32
|
<% end %>
|
35
33
|
</div>
|
36
34
|
</div>
|
37
|
-
|
38
|
-
<% end %>
|
@@ -1,33 +1,33 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html>
|
3
3
|
<head>
|
4
|
-
<title>
|
4
|
+
<title>Social Stream Presence</title>
|
5
5
|
</head>
|
6
6
|
<body>
|
7
7
|
|
8
8
|
|
9
|
-
<p>
|
9
|
+
<p> Social Stream connected users </p>
|
10
10
|
|
11
11
|
<p> </p>
|
12
12
|
<ul>
|
13
|
-
<%@users.each do |user| %>
|
14
|
-
|
15
|
-
<%end%>
|
13
|
+
<%@users.each do |user| %>
|
14
|
+
<li><b><%=user.name%></b></li>
|
15
|
+
<%end%>
|
16
16
|
</ul>
|
17
17
|
<p> </p>
|
18
18
|
|
19
19
|
|
20
|
-
<p>
|
20
|
+
<p> All Social Stream users </p>
|
21
21
|
|
22
22
|
<p> </p>
|
23
23
|
<ul>
|
24
|
-
<%@all_users.each do |user| %>
|
25
|
-
|
26
|
-
<%end%>
|
24
|
+
<%@all_users.each do |user| %>
|
25
|
+
<li><b><%=user.slug%></b> with email: <%=user.email%></li>
|
26
|
+
<%end%>
|
27
27
|
</ul>
|
28
28
|
<p> </p>
|
29
29
|
|
30
|
-
<p> <a href="/test">
|
30
|
+
<p> <a href="/test">Come back</a></p>
|
31
31
|
|
32
32
|
</body>
|
33
33
|
</html>
|
data/config/locales/en.yml
CHANGED
data/config/locales/es.yml
CHANGED
@@ -8,4 +8,9 @@ es:
|
|
8
8
|
choose: "Establecer estado"
|
9
9
|
available: "Disponible"
|
10
10
|
away: "Ausente"
|
11
|
-
dnd: "No molestar"
|
11
|
+
dnd: "No molestar"
|
12
|
+
settings:
|
13
|
+
title: "Activación y configuración del chat de Social Stream"
|
14
|
+
checkbox: "Activar o desactivar chat"
|
15
|
+
update: "Guardar configuración"
|
16
|
+
|
data/config/routes.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
|
-
match "/
|
3
|
-
match "/xmpp4r_test" => "Xmpp#test"
|
4
|
-
match "/active_users" => "Xmpp#active_users"
|
5
|
-
match '/chat' => "Xmpp#chat"
|
2
|
+
#match "/active_users" => "Xmpp#active_users"
|
6
3
|
|
7
4
|
match '/xmpp/resetConnection' => "Xmpp#resetConnection"
|
8
5
|
match '/xmpp/setConnection' => "Xmpp#setConnection"
|
@@ -1,6 +1,12 @@
|
|
1
1
|
require 'social_stream-base'
|
2
2
|
|
3
3
|
module SocialStream
|
4
|
+
module Views
|
5
|
+
module Settings
|
6
|
+
autoload :Presence, 'social_stream/views/settings/presence'
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
4
10
|
module Presence
|
5
11
|
|
6
12
|
autoload :XmppServerOrder, 'social_stream/presence/xmpp_server_order'
|
@@ -9,6 +15,7 @@ module SocialStream
|
|
9
15
|
autoload :BuddyManager, 'social_stream/presence/models/buddy_manager'
|
10
16
|
end
|
11
17
|
|
18
|
+
|
12
19
|
mattr_accessor :domain
|
13
20
|
mattr_accessor :bosh_service
|
14
21
|
mattr_accessor :auth_method
|
@@ -37,4 +44,4 @@ module SocialStream
|
|
37
44
|
end
|
38
45
|
end
|
39
46
|
|
40
|
-
require 'social_stream/presence/engine'
|
47
|
+
require 'social_stream/presence/engine'
|
@@ -1,15 +1,17 @@
|
|
1
1
|
module SocialStream
|
2
2
|
module Presence
|
3
3
|
class Engine < Rails::Engine
|
4
|
-
|
5
|
-
|
6
|
-
#Patching Tie
|
7
|
-
Tie.class_eval do
|
4
|
+
initializer "social_stream-presence.tie" do
|
5
|
+
ActiveSupport.on_load(:tie) do
|
8
6
|
include SocialStream::Presence::Models::BuddyManager
|
9
7
|
end
|
10
|
-
|
11
8
|
end
|
12
|
-
|
9
|
+
|
10
|
+
initializer "social_stream-presence.views.settings" do
|
11
|
+
SocialStream::Views::Settings.module_eval do
|
12
|
+
include SocialStream::Views::Settings::Presence
|
13
|
+
end
|
14
|
+
end
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module SocialStream
|
2
|
+
module Views
|
3
|
+
module Settings
|
4
|
+
module Presence
|
5
|
+
def settings_items
|
6
|
+
super.tap do |items|
|
7
|
+
if SocialStream::Presence.enable
|
8
|
+
if current_subject == current_user
|
9
|
+
items.insert_before 'notifications', {
|
10
|
+
:key => 'chat',
|
11
|
+
:html => render(:partial => "chat/settings")
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -54,11 +54,18 @@
|
|
54
54
|
//Get highlight color from css
|
55
55
|
var dummy_element = $("<p class=\"chatWindowhighlighted\"></div>");
|
56
56
|
var options = {color: $(dummy_element).css("color")};
|
57
|
+
|
57
58
|
self.elem.uiChatboxTitlebar.effect("highlight", options, 300);
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
|
60
|
+
|
61
|
+
if (((typeof mustBounceBoxForChatWindow == 'function')&&(mustBounceBoxForChatWindow(self)))||((typeof mustBounceBoxForChatWindow != 'function'))) {
|
62
|
+
self.elem.uiChatbox.effect("bounce", {times:3}, 300, function(){
|
63
|
+
self.highlightLock = false;
|
64
|
+
self._scrollToBottom();
|
65
|
+
});
|
66
|
+
} else {
|
67
|
+
self.highlightLock = false;
|
68
|
+
}
|
62
69
|
},
|
63
70
|
toggleBox: function(show) {
|
64
71
|
this.elem.uiChatbox.toggle(show);
|
@@ -187,15 +194,17 @@
|
|
187
194
|
)
|
188
195
|
.appendTo(uiChatboxInput)
|
189
196
|
.keydown(function(event) {
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
197
|
+
if(event.keyCode && event.keyCode == $.ui.keyCode.ENTER) {
|
198
|
+
if (((typeof floodControl == 'function')&&(floodControl()))||((typeof floodControl != 'function'))) {
|
199
|
+
msg = $.trim($(this).val());
|
200
|
+
if (msg.length > 0) {
|
201
|
+
self.options.messageSent(self.options.id, self.options.user, msg);
|
202
|
+
}
|
203
|
+
$(this).val('');
|
204
|
+
}
|
205
|
+
return false;
|
206
|
+
}
|
207
|
+
})
|
199
208
|
.focusin(function() {
|
200
209
|
uiChatboxInputBox.addClass('ui-chatbox-input-focus');
|
201
210
|
var box = $(this).parent().prev();
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Aldo Gordillo
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-11-
|
17
|
+
date: 2011-11-25 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -118,8 +118,6 @@ files:
|
|
118
118
|
- app/views/chat/_off.html.erb
|
119
119
|
- app/views/chat/_settings.html.erb
|
120
120
|
- app/views/xmpp/active_users.html.erb
|
121
|
-
- app/views/xmpp/index.html
|
122
|
-
- app/views/xmpp/test.html.erb
|
123
121
|
- config/locales/en.yml
|
124
122
|
- config/locales/es.yml
|
125
123
|
- config/routes.rb
|
@@ -154,6 +152,7 @@ files:
|
|
154
152
|
- lib/social_stream/presence/models/buddy_manager.rb
|
155
153
|
- lib/social_stream/presence/version.rb
|
156
154
|
- lib/social_stream/presence/xmpp_server_order.rb
|
155
|
+
- lib/social_stream/views/settings/presence.rb
|
157
156
|
- lib/tasks/presence/synchronize.rake
|
158
157
|
- social_stream-presence.gemspec
|
159
158
|
- spec/demo/.gitignore
|
data/app/views/xmpp/index.html
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>Ruby on Rails: Welcome aboard</title>
|
5
|
-
<script type="text/javascript">
|
6
|
-
|
7
|
-
</script>
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
<div id="page">
|
11
|
-
<p> Hello World </p>
|
12
|
-
|
13
|
-
<p> <a href="/xmpp4r_test">Test</a></p>
|
14
|
-
<p> <a href="/active_users">Usuarios conectados al servidor XMPP</a></p>
|
15
|
-
|
16
|
-
</div>
|
17
|
-
</body>
|
18
|
-
</html>
|