social_stream 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/base/app/assets/javascripts/social_stream/actor.js +7 -1
  3. data/base/app/assets/javascripts/social_stream/contact.js +8 -0
  4. data/base/app/assets/javascripts/social_stream/flash.js +11 -1
  5. data/base/app/controllers/groups_controller.rb +1 -1
  6. data/base/app/controllers/profiles_controller.rb +7 -2
  7. data/base/app/controllers/search_controller.rb +9 -11
  8. data/base/app/models/permission.rb +4 -3
  9. data/base/app/models/relation/custom.rb +5 -5
  10. data/base/app/models/user.rb +2 -0
  11. data/base/app/views/contacts/_new_modal.html.erb +2 -2
  12. data/base/app/views/contacts/index.html.erb +3 -2
  13. data/base/app/views/devise/registrations/edit.html.erb +1 -15
  14. data/base/app/views/groups/_form.html.erb +1 -1
  15. data/base/app/views/groups/_new_modal.html.erb +1 -1
  16. data/base/app/views/groups/new.html.erb +1 -1
  17. data/base/app/views/profiles/_comunication-info_edit.html.erb +1 -1
  18. data/base/app/views/profiles/_experience_edit.html.erb +2 -2
  19. data/base/app/views/profiles/_personal_edit.html.erb +3 -3
  20. data/base/app/views/relation/customs/destroy.js.erb +1 -0
  21. data/base/app/views/relation/customs/update.js.erb +1 -1
  22. data/base/app/views/settings/index.html.erb +1 -1
  23. data/base/config/locales/en.yml +3 -0
  24. data/base/config/locales/es.yml +1 -1
  25. data/base/lib/social_stream/base/autoload.rb +15 -8
  26. data/base/lib/social_stream/base/version.rb +1 -1
  27. data/base/lib/social_stream/population.rb +14 -0
  28. data/base/lib/social_stream/search.rb +4 -2
  29. data/base/lib/tasks/db/populate.rake +108 -160
  30. data/lib/social_stream/version.rb +1 -1
  31. data/oauth2_server/app/assets/images/logos/{app-default.png → medium/site.png} +0 -0
  32. data/oauth2_server/app/assets/stylesheets/social_stream/oauth2_server/applications/layout/_applications-oauth2server.css.sass +3 -0
  33. data/oauth2_server/app/assets/stylesheets/social_stream/oauth2_server/mixins/_mixin.css.sass +46 -1
  34. data/oauth2_server/app/controllers/site/clients_controller.rb +21 -2
  35. data/oauth2_server/app/views/site/clients/_list.html.erb +2 -0
  36. data/oauth2_server/app/views/site/clients/index.html.erb +9 -2
  37. data/oauth2_server/app/views/site/clients/show.html.erb +11 -12
  38. data/oauth2_server/config/locales/en.yml +2 -1
  39. data/oauth2_server/config/locales/es.yml +1 -1
  40. data/oauth2_server/lib/social_stream/oauth2_server/controllers/helpers.rb +4 -6
  41. data/oauth2_server/lib/social_stream/oauth2_server/version.rb +1 -1
  42. data/oauth2_server/social_stream-oauth2_server.gemspec +1 -1
  43. data/oauth2_server/spec/controllers/dummy_controller_spec.rb +9 -2
  44. data/social_stream.gemspec +2 -2
  45. metadata +8 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0fa777d423bc8bdb5da4bdcd89bb767e882b98b3
4
- data.tar.gz: ed92fae8cd6c25a55482b4723ebcbf26e8bae22f
3
+ metadata.gz: 978d9e87fb278626d427da3ada3ffd333defe398
4
+ data.tar.gz: b230736937ad6c26148ea5e92b74ef9417089c44
5
5
  SHA512:
