social_stream 0.16.3 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. data/LICENSE +1 -1
  2. data/README.rdoc +1 -0
  3. data/base/LICENSE +1 -1
  4. data/base/README.rdoc +1 -1
  5. data/base/app/assets/stylesheets/header.css.scss +9 -7
  6. data/base/app/controllers/groups_controller.rb +3 -4
  7. data/base/app/controllers/settings_controller.rb +14 -3
  8. data/base/app/controllers/users_controller.rb +3 -4
  9. data/base/app/helpers/permissions_helper.rb +2 -1
  10. data/base/app/models/activity_object.rb +29 -28
  11. data/base/app/models/actor.rb +27 -19
  12. data/base/app/models/channel.rb +48 -0
  13. data/base/app/views/contacts/_pendings.html.erb +1 -1
  14. data/base/app/views/devise/registrations/_edit_user.html.erb +0 -25
  15. data/base/app/views/devise/registrations/edit.html.erb +1 -0
  16. data/base/app/views/layouts/_footer.html.erb +1 -1
  17. data/base/app/views/layouts/_header_dropdown_menu_sessions.html.erb +5 -2
  18. data/base/app/views/settings/_language.html.erb +32 -0
  19. data/base/app/views/settings/_notifications.html.erb +1 -1
  20. data/base/config/locales/en.yml +5 -0
  21. data/base/config/locales/es.yml +7 -0
  22. data/base/db/migrate/20120103103125_add_channels.rb +88 -0
  23. data/base/db/migrate/20120109081509_update_notify_permissions.rb +15 -0
  24. data/base/lib/social_stream-base.rb +7 -4
  25. data/base/lib/social_stream/base/engine.rb +10 -2
  26. data/base/lib/social_stream/base/version.rb +1 -1
  27. data/base/lib/social_stream/controllers/i18n_integration.rb +29 -0
  28. data/base/lib/social_stream/controllers/subjects.rb +19 -0
  29. data/base/lib/social_stream/models/object.rb +12 -26
  30. data/base/lib/social_stream/models/subject.rb +2 -24
  31. data/base/lib/social_stream/models/subtype.rb +80 -0
  32. data/base/lib/social_stream/models/supertype.rb +16 -3
  33. data/base/lib/social_stream/views/settings/base.rb +5 -0
  34. data/base/lib/tasks/db/populate.rake +1 -0
  35. data/base/spec/controllers/settings_controller_spec.rb +1 -1
  36. data/base/spec/spec_helper.rb +3 -0
  37. data/documents/app/assets/stylesheets/documents.css.scss +9 -0
  38. data/documents/app/controllers/documents_controller.rb +3 -2
  39. data/documents/app/models/document.rb +1 -1
  40. data/documents/app/views/documents/_new_activity_fields.html.erb +14 -0
  41. data/documents/app/views/videos/_video_show.html.erb +23 -19
  42. data/documents/config/locales/en.yml +6 -2
  43. data/documents/config/locales/es.yml +6 -2
  44. data/documents/db/migrate/20120109155431_document_object_type.rb +16 -0
  45. data/documents/lib/social_stream/documents/version.rb +1 -1
  46. data/documents/social_stream-documents.gemspec +2 -2
  47. data/documents/spec/dummy/Rakefile +1 -1
  48. data/documents/spec/dummy/app/assets/javascripts/application.js +9 -0
  49. data/documents/spec/dummy/app/assets/stylesheets/application.css +7 -0
  50. data/documents/spec/dummy/app/views/layouts/application.html.erb +3 -3
  51. data/documents/spec/dummy/config/application.rb +8 -8
  52. data/documents/spec/dummy/config/database.yml +3 -0
  53. data/documents/spec/dummy/config/environments/development.rb +7 -2
  54. data/documents/spec/dummy/config/environments/production.rb +23 -12
  55. data/documents/spec/dummy/config/environments/test.rb +5 -3
  56. data/documents/spec/dummy/config/initializers/secret_token.rb +1 -1
  57. data/documents/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  58. data/documents/spec/dummy/config/locales/en.yml +1 -1
  59. data/documents/spec/dummy/config/routes.rb +1 -1
  60. data/documents/spec/dummy/db/schema.rb +6 -0
  61. data/events/app/assets/stylesheets/events.css.scss +3 -0
  62. data/events/app/helpers/events_helper.rb +11 -1
  63. data/events/app/models/event.rb +12 -1
  64. data/events/lib/social_stream/events/models/actor.rb +6 -0
  65. data/events/lib/social_stream/events/version.rb +1 -1
  66. data/events/lib/social_stream/views/sidebar/events.rb +4 -2
  67. data/events/social_stream-events.gemspec +2 -2
  68. data/lib/generators/social_stream/install_generator.rb +1 -0
  69. data/lib/social_stream.rb +2 -0
  70. data/lib/social_stream/version.rb +1 -1
  71. data/lib/tasks/migrations.rake +14 -0
  72. data/linkser/app/assets/javascripts/linkser.js.erb +3 -3
  73. data/linkser/lib/social_stream/linkser/version.rb +1 -1
  74. data/linkser/social_stream-linkser.gemspec +2 -2
  75. data/presence/lib/social_stream/presence/version.rb +1 -1
  76. data/presence/social_stream-presence.gemspec +1 -1
  77. data/social_stream.gemspec +9 -6
  78. data/spec/dummy/config/application.rb +5 -5
  79. data/spec/dummy/config/environments/development.rb +3 -0
  80. data/spec/dummy/config/environments/production.rb +10 -4
  81. data/spec/dummy/config/initializers/secret_token.rb +1 -1
  82. data/spec/dummy/config/initializers/wrap_parameters.rb +5 -3
  83. data/spec/dummy/db/schema.rb +2 -8
  84. data/spec/dummy/script/rails +0 -0
  85. data/spec/spec_helper.rb +3 -0
  86. data/spec/support/db.rb +1 -1
  87. metadata +51 -31
  88. data/base/spec/dummy/app/helpers/application_helper.rb +0 -2
  89. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  90. data/spec/dummy/app/mailers/.gitkeep +0 -0
  91. data/spec/dummy/app/models/.gitkeep +0 -0
