social_stream 0.11.5 → 0.11.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/base/app/assets/javascripts/contacts.js +0 -6
  2. data/base/app/assets/javascripts/relation_customs.js +28 -81
  3. data/base/app/assets/javascripts/settings.js +12 -33
  4. data/base/app/assets/stylesheets/base.css.scss +2 -1
  5. data/base/app/assets/stylesheets/relation_customs.css.scss +8 -2
  6. data/base/app/controllers/contacts_controller.rb +7 -3
  7. data/base/app/controllers/messages_controller.rb +1 -1
  8. data/base/app/controllers/search_controller.rb +22 -6
  9. data/base/app/controllers/settings_controller.rb +1 -1
  10. data/base/app/models/contact.rb +7 -1
  11. data/base/app/models/relation.rb +14 -1
  12. data/base/app/views/activities/_new.html.erb +3 -2
  13. data/base/app/views/contacts/_link.html.erb +1 -1
  14. data/base/app/views/contacts/index.html.erb +1 -1
  15. data/base/app/views/conversations/_conversation.html.erb +3 -3
  16. data/base/app/views/conversations/_conversation_full.html.erb +3 -3
  17. data/base/app/views/devise/registrations/_delete_account.html.erb +20 -0
  18. data/base/app/views/devise/registrations/_edit_user.html.erb +87 -0
  19. data/base/app/views/devise/registrations/edit.html.erb +16 -93
  20. data/base/app/views/layouts/_header_dropdown_menu.html.erb +0 -3
  21. data/base/app/views/messages/_form.html.erb +1 -1
  22. data/base/app/views/permissions/_index.html.erb +2 -2
  23. data/base/app/views/permissions/index.js.erb +7 -2
  24. data/base/app/views/relation/customs/_list.html.erb +12 -5
  25. data/base/app/views/relation/customs/create.js.erb +4 -2
  26. data/base/app/views/relation/customs/index.html.erb +0 -5
  27. data/base/app/views/search/_form.html.erb +1 -1
  28. data/base/app/views/settings/_api_key.html.erb +3 -3
  29. data/base/app/views/settings/_index.html.erb +6 -1
  30. data/base/app/views/settings/_notifications.html.erb +3 -3
  31. data/base/app/views/settings/index.html.erb +4 -1
  32. data/base/config/locales/en.yml +31 -12
  33. data/base/config/locales/es.yml +33 -10
  34. data/base/config/routes.rb +10 -11
  35. data/base/lib/mailboxer/notification_decoder.rb +13 -4
  36. data/base/lib/social_stream/base/version.rb +1 -1
  37. data/documents/app/assets/javascripts/social_stream-documents.js +1 -1
  38. data/documents/app/views/pictures/_picture.html.erb +3 -1
  39. data/documents/lib/social_stream/documents/version.rb +1 -1
  40. data/documents/social_stream-documents.gemspec +1 -1
  41. data/documents/vendor/assets/javascripts/jquery.lightbox-with-resize-plugin.js +533 -0
  42. data/events/vendor/assets/stylesheets/jquery.ad-gallery.css +1 -1
  43. data/lib/social_stream/version.rb +1 -1
  44. data/presence/app/assets/stylesheets/chat.css +9 -1
  45. data/presence/app/controllers/xmpp_controller.rb +19 -10
  46. data/presence/app/helpers/xmpp_helper.rb +10 -23
  47. data/presence/app/views/xmpp/_chat.html.erb +9 -7
  48. data/presence/app/views/xmpp/_chat_off.html.erb +1 -1
  49. data/presence/lib/social_stream-presence.rb +12 -0
  50. data/presence/lib/social_stream/presence/config.rb +0 -4
  51. data/presence/lib/social_stream/presence/engine.rb +27 -14
  52. data/presence/lib/social_stream/presence/models/buddy_manager.rb +20 -12
  53. data/social_stream.gemspec +2 -2
  54. metadata +13 -14
  55. data/base/app/assets/images/title_background.png +0 -0
  56. data/base/vendor/assets/javascripts/ui.checkbox.js +0 -309
  57. data/documents/vendor/assets/javascripts/jquery.lightbox.min.js +0 -42
  58. data/presence/app/assets/images/arrow.png +0 -0
