Commit caf264468071a2636d0150726742171d0a331dca
Exists in
master
and in
29 other branches
Merge branch 'stable'
Showing
24 changed files
with
135 additions
and
46 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/helpers/forms_helper.rb
app/helpers/layout_helper.rb
app/models/article.rb
app/models/event.rb
... | ... | @@ -14,7 +14,6 @@ class Event < Article |
14 | 14 | maybe_add_http(self.setting[:link]) |
15 | 15 | end |
16 | 16 | |
17 | - xss_terminate :only => [ :link ], :on => 'validation' | |
18 | 17 | xss_terminate :only => [ :body, :link, :address ], :with => 'white_list', :on => 'validation' |
19 | 18 | |
20 | 19 | def initialize(*args) | ... | ... |
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/content_viewer/view_page.rhtml
... | ... | @@ -60,7 +60,6 @@ |
60 | 60 | addthis_options = '<%= escape_javascript( NOOSFERO_CONF['addthis_options'] ) %>'; |
61 | 61 | </script> |
62 | 62 | <a href="http://www.addthis.com/bookmark.php" id="bt_addThis" target="_blank" onmouseover="return addthis_open(this, '', '[URL]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><%= addthis_image_tag %></a> |
63 | -<script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"></script> | |
64 | 63 | </div> |
65 | 64 | <% end %> |
66 | 65 | ... | ... |
app/views/layouts/application-ng.rhtml
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> | ... | ... |
db/migrate/20130605135210_change_article_published_at_from_date_to_datetime.rb
0 → 100644
db/migrate/20130606110602_change_article_versions_published_at_from_date_to_datetime.rb
0 → 100644
db/schema.rb
... | ... | @@ -9,7 +9,7 @@ |
9 | 9 | # |
10 | 10 | # It's strongly recommended to check this file into your version control system. |
11 | 11 | |
12 | -ActiveRecord::Schema.define(:version => 20130429214630) do | |
12 | +ActiveRecord::Schema.define(:version => 20130606110602) do | |
13 | 13 | |
14 | 14 | create_table "abuse_reports", :force => true do |t| |
15 | 15 | t.integer "reporter_id" |
... | ... | @@ -76,7 +76,7 @@ ActiveRecord::Schema.define(:version => 20130429214630) do |
76 | 76 | t.text "setting" |
77 | 77 | t.boolean "notify_comments", :default => false |
78 | 78 | t.integer "hits", :default => 0 |
79 | - t.date "published_at" | |
79 | + t.datetime "published_at" | |
80 | 80 | t.string "source" |
81 | 81 | t.boolean "highlighted", :default => false |
82 | 82 | t.string "external_link" |
... | ... | @@ -119,7 +119,7 @@ ActiveRecord::Schema.define(:version => 20130429214630) do |
119 | 119 | t.text "setting" |
120 | 120 | t.boolean "notify_comments", :default => true |
121 | 121 | t.integer "hits", :default => 0 |
122 | - t.date "published_at" | |
122 | + t.datetime "published_at" | |
123 | 123 | t.string "source" |
124 | 124 | t.boolean "highlighted", :default => false |
125 | 125 | t.string "external_link" |
... | ... | @@ -264,11 +264,11 @@ ActiveRecord::Schema.define(:version => 20130429214630) do |
264 | 264 | t.text "design_data" |
265 | 265 | t.text "custom_header" |
266 | 266 | t.text "custom_footer" |
267 | - t.string "theme", :default => "default", :null => false | |
267 | + t.string "theme", :default => "default", :null => false | |
268 | 268 | t.text "terms_of_use_acceptance_text" |
269 | 269 | t.datetime "created_at" |
270 | 270 | t.datetime "updated_at" |
271 | - t.integer "reports_lower_bound", :default => 0, :null => false | |
271 | + t.integer "reports_lower_bound", :default => 0, :null => false | |
272 | 272 | t.string "redirection_after_login", :default => "keep_on_same_page" |
273 | 273 | t.text "signup_welcome_text" |
274 | 274 | t.string "languages" |
... | ... | @@ -428,7 +428,7 @@ ActiveRecord::Schema.define(:version => 20130429214630) do |
428 | 428 | t.string "type" |
429 | 429 | t.string "identifier" |
430 | 430 | t.integer "environment_id" |
431 | - t.boolean "active", :default => true | |
431 | + t.boolean "active", :default => true | |
432 | 432 | t.string "address" |
433 | 433 | t.string "contact_phone" |
434 | 434 | t.integer "home_page_id" |
... | ... | @@ -439,21 +439,21 @@ ActiveRecord::Schema.define(:version => 20130429214630) do |
439 | 439 | t.float "lat" |
440 | 440 | t.float "lng" |
441 | 441 | t.integer "geocode_precision" |
442 | - t.boolean "enabled", :default => true | |
443 | - t.string "nickname", :limit => 16 | |
442 | + t.boolean "enabled", :default => true | |
443 | + t.string "nickname", :limit => 16 | |
444 | 444 | t.text "custom_header" |
445 | 445 | t.text "custom_footer" |
446 | 446 | t.string "theme" |
447 | - t.boolean "public_profile", :default => true | |
447 | + t.boolean "public_profile", :default => true | |
448 | 448 | t.date "birth_date" |
449 | 449 | t.integer "preferred_domain_id" |
450 | 450 | t.datetime "updated_at" |
451 | - t.boolean "visible", :default => true | |
451 | + t.boolean "visible", :default => true | |
452 | 452 | t.integer "image_id" |
453 | - t.boolean "validated", :default => true | |
453 | + t.boolean "validated", :default => true | |
454 | 454 | t.string "cnpj" |
455 | 455 | t.string "national_region_code" |
456 | - t.boolean "is_template", :default => false | |
456 | + t.boolean "is_template", :default => false | |
457 | 457 | t.integer "template_id" |
458 | 458 | t.string "redirection_after_login" |
459 | 459 | end | ... | ... |
plugins/custom_forms/controllers/custom_forms_plugin_profile_controller.rb
... | ... | @@ -27,6 +27,7 @@ class CustomFormsPluginProfileController < ProfileController |
27 | 27 | failed_answers.each do |answer| |
28 | 28 | @submission.errors.add(answer.field.name.to_sym, answer.errors[answer.field.slug.to_sym]) |
29 | 29 | end |
30 | + raise 'Submission failed: answers not valid' | |
30 | 31 | end |
31 | 32 | session[:notice] = _('Submission saved') |
32 | 33 | redirect_to :action => 'show' | ... | ... |
plugins/custom_forms/lib/custom_forms_plugin/helper.rb
... | ... | @@ -103,14 +103,17 @@ module CustomFormsPlugin::Helper |
103 | 103 | |
104 | 104 | def build_answers(submission, form) |
105 | 105 | answers = [] |
106 | - submission.each do |slug, value| | |
107 | - field = form.fields.select {|field| field.slug==slug}.first | |
108 | - if value.kind_of?(String) | |
109 | - final_value = value | |
110 | - elsif value.kind_of?(Array) | |
111 | - final_value = value.join(',') | |
112 | - elsif value.kind_of?(Hash) | |
113 | - final_value = value.map {|option, present| present == '1' ? option : nil}.compact.join(',') | |
106 | + form.fields.each do |field| | |
107 | + final_value = '' | |
108 | + if submission.has_key?(field.slug) | |
109 | + value = submission[field.slug] | |
110 | + if value.kind_of?(String) | |
111 | + final_value = value | |
112 | + elsif value.kind_of?(Array) | |
113 | + final_value = value.join(',') | |
114 | + elsif value.kind_of?(Hash) | |
115 | + final_value = value.map {|option, present| present == '1' ? option : nil}.compact.join(',') | |
116 | + end | |
114 | 117 | end |
115 | 118 | answers << CustomFormsPlugin::Answer.new(:field => field, :value => final_value) |
116 | 119 | end | ... | ... |
plugins/custom_forms/public/field.js
... | ... | @@ -8,7 +8,6 @@ jQuery('.icon-edit').live('click', function() { |
8 | 8 | id = jQuery(elem).attr('field_id'); |
9 | 9 | type = jQuery('#fields_'+id+'_type').val().split('_')[0]; |
10 | 10 | selector = '#edit-'+type+'-'+id |
11 | - jQuery(selector).show(); | |
12 | 11 | return selector |
13 | 12 | } |
14 | 13 | }); | ... | ... |
plugins/custom_forms/public/style.css
plugins/custom_forms/test/functional/custom_forms_plugin_profile_controller_test.rb
0 → 100644
... | ... | @@ -0,0 +1,31 @@ |
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
2 | +require File.dirname(__FILE__) + '/../../controllers/custom_forms_plugin_profile_controller' | |
3 | + | |
4 | +# Re-raise errors caught by the controller. | |
5 | +class CustomFormsPluginProfileController; def rescue_action(e) raise e end; end | |
6 | + | |
7 | +class CustomFormsPluginProfileControllerTest < ActionController::TestCase | |
8 | + def setup | |
9 | + @controller = CustomFormsPluginProfileController.new | |
10 | + @request = ActionController::TestRequest.new | |
11 | + @response = ActionController::TestResponse.new | |
12 | + @profile = create_user('profile').person | |
13 | + login_as(@profile.identifier) | |
14 | + environment = Environment.default | |
15 | + environment.enable_plugin(CustomFormsPlugin) | |
16 | + end | |
17 | + | |
18 | + attr_reader :profile | |
19 | + | |
20 | + should 'save submission if fields are ok' do | |
21 | + form = CustomFormsPlugin::Form.create!(:profile => profile, :name => 'Free Software') | |
22 | + field1 = CustomFormsPlugin::TextField.create(:name => 'Name', :form => form, :mandatory => true) | |
23 | + field2 = CustomFormsPlugin::TextField.create(:name => 'License', :form => form) | |
24 | + | |
25 | + assert_difference CustomFormsPlugin::Submission, :count, 1 do | |
26 | + post :show, :profile => profile.identifier, :id => form.id, :submission => {field1.name.to_slug => 'Noosfero', field2.name.to_slug => 'GPL'} | |
27 | + end | |
28 | + assert !session[:notice].include?('not saved') | |
29 | + assert_redirected_to :action => 'show' | |
30 | + end | |
31 | +end | ... | ... |
plugins/custom_forms/views/custom_forms_plugin_myprofile/_empty_option.html.erb
1 | 1 | <tr id=<%= "empty-option-#{counter}" %> option_id=<%= option_counter %> style="display: none;"> |
2 | 2 | <td><%= text_field_tag("fields[#{counter}][choices][#{option_counter}][name]") %></td> |
3 | - <td><%= text_field_tag("fields[#{counter}][choices][#{option_counter}][value]", nil, :size => 15) %></td> | |
3 | + <td><%= text_field_tag("fields[#{counter}][choices][#{option_counter}][value]") %></td> | |
4 | 4 | <td class='actions'> |
5 | 5 | <%= button_without_text :remove, _('Remove'), '#', :class => 'remove-option', :field_id => counter, :option_id => option_counter, :confirm => _('Are you sure you want to remove this option?') %> |
6 | 6 | </td> | ... | ... |
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/block_helper_test.rb
test/unit/event_test.rb
... | ... | @@ -234,6 +234,14 @@ class EventTest < ActiveSupport::TestCase |
234 | 234 | assert_equal "<strong> Address <strong>", event.address |
235 | 235 | end |
236 | 236 | |
237 | + should 'not filter & on link field' do | |
238 | + event = Event.new | |
239 | + event.link = 'myevent.com/?param1=value¶m2=value2' | |
240 | + event.valid? | |
241 | + | |
242 | + assert_equal "http://myevent.com/?param1=value¶m2=value2", event.link | |
243 | + end | |
244 | + | |
237 | 245 | should 'escape malformed html tags' do |
238 | 246 | event = Event.new |
239 | 247 | event.body = "<h1<< Description >>/h1>" | ... | ... |
test/unit/user_test.rb
... | ... | @@ -335,7 +335,7 @@ class UserTest < ActiveSupport::TestCase |
335 | 335 | Person.any_instance.stubs(:is_admin?).returns(true) |
336 | 336 | Person.any_instance.stubs(:created_at).returns(DateTime.parse('16-08-2010')) |
337 | 337 | expected_hash = { |
338 | - 'login' => 'x_and_y', 'is_admin' => true, 'since_month' => 8, 'since_year' => 2010, 'email_domain' => nil, 'amount_of_friends' => 0, | |
338 | + 'login' => 'x_and_y', 'is_admin' => true, 'since_month' => 8, 'chat_enabled' => false, 'since_year' => 2010, 'email_domain' => nil, 'amount_of_friends' => 0, | |
339 | 339 | 'friends_list' => {}, 'enterprises' => [], |
340 | 340 | } |
341 | 341 | assert_equal expected_hash, person.user.data_hash |
... | ... | @@ -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' | ... | ... |