@@ -31,4 +31,4 @@
31
31
  </ul>
32
32
  <% end %>
33
33
  </div>
34
- </div>
34
+ </div>
@@ -372,6 +372,8 @@ en:
372
372
  activity: "Read wall"
373
373
  represent:
374
374
  nil: "Administrate"
375
+ notify:
376
+ nil: "Notify via email"
375
377
  detailed:
376
378
  create:
377
379
  activity: "Post to \"%{relation}\" wall"
@@ -382,6 +384,8 @@ en:
382
384
  tie: "See contacts in levels: %{relations} and %{public}"
383
385
  represent:
384
386
  nil: "Change session to act as %{subject}"
387
+ notify:
388
+ nil: "Updates of contacts at %{relation} will be sent to your email"
385
389
  of_relation:
386
390
  choose: "2. Permissions in <strong>%{name}</strong> sphere"
387
391
  privacy:
@@ -433,6 +437,7 @@ en:
433
437
  briefing: "Change your email"
434
438
  lang_change:
435
439
  briefing: "Change your language"
440
+ name: "Change your language"
436
441
  error: "Some errors raised when saving your changes"
437
442
  for: "Settings for"
438
443
  main: "Settings"
@@ -371,6 +371,8 @@ es:
371
371
  activity: "Leer muro"
372
372
  represent:
373
373
  nil: "Administrar"
374
+ notify:
375
+ nil: "Notificar por email"
374
376
  detailed:
375
377
  create:
376
378
  activity: "Publicar en el muro de\"%{relation}\""
@@ -381,6 +383,8 @@ es:
381
383
  tie: "Ver contactos en los niveles: %{relations} y %{public}"
382
384
  represent:
383
385
  nil: "Cambiar sesión para actuar en nombre de %{subject}"
386
+ notify:
387
+ nil: "Las actividades de los contactos en %{relation} se te enviarán al email"
384
388
  of_relation:
385
389
  choose: "2. Permisos para <strong>%{name}</strong>"
386
390
  privacy:
@@ -430,6 +434,9 @@ es:
430
434
  briefing: "Te permite cancelar tu cuenta"
431
435
  email_change:
432
436
  briefing: "Cambia tu email"
437
+ lang_change:
438
+ briefing: "Cambia tu idioma"
439
+ name: "Cambia tu idioma"
433
440
  error: "Hubo errores al guardar los cambios"
434
441
  for: "Ajustes para"
435
442
  main: "Ajustes"
