social_stream 0.3.6 → 0.4.0
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.
- data/.gitignore +1 -0
- data/Gemfile +6 -0
- data/app/controllers/api_controller.rb +39 -0
- data/app/controllers/frontpage_controller.rb +2 -0
- data/app/controllers/groups_controller.rb +8 -2
- data/app/controllers/likes_controller.rb +9 -29
- data/app/controllers/logos_controller.rb +21 -0
- data/app/controllers/mailbox/conversation_controller.rb +110 -0
- data/app/controllers/mailbox_controller.rb +35 -0
- data/app/controllers/posts_controller.rb +2 -0
- data/app/controllers/profiles_controller.rb +3 -0
- data/app/controllers/ties_controller.rb +10 -0
- data/app/controllers/users_controller.rb +5 -5
- data/app/helpers/groups_helper.rb +0 -2
- data/app/helpers/subjects_helper.rb +11 -0
- data/app/helpers/ties_helper.rb +1 -1
- data/app/models/activity.rb +24 -1
- data/app/models/activity_object.rb +10 -0
- data/app/models/activity_object_activity.rb +10 -0
- data/app/models/actor.rb +87 -60
- data/app/models/group.rb +10 -4
- data/app/models/like.rb +34 -0
- data/app/models/logo.rb +51 -0
- data/app/models/permission.rb +7 -5
- data/app/models/profile.rb +24 -8
- data/app/models/tie.rb +15 -2
- data/app/models/user.rb +2 -2
- data/app/views/activities/_activities.html.erb +1 -1
- data/app/views/activities/_new.html.erb +12 -7
- data/app/views/api/activity_atom_feed.atom.builder +40 -0
- data/app/views/comments/_new.html.erb +1 -1
- data/app/views/devise/passwords/edit.html.erb +21 -0
- data/app/views/devise/passwords/new.html.erb +16 -0
- data/app/views/devise/registrations/new.html.erb +35 -19
- data/app/views/devise/sessions/new.html.erb +30 -0
- data/app/views/frontpage/_header.html.erb +18 -20
- data/app/views/frontpage/_search.html.erb +13 -0
- data/app/views/frontpage/_sponsor.html.erb +12 -13
- data/app/views/frontpage/index.html.erb +88 -80
- data/app/views/groups/_group.html.erb +2 -6
- data/app/views/groups/_index.html.erb +22 -25
- data/app/views/groups/_logo.html.erb +1 -1
- data/app/views/groups/_new.html.erb +56 -39
- data/app/views/groups/_profile.html.erb +142 -0
- data/app/views/groups/_sidebar_index.html.erb +73 -0
- data/app/views/groups/{_middle_show.html.erb → _sidebar_show.html.erb} +2 -2
- data/app/views/groups/_tabs.html.erb +37 -31
- data/app/views/groups/_toolbar_show.html.erb +12 -0
- data/app/views/groups/edit.html.erb +136 -0
- data/app/views/groups/index.html.erb +47 -46
- data/app/views/groups/new.html.erb +2 -0
- data/app/views/groups/show.html.erb +9 -4
- data/app/views/groups/update.js.erb +39 -0
- data/app/views/home/_groups.html.erb +4 -5
- data/app/views/{users/_middle_index.html.erb → home/_sidebar.html.erb} +0 -2
- data/app/views/home/index.html.erb +3 -5
- data/app/views/layouts/_footer.html.erb +4 -0
- data/app/views/layouts/_header.erb +29 -37
- data/app/views/layouts/_representation.html.erb +2 -2
- data/app/views/layouts/application.html.erb +47 -74
- data/app/views/layouts/frontpage.html.erb +27 -48
- data/app/views/layouts/test.html +44 -0
- data/app/views/likes/create.js.erb +1 -1
- data/app/views/likes/destroy.js.erb +1 -1
- data/app/views/logos/_form.html.erb +33 -0
- data/app/views/logos/_precrop.html.erb +48 -0
- data/app/views/logos/edit.html.erb +6 -0
- data/app/views/logos/index.html.erb +27 -0
- data/app/views/logos/new.html.erb +20 -0
- data/app/views/logos/show.html.erb +5 -0
- data/app/views/mailbox/_conversation.html.erb +23 -0
- data/app/views/mailbox/_conversations.html.erb +9 -0
- data/app/views/mailbox/_index.html.erb +16 -0
- data/app/views/{messages → mailbox}/_location.html.erb +0 -0
- data/app/views/mailbox/_menu_options.html.erb +19 -0
- data/app/views/mailbox/_show.html.erb +15 -0
- data/app/views/mailbox/conversation/_conversation.html.erb +40 -0
- data/app/views/mailbox/conversation/_form.html.erb +54 -0
- data/app/views/mailbox/conversation/_location.html.erb +3 -0
- data/app/views/mailbox/conversation/_new.html.erb +19 -0
- data/app/views/mailbox/conversation/_show.html.erb +27 -0
- data/app/views/mailbox/conversation/edit.html.erb +6 -0
- data/app/views/mailbox/conversation/new.html.erb +10 -0
- data/app/views/mailbox/conversation/new.js.erb +1 -0
- data/app/views/mailbox/conversation/show.html.erb +1 -0
- data/app/views/{messages → mailbox}/edit.html.erb +0 -0
- data/app/views/mailbox/index.html.erb +10 -0
- data/app/views/{messages → mailbox}/index.js.erb +0 -0
- data/app/views/mailbox/new.html.erb +14 -0
- data/app/views/mailbox/show.html.erb +11 -0
- data/app/views/mailbox/show.js.erb +1 -0
- data/app/views/menu/_group.html.erb +15 -0
- data/{lib/generators/social_stream/templates/public/stylesheets/users.css → app/views/menu/_home_user.html.erb} +0 -0
- data/app/views/menu/_options.html.erb +11 -0
- data/app/views/menu/_services.html.erb +11 -0
- data/app/views/menu/_tiesGroup.html.erb +14 -0
- data/app/views/menu/_tiesUser.html.erb +11 -0
- data/app/views/menu/_user.html.erb +15 -0
- data/app/views/profiles/show.html.erb +1 -0
- data/app/views/subjects/_contacts.html.erb +8 -9
- data/app/views/subjects/_menu_options.html.erb +14 -0
- data/app/views/subjects/_toolbar.html.erb +15 -0
- data/app/views/ties/_new.html.erb +3 -2
- data/app/views/ties/_pendings.html.erb +7 -12
- data/app/views/ties/_suggestions.html.erb +12 -12
- data/app/views/ties/_tie.html.erb +9 -7
- data/app/views/ties/new.js.erb +1 -2
- data/app/views/users/_groups.html.erb +4 -3
- data/app/views/users/_index.html.erb +24 -22
- data/app/views/users/_logo.html.erb +1 -1
- data/app/views/users/_profile.html.erb +167 -164
- data/app/views/users/_sidebar_index.html.erb +6 -0
- data/app/views/users/{_middle_show.html.erb → _sidebar_show.html.erb} +0 -0
- data/app/views/users/_toolbar_show.html.erb +17 -0
- data/app/views/users/edit.html.erb +193 -165
- data/app/views/users/index.html.erb +34 -47
- data/{spec/dummy/public/stylesheets/.gitkeep → app/views/users/info.html.erb} +0 -0
- data/app/views/users/show.html.erb +4 -4
- data/app/views/users/show.xml.builder +28 -0
- data/app/views/users/update.js.erb +3 -1
- data/config/locales/en.yml +88 -9
- data/config/routes.rb +30 -14
- data/lib/generators/social_stream/install_generator.rb +8 -2
- data/lib/generators/social_stream/templates/migration.rb +75 -81
- data/lib/generators/social_stream/templates/public/images/{frontpage/facebook.png → btn/1-facebook.png} +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/edit.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/facebook.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/linkedin.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/twitter-follow-icon.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/twitter.png +0 -0
- data/lib/generators/social_stream/templates/public/images/frontpage/collaborate.png +0 -0
- data/lib/generators/social_stream/templates/public/images/frontpage/meet.png +0 -0
- data/lib/generators/social_stream/templates/public/images/frontpage/share.png +0 -0
- data/lib/generators/social_stream/templates/public/images/icons/favicon.ico +0 -0
- data/lib/generators/social_stream/templates/public/images/logo.png +0 -0
- data/lib/generators/social_stream/templates/public/images/w3c_css.png +0 -0
- data/lib/generators/social_stream/templates/public/images/w3c_xhtml.png +0 -0
- data/lib/generators/social_stream/templates/public/javascripts/jquery-ui-1.8.4.custom.min.js +3 -3
- data/lib/generators/social_stream/templates/public/javascripts/jquery-ui-personalized-1.5.2.packed.js +1 -0
- data/lib/generators/social_stream/templates/public/javascripts/jquery-ui.min.js +3 -3
- data/lib/generators/social_stream/templates/public/javascripts/jquery.Jcrop.min.js +163 -0
- data/lib/generators/social_stream/templates/public/javascripts/jquery.fcbkcomplete.min.js +76 -76
- data/lib/generators/social_stream/templates/public/javascripts/jquery.min.js +156 -5
- data/lib/generators/social_stream/templates/public/javascripts/main.js +9 -0
- data/lib/generators/social_stream/templates/public/javascripts/menu-collapsed.js +42 -0
- data/lib/generators/social_stream/templates/public/javascripts/menu.js +1 -1
- data/lib/generators/social_stream/templates/public/javascripts/rails.js +30 -29
- data/lib/generators/social_stream/templates/public/javascripts/superfish.js +121 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/activities.css +72 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/base.css +150 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/carousel.css +23 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{fcbkComplete.css → default/fcbkComplete.css} +2 -2
- data/lib/generators/social_stream/templates/public/stylesheets/default/footer.css +25 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/frontpage.css +54 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/header.css +44 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/home.css +44 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-icons_222222_256x240.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-icons_2e83ff_256x240.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-icons_454545_256x240.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-icons_888888_256x240.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-icons_cd0a0a_256x240.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/jqcloud.css +15 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{jquery-ui.css → default/jquery-ui.css} +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/jquery.Jcrop.css +35 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/menu.css +33 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-icons_222222_256x240.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-icons_2e83ff_256x240.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-icons_454545_256x240.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-icons_888888_256x240.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/jquery-ui-1.7.3.custom.css +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/jquery-ui-1.8.4.custom.css +0 -0
- data/lib/social_stream.rb +11 -2
- data/lib/social_stream/ability.rb +21 -3
- data/lib/social_stream/models/object.rb +5 -3
- data/lib/social_stream/models/subject.rb +50 -31
- data/lib/social_stream/rails.rb +5 -0
- data/lib/social_stream/test_helpers.rb +11 -0
- data/lib/social_stream/test_helpers/controllers.rb +64 -0
- data/lib/social_stream/version.rb +1 -1
- data/lib/tasks/db/populate.rake +110 -25
- data/social_stream.gemspec +7 -1
- data/spec/controllers/contacts_controller_spec.rb +1 -1
- data/spec/controllers/groups_controller_spec.rb +8 -0
- data/spec/controllers/home_controller_spec.rb +15 -0
- data/spec/controllers/likes_controller_spec.rb +29 -0
- data/spec/controllers/posts_controller_spec.rb +41 -0
- data/spec/controllers/profiles_controller_spec.rb +46 -0
- data/spec/controllers/users_controller_spec.rb +2 -2
- data/spec/dummy/.gitignore +4 -0
- data/spec/dummy/config/database.yml +8 -0
- data/spec/dummy/config/environments/test_pg.rb +35 -0
- data/spec/dummy/config/routes.rb +2 -0
- data/spec/factories/group.rb +1 -1
- data/spec/integration/navigation_spec.rb +1 -1
- data/spec/models/actor_spec.rb +4 -4
- data/spec/models/user_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -1
- data/spec/support/db.rb +7 -0
- metadata +198 -116
- data/app/controllers/messages_controller.rb +0 -3
- data/app/models/message.rb +0 -2
- data/app/views/groups/_middle_index.html.erb +0 -74
- data/app/views/groups/_right_index.html.erb +0 -19
- data/app/views/groups/_right_show.html.erb +0 -8
- data/app/views/home/_middle.html.erb +0 -4
- data/app/views/home/_options.html.erb +0 -8
- data/app/views/home/_right.html.erb +0 -17
- data/app/views/messages/_form.html.erb +0 -24
- data/app/views/messages/_index.html.erb +0 -24
- data/app/views/messages/_message.html.erb +0 -17
- data/app/views/messages/_messages.html.erb +0 -2
- data/app/views/messages/index.html.erb +0 -1
- data/app/views/messages/new.html.erb +0 -14
- data/app/views/messages/show.html.erb +0 -21
- data/app/views/users/_menu.html.erb +0 -7
- data/app/views/users/_options.html.erb +0 -5
- data/app/views/users/_right_index.html.erb +0 -19
- data/app/views/users/_right_show.html.erb +0 -14
- data/lib/generators/social_stream/templates/public/images/btn/btn_share.png +0 -0
- data/lib/generators/social_stream/templates/public/images/favicon.ico +0 -0
- data/lib/generators/social_stream/templates/public/images/frontpage/collaborate.gif +0 -0
- data/lib/generators/social_stream/templates/public/images/frontpage/meet.gif +0 -0
- data/lib/generators/social_stream/templates/public/images/frontpage/share.gif +0 -0
- data/lib/generators/social_stream/templates/public/javascripts/hoverIntent.js +0 -84
- data/lib/generators/social_stream/templates/public/stylesheets/activities.css +0 -235
- data/lib/generators/social_stream/templates/public/stylesheets/base.css +0 -68
- data/lib/generators/social_stream/templates/public/stylesheets/boxy.css +0 -49
- data/lib/generators/social_stream/templates/public/stylesheets/browse.css +0 -162
- data/lib/generators/social_stream/templates/public/stylesheets/carousel.css +0 -57
- data/lib/generators/social_stream/templates/public/stylesheets/edit_user.css +0 -104
- data/lib/generators/social_stream/templates/public/stylesheets/frontpage.css +0 -708
- data/lib/generators/social_stream/templates/public/stylesheets/header.css +0 -116
- data/lib/generators/social_stream/templates/public/stylesheets/home.css +0 -121
- data/lib/generators/social_stream/templates/public/stylesheets/index.css +0 -625
- data/lib/generators/social_stream/templates/public/stylesheets/jqcloud.css +0 -62
- data/lib/generators/social_stream/templates/public/stylesheets/menu.css +0 -83
- data/lib/generators/social_stream/templates/public/stylesheets/message.css +0 -46
- data/lib/generators/social_stream/templates/public/stylesheets/middle.css +0 -113
- data/lib/generators/social_stream/templates/public/stylesheets/right.css +0 -58
- data/lib/generators/social_stream/templates/public/stylesheets/social_stream.css +0 -78
- data/lib/generators/social_stream/templates/public/stylesheets/ui.dropdownchecklist.css +0 -21
- data/spec/dummy/db/.gitignore +0 -2
- data/spec/dummy/log/.gitignore +0 -1
- data/spec/dummy/public/javascripts/application.js +0 -2
- data/spec/dummy/public/javascripts/controls.js +0 -965
- data/spec/dummy/public/javascripts/dragdrop.js +0 -974
- data/spec/dummy/public/javascripts/effects.js +0 -1123
- data/spec/dummy/public/javascripts/prototype.js +0 -6001
- data/spec/dummy/public/javascripts/rails.js +0 -175
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
# The {ActivityObject} is any object that receives actions. Examples are
|
|
2
|
+
# creating post, liking a comment, contacting a user.
|
|
3
|
+
#
|
|
4
|
+
# = ActivityObject subtypes
|
|
5
|
+
# All post, comment and user are {SocialStream::Models::Object objects}.
|
|
6
|
+
# Social Stream privides 3 {ActivityObject} subtypes, {Post}, {Comment} and
|
|
7
|
+
# {Actor}. The application developer can define as many {ActivityObject} subtypes
|
|
8
|
+
# as required.
|
|
9
|
+
# Objects are added to +config/initializers/social_stream.rb+
|
|
10
|
+
#
|
|
1
11
|
class ActivityObject < ActiveRecord::Base
|
|
2
12
|
@subtypes_name = :object
|
|
3
13
|
include SocialStream::Models::Supertype
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
class ActivityObjectActivity < ActiveRecord::Base
|
|
2
2
|
belongs_to :activity, :dependent => :destroy
|
|
3
3
|
belongs_to :activity_object
|
|
4
|
+
|
|
5
|
+
before_create :default_object_type
|
|
6
|
+
|
|
7
|
+
private
|
|
8
|
+
|
|
9
|
+
# Default objects are direct objects. http://activitystrea.ms/head/atom-activity.html#activity.object
|
|
10
|
+
# Other type of objects are targets. http://activitystrea.ms/head/atom-activity.html#activity.target
|
|
11
|
+
def default_object_type
|
|
12
|
+
self.object_type ||= "object"
|
|
13
|
+
end
|
|
4
14
|
end
|
data/app/models/actor.rb
CHANGED
|
@@ -1,89 +1,106 @@
|
|
|
1
|
-
# An {Actor} is a social entity. This includes individuals, but also groups, departments,
|
|
1
|
+
# An {Actor} is a social entity. This includes individuals, but also groups, departments,
|
|
2
|
+
# organizations even nations or states.
|
|
2
3
|
#
|
|
3
4
|
# Actors are the nodes of a social network. Two actors are linked by a {Tie}. The
|
|
4
5
|
# type of a {tie} is a {Relation}. Each actor can define and customize their relations.
|
|
5
6
|
#
|
|
6
7
|
# = Actor subtypes
|
|
7
8
|
# An actor subtype is called a {SocialStream::Models::Subject Subject}.
|
|
8
|
-
# {SocialStream} provides
|
|
9
|
+
# {SocialStream} provides 2 actor subtypes, {User} and {Group}, but the
|
|
9
10
|
# application developer can define as many actor subtypes as required.
|
|
10
11
|
# Actors subtypes are added to +config/initializers/social_stream.rb+
|
|
11
12
|
#
|
|
12
13
|
class Actor < ActiveRecord::Base
|
|
13
14
|
@subtypes_name = :subject
|
|
14
15
|
include SocialStream::Models::Supertype
|
|
15
|
-
|
|
16
|
+
|
|
16
17
|
validates_presence_of :name, :subject_type
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
|
|
19
|
+
acts_as_messageable
|
|
20
|
+
acts_as_url :name, :url_attribute => :slug
|
|
21
|
+
|
|
20
22
|
has_attached_file :logo,
|
|
21
23
|
:styles => { :tie => "30x30>",
|
|
22
24
|
:actor => '35x35>',
|
|
23
25
|
:profile => '94x94' },
|
|
24
26
|
:default_url => "/images/:attachment/:style/:subtype_class.png"
|
|
25
|
-
|
|
27
|
+
|
|
26
28
|
has_one :profile, :dependent => :destroy
|
|
27
|
-
|
|
29
|
+
|
|
28
30
|
has_many :sent_ties,
|
|
29
31
|
:class_name => "Tie",
|
|
30
32
|
:foreign_key => 'sender_id',
|
|
31
33
|
:dependent => :destroy
|
|
32
|
-
|
|
34
|
+
|
|
33
35
|
has_many :received_ties,
|
|
34
36
|
:class_name => "Tie",
|
|
35
37
|
:foreign_key => 'receiver_id',
|
|
36
38
|
:dependent => :destroy
|
|
37
|
-
|
|
39
|
+
|
|
38
40
|
has_many :senders,
|
|
39
41
|
:through => :received_ties,
|
|
40
42
|
:uniq => true
|
|
41
|
-
|
|
43
|
+
|
|
42
44
|
has_many :receivers,
|
|
43
45
|
:through => :sent_ties,
|
|
44
46
|
:uniq => true
|
|
45
|
-
|
|
47
|
+
|
|
46
48
|
after_create :initialize_ties
|
|
47
|
-
|
|
49
|
+
|
|
48
50
|
after_create :create_profile
|
|
49
|
-
|
|
51
|
+
|
|
50
52
|
class << self
|
|
51
53
|
# Get actor's id from an object, if possible
|
|
52
54
|
def normalize_id(a)
|
|
53
55
|
case a
|
|
54
|
-
|
|
55
|
-
a
|
|
56
|
-
when Array
|
|
56
|
+
when Array
|
|
57
57
|
a.map{ |e| normalize_id(e) }
|
|
58
|
-
when Actor
|
|
59
|
-
a.id
|
|
60
58
|
else
|
|
61
|
-
a.
|
|
59
|
+
Actor.normalize(a).id
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
# Get actor from object, if possible
|
|
63
|
+
def normalize(a)
|
|
64
|
+
case a
|
|
65
|
+
when Actor
|
|
66
|
+
a
|
|
67
|
+
when Integer
|
|
68
|
+
Actor.find a
|
|
69
|
+
when Array
|
|
70
|
+
a.map{ |e| Actor.normalize(e) }
|
|
71
|
+
else
|
|
72
|
+
begin
|
|
73
|
+
a.actor
|
|
74
|
+
rescue
|
|
75
|
+
raise "Unable to normalize actor #{ a.inspect }"
|
|
76
|
+
end
|
|
62
77
|
end
|
|
63
78
|
end
|
|
64
79
|
end
|
|
65
|
-
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
66
83
|
# The subject instance for this actor
|
|
67
84
|
def subject
|
|
68
85
|
subtype_instance ||
|
|
69
|
-
|
|
86
|
+
activity_object.try(:object)
|
|
70
87
|
end
|
|
71
|
-
|
|
88
|
+
|
|
72
89
|
# All the ties sent or received by this actor
|
|
73
90
|
def ties
|
|
74
91
|
Tie.sent_or_received_by(self)
|
|
75
92
|
end
|
|
76
|
-
|
|
93
|
+
|
|
77
94
|
# Relations defined and managed by this actor
|
|
78
95
|
def relations
|
|
79
96
|
Relation.includes(:ties).merge(Tie.sent_by(self))
|
|
80
97
|
end
|
|
81
|
-
|
|
98
|
+
|
|
82
99
|
# A given relation defined and managed by this actor
|
|
83
100
|
def relation(name)
|
|
84
101
|
relations.find_by_name(name)
|
|
85
102
|
end
|
|
86
|
-
|
|
103
|
+
|
|
87
104
|
# All the actors this one has relation with
|
|
88
105
|
#
|
|
89
106
|
# Options:
|
|
@@ -95,32 +112,32 @@ class Actor < ActiveRecord::Base
|
|
|
95
112
|
def actors(options = {})
|
|
96
113
|
subject_types = Array(options[:subject_type] || self.class.subtypes)
|
|
97
114
|
subject_classes = subject_types.map{ |s| s.to_s.classify }
|
|
98
|
-
|
|
115
|
+
|
|
99
116
|
as = Actor.select("DISTINCT actors.*").
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
117
|
+
where('actors.subject_type' => subject_classes).
|
|
118
|
+
includes(subject_types)
|
|
119
|
+
|
|
120
|
+
|
|
104
121
|
case options[:direction]
|
|
105
|
-
|
|
122
|
+
when :senders
|
|
106
123
|
as = as.joins(:sent_ties).merge(Tie.received_by(self))
|
|
107
|
-
|
|
124
|
+
when :receivers
|
|
108
125
|
as = as.joins(:received_ties).merge(Tie.sent_by(self))
|
|
109
126
|
else
|
|
110
127
|
raise "actors in both directions is not supported yet"
|
|
111
128
|
end
|
|
112
|
-
|
|
129
|
+
|
|
113
130
|
if options[:include_self].blank?
|
|
114
131
|
as = as.where("actors.id != ?", self.id)
|
|
115
132
|
end
|
|
116
|
-
|
|
133
|
+
|
|
117
134
|
if options[:relations].present?
|
|
118
135
|
as &= Tie.related_by(options[:relations])
|
|
119
136
|
end
|
|
120
|
-
|
|
137
|
+
|
|
121
138
|
as
|
|
122
139
|
end
|
|
123
|
-
|
|
140
|
+
|
|
124
141
|
# All the subject actors that send or receive at least one tie to this actor
|
|
125
142
|
#
|
|
126
143
|
# When passing a block, it will be evaluated for the actors query, allowing to add
|
|
@@ -129,23 +146,23 @@ class Actor < ActiveRecord::Base
|
|
|
129
146
|
# See actors for options
|
|
130
147
|
def subjects(options = {})
|
|
131
148
|
as = actors(options)
|
|
132
|
-
|
|
149
|
+
|
|
133
150
|
if block_given?
|
|
134
151
|
as = yield(as)
|
|
135
152
|
end
|
|
136
|
-
|
|
153
|
+
|
|
137
154
|
as.map(&:subject)
|
|
138
155
|
end
|
|
139
|
-
|
|
156
|
+
|
|
140
157
|
# This is an scaffold for a recomendations engine
|
|
141
158
|
#
|
|
142
|
-
|
|
159
|
+
|
|
143
160
|
# Make n suggestions
|
|
144
161
|
# TODO: make more
|
|
145
162
|
def suggestions(n)
|
|
146
163
|
n.times.map{ |m| suggestion }
|
|
147
164
|
end
|
|
148
|
-
|
|
165
|
+
|
|
149
166
|
# By now, it returns a tie suggesting a relation from SuggestedRelations
|
|
150
167
|
# to another subject without any current relation
|
|
151
168
|
#
|
|
@@ -155,10 +172,10 @@ class Actor < ActiveRecord::Base
|
|
|
155
172
|
# @return [Tie]
|
|
156
173
|
def suggestion(options = {})
|
|
157
174
|
candidates_types =
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
175
|
+
options[:type].present? ?
|
|
176
|
+
Array(options[:type]) :
|
|
177
|
+
self.class.subtypes
|
|
178
|
+
|
|
162
179
|
candidates_classes = candidates_types.map{ |t| t.to_s.classify.constantize }
|
|
163
180
|
|
|
164
181
|
# Candidates are all the instance of "type" minus all the subjects
|
|
@@ -168,56 +185,67 @@ class Actor < ActiveRecord::Base
|
|
|
168
185
|
cs -= Array(subject) if subject.is_a?(klass)
|
|
169
186
|
cs
|
|
170
187
|
end
|
|
171
|
-
|
|
188
|
+
|
|
172
189
|
candidate = candidates[rand(candidates.size)]
|
|
173
|
-
|
|
190
|
+
|
|
174
191
|
return nil unless candidate.present?
|
|
175
|
-
|
|
192
|
+
|
|
176
193
|
# Building ties with sent_ties catches them and excludes them from pending ties.
|
|
177
194
|
# An useful side effect for excluding this ones from pending, but can be weird!
|
|
178
195
|
# Maybe we must use:
|
|
179
196
|
# Tie.sent_by(self).build :receiver_id => candidate.actor.id
|
|
180
197
|
sent_ties.build :receiver_id => candidate.actor.id
|
|
181
198
|
end
|
|
182
|
-
|
|
199
|
+
|
|
183
200
|
# Set of ties sent by this actor received by a
|
|
184
201
|
def ties_to(a)
|
|
185
202
|
sent_ties.received_by(a)
|
|
186
203
|
end
|
|
187
|
-
|
|
204
|
+
|
|
188
205
|
# All the ties this actor has with subject that support permission
|
|
189
206
|
def sent_ties_allowing(subject, action, objective)
|
|
190
207
|
return [] if subject.blank?
|
|
191
|
-
|
|
208
|
+
|
|
192
209
|
sent_ties.allowing(subject, action, objective)
|
|
193
210
|
end
|
|
194
211
|
|
|
212
|
+
# The ties that allow attaching an activity to them. This method is used for caching
|
|
213
|
+
def active_ties
|
|
214
|
+
@active_ties ||= {}
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
# The ties that allow subject creating activities for this actor
|
|
218
|
+
def active_ties_for(subject)
|
|
219
|
+
active_ties[subject] ||=
|
|
220
|
+
sent_ties_allowing(subject, 'create', 'activity')
|
|
221
|
+
end
|
|
222
|
+
|
|
195
223
|
def pending_ties
|
|
196
224
|
@pending_ties ||=
|
|
197
|
-
|
|
198
|
-
|
|
225
|
+
received_ties.where('ties.sender_id NOT IN (?)', sent_ties.map(&:receiver_id).uniq).map(&:sender_id).uniq.
|
|
226
|
+
map{ |i| Tie.new :sender => self,
|
|
199
227
|
:receiver_id => i }
|
|
200
228
|
end
|
|
201
|
-
|
|
229
|
+
|
|
202
230
|
# The set of activities in the wall of this actor, includes all the activities
|
|
203
231
|
# from the ties the actor has access to
|
|
204
232
|
#
|
|
205
233
|
def home_wall
|
|
206
234
|
Activity.home_wall ties
|
|
207
235
|
end
|
|
208
|
-
|
|
236
|
+
|
|
209
237
|
# The set of activities in the wall profile of this actor, includes the activities
|
|
210
238
|
# from the ties of this actor that can be read by user
|
|
211
239
|
#
|
|
212
240
|
def profile_wall(user)
|
|
213
241
|
# FIXME: show public activities
|
|
214
242
|
return [] if user.blank?
|
|
215
|
-
|
|
243
|
+
|
|
216
244
|
Activity.profile_wall ties.allowing(user, 'read', 'activity')
|
|
217
245
|
end
|
|
218
|
-
|
|
246
|
+
|
|
219
247
|
private
|
|
220
|
-
|
|
248
|
+
|
|
221
249
|
def initialize_ties
|
|
222
250
|
::SocialStream::Relations.create(subject_type).each do |r|
|
|
223
251
|
sent_ties.create! :receiver => self,
|
|
@@ -225,4 +253,3 @@ class Actor < ActiveRecord::Base
|
|
|
225
253
|
end
|
|
226
254
|
end
|
|
227
255
|
end
|
|
228
|
-
|
data/app/models/group.rb
CHANGED
|
@@ -2,12 +2,18 @@ class Group < ActiveRecord::Base
|
|
|
2
2
|
attr_accessor :_founder
|
|
3
3
|
attr_accessor :_participants
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
subjects(:subject_type => :user, :direction => :senders)
|
|
7
|
-
end
|
|
5
|
+
delegate :description, :description=, :to => :profile!
|
|
8
6
|
|
|
9
7
|
after_create :create_founder
|
|
10
8
|
after_create :create_participants
|
|
9
|
+
|
|
10
|
+
def profile!
|
|
11
|
+
actor!.profile || actor!.build_profile
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def followers
|
|
15
|
+
subjects(:subject_type => :user, :direction => :senders)
|
|
16
|
+
end
|
|
11
17
|
|
|
12
18
|
def recent_groups
|
|
13
19
|
subjects(:subject_type => :group, :direction => :receivers) do |q|
|
|
@@ -21,7 +27,7 @@ class Group < ActiveRecord::Base
|
|
|
21
27
|
#Creates the ties between the group and the founder
|
|
22
28
|
def create_founder
|
|
23
29
|
founder =
|
|
24
|
-
Actor.
|
|
30
|
+
Actor.find_by_slug(_founder) || raise("Cannot create group without founder")
|
|
25
31
|
|
|
26
32
|
sent_ties.create! :receiver => founder,
|
|
27
33
|
:relation => relations.sort.first
|
data/app/models/like.rb
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Convenience class for managing like activities
|
|
2
|
+
class Like
|
|
3
|
+
attr_reader :activity
|
|
4
|
+
|
|
5
|
+
class << self
|
|
6
|
+
# Find the children activity of activity_id liked by subject
|
|
7
|
+
def find(subject, activity_id)
|
|
8
|
+
find_activity(activity_id).liked_by(subject).first
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Like #find but raises error if not found
|
|
12
|
+
def find!(subject, activity_id)
|
|
13
|
+
find(subject, activity_id) ||
|
|
14
|
+
raise(ActiveRecord::RecordNotFound)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Find the activity that is liked
|
|
18
|
+
def find_activity(id)
|
|
19
|
+
Activity.find(id) ||
|
|
20
|
+
raise(ActiveRecord::RecordNotFound)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Initialize a new like activity
|
|
25
|
+
def initialize(subject, activity_id)
|
|
26
|
+
@subject = subject
|
|
27
|
+
@activity = self.class.find_activity(activity_id)
|
|
28
|
+
@like = @activity.new_like(@subject)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def save
|
|
32
|
+
@like.save
|
|
33
|
+
end
|
|
34
|
+
end
|
data/app/models/logo.rb
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require 'RMagick'
|
|
2
|
+
|
|
3
|
+
class Logo < ActiveRecord::Base
|
|
4
|
+
has_attached_file :logo,
|
|
5
|
+
:styles => { :tie => "30x30>",
|
|
6
|
+
:actor => '35x35>',
|
|
7
|
+
:profile => '94x94' },
|
|
8
|
+
:default_url => "/images/:attachment/:style/:subtype_class.png"
|
|
9
|
+
before_post_process :process_precrop
|
|
10
|
+
attr_accessor :crop_x, :crop_y, :crop_w, :crop_h
|
|
11
|
+
validates_attachment_presence :logo
|
|
12
|
+
|
|
13
|
+
def process_precrop
|
|
14
|
+
logo.errors['precrop'] = "You have to make precrop"
|
|
15
|
+
|
|
16
|
+
images_path = File.join(RAILS_ROOT, "public", "images")
|
|
17
|
+
tmp_path = FileUtils.mkdir_p(File.join(images_path, "tmp"))
|
|
18
|
+
|
|
19
|
+
resize_image(logo.queued_for_write[:original].path,600,600)
|
|
20
|
+
|
|
21
|
+
my_file_name = File.basename(logo.queued_for_write[:original].path)
|
|
22
|
+
FileUtils.cp(logo.queued_for_write[:original].path,tmp_path)
|
|
23
|
+
temp_file = File.open(logo.queued_for_write[:original].path, "w+")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def image_dimensions(name)
|
|
27
|
+
images_path = File.join(RAILS_ROOT, "public", "images")
|
|
28
|
+
tmp_path = FileUtils.mkdir_p(File.join(images_path, "tmp"))
|
|
29
|
+
file_path = File.join(tmp_path,name)
|
|
30
|
+
|
|
31
|
+
img_orig = Magick::Image.read(file_path).first
|
|
32
|
+
dimensions = {}
|
|
33
|
+
dimensions[:width] = img_orig.columns
|
|
34
|
+
dimensions[:height] = img_orig.rows
|
|
35
|
+
dimensions
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def resize_image(path,width,height)
|
|
39
|
+
img_orig = Magick::Image.read(path).first
|
|
40
|
+
img_orig = img_orig.resize_to_fit(width, height)
|
|
41
|
+
img_orig.write(path)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def make_precrop(path,x,y,width,height)
|
|
45
|
+
img_orig = Magick::Image.read(path).first
|
|
46
|
+
crop_args = [x,y,width,height]
|
|
47
|
+
img_orig = img_orig.crop(*crop_args)
|
|
48
|
+
img_orig.write(path)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|