6
- metadata.gz: 6f54c0b15d0b36ac58dadf3347b568b6197900e3caa1e923653b3d36b4663828345d3c6e680de1fc604558030002697b0f3886b53d00bcc4618e365ebb0e98c3
7
- data.tar.gz: 36700f4bf7ca3cc7761f2015e587a39579d060a3c9b1f169655a31860313e9160166b59dbd234523b7f342e646a23d306ed6061086c3ae851a14d95de5a4f7f4
6
+ metadata.gz: a88183687d93df8c329a3d7b1f760150effe0ec36efd54d77fc66f7f805eabba11934223b50e9afe64896b0c126e1ac8ae56af678b6e98b3beb4e86cebb43b8a
7
+ data.tar.gz: 03bf445c73f5974b0daee3ae54b11b4767f534c92d2fea64b9ca86775e63583db17cdb6f3ba57f5cd0c0cfe4e69d1fb69fb8414243d0ca4472a517d830d37c84
@@ -3,6 +3,7 @@ SocialStream.Actor = (function(SS, $, undefined) {
3
3
  var select2 = function(selector) {
4
4
  $(selector).select2({
5
5
  multiple: true,
6
+ minimumInputLength: 1,
6
7
  ajax: {
7
8
  url: $(selector).attr('data-path'),
8
9
  dataType: 'json',
@@ -15,7 +16,8 @@ SocialStream.Actor = (function(SS, $, undefined) {
15
16
  },
16
17
  id: function(object) { return object.id.toString(); },
17
18
  formatResult: select2FormatResult,
18
- formatSelection: select2FormatSelection
19
+ formatSelection: select2FormatSelection,
20
+ initSelection: select2InitSelection
19
21
  });
20
22
  };
21
23
 
@@ -27,6 +29,10 @@ SocialStream.Actor = (function(SS, $, undefined) {
27
29
  return '<img src="' + object.image.url + '"> ' + object.name;
28
30
  };
29
31
 
32
+ var select2InitSelection = function(element, callback) {
33
+ callback([ { id: element.val(), name: element.attr('data-actor_name'), locked: true } ]);
34
+ };
35
+
30
36
  return {
31
37
  select2: select2
32
38
  };
@@ -171,6 +171,13 @@ SocialStream.Contact = (function($, SS, undefined) {
171
171
 
172
172
  // new_ callbacks
173
173
 
174
+ var initHideModal = function() {
175
+ $('#add-contact-modal').on('hide', function () {
176
+ $('input[name="actors"]').select2('close');
177
+ $('select[name="relations[]"]').select2('close');
178
+ });
179
+ };
180
+
174
181
  var initActorSelect2 = function() {
175
182
  SS.Actor.select2('input[name="actors"]');
176
183
  };
@@ -298,6 +305,7 @@ SocialStream.Contact = (function($, SS, undefined) {
298
305
  hideLoading);
299
306
 
300
307
  callback.register('new_',
308
+ initHideModal,
301
309
  initActorSelect2,
302
310
  initRelationSelect2);
303
311
 
@@ -1,4 +1,8 @@
1
1
  SocialStream.Flash = (function(Flashy, undefined) {
2
+ var notice = function(message) {
3
+ Flashy.message('notice', message);
4
+ };
5
+
2
6
  var error = function(message) {
3
7
  if (message === undefined) {
4
8
  message = I18n.t('ajax.error');
@@ -11,8 +15,14 @@ SocialStream.Flash = (function(Flashy, undefined) {
11
15
  Flashy.message('success', message);
12
16
  };
13
17
 
18
+ var warning = function(message) {
19
+ Flashy.message('warning', message);
20
+ };
21
+
14
22
  return {
23
+ notice: notice,
15
24
  error: error,
16
- success: success
25
+ success: success,
26
+ warning: warning
17
27
  };
18
28
  })(Flashy);
@@ -4,7 +4,7 @@ class GroupsController < ApplicationController
4
4
 
5
5
  before_filter :authenticate_user!, :except => [ :index, :show ]
6
6
 
7
- load_and_authorize_resource
7
+ load_and_authorize_resource except: :index
8
8
 
9
9
  respond_to :html, :js
10
10
 
@@ -1,6 +1,8 @@
1
1
  class ProfilesController < ApplicationController
2
2
  before_filter :authenticate_user!, :except => [ :show ]
3
3
 
4
+ before_filter :authorize_update, except: [ :show ]
5
+
4
6
  respond_to :html, :js
5
7
 
6
8
  def show
@@ -14,11 +16,10 @@ class ProfilesController < ApplicationController
14
16
  end
15
17
 
16
18
  def edit
17
- current_profile
18
19
  end
19
20
 
20
21
  def update
21
- current_profile.update_attributes profile_params
22
+ subject_profile.update_attributes profile_params
22
23
 
23
24
  respond_to do |format|
24
25
  format.html{ redirect_to [profile_subject, :profile] }
@@ -53,4 +54,8 @@ class ProfilesController < ApplicationController
53
54
 
54
55
  current_subject.profile
55
56
  end
57
+
58
+ def authorize_update
59
+ authorize! :update, subject_profile
60
+ end
56
61
  end
@@ -45,17 +45,15 @@ class SearchController < ApplicationController
45
45
  private
46
46
 
47
47
  def search mode
48
- result = SocialStream::Search.search(params[:q],
49
- current_subject,
50
- :mode => mode,
51
- :key => params[:type])
52
-
53
- if mode.to_s.eql? "quick"
54
- result = Kaminari.paginate_array(result).page(1).per(7)
55
- else
56
- result = Kaminari.paginate_array(result).page(params[:page]).per(RESULTS_SEARCH_PER_PAGE)
57
- end
48
+ page = ( mode == "quick" ? 1 : params[:page] )
49
+ limit = ( mode == "quick" ? 7 : RESULTS_SEARCH_PER_PAGE )
50
+
51
+ SocialStream::Search.search(params[:q],
52
+ current_subject,
53
+ mode: mode,
54
+ key: params[:type],
55
+ page: page,
56
+ limit: limit)
58
57
 
59
- result
60
58
  end
61
59
  end
@@ -51,18 +51,19 @@ class Permission < ActiveRecord::Base
51
51
  # if the class is not found
52
52
  def available(subject)
53
53
  class_name = subject.class.to_s.underscore
54
+ # TODO add further classes
54
55
  base_class_name = subject.class.base_class.to_s.underscore
55
56
 
56
- candidates = [ class_name, class_name.to_sym ]
57
+ candidates = [ class_name ]
57
58
 
58
59
  if class_name != base_class_name
59
- candidates += [ base_class_name, base_class_name.to_sym ]
60
+ candidates += [ base_class_name ]
60
61
  end
61
62
 
62
63
  list = nil
63
64
 
64
65
  candidates.each do |n|
65
- list = SocialStream.available_permissions[n]
66
+ list = SocialStream.available_permissions.with_indifferent_access[n]
66
67
 
67
68
  break if list.present?
68
69
  end
@@ -24,8 +24,8 @@ class Relation::Custom < Relation
24
24
  class << self
25
25
  def defaults_for(actor)
26
26
  subject_type = actor.subject.class.to_s.underscore
27
- cfg_rels = SocialStream.custom_relations[subject_type] ||
28
- SocialStream.custom_relations[subject_type.to_sym]
27
+
28
+ cfg_rels = SocialStream.custom_relations.with_indifferent_access[subject_type]
29
29
 
30
30
  if cfg_rels.nil?
31
31
  raise "Undefined relations for subject type #{ subject_type }. Please, add an entry to config/initializers/social_stream.rb"
@@ -36,10 +36,10 @@ class Relation::Custom < Relation
36
36
  cfg_rels.each_pair do |name, cfg_rel|
37
37
  rels[name] =
38
38
  create! :actor => actor,
39
- :name => cfg_rel['name'],
40
- :receiver_type => cfg_rel['receiver_type']
39
+ :name => cfg_rel[:name],
40
+ :receiver_type => cfg_rel[:receiver_type]
41
41
 
42
- if (ps = cfg_rel['permissions']).present?
42
+ if (ps = cfg_rel[:permissions]).present?
43
43
  ps.each do |p|
44
44
  p.push(nil) if p.size == 1
45
45
 
@@ -50,6 +50,8 @@ class User < ActiveRecord::Base
50
50
 
51
51
  def as_json options = nil
52
52
  {
53
+ id: id,
54
+ actorId: actor_id,
53
55
  nickName: slug,
54
56
  displayName: name,
55
57
  email: email,
@@ -6,10 +6,10 @@
6
6
  </div>
7
7
  <div class="modal-body">
8
8
  <%= label_tag 'actors', t('actor.title.other') %>
9
- <%= text_field_tag 'actors', '', 'data-path' => actors_path(stranger: true, sender_id: Actor.normalize_id(sender)), 'data-type' => Array.wrap(type).compact.join(',') %>
9
+ <%= text_field_tag 'actors', '', 'data-path' => actors_path(stranger: true, sender_id: Actor.normalize_id(sender)), 'data-type' => Array.wrap(type).compact.join(','), placeholder: t('contact.new.modal.placeholder.actors') %>
10
10
 
11
11
  <%= label_tag 'relations', t('activerecord.attributes.contact.relation_ids') %>
12
- <%= select_tag 'relations', contact_select_options(sender.options_for_contact_select), multiple: true %>
12
+ <%= select_tag 'relations', contact_select_options(sender.options_for_contact_select), multiple: true, "data-placeholder" => t('contact.new.modal.placeholder.actors') %>
13
13
  </div>
14
14
  <div class="modal-footer">
15
15
  <%= submit_tag t('contact.new.modal.button') %>
@@ -20,10 +20,11 @@
20
20
  <div id="<%= type %>" class="tab-pane <%= 'active' if current_contact_section?(type) %>">
21
21
  <%= text_field_tag "contact-filter-#{ type }", (current_contact_section?(type) ? params[:q] : ""), class: "pull-right contact-filter", placeholder: "filter", autocomplete: "off" %>
22
22
 
23
- <% if type == :group %>
23
+ <% if user_signed_in? && type == :group %>
24
24
  <%= link_to t('group.new.link'), new_group_path, class: 'new_group-modal-link', 'data-toggle' => 'modal' %>
25
25
 
26
- <%= render partial: 'groups/new_modal' %>
26
+ <%= render partial: 'groups/new_modal',
27
+ locals: { resource_class: Group } %>
27
28
  <% end %>
28
29
 
29
30
  <div class="contact-list">
@@ -1,15 +1 @@
1
- <%= location(t('account.one'),
2
- link_to(t('settings.main'), settings_path)
3
- ) %>
4
-
5
- <h2>
6
- <%= t('settings.for')%> <%= current_subject.name %>
7
- </h2>
8
-
9
- <%= render :partial => "edit_user"%>
10
- <%= render :partial => "settings/language" %>
11
- <%= render :partial => "settings/notifications" %>
12
- <% if current_subject.respond_to? :authentication_token%>
13
- <%= render :partial => "settings/api_key" %>
14
- <% end %>
15
- <%= render :partial => "delete_account"%>
1
+ <%= render template: 'settings/index' %>
@@ -18,7 +18,7 @@
18
18
  </section>
19
19
  <section class="owners">
20
20
  <%= f.label :owners %>
21
- <%= f.hidden_field :owners, 'data-path' => actors_path(format: :json) %>
21
+ <%= f.hidden_field :owners, 'data-path' => actors_path(format: :json), "data-actor_name" => current_subject.name %>
22
22
  </section>
23
23
  <section class="tags">
24
24
  <%= f.label :tags_list %>
@@ -5,7 +5,7 @@
5
5
  </div>
6
6
  <div class="modal-body">
7
7
  <%= render partial: 'groups/form',
8
- object: Group.new,
8
+ object: resource_class.new(owners: current_subject.actor_id),
9
9
  as: :group %>
10
10
  </div>
11
11
  </div>
@@ -8,6 +8,6 @@
8
8
  <h2><%= t('group.new.title') %></h2>
9
9
 
10
10
  <%= render partial: 'form',
11
- object: @group,
11
+ object: resource_class.new(owners: current_subject.actor_id),
12
12
  as: :group %>
13
13
  </section>
@@ -1,4 +1,4 @@
1
- <%= form_for(@profile, :url => [current_subject, :profile]) do |f| %>
1
+ <%= form_for(@profile, :url => [@profile.subject, :profile]) do |f| %>
2
2
  <%= f.label :phone, t('profile.phone') %>
3
3
 
4
4
  <%= f.phone_field :phone %>
@@ -1,5 +1,5 @@
1
- <%= form_for(@profile, :url => [current_subject, :profile]) do |f| %>
1
+ <%= form_for(@profile, :url => [@profile.subject, :profile]) do |f| %>
2
2
  <%= f.text_area :experience, :maxlength => 246, :rows => 5 %>
3
3
 
4
4
  <%= f.submit :class => "btn" %>
5
- <% end %>
5
+ <% end %>
@@ -1,10 +1,10 @@
1
- <%= form_for(@profile, :url => [current_subject, :profile]) do |f| %>
1
+ <%= form_for(@profile, :url => [@profile.subject, :profile]) do |f| %>
2
2
  <span class="required">*</span>
3
3
  <%= f.label :name %>
4
4
 
5
5
  <%= f.text_field :name, :class => "required" %>
6
6
 
7
- <%= f.label :description, t("profile.#{ current_subject.class.to_s.downcase }.about") %>
7
+ <%= f.label :description, t("profile.#{ f.object.subject.class.to_s.downcase }.about") %>
8
8
 
9
9
  <%= f.text_area :description, :maxlength => 200, :rows => 10 %>
10
10
 
@@ -12,7 +12,7 @@
12
12
 
13
13
  <%= f.text_field :organization %>
14
14
 
15
- <%= f.label :birthday, t('profile.' + current_subject.class.to_s.downcase + '.birthday') %>
15
+ <%= f.label :birthday, t('profile.' + f.object.subject.class.to_s.downcase + '.birthday') %>
16
16
 
17
17
  <%= date_select "profile", "birthday", :order => [:day, :month, :year], :end_year => Date.today.year, :start_year => (Date.today.year - 100), :prompt => {:day => 'Day', :month => 'Month', :year => 'Year'} %>
18
18
 
@@ -5,4 +5,5 @@
5
5
  }
6
6
  });
7
7
  <% else %>
8
+ SocialStream.Flash.error('<%= @custom.errors.full_messages.to_sentence %>');
8
9
  <% end %>
@@ -7,5 +7,5 @@
7
7
  section: '<%= params[:section] %>'
8
8
  });
9
9
  <% else %>
10
-
10
+ SocialStream.Flash.error('<%= @custom.errors.full_messages.to_sentence %>');
11
11
  <% end %>
@@ -5,5 +5,5 @@
5
5
  <section id="settings">
6
6
  <%= render partial: 'toolbar/profile', locals: { subject: current_subject } %>
7
7
 
8
- <%= render :partial => 'index' %>
8
+ <%= render partial: 'settings/index' %>
9
9
  </section>
@@ -184,6 +184,9 @@ en:
184
184
  link: Add contact
185
185
  modal:
186
186
  button: Add
187
+ placeholder:
188
+ actors: Type names
189
+ relations: Type names
187
190
  title: Add contacts
188
191
  title: Add %{name} to your contacts
189
192
  menu: Add contact
@@ -586,7 +586,7 @@ es:
586
586
  query: Más resultados para %{query} >
587
587
  name: Buscar
588
588
  no_subject_found: No se encontró a %{subject}.
589
- nothing: No se ha econtrado nada.
589
+ nothing: No se ha encontrado nada.
590
590
  searching: 'Buscando: %{query}'
591
591
  show_all: Todos
592
592
  write: Escribe tu búsqueda...
@@ -1,17 +1,16 @@
1
1
  module SocialStream
2
+
2
3
  autoload :Ability, 'social_stream/ability'
3
4
  autoload :ActivityStreams, 'social_stream/activity_streams'
5
+
4
6
  module ActivityStreams
5
7
  autoload :Supertype, 'social_stream/activity_streams/supertype'
6
8
  autoload :Subtype, 'social_stream/activity_streams/subtype'
7
9
  end
10
+
8
11
  module Base
9
12
  autoload :Ability, 'social_stream/base/ability'
10
13
  end
11
- autoload :D3, 'social_stream/d3'
12
- autoload :Populate, 'social_stream/populate'
13
- autoload :Relations, 'social_stream/relations'
14
- autoload :TestHelpers, 'social_stream/test_helpers'
15
14
 
16
15
  module Controllers
17
16
  autoload :Authorship, 'social_stream/controllers/authorship'
@@ -23,6 +22,8 @@ module SocialStream
23
22
  autoload :Subjects, 'social_stream/controllers/subjects'
24
23
  end
25
24
 
25
+ autoload :D3, 'social_stream/d3'
26
+
26
27
  module Devise
27
28
  module Controllers
28
29
  autoload :UserSignIn, 'social_stream/devise/controllers/user_sign_in'
@@ -36,6 +37,8 @@ module SocialStream
36
37
  autoload :Supertype, 'social_stream/models/supertype'
37
38
  end
38
39
 
40
+ autoload :Population, 'social_stream/population'
41
+
39
42
  module Population
40
43
  autoload :ActivityObject, 'social_stream/population/activity_object'
41
44
  autoload :Actor, 'social_stream/population/actor'
@@ -43,6 +46,8 @@ module SocialStream
43
46
  autoload :Timestamps, 'social_stream/population/timestamps'
44
47
  end
45
48
 
49
+ autoload :Relations, 'social_stream/relations'
50
+
46
51
  module Routing
47
52
  module Constraints
48
53
  autoload :Custom, 'social_stream/routing/constraints/custom'
@@ -53,12 +58,14 @@ module SocialStream
53
58
 
54
59
  autoload :Search, 'social_stream/search'
55
60
 
56
- module Views
57
- autoload :List, 'social_stream/views/list'
58
- autoload :Location, 'social_stream/views/location'
59
- end
61
+ autoload :TestHelpers, 'social_stream/test_helpers'
60
62
 
61
63
  module TestHelpers
62
64
  autoload :Controllers, 'social_stream/test_helpers/controllers'
63
65
  end
66
+
67
+ module Views
68
+ autoload :List, 'social_stream/views/list'
69
+ autoload :Location, 'social_stream/views/location'
70
+ end
64
71
  end