@@ -0,0 +1,88 @@
1
+ class AddChannels < ActiveRecord::Migration
2
+ def up
3
+ create_table :channels do |t|
4
+ t.integer :author_id
5
+ t.integer :owner_id
6
+ t.integer :user_author_id
7
+
8
+ t.timestamps
9
+ end
10
+
11
+ add_index "channels", "author_id"
12
+ add_index "channels", "owner_id"
13
+ add_index "channels", "user_author_id"
14
+
15
+ add_foreign_key "channels", "actors", :name => "index_channels_on_author_id", :column => :author_id
16
+ add_foreign_key "channels", "actors", :name => "index_channels_on_owner_id", :column => :owner_id
17
+ add_foreign_key "channels", "actors", :name => "index_channels_on_user_author_id", :column => :user_author_id
18
+
19
+ change_table :activity_objects do |t|
20
+ t.integer :channel_id
21
+ end
22
+
23
+ add_index "activity_objects", "channel_id"
24
+
25
+ add_foreign_key "activity_objects", "channels", :name => "index_activity_objects_on_channel_id"
26
+
27
+ ActivityObject.record_timestamps = false
28
+
29
+ ActivityObject.reset_column_information
30
+
31
+ ActivityObject.all.each do |a|
32
+ %w( author user_author owner ).each do |m|
33
+ a.channel!.__send__ "#{ m }_id=", a.read_attribute("#{ m }_id") # a.channel!.author_id = a.read_attribute("author_id")
34
+ end
35
+
36
+ a.save!
37
+ end
38
+
39
+ remove_foreign_key "activity_objects", :name => "index_activity_objects_on_author_id"
40
+ remove_foreign_key "activity_objects", :name => "index_activity_objects_on_owner_id"
41
+ remove_foreign_key "activity_objects", :name => "index_activity_objects_on_user_author_id"
42
+
43
+ remove_column :activity_objects, :author_id
44
+ remove_column :activity_objects, :owner_id
45
+ remove_column :activity_objects, :user_author_id
46
+
47
+ ActivityObject.reset_column_information
48
+ end
49
+
50
+ def down
51
+ change_table :activity_objects do |t|
52
+ t.integer :author_id
53
+ t.integer :owner_id
54
+ t.integer :user_author_id
55
+ end
56
+
57
+ add_index "activity_objects", "author_id"
58
+ add_index "activity_objects", "owner_id"
59
+ add_index "activity_objects", "user_author_id"
60
+
61
+ add_foreign_key "activity_objects", "actors", :name => "index_activity_objects_on_author_id", :column => :author_id
62
+ add_foreign_key "activity_objects", "actors", :name => "index_activity_objects_on_owner_id", :column => :owner_id
63
+ add_foreign_key "activity_objects", "actors", :name => "index_activity_objects_on_user_author_id", :column => :user_author_id
64
+
65
+ ActivityObject.reset_column_information
66
+ ActivityObject.record_timestamps = false
67
+
68
+ ActivityObject.all.each do |a|
69
+ next if a.channel.blank?
70
+
71
+ a.author_id = a.channel.author_id
72
+ a.owner_id = a.channel.owner_id
73
+ a.user_author_id = a.channel.user_author_id
74
+
75
+ a.save!
76
+ end
77
+
78
+ remove_foreign_key "activity_objects", :name => "index_activity_objects_on_channel_id"
79
+
80
+ remove_column :activity_objects, :channel_id
81
+
82
+ remove_foreign_key "channels", :name => "index_channels_on_author_id"
83
+ remove_foreign_key "channels", :name => "index_channels_on_owner_id"
84
+ remove_foreign_key "channels", :name => "index_channels_on_user_author_id"
85
+
86
+ drop_table :channels
87
+ end
88
+ end
@@ -0,0 +1,15 @@
1
+ # Before the 'notify' permission was added, only users with the first relation in each group where notified by email
2
+ # This migration preserves the old behavior by granting the 'notify' permission to the first relation in each group
3
+ class UpdateNotifyPermissions < ActiveRecord::Migration
4
+ def up
5
+ perm_notify = Permission.find_or_create_by_action('notify')
6
+ Group.all.each do |g|
7
+ r = g.relation_customs.first
8
+ next if r.blank?
9
+ r.permissions << perm_notify
10
+ end
11
+ end
12
+
13
+ def down
14
+ end
15
+ end
@@ -10,15 +10,18 @@ module SocialStream
10
10
  autoload :TestHelpers, 'social_stream/test_helpers'
11
11
 
12
12
  module Controllers
13
+ autoload :I18nIntegration, 'social_stream/controllers/i18n_integration'
13
14
  autoload :CancanDeviseIntegration, 'social_stream/controllers/cancan_devise_integration'
14
- autoload :Helpers, 'social_stream/controllers/helpers'
15
- autoload :Objects, 'social_stream/controllers/objects'
15
+ autoload :Helpers, 'social_stream/controllers/helpers'
16
+ autoload :Objects, 'social_stream/controllers/objects'
17
+ autoload :Subjects, 'social_stream/controllers/subjects'
16
18
  end