@@ -2,9 +2,3 @@
2
2
  //= require jquery.ba-url
3
3
  //= require ajax.paginate
4
4
  //
5
- // edit
6
- //= require ui.checkbox
7
-
8
- $(function() {
9
- $('input[id^="relation_custom"]').checkBox();
10
- });
@@ -1,85 +1,32 @@
1
- //= require ui.checkbox
2
-
3
- var relations;
4
-
5
- function checkBoxId(id) {
1
+ function getDomId(id) {
6
2
  return id.match(/\d+$/)[0];
7
3
  }
8
4
 
9
- function checkBoxType(id) {
10
- return id.match(/(.*)_\d+$/)[1]
11
- }
12
-
13
- function checkBoxValue(id) {
14
- return $('label[for$=' + id +']').html();
15
- }
16
-
17
- function checkBoxOrder(id) {
18
- return parseInt($('label[for$=' + id +']').attr("order"));
19
- }
20
-
21
- function checkBoxIdByOrder(order) {
22
- return $('label[order$=' + order +']').attr("for");
23
- }
24
-
25
-
26
- function checkBoxEnable(id) {
27
- $('div[contain$='+id+']').addClass("checked-option");
28
-
29
- switch (checkBoxType(id)) {
30
-
31
- case "relation_custom":
32
- if ($('#' + id).parents().hasClass('edit_contact')) {
33
- break;
34
- };
35
-
36
- $(':checkbox[id^="relation_custom"]:checked:not(#' + id + ')').checkBox('changeCheckStatus', false);
37
- $('div[contain$='+id+'] div.options').show();
38
-
39
- $.ajax({
40
- url: "../permissions",
41
- context: document.body,
42
- data: { relation_id: checkBoxId(id) },
43
- dataType: "script"
44
- });
45
-
46
- break;
47
-
48
- case "permission":
49
- $('input[id="relation_custom_permission_ids_' + checkBoxId(id) + '"]').attr('checked', 'checked');
50
- $('label[for="relation_custom_permission_ids_' + checkBoxId(id) + '"]').parent().show();
51
-
52
- break;
53
-
54
- default:
55
- alert("Unknown type of checkBox: " + checkBoxType(id));
56
- }
5
+ function selectRelation(radio){
6
+ $("#permissions").html("");
7
+ $('#relation_customs_list div.options').hide();
8
+
9
+ $(radio).siblings('div.options').show();
10
+
11
+ $.ajax({
12
+ url: "../permissions",
13
+ context: document.body,
14
+ data: { relation_id: getDomId($(radio).attr('id')) },
15
+ dataType: "script"
16
+ });
17
+
18
+ };
19
+
20
+ function selectPermission(box){
21
+ var id = getDomId($(box).attr('id'));
22
+ var input = $('input[id="relation_custom_permission_ids_' + id + '"]');
23
+ var label = $('label[for="relation_custom_permission_ids_' + id + '"]');
24
+
25
+ if ($(box).is(':checked')) {
26
+ input.attr('checked', 'checked');
27
+ label.parent().show();
28
+ } else {
29
+ input.removeAttr('checked');
30
+ label.parent().hide();
31
+ }
57
32
  }
58
-
59
- function checkBoxDisable(id) {
60
- $('div[contain$='+id+']').removeClass("checked-option");
61
-
62
- switch (checkBoxType(id)) {
63
-
64
- case "relation_custom":
65
- if ($('#' + id).parents().hasClass('edit_contact')) {
66
- break;
67
- };
68
-
69
- $("#permissions").html("");
70
- $("#permissions").hide();
71
-
72
- $('div[contain$='+id+'] div.options').hide();
73
-
74
- break;
75
-
76
- case "permission":
77
- $('input[id="relation_custom_permission_ids_' + checkBoxId(id) + '"]').removeAttr('checked');
78
- $('label[for="relation_custom_permission_ids_' + checkBoxId(id) + '"]').parent().hide();
79
-
80
- break;
81
- default:
82
- alert("Unknown type of checkBox: " + checkBoxType(id));
83
-
84
- }
85
- }
@@ -1,35 +1,14 @@
1
- var notifications_open = false;
2
- var api_key_open = false;
3
-
4
1
  closeAllSettings = function() {
5
- $("#notifications_settings_content").hide("slow");
6
- $("#notifications_settings_briefing").show("slow");
7
- notifications_open = false;
8
- $("#api_key_settings_content").hide("slow");
9
- $("#api_key_settings_briefing").show("slow");
10
- api_key_open = false;
11
- }
12
- showNotificationsSettings = function() {
13
- if (notifications_open) {
14
- $("#notifications_settings_content").hide("slow");
15
- $("#notifications_settings_briefing").show("slow");
16
- notifications_open = false;
17
- } else {
18
- closeAllSettings();
19
- $("#notifications_settings_content").show("slow");
20
- $("#notifications_settings_briefing").hide("slow");
21
- notifications_open = true;
22
- }
23
- }
24
- showApiKeySettings = function() {
25
- if (api_key_open) {
26
- $("#api_key_settings_content").hide("slow");
27
- $("#api_key_settings_briefing").show("slow");
28
- api_key_open = false;
29
- } else {
30
- closeAllSettings();
31
- $("#api_key_settings_content").show("slow");
32
- $("#api_key_settings_briefing").hide("slow");
33
- api_key_open = true;
34
- }
2
+ $(".settings_content").hide("slow");
3
+ $(".settings_briefing").show("slow");
35
4
  }
5
+ showSettings = function(name) {
6
+ closeAllSettings();
7
+ if($("#" + name + "_content").css("display") == "none") {
8
+ $("#" + name + "_briefing").hide("slow");
9
+ $("#" + name + "_content").show("slow");
10
+ } else {
11
+ $("#" + name + "_briefing").show("slow");
12
+ $("#" + name + "_content").hide("slow");
13
+ }
14
+ }
@@ -76,7 +76,7 @@ button, input[type=submit]{margin: 10px 0 10px 0px;padding: 3px 20px 3px 20px;co
76
76
  .block .center{ text-align:center;}
77
77
  .block .close { float:right; vertical-align:top;}
78
78
  .block .content{ padding: 5px 4px 5px 4px; }
79
- .block .header{vertical-align: middle; background: transparent url(title_background.png) scroll 0px;
79
+ .block .header{vertical-align: middle; background: #DEEFF8;
80
80
  padding-left: 10px; display: block; height:20px; font-weight:bold;}
81
81
  .block .header_icon{ margin-top: 2px; width:14px; height:14px; }
82
82
  .block .header_icon_right { float: right; padding-right: 5px; padding-top: 3px;}
@@ -122,6 +122,7 @@ button, input[type=submit]{margin: 10px 0 10px 0px;padding: 3px 20px 3px 20px;co
122
122
  .block .select_relations{ padding-top:20px; text-align: center; }
123
123
  #form_participants{vertical-align:60%;}
124
124
 
125
+ div.chzn-container ul.chzn-choices li.search-field input.default{ cursor:pointer;}
125
126
 
126
127
  /********* Links SECTION **********/
127
128
  .contact_link a{ text-decoration:none;}
@@ -33,8 +33,9 @@ span.ui-radio-state-checked-hover {
33
33
  background-position: 0 -200px;
34
34
  }
35
35
 
36
- #relation_customs input {
36
+ #relation_customs input, #relation_customs button{
37
37
  float: left;
38
+ padding: 3px 10px 3px 10px;
38
39
  }
39
40
 
40
41
  #relation_customs span {
@@ -160,13 +161,17 @@ span.privacy_span_new {
160
161
  margin-top: 10px;
161
162
  }
162
163
 
163
- #permissions_list_block{
164
+ #permissions_list{
164
165
  width: 50%;
165
166
  float: left;
166
167
  text-align: center;
167
168
  display: block;
168
169
  }
169
170
 
171
+ #permissions_list input.permission {
172
+ float: left;
173
+ }
174
+
170
175
  #privacy_rules{
171
176
  width: 45%;
172
177
  float: right;
@@ -193,6 +198,7 @@ span.privacy_span_new {
193
198
  #relation_custom_permissions_input ol li{
194
199
  font-family: sans-serif;
195
200
  padding: 5px 0px 5px 0px;
201
+ display: block;
196
202
  }
197
203
 
198
204
  #relation_custom_permissions_input label {
@@ -3,13 +3,17 @@ class ContactsController < ApplicationController
3
3
  before_filter :exclude_reflexive, :except => [ :index, :pending ]
4
4
 
5
5
  def index
6
- @contacts =
6
+ @total_contacts =
7
7
  Contact.sent_by(current_subject).
8
8
  joins(:receiver).merge(Actor.alphabetic).
9
+ positive.
10
+ select("actors.name")
11
+
12
+ @contacts =
13
+ @total_contacts.
9
14
  merge(Actor.letter(params[:letter])).
10
15
  merge(Actor.name_search(params[:search])).
11
- related_by_param(params[:relation]).
12
- active
16
+ related_by_param(params[:relation])
13
17
 
14
18
  respond_to do |format|
15
19
  format.html { @contacts = @contacts.page(params[:page]).per(10) }
@@ -47,7 +47,7 @@ class MessagesController < ApplicationController
47
47
  @receipt = @actor.send_message(@recipients, params[:body], params[:subject])
48
48
  if (@receipt.errors.blank?)
49
49
  @conversation = @receipt.conversation
50
- flash[:success]="Your message was sent"
50
+ flash[:success]= t('mailboxer.sent')
51
51
  redirect_to conversation_path(@conversation, :box => :sentbox)
52
52
  else
53
53
  render :action => :new
@@ -1,11 +1,10 @@
1
1
  class SearchController < ApplicationController
2
2
  include ActionView::Helpers::SanitizeHelper
3
-
3
+
4
4
  helper_method :get_search_query
5
5
 
6
6
  RESULTS_SEARCH_PER_PAGE=12
7
7
  MIN_QUERY=2
8
-
9
8
  def index
10
9
  if params[:search_query].blank? or too_short_query
11
10
  @search_result = []
@@ -31,10 +30,11 @@ class SearchController < ApplicationController
31
30
  models = SocialStream.quick_search_models if mode.to_s.eql? "quick"
32
31
  models.map! {|model_sym| model_sym.to_s.classify.constantize}
33
32
  result = ThinkingSphinx.search(get_search_query, :classes => models)
33
+ result = authorization_filter result
34
34
  if mode.to_s.eql? "quick"
35
- result.page(1).per(7)
35
+ result = Kaminari.paginate_array(result).page(1).per(7)
36
36
  else
37
- result.page(params[:page]).per(RESULTS_SEARCH_PER_PAGE)
37
+ result = Kaminari.paginate_array(result).page(params[:page]).per(RESULTS_SEARCH_PER_PAGE)
38
38
  end
39
39
  return result
40
40
  end
@@ -42,7 +42,9 @@ class SearchController < ApplicationController
42
42
  def focus_search
43
43
  @search_class_sym = params[:focus].singularize.to_sym unless params[:focus].blank?
44
44
  search_class = @search_class_sym.to_s.classify.constantize
45
- ThinkingSphinx.search(get_search_query, :classes => [search_class]).page(params[:page]).per(RESULTS_SEARCH_PER_PAGE)
45
+ result = ThinkingSphinx.search(get_search_query, :classes => [search_class])
46
+ result = authorization_filter result
47
+ return Kaminari.paginate_array(result).page(params[:page]).per(RESULTS_SEARCH_PER_PAGE)
46
48
  end
47
49
 
48
50
  def too_short_query
@@ -52,7 +54,8 @@ class SearchController < ApplicationController
52
54
 
53
55
  def get_search_query
54
56
  search_query = ""
55
- bare_query = strip_tags(params[:search_query]) unless bare_query.html_safe?
57
+ param = strip_tags(params[:search_query]) || ""
58
+ bare_query = param unless bare_query.html_safe?
56
59
  search_query_words = bare_query.strip.split
57
60
  search_query_words.each_index do |i|
58
61
  search_query+= search_query_words[i] + " " if i < (search_query_words.size - 1)
@@ -60,4 +63,17 @@ class SearchController < ApplicationController
60
63
  end
61
64
  return search_query.strip
62
65
  end
66
+
67
+ def authorization_filter results
68
+ filtered_results = Array.new
69
+ results.each do |result|
70
+ puts result
71
+ if result.is_a? SocialStream::Models::Object
72
+ filtered_results << result if can? :read, result
73
+ else
74
+ filtered_results << result
75
+ end
76
+ end
77
+ return filtered_results
78
+ end
63
79
  end
@@ -1,5 +1,5 @@
1
1
  class SettingsController < ApplicationController
2
-
2
+
3
3
  before_filter :authenticate_user!
4
4
 
5
5
  def index
@@ -50,6 +50,12 @@ class Contact < ActiveRecord::Base
50
50
 
51
51
  scope :active, where(arel_table[:ties_count].gt(0))
52
52
 
53
+ scope :positive, lambda {
54
+ select("DISTINCT contacts.*").
55
+ joins(:relations).
56
+ merge(Relation.where(:type => Relation.positive_names))
57
+ }
58
+
53
59
  scope :not_reflexive, where(arel_table[:sender_id].not_eq(arel_table[:receiver_id]))
54
60
 
55
61
  scope :pending, active.
@@ -128,7 +134,7 @@ class Contact < ActiveRecord::Base
128
134
  # a {Relation::Public public relation}
129
135
  #
130
136
  def action
131
- if ties_count > 0 && relations.where(:type => ['Relation::Custom', 'Relation::Public']).any?
137
+ if ties_count > 0 && relations.where(:type => Relation.positive_names).any?
132
138
  'edit'
133
139
  else
134
140
  replied? ? 'reply' : 'new'
@@ -24,6 +24,9 @@
24
24
  # It sets the {Audience} that has access to it, and the {Permission Permissions} that rule that access.
25
25
  #
26
26
  class Relation < ActiveRecord::Base
27
+ Positive = %w{ custom public }
28
+ Negative = %w{ reject }
29
+
27
30
  belongs_to :actor
28
31
 
29
32
  has_many :relation_permissions, :dependent => :destroy
@@ -81,7 +84,17 @@ class Relation < ActiveRecord::Base
81
84
  normalize(r, options).id
82
85
  end
83
86
  end
84
-
87
+
88
+ # Positive relation names: [ 'Relation::Custom', 'Relation::Public' ]
89
+ def positive_names
90
+ Positive.map{ |r| "Relation::#{ r.classify }" }
91
+ end
92
+
93
+ # Negative relations: [ 'Relation::Reject' ]
94
+ def negative_names
95
+ Negative.map{ |r| "Relation::#{ r.classify }" }
96
+ end
97
+
85
98
  # All the relations that allow subject to perform action
86
99
  #
87
100
  # Options:
@@ -1,3 +1,4 @@
1
+
1
2
  <% if can? :create, new_post(receiver) %>
2
3
  <div id="activities_header" class="content_size">
3
4
  <% SocialStream.activity_forms.each do |element| %>
@@ -24,12 +25,12 @@
24
25
 
25
26
  <div id="securities">
26
27
  <% if current_subject == receiver %>
27
- <%= select_tag :_relation_ids, options_for_select(current_subject.activity_relations(receiver).sort.map{ |r| [ r.name, r.id ] }), :id => 'security', :multiple => true, :title => t("activity.privacy.contacts.#{ receiver.class.to_s.underscore }", :receiver => receiver.name) %>
28
+ <%= select_tag :_relation_ids, options_for_select(current_subject.activity_relations(receiver).sort.map{ |r| [ r.name, r.id ] }), :id => 'security', :multiple => true, :title => t("activity.privacy.myself.contacts.#{ receiver.class.to_s.underscore }") %>
28
29
  <% else %>
29
30
  <div id="security_chzn" class="chzn-container chzn-container-multi">
30
31
  <ul class="chzn-choices">
31
32
  <li class="search-field">
32
- <input type="text" value="<%= t "activity.privacy.contacts.#{ receiver.class.to_s.underscore }", :receiver => receiver.name %>" class="default" disabled="disabled">
33
+ <input type="text" value="<%= t "activity.privacy.outside.contacts.#{ receiver.class.to_s.underscore }", :receiver => truncate_name(receiver.name,:length => 15) %>" class="default" disabled="disabled">
33
34
  </li>
34
35
  </ul>
35
36
  </div>
@@ -4,6 +4,6 @@
4
4
  <% if controller.controller_name == "contacts" %>
5
5
 
6
6
  <br/>
7
- <%= link_to(t('contact.delete'), contact_path(contact), :action => :destroy, :confirm => t('contact.confirm_delete'), :remote => true) %>
7
+ <%= link_to(t('contact.delete'), contact_path(contact), :method => :delete, :confirm => t('contact.confirm_delete'), :remote => true) %>
8
8
 
9
9
  <% end %>
@@ -17,7 +17,7 @@
17
17
  <div class="space_center"></div>
18
18
  <div class="row" >
19
19
  <div class="center">
20
- <%= link_to t('contact.all_n', :count => current_subject.contact_subjects(:direction => :sent).count), contacts_path %> -
20
+ <%= link_to t('contact.all_n', :count => @total_contacts.count("DISTINCT contacts.id")), contacts_path %> -
21
21
  <% Actor.distinct_initials.
22
22
  contacted_from(current_subject).
23
23
  merge(Tie.related_by(current_subject.relation_customs.find_by_id(params[:relation]))).
@@ -26,10 +26,10 @@
26
26
  </div>
27
27
  <% unless @box.eql?'trash' %>
28
28
  <div class="action">
29
- <% link_to(image_tag('btn/btn_read.png', :alt => "Mark as read", :title => "Mark as read")) %>
30
- <%= link_to(image_tag('btn/btn_delete.png', :alt => "Delete", :title => "Delete"),
29
+ <% link_to(image_tag('btn/btn_read.png', :alt => t('mailboxer.mark_as_read'), :title => t('mailboxer.mark_as_read'))) %>
30
+ <%= link_to(image_tag('btn/btn_delete.png', :alt => t('mailboxer.delete'), :title => t('mailboxer.delete')),
31
31
  conversation_path(conversation, :location => @box, :box => @box, :page => params[:page]),
32
- :confirm => 'Do you want to move "' + conversation.subject + '" to trash?',
32
+ :confirm => t('mailboxer.delete_confirm', :object => conversation.subject),
33
33
  :method => :delete, :remote => true) %>
34
34
  </div>
35
35
  <% end %>
@@ -2,9 +2,9 @@
2
2
  <h2><%= conversation.subject %></h2>
3
3
  </div>
4
4
  <div class="action">
5
- <% unless @box.eql?'trash' %><%= link_to(image_tag('btn/btn_delete.png', :atl => "Delete", :title => "Delete"),
5
+ <% unless @box.eql?'trash' %><%= link_to(image_tag('btn/btn_delete.png', :atl => t('mailboxer.delete'), :title => t('mailboxer.delete')),
6
6
  conversation_path(conversation, :location => 'conversation', :box => @box),
7
- :confirm => 'Do you want to move "' + conversation.subject + '" to trash?',
7
+ :confirm => t('mailboxer.delete_confirm', :object => conversation.subject),
8
8
  :method => :delete, :remote => true) %><% end %>
9
9
  </div>
10
10
  <div class="clearfloat">
@@ -45,7 +45,7 @@
45
45
  <%= text_area_tag :body, nil,:rows =>6, :cols=> 53, :class => "required form_tag" %>
46
46
  </div>
47
47
  <div class="actions center">
48
- <%= submit_tag "Reply", :name => :reply_all,:class => "button" %>
48
+ <%= submit_tag t('mailboxer.reply'), :name => :reply_all,:class => "button" %>
49
49
  </div>
50
50
  </div>
51
51
  <% end %>