Commit edd73ed5bb270dc5fdbaf3c172e6481d1c42b90b
Exists in
master
and in
28 other branches
Merge commit 'refs/merge-requests/314' of git://gitorious.org/noosfero/noosfero …
…into merge-requests/314
Showing
7 changed files
with
39 additions
and
18 deletions
Show diff stats
INSTALL.chat
| ... | ... | @@ -6,15 +6,13 @@ To configure XMPP/BOSH in Noosfero you need: |
| 6 | 6 | * SystemTimer - http://ph7spot.com/musings/system-timer |
| 7 | 7 | * Pidgin data files - http://www.pidgin.im/ |
| 8 | 8 | |
| 9 | -If you use Debian Lenny: | |
| 9 | +If you use Debian Wheezy: | |
| 10 | 10 | |
| 11 | -# apt-get install librestclient-ruby (from backports) | |
| 12 | -# apt-get install pidgin-data | |
| 13 | -# apt-get install ruby1.8-dev | |
| 11 | +# apt-get install librestclient-ruby pidgin-data ruby1.8-dev | |
| 14 | 12 | # gem install SystemTimer |
| 15 | 13 | |
| 16 | -Take a look at util/chat directory to see samples of config file to configure a | |
| 17 | -XMPP/BOSH server with ejabberd, postgresql and apache2. | |
| 14 | +The samples of config file to configure a XMPP/BOSH server with | |
| 15 | +ejabberd, postgresql and apache2 can be found at util/chat directory. | |
| 18 | 16 | |
| 19 | 17 | == XMPP/Chat Server Setup |
| 20 | 18 | |
| ... | ... | @@ -22,8 +20,7 @@ This is a step-by-step guide to get a XMPP service working, in a Debian system. |
| 22 | 20 | |
| 23 | 21 | 1. Install the required packages |
| 24 | 22 | |
| 25 | -# apt-get -t lenny-backports install ejabberd | |
| 26 | -# apt-get install odbc-postgresql | |
| 23 | +# apt-get install ejabberd odbc-postgresql | |
| 27 | 24 | |
| 28 | 25 | 2. Ejabberd configuration |
| 29 | 26 | |
| ... | ... | @@ -108,7 +105,7 @@ Unused modules can be disabled, for example: |
| 108 | 105 | * web_admin |
| 109 | 106 | * mod_pubsub |
| 110 | 107 | * mod_irc |
| 111 | - * mod_offine | |
| 108 | + * mod_offline | |
| 112 | 109 | * mod_admin_extra |
| 113 | 110 | * mod_register |
| 114 | 111 | |
| ... | ... | @@ -132,7 +129,7 @@ This will create a new schema inside the noosfero database, called 'ejabberd'. |
| 132 | 129 | |
| 133 | 130 | Note 'noosfero' user should have permission to create Postgresql schemas. Also, |
| 134 | 131 | there should be at least one domain with 'is_default = true' in 'domains' |
| 135 | -table, otherwise people couldn't see your friends online. | |
| 132 | +table, otherwise people won't be able to see their friends online. | |
| 136 | 133 | |
| 137 | 134 | |
| 138 | 135 | 4. ODBC configuration |
| ... | ... | @@ -168,9 +165,12 @@ Debug = 0 |
| 168 | 165 | CommLog = 1 |
| 169 | 166 | UsageCount = 3 |
| 170 | 167 | |
| 171 | - * testing all: | |
| 168 | + 4.1 testing all: | |
| 172 | 169 | |
| 173 | -# isql 'PostgreSQLEjabberdNoosfero' DBUSER | |
| 170 | +# isql 'PostgreSQLEjabberdNoosfero' | |
| 171 | + | |
| 172 | +If the configuration was done right, the message "Connected!" | |
| 173 | +will be displayed. | |
| 174 | 174 | |
| 175 | 175 | |
| 176 | 176 | 5. Enabling kernel polling and SMP in /etc/default/ejabberd | ... | ... |
app/models/user.rb
| ... | ... | @@ -294,7 +294,8 @@ class User < ActiveRecord::Base |
| 294 | 294 | 'email_domain' => self.enable_email ? self.email_domain : nil, |
| 295 | 295 | 'friends_list' => friends_list, |
| 296 | 296 | 'enterprises' => enterprises, |
| 297 | - 'amount_of_friends' => friends_list.count | |
| 297 | + 'amount_of_friends' => friends_list.count, | |
| 298 | + 'chat_enabled' => person.environment.enabled?('xmpp_chat') | |
| 298 | 299 | } |
| 299 | 300 | end |
| 300 | 301 | ... | ... |
app/views/shared/logged_in/xmpp_chat.rhtml
| ... | ... | @@ -6,6 +6,6 @@ |
| 6 | 6 | </div> |
| 7 | 7 | </div> |
| 8 | 8 | <a href='#' id='chat-online-users-title' onclick='return false;'> |
| 9 | - <div class='header'><i class='icon-chat'></i><span><%= _("Friends in chat <span class='amount_of_friends'>(%{amount})</span>") %></span></div> | |
| 9 | + <div class='header'><i class='icon-chat'></i><span><%= _("Friends in chat (<span class='amount_of_friends'>%{amount}</span>)") %></span></div> | |
| 10 | 10 | </a> |
| 11 | 11 | </div> | ... | ... |
public/javascripts/application.js
| ... | ... | @@ -486,7 +486,9 @@ jQuery(function($) { |
| 486 | 486 | // logged in |
| 487 | 487 | loggedInDataCallBack(data); |
| 488 | 488 | addManageEnterprisesToOldStyleMenu(data); |
| 489 | - chatOnlineUsersDataCallBack(data); | |
| 489 | + if (data.chat_enabled) { | |
| 490 | + setInterval(function(){ $.getJSON('/account/user_data', chatOnlineUsersDataCallBack)}, 10000); | |
| 491 | + } | |
| 490 | 492 | } else { |
| 491 | 493 | // not logged in |
| 492 | 494 | $('#user .not-logged-in, .login-block .not-logged-user').fadeIn(); |
| ... | ... | @@ -538,7 +540,7 @@ jQuery(function($) { |
| 538 | 540 | return; |
| 539 | 541 | } |
| 540 | 542 | var content = ''; |
| 541 | - $('#chat-online-users').html($('#chat-online-users').html().replace(/%{amount}/g, data['amount_of_friends'])); | |
| 543 | + $('#chat-online-users .amount_of_friends').html(data['amount_of_friends']); | |
| 542 | 544 | $('#chat-online-users').fadeIn(); |
| 543 | 545 | for (var user in data['friends_list']) { |
| 544 | 546 | var name = "<span class='friend_name'>%{name}</span>"; | ... | ... |
public/javascripts/chat.js
| ... | ... | @@ -253,7 +253,7 @@ jQuery(function($) { |
| 253 | 253 | result.show = 'away'; |
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | - if ($(stanza).find('x[xmlns='+ Strophe.NS.MUC_USER +']').length > 0) { | |
| 256 | + if ($(stanza).find('x[xmlns="'+ Strophe.NS.MUC_USER +'"]').length > 0) { | |
| 257 | 257 | result.is_from_room = true; |
| 258 | 258 | result.from_user = $(stanza).find('x item').attr('jid'); |
| 259 | 259 | if ($(stanza).find('x item').attr('affiliation') == 'owner') { |
| ... | ... | @@ -351,7 +351,7 @@ jQuery(function($) { |
| 351 | 351 | }, |
| 352 | 352 | |
| 353 | 353 | on_muc_support: function(iq) { |
| 354 | - if ($(iq).find('identity[category=conference]').length > 0 && $(iq).find('feature[var='+ Strophe.NS.MUC +']').length > 0) { | |
| 354 | + if ($(iq).find('identity[category=conference]').length > 0 && $(iq).find('feature[var="'+ Strophe.NS.MUC +'"]').length > 0) { | |
| 355 | 355 | var name = $(iq).find('identity[category=conference]').attr('name'); |
| 356 | 356 | log('muc support found with identity '+ name); |
| 357 | 357 | Jabber.muc_supported = true; | ... | ... |
public/stylesheets/application.css
| ... | ... | @@ -4884,6 +4884,11 @@ h1#agenda-title { |
| 4884 | 4884 | #chat-window .history .message h5, #chat-window .history .message p { |
| 4885 | 4885 | margin: 0; |
| 4886 | 4886 | } |
| 4887 | +#chat-window .history .message p { | |
| 4888 | + max-width: 100%; | |
| 4889 | + overflow: auto; | |
| 4890 | +} | |
| 4891 | + | |
| 4887 | 4892 | #chat-window .history .message .avatar { |
| 4888 | 4893 | position: absolute; |
| 4889 | 4894 | left: 0; | ... | ... |
test/unit/user_test.rb
| ... | ... | @@ -399,6 +399,19 @@ class UserTest < ActiveSupport::TestCase |
| 399 | 399 | assert_equal 15, User.expires_chat_status_every |
| 400 | 400 | end |
| 401 | 401 | |
| 402 | + should "return status of chat on environment in data_hash" do | |
| 403 | + person = create_user('coldplay').person | |
| 404 | + env = person.environment | |
| 405 | + env.enable('xmpp_chat') | |
| 406 | + env.save | |
| 407 | + assert_equal true, person.user.data_hash['chat_enabled'] | |
| 408 | + | |
| 409 | + env.disable('xmpp_chat') | |
| 410 | + env.save | |
| 411 | + person.reload | |
| 412 | + assert_equal false, person.user.data_hash['chat_enabled'] | |
| 413 | + end | |
| 414 | + | |
| 402 | 415 | should 'respond name with related person name' do |
| 403 | 416 | user = create_user('testuser') |
| 404 | 417 | user.person.name = 'Test User' | ... | ... |