17
19
 
18
20
  module Models
19
- autoload :Supertype, 'social_stream/models/supertype'
20
- autoload :Subject, 'social_stream/models/subject'
21
21
  autoload :Object, 'social_stream/models/object'
22
+ autoload :Subject, 'social_stream/models/subject'
23
+ autoload :Subtype, 'social_stream/models/subtype'
24
+ autoload :Supertype, 'social_stream/models/supertype'
22
25
  end
23
26
 
24
27
  module Views
@@ -14,14 +14,22 @@ module SocialStream
14
14
  end
15
15
  end
16
16
 
17
- initializer "social_stream-base.mime_types" do
17
+ initializer "social_stream-base.mime_types" do
18
18
  Mime::Type.register 'application/xrd+xml', :xrd
19
19
  end
20
20
 
21
- initializer "social_stream-base.controller_helpers" do
21
+ initializer "social_stream-base.model.supertype" do
22
+ ActiveSupport.on_load(:active_record) do
23
+ include SocialStream::Models::Subtype::ActiveRecord
24
+ include SocialStream::Models::Supertype::ActiveRecord
25
+ end
26
+ end
27
+
28
+ initializer "social_stream-base.controller.helpers" do
22
29
  ActiveSupport.on_load(:action_controller) do
23
30
  include SocialStream::Controllers::Helpers
24
31
  include SocialStream::Controllers::CancanDeviseIntegration
32
+ include SocialStream::Controllers::I18nIntegration
25
33
  end
26
34
  end
27
35
 
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Base
3
- VERSION = "0.11.2".freeze
3
+ VERSION = "0.12.0".freeze
4
4
  end
5
5
  end
@@ -0,0 +1,29 @@
1
+ module SocialStream
2
+ module Controllers
3
+ # Common methods added to ApplicationController
4
+ module I18nIntegration
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ before_filter :set_locale
9
+ end
10
+
11
+ module InstanceMethods
12
+ # Set locale as per params, user preference or default
13
+ def set_locale
14
+ I18n.locale = params[:locale] || user_preferred_locale || extract_locale_from_accept_language_header || I18n.default_locale
15
+ end
16
+
17
+ private
18
+ def extract_locale_from_accept_language_header
19
+ return nil if request.env['HTTP_ACCEPT_LANGUAGE'].nil?
20
+ (request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).map{|l| l.to_sym} & I18n.available_locales).first
21
+ end
22
+
23
+ def user_preferred_locale
24
+ current_user.language if user_signed_in?
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,19 @@
1
+ module SocialStream
2
+ module Controllers
3
+ module Subjects
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ inherit_resources
8
+ end
9
+
10
+ module InstanceMethods
11
+ # Overwrite {SocialStream::Controllers::Helpers::InstanceMethods#profile_subject}
12
+ def profile_subject
13
+ !resource.new? && resource || current_subject
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+
@@ -10,12 +10,11 @@ module SocialStream
10
10
  attr_writer :_relation_ids
11
11
  attr_accessor :_activity_parent_id
12
12
 
13
- belongs_to :activity_object,
14
- :validate => true,
15
- :autosave => true,
16
- :dependent => :destroy
13
+ subtype_of :activity_object,
14
+ :build => { :object_type => to_s }
17
15
 
18
- has_many :activity_object_activities, :through => :activity_object
16
+ has_one :channel, :through => :activity_object
17
+ has_many :activity_object_activities, :through => :activity_object
19
18
 
20
19
  # before_create :create_activity_object_with_type
21
20
 
@@ -23,31 +22,18 @@ module SocialStream
23
22
  validates_presence_of :author_id, :owner_id, :user_author_id
24
23
 
25
24
  after_create :create_post_activity
26
- after_update :create_update_activity
25
+ # Disable update activity for now
26
+ # It usually appears repeated in the wall and provides no useful information
27
+ #after_update :create_update_activity
27
28
  end
29
+
30
+ scope :authored_by, lambda { |subject|
31
+ joins(:activity_object).
32
+ merge(ActivityObject.authored_by(subject))
33
+ }
28
34
  end
29
35
 
30
36
  module InstanceMethods
31
- def activity_object!
32
- activity_object || build_activity_object(:object_type => self.class.to_s)
33
- end
34
-
35
- # Delegate missing methods to {ActivityObject}, if they exist there
36
- def method_missing(method, *args, &block)
37
- super
38
- rescue NameError => object_error
39
- # These methods must be raised to avoid loops (the :activity_object association calls here again)
40
- exceptions = [ :_activity_object_id ]
41
- raise object_error if exceptions.include?(method)
42
-
43
- activity_object!.__send__ method, *args, &block
44
- end
45
-
46
- # {ActivityObject} handles some methods
47
- def respond_to? *args
48
- super || activity_object!.respond_to?(*args)
49
- end
50
-
51
37
  # Was the author represented with this {SocialStream::Models::Object object} was created?
52
38
  def represented_author?
53
39
  author_id == user_author_id
@@ -21,10 +21,8 @@ module SocialStream
21
21
  extend ActiveSupport::Concern
22
22
 
23
23
  included do
24
- belongs_to :actor,
25
- :validate => true,
26
- :autosave => true,
27
- :dependent => :destroy
24
+ subtype_of :actor,
25
+ :build => { :subject_type => to_s }
28
26
 
29
27
  has_one :profile, :through => :actor
30
28
 
@@ -78,29 +76,9 @@ module SocialStream
78
76
  end
79
77
 
80
78
  module InstanceMethods
81
- def actor!
82
- actor || build_actor(:subject_type => self.class.to_s)
83
- end
84
-
85
79
  def to_param
86
80
  slug
87
81
  end
88
-
89
- # Delegate missing methods to {Actor}, if they exist there
90
- def method_missing(method, *args, &block)
91
- super
92
- rescue NameError => subject_error
93
- # These methods must be raised to avoid loops (the :actor association calls here again)
94
- exceptions = [ :_actor_id ]
95
- raise subject_error if exceptions.include?(method)
96
-
97
- actor!.__send__ method, *args, &block
98
- end
99
-
100
- # {Actor} handles some methods
101
- def respond_to? *args
102
- super || actor!.respond_to?(*args)
103
- end
104
82
  end
105
83
 
106
84
  module ClassMethods
@@ -0,0 +1,80 @@
1
+ require 'active_support/concern'
2
+
3
+ module SocialStream #:nodoc:
4
+ module Models
5
+ # Common methods for models that have a {SocialStream::Models::Supertype}
6
+ module Subtype
7
+ extend ActiveSupport::Concern
8
+
9
+ included do
10
+ class << self
11
+ attr_reader :supertype_name, :supertype_options
12
+ end
13
+
14
+ belongs_to supertype_name, {
15
+ :validate => true,
16
+ :autosave => true,
17
+ :dependent => :destroy
18
+ }.merge(supertype_options[:belongs] || {})
19
+
20
+ class_eval <<-EOS
21
+ def #{ supertype_name }! # def actor!
22
+ #{ supertype_name } || # actor ||
23
+ # FIXME: ruby1.9 remove .inspect
24
+ build_#{ supertype_name }(#{ supertype_options[:build].inspect }) # build_actor(:subject_type => "User")
25
+ end # end
26
+
27
+ EOS
28
+
29
+ alias_method :supertype!, "#{ supertype_name }!"
30
+
31
+ before_validation :supertype!
32
+ end
33
+
34
+ module ClassMethods
35
+ def supertype_foreign_key
36
+ "#{ supertype_name }_id"
37
+ end
38
+ end
39
+
40
+ module InstanceMethods
41
+ # Delegate missing methods to supertype, if they exist there
42
+ def method_missing(method, *args, &block)
43
+ super
44
+ rescue NameError => subtype_error
45
+ # These methods must be raised to avoid loops
46
+ # (the @supertype_name association (i.e. :actor) calls here again)
47
+ exceptions = [ "_#{ self.class.supertype_foreign_key }".to_sym ] # [ :_actor_id ]
48
+ raise subtype_error if exceptions.include?(method)
49
+
50
+ begin
51
+ supertype!.__send__ method, *args, &block
52
+ # We rescue supertype's NameErrors so methods not defined are raised from
53
+ # the subtype. Example: user.foo should raise "foo is not defined in user"
54
+ # and not "in actor"
55
+ rescue NameError => supertype_error
56
+ raise subtype_error
57
+ end
58
+ end
59
+
60
+ # {SocialStream::Models::Supertype} handles some methods
61
+ def respond_to? *args
62
+ super || supertype!.respond_to?(*args)
63
+ end
64
+ end
65
+
66
+ module ActiveRecord
67
+ extend ActiveSupport::Concern
68
+
69
+ module ClassMethods
70
+ # This class is a subtype. Its supertype class is name
71
+ def subtype_of name, options = {}
72
+ @supertype_name = name
73
+ @supertype_options = options
74
+ include SocialStream::Models::Subtype
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end