socializer 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +11 -0
- data/.gitignore +29 -0
- data/.rubocop.yml +42 -0
- data/.travis.yml +13 -0
- data/CONTRIBUTING.md +46 -0
- data/Gemfile +31 -0
- data/README.md +91 -0
- data/Rakefile +38 -0
- data/app/assets/images/socializer/.gitkeep +0 -0
- data/app/assets/images/socializer/auth_buttons/facebook_128.png +0 -0
- data/app/assets/images/socializer/auth_buttons/facebook_256.png +0 -0
- data/app/assets/images/socializer/auth_buttons/facebook_32.png +0 -0
- data/app/assets/images/socializer/auth_buttons/facebook_64.png +0 -0
- data/app/assets/images/socializer/auth_buttons/google_128.png +0 -0
- data/app/assets/images/socializer/auth_buttons/google_256.png +0 -0
- data/app/assets/images/socializer/auth_buttons/google_32.png +0 -0
- data/app/assets/images/socializer/auth_buttons/google_64.png +0 -0
- data/app/assets/images/socializer/auth_buttons/linkedin_128.png +0 -0
- data/app/assets/images/socializer/auth_buttons/linkedin_256.png +0 -0
- data/app/assets/images/socializer/auth_buttons/linkedin_32.png +0 -0
- data/app/assets/images/socializer/auth_buttons/linkedin_64.png +0 -0
- data/app/assets/images/socializer/auth_buttons/twitter_128.png +0 -0
- data/app/assets/images/socializer/auth_buttons/twitter_256.png +0 -0
- data/app/assets/images/socializer/auth_buttons/twitter_32.png +0 -0
- data/app/assets/images/socializer/auth_buttons/twitter_64.png +0 -0
- data/app/assets/images/socializer/auth_buttons/yahoo_128.png +0 -0
- data/app/assets/images/socializer/auth_buttons/yahoo_256.png +0 -0
- data/app/assets/images/socializer/auth_buttons/yahoo_32.png +0 -0
- data/app/assets/images/socializer/auth_buttons/yahoo_64.png +0 -0
- data/app/assets/images/socializer/close.png +0 -0
- data/app/assets/images/socializer/icons/Bell.png +0 -0
- data/app/assets/images/socializer/icons/Edit.png +0 -0
- data/app/assets/images/socializer/icons/Home.png +0 -0
- data/app/assets/images/socializer/icons/Power.png +0 -0
- data/app/assets/images/socializer/icons/Safe.png +0 -0
- data/app/assets/images/socializer/icons/User.png +0 -0
- data/app/assets/images/socializer/icons/Users.png +0 -0
- data/app/assets/images/socializer/icons/Web.png +0 -0
- data/app/assets/images/socializer/loading.gif +0 -0
- data/app/assets/images/socializer/next.png +0 -0
- data/app/assets/images/socializer/pause.png +0 -0
- data/app/assets/images/socializer/play.png +0 -0
- data/app/assets/images/socializer/previous.png +0 -0
- data/app/assets/javascripts/socializer/activities.js.coffee +47 -0
- data/app/assets/javascripts/socializer/application.js +24 -0
- data/app/assets/javascripts/socializer/circles.js.coffee +33 -0
- data/app/assets/javascripts/socializer/jquery.qtip.min.js +7 -0
- data/app/assets/javascripts/socializer/jquery.tokeninput.js +862 -0
- data/app/assets/javascripts/socializer/notes.js.coffee +38 -0
- data/app/assets/javascripts/socializer/people.js.coffee +7 -0
- data/app/assets/javascripts/socializer/shares.js.coffee +8 -0
- data/app/assets/stylesheets/socializer/activities.css +84 -0
- data/app/assets/stylesheets/socializer/application.css +409 -0
- data/app/assets/stylesheets/socializer/authentications.css +4 -0
- data/app/assets/stylesheets/socializer/circles.css +74 -0
- data/app/assets/stylesheets/socializer/comments.css +4 -0
- data/app/assets/stylesheets/socializer/groups.css +61 -0
- data/app/assets/stylesheets/socializer/jquery.qtip.min.css +2 -0
- data/app/assets/stylesheets/socializer/likes.css +4 -0
- data/app/assets/stylesheets/socializer/memberships.css +4 -0
- data/app/assets/stylesheets/socializer/notes.css +21 -0
- data/app/assets/stylesheets/socializer/notifications.css +46 -0
- data/app/assets/stylesheets/socializer/pages.css +4 -0
- data/app/assets/stylesheets/socializer/persons.css +25 -0
- data/app/assets/stylesheets/socializer/sessions.css +4 -0
- data/app/assets/stylesheets/socializer/shares.css.scss +3 -0
- data/app/assets/stylesheets/socializer/ties.css +4 -0
- data/app/assets/stylesheets/socializer/token-input.css +183 -0
- data/app/controllers/socializer/activities_controller.rb +84 -0
- data/app/controllers/socializer/application_controller.rb +37 -0
- data/app/controllers/socializer/audiences_controller.rb +30 -0
- data/app/controllers/socializer/authentications_controller.rb +13 -0
- data/app/controllers/socializer/circles_controller.rb +54 -0
- data/app/controllers/socializer/comments_controller.rb +37 -0
- data/app/controllers/socializer/groups_controller.rb +70 -0
- data/app/controllers/socializer/likes_controller.rb +50 -0
- data/app/controllers/socializer/memberships_controller.rb +46 -0
- data/app/controllers/socializer/notes_controller.rb +43 -0
- data/app/controllers/socializer/notifications_controller.rb +29 -0
- data/app/controllers/socializer/pages_controller.rb +7 -0
- data/app/controllers/socializer/people_controller.rb +37 -0
- data/app/controllers/socializer/person_addresses_controller.rb +27 -0
- data/app/controllers/socializer/person_contributions_controller.rb +27 -0
- data/app/controllers/socializer/person_educations_controller.rb +27 -0
- data/app/controllers/socializer/person_employments_controller.rb +27 -0
- data/app/controllers/socializer/person_links_controller.rb +27 -0
- data/app/controllers/socializer/person_phones_controller.rb +27 -0
- data/app/controllers/socializer/person_places_controller.rb +27 -0
- data/app/controllers/socializer/person_profiles_controller.rb +27 -0
- data/app/controllers/socializer/sessions_controller.rb +37 -0
- data/app/controllers/socializer/shares_controller.rb +54 -0
- data/app/controllers/socializer/ties_controller.rb +16 -0
- data/app/helpers/socializer/application_helper.rb +22 -0
- data/app/models/concerns/socializer/object_type_base.rb +58 -0
- data/app/models/socializer/activity.rb +162 -0
- data/app/models/socializer/activity_field.rb +10 -0
- data/app/models/socializer/activity_object.rb +118 -0
- data/app/models/socializer/audience.rb +19 -0
- data/app/models/socializer/authentication.rb +20 -0
- data/app/models/socializer/circle.rb +32 -0
- data/app/models/socializer/comment.rb +13 -0
- data/app/models/socializer/group.rb +100 -0
- data/app/models/socializer/group_category.rb +11 -0
- data/app/models/socializer/group_link.rb +12 -0
- data/app/models/socializer/identity.rb +9 -0
- data/app/models/socializer/membership.rb +24 -0
- data/app/models/socializer/note.rb +13 -0
- data/app/models/socializer/notification.rb +16 -0
- data/app/models/socializer/person.rb +129 -0
- data/app/models/socializer/person_address.rb +12 -0
- data/app/models/socializer/person_contribution.rb +12 -0
- data/app/models/socializer/person_education.rb +8 -0
- data/app/models/socializer/person_employment.rb +8 -0
- data/app/models/socializer/person_link.rb +12 -0
- data/app/models/socializer/person_phone.rb +16 -0
- data/app/models/socializer/person_place.rb +11 -0
- data/app/models/socializer/person_profile.rb +12 -0
- data/app/models/socializer/tie.rb +12 -0
- data/app/models/socializer/verb.rb +9 -0
- data/app/views/layouts/socializer/_header.html.erb +11 -0
- data/app/views/layouts/socializer/application.html.erb +60 -0
- data/app/views/socializer/activities/_activity.html.erb +23 -0
- data/app/views/socializer/activities/_activity_bottom.html.erb +55 -0
- data/app/views/socializer/activities/_activity_content.html.erb +19 -0
- data/app/views/socializer/activities/_activity_top.html.erb +22 -0
- data/app/views/socializer/activities/_stream_card.html.erb +6 -0
- data/app/views/socializer/activities/_stream_list.html.erb +16 -0
- data/app/views/socializer/activities/audience.html.erb +19 -0
- data/app/views/socializer/activities/destroy.js.erb +3 -0
- data/app/views/socializer/activities/edit.html.erb +0 -0
- data/app/views/socializer/activities/index.html.erb +15 -0
- data/app/views/socializer/authentications/_form.html.erb +0 -0
- data/app/views/socializer/authentications/_menu.html.erb +5 -0
- data/app/views/socializer/authentications/index.html.erb +8 -0
- data/app/views/socializer/authentications/new.html.erb +8 -0
- data/app/views/socializer/circles/_card.html.erb +7 -0
- data/app/views/socializer/circles/_circles.html.erb +6 -0
- data/app/views/socializer/circles/_form.html.erb +6 -0
- data/app/views/socializer/circles/_menu.html.erb +7 -0
- data/app/views/socializer/circles/contact_of.html.erb +7 -0
- data/app/views/socializer/circles/contacts.html.erb +7 -0
- data/app/views/socializer/circles/edit.html.erb +1 -0
- data/app/views/socializer/circles/find_people.html.erb +7 -0
- data/app/views/socializer/circles/index.html.erb +6 -0
- data/app/views/socializer/circles/new.html.erb +1 -0
- data/app/views/socializer/circles/show.html.erb +10 -0
- data/app/views/socializer/comments/_form.html.erb +8 -0
- data/app/views/socializer/comments/edit.html.erb +1 -0
- data/app/views/socializer/comments/new.html.erb +1 -0
- data/app/views/socializer/groups/_card.html.erb +6 -0
- data/app/views/socializer/groups/_form.html.erb +6 -0
- data/app/views/socializer/groups/_menu.html.erb +10 -0
- data/app/views/socializer/groups/edit.html.erb +1 -0
- data/app/views/socializer/groups/index.html.erb +0 -0
- data/app/views/socializer/groups/joinable.html.erb +16 -0
- data/app/views/socializer/groups/memberships.html.erb +19 -0
- data/app/views/socializer/groups/new.html.erb +1 -0
- data/app/views/socializer/groups/ownerships.html.erb +20 -0
- data/app/views/socializer/groups/pending_invites.html.erb +20 -0
- data/app/views/socializer/groups/public.html.erb +16 -0
- data/app/views/socializer/groups/restricted.html.erb +16 -0
- data/app/views/socializer/groups/show.html.erb +29 -0
- data/app/views/socializer/likes/create.js.erb +2 -0
- data/app/views/socializer/likes/destroy.js.erb +2 -0
- data/app/views/socializer/likes/index.html.erb +5 -0
- data/app/views/socializer/notes/_form.html.erb +7 -0
- data/app/views/socializer/notes/create.js.erb +10 -0
- data/app/views/socializer/notes/destroy.js.erb +3 -0
- data/app/views/socializer/notes/edit.html.erb +1 -0
- data/app/views/socializer/notes/new.html.erb +2 -0
- data/app/views/socializer/notifications/index.html.erb +35 -0
- data/app/views/socializer/pages/index.html.erb +2 -0
- data/app/views/socializer/people/_card.html.erb +15 -0
- data/app/views/socializer/people/_form.html.erb +30 -0
- data/app/views/socializer/people/_login.html.erb +14 -0
- data/app/views/socializer/people/_menu.html.erb +9 -0
- data/app/views/socializer/people/edit.html.erb +2 -0
- data/app/views/socializer/people/index.html.erb +5 -0
- data/app/views/socializer/people/likes.html.erb +6 -0
- data/app/views/socializer/people/message.html.erb +5 -0
- data/app/views/socializer/people/show.html.erb +122 -0
- data/app/views/socializer/person_addresses/_form.html.erb +12 -0
- data/app/views/socializer/person_contributions/_form.html.erb +7 -0
- data/app/views/socializer/person_educations/_form.html.erb +10 -0
- data/app/views/socializer/person_employments/_form.html.erb +10 -0
- data/app/views/socializer/person_links/_form.html.erb +6 -0
- data/app/views/socializer/person_phones/_form.html.erb +6 -0
- data/app/views/socializer/person_places/_form.html.erb +6 -0
- data/app/views/socializer/person_profiles/_form.html.erb +6 -0
- data/app/views/socializer/shares/_form.html.erb +19 -0
- data/app/views/socializer/shares/new.html.erb +1 -0
- data/config.ru +4 -0
- data/config/cucumber.yml +8 -0
- data/config/initializers/inflections.rb +3 -0
- data/config/locales/en.yml +108 -0
- data/config/locales/fr.yml +329 -0
- data/config/rails_best_practices.yml +41 -0
- data/config/routes.rb +71 -0
- data/db/migrate/20110804175740_create_socializer_activity_objects.rb +14 -0
- data/db/migrate/20110804180557_create_socializer_people.rb +31 -0
- data/db/migrate/20110804184415_create_socializer_notes.rb +12 -0
- data/db/migrate/20110804192211_create_socializer_authentications.rb +12 -0
- data/db/migrate/20110805085417_create_socializer_circles.rb +14 -0
- data/db/migrate/20110805090617_create_socializer_activities.rb +17 -0
- data/db/migrate/20110805092635_create_socializer_audiences.rb +14 -0
- data/db/migrate/20110805094846_create_socializer_comments.rb +12 -0
- data/db/migrate/20110805121454_create_socializer_groups.rb +19 -0
- data/db/migrate/20110805121543_create_socializer_memberships.rb +14 -0
- data/db/migrate/20110805125606_create_socializer_ties.rb +13 -0
- data/db/migrate/20111207234435_create_socializer_identities.rb +12 -0
- data/db/migrate/20130524000429_create_socializer_verbs.rb +10 -0
- data/db/migrate/20130528143831_create_socializer_activity_fields.rb +10 -0
- data/db/migrate/20140128235250_create_socializer_notifications.rb +11 -0
- data/db/migrate/20140131065531_create_socializer_person_employments.rb +15 -0
- data/db/migrate/20140131065733_create_socializer_person_educations.rb +15 -0
- data/db/migrate/20140131065836_create_socializer_person_places.rb +11 -0
- data/db/migrate/20140131070051_create_socializer_person_contributions.rb +12 -0
- data/db/migrate/20140131070232_create_socializer_person_links.rb +11 -0
- data/db/migrate/20140131070259_create_socializer_person_profiles.rb +11 -0
- data/db/migrate/20140131070417_create_socializer_person_phones.rb +12 -0
- data/db/migrate/20140131070611_create_socializer_person_addresses.rb +17 -0
- data/db/migrate/20140131070839_create_socializer_group_links.rb +11 -0
- data/db/migrate/20140131070951_create_socializer_group_categories.rb +10 -0
- data/features/support/capybara.rb +14 -0
- data/features/support/env.rb +57 -0
- data/features/support/factory_girl.rb +1 -0
- data/lib/socializer.rb +4 -0
- data/lib/socializer/engine.rb +27 -0
- data/lib/socializer/version.rb +3 -0
- data/lib/tasks/cucumber.rake +65 -0
- data/lib/tasks/socializer_tasks.rake +4 -0
- data/script/cucumber +10 -0
- data/socializer.gemspec +49 -0
- data/spec/controllers/socializer/likes_controller_spec.rb +29 -0
- data/spec/controllers/socializer/shares_controller_spec.rb +22 -0
- data/spec/factories/socializer_activities.rb +11 -0
- data/spec/factories/socializer_activity_fields.rb +8 -0
- data/spec/factories/socializer_activity_objects.rb +7 -0
- data/spec/factories/socializer_audiences.rb +9 -0
- data/spec/factories/socializer_authentications.rb +6 -0
- data/spec/factories/socializer_circles.rb +9 -0
- data/spec/factories/socializer_comments.rb +6 -0
- data/spec/factories/socializer_group_categories.rb +8 -0
- data/spec/factories/socializer_group_links.rb +9 -0
- data/spec/factories/socializer_groups.rb +9 -0
- data/spec/factories/socializer_identities.rb +10 -0
- data/spec/factories/socializer_memberships.rb +6 -0
- data/spec/factories/socializer_notes.rb +7 -0
- data/spec/factories/socializer_notifications.rb +10 -0
- data/spec/factories/socializer_people.rb +7 -0
- data/spec/factories/socializer_person_addresses.rb +8 -0
- data/spec/factories/socializer_person_contributions.rb +9 -0
- data/spec/factories/socializer_person_educations.rb +7 -0
- data/spec/factories/socializer_person_employments.rb +7 -0
- data/spec/factories/socializer_person_links.rb +9 -0
- data/spec/factories/socializer_person_phones.rb +9 -0
- data/spec/factories/socializer_person_places.rb +8 -0
- data/spec/factories/socializer_person_profiles.rb +9 -0
- data/spec/factories/socializer_ties.rb +6 -0
- data/spec/factories/socializer_verbs.rb +7 -0
- data/spec/inflector_spec.rb +19 -0
- data/spec/models/socializer/activity_field_spec.rb +25 -0
- data/spec/models/socializer/activity_object_spec.rb +118 -0
- data/spec/models/socializer/activity_spec.rb +16 -0
- data/spec/models/socializer/audience_spec.rb +32 -0
- data/spec/models/socializer/authentication_spec.rb +29 -0
- data/spec/models/socializer/circle_spec.rb +53 -0
- data/spec/models/socializer/comment_spec.rb +19 -0
- data/spec/models/socializer/group_category_spec.rb +23 -0
- data/spec/models/socializer/group_link_spec.rb +25 -0
- data/spec/models/socializer/group_spec.rb +218 -0
- data/spec/models/socializer/identity_spec.rb +32 -0
- data/spec/models/socializer/membership_spec.rb +68 -0
- data/spec/models/socializer/note_spec.rb +19 -0
- data/spec/models/socializer/notification_spec.rb +28 -0
- data/spec/models/socializer/person_address_spec.rb +27 -0
- data/spec/models/socializer/person_contribution_spec.rb +27 -0
- data/spec/models/socializer/person_education_spec.rb +25 -0
- data/spec/models/socializer/person_employment_spec.rb +25 -0
- data/spec/models/socializer/person_link_spec.rb +26 -0
- data/spec/models/socializer/person_phone_spec.rb +28 -0
- data/spec/models/socializer/person_place_spec.rb +25 -0
- data/spec/models/socializer/person_profile_spec.rb +26 -0
- data/spec/models/socializer/person_spec.rb +105 -0
- data/spec/models/socializer/tie_spec.rb +24 -0
- data/spec/models/socializer/verb_spec.rb +24 -0
- data/spec/spec_helper.rb +84 -0
- data/vendor/assets/javascripts/moment/langs.js +5841 -0
- data/vendor/assets/javascripts/moment/moment.js +2400 -0
- metadata +754 -0
@@ -0,0 +1,84 @@
|
|
1
|
+
module Socializer
|
2
|
+
class ActivitiesController < ApplicationController
|
3
|
+
def index
|
4
|
+
@activities = Activity.stream(provider: params[:provider], actor_id: params[:id], viewer_id: current_user.id)
|
5
|
+
@current_id = nil
|
6
|
+
if params[:provider] == 'circles'
|
7
|
+
@circle = Circle.find(params[:id])
|
8
|
+
@title = @circle.name
|
9
|
+
@current_id = @circle.guid
|
10
|
+
elsif params[:provider] == 'people'
|
11
|
+
@person = Person.find(params[:id])
|
12
|
+
@title = @person.display_name
|
13
|
+
@current_id = @person.guid
|
14
|
+
elsif params[:provider] == 'groups'
|
15
|
+
@group = Group.find(params[:id])
|
16
|
+
@title = @group.name
|
17
|
+
@current_id = @group.guid
|
18
|
+
else
|
19
|
+
@title = 'Activity stream'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def audience
|
24
|
+
activities = Activity.stream(provider: 'activities', actor_id: params[:id], viewer_id: current_user.id)
|
25
|
+
|
26
|
+
@object_ids = []
|
27
|
+
is_public = false
|
28
|
+
|
29
|
+
activities.each do |activity|
|
30
|
+
activity.audiences.each do |audience|
|
31
|
+
# In case of CIRCLES audience, add each contacts of every circles
|
32
|
+
# of the actor of the activity.
|
33
|
+
if audience.privacy_level.public?
|
34
|
+
@object_ids.push audience.privacy_level
|
35
|
+
is_public = true
|
36
|
+
elsif audience.privacy_level.circles?
|
37
|
+
activity.actor.circles.each do |circle|
|
38
|
+
circle.activity_contacts.each do |contact|
|
39
|
+
@object_ids.push contact
|
40
|
+
end
|
41
|
+
end
|
42
|
+
else
|
43
|
+
if audience.activity_object.activitable_type == 'Socializer::Circle'
|
44
|
+
# In the case of LIMITED audience, then go through all the audience
|
45
|
+
# circles and add contacts from those circles in the list of allowed
|
46
|
+
# audience.
|
47
|
+
audience.activity_object.activitable.activity_contacts.each do |contact|
|
48
|
+
@object_ids.push contact
|
49
|
+
end
|
50
|
+
else
|
51
|
+
# Otherwise, the target audience is either a group or a person,
|
52
|
+
# which means we can add it as it is in the audience list.
|
53
|
+
@object_ids.push audience.activity_object
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
unless is_public
|
60
|
+
activities.each do |activity|
|
61
|
+
# The actor of the activity is always part of the audience.
|
62
|
+
@object_ids.push activity.activitable_actor
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Remove any duplicates from the list. It can happen when, for example, someone
|
67
|
+
# post a message to itself.
|
68
|
+
@object_ids.uniq!
|
69
|
+
|
70
|
+
respond_to do |format|
|
71
|
+
format.html { render layout: false if request.xhr? }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def destroy
|
76
|
+
@activity = Activity.find(params[:id])
|
77
|
+
@activity_guid = @activity.guid
|
78
|
+
@activity.destroy
|
79
|
+
respond_to do |format|
|
80
|
+
format.js
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Socializer
|
2
|
+
class ApplicationController < ActionController::Base
|
3
|
+
# Prevent CSRF attacks by raising an exception.
|
4
|
+
# For APIs, you may want to use :null_session instead.
|
5
|
+
# FIXME: Not sure why protect_from_forgery is no longer working
|
6
|
+
# protect_from_forgery with: :exception
|
7
|
+
|
8
|
+
helper_method :current_user
|
9
|
+
helper_method :signed_in?
|
10
|
+
|
11
|
+
before_action :set_locale
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def current_user
|
16
|
+
@current_user ||= Person.find_by(id: cookies[:user_id]) if cookies[:user_id].present?
|
17
|
+
end
|
18
|
+
|
19
|
+
def signed_in?
|
20
|
+
current_user.present?
|
21
|
+
end
|
22
|
+
|
23
|
+
def set_locale
|
24
|
+
if signed_in? && current_user.language.present? && params[:locale].nil?
|
25
|
+
I18n.locale = current_user.language
|
26
|
+
else
|
27
|
+
I18n.locale = params[:locale] || extract_locale_from_accept_language_header || I18n.default_locale
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def extract_locale_from_accept_language_header
|
32
|
+
if request.present? && request.env['HTTP_ACCEPT_LANGUAGE'].present?
|
33
|
+
request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Socializer
|
2
|
+
class AudiencesController < ApplicationController
|
3
|
+
def index
|
4
|
+
if params[:q].present? && params[:q].size > 0
|
5
|
+
query_value = "%#{params[:q]}%"
|
6
|
+
|
7
|
+
@people = Person.where { display_name.like query_value }
|
8
|
+
@circles = current_user.circles.where { name.like query_value }
|
9
|
+
@groups = current_user.groups.where { name.like query_value }
|
10
|
+
else
|
11
|
+
@people = []
|
12
|
+
@circles = current_user.circles
|
13
|
+
@groups = current_user.groups
|
14
|
+
end
|
15
|
+
|
16
|
+
public = Socializer::Audience.privacy_level.find_value(:public)
|
17
|
+
circles = Socializer::Audience.privacy_level.find_value(:circles)
|
18
|
+
|
19
|
+
@audiences = [id: public.value, name: public.text] +
|
20
|
+
[id: circles.value, name: circles.text] +
|
21
|
+
@people.map { |x| { id: x.guid, name: x.display_name } } +
|
22
|
+
@circles.map { |x| { id: x.guid, name: x.name } } +
|
23
|
+
@groups.map { |x| { id: x.guid, name: x.name } }
|
24
|
+
|
25
|
+
respond_to do |format|
|
26
|
+
format.json { render json: @audiences }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Socializer
|
2
|
+
class AuthenticationsController < ApplicationController
|
3
|
+
def index
|
4
|
+
@authentications = current_user.services
|
5
|
+
end
|
6
|
+
|
7
|
+
def destroy
|
8
|
+
@authentication = current_user.authentications.find(params[:id])
|
9
|
+
@authentication.destroy
|
10
|
+
redirect_to authentications_path
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Socializer
|
2
|
+
class CirclesController < ApplicationController
|
3
|
+
before_filter :set_circle, only: [:show, :edit, :update, :destroy]
|
4
|
+
|
5
|
+
def index
|
6
|
+
@circles = current_user.circles
|
7
|
+
end
|
8
|
+
|
9
|
+
def contacts
|
10
|
+
@circles = current_user.circles
|
11
|
+
end
|
12
|
+
|
13
|
+
def contact_of
|
14
|
+
@circles = current_user.circles
|
15
|
+
end
|
16
|
+
|
17
|
+
def find_people
|
18
|
+
@circles = current_user.circles
|
19
|
+
end
|
20
|
+
|
21
|
+
def show
|
22
|
+
@users = Person.all
|
23
|
+
end
|
24
|
+
|
25
|
+
def new
|
26
|
+
@circle = Circle.new
|
27
|
+
end
|
28
|
+
|
29
|
+
def create
|
30
|
+
@circle = current_user.circles.build(params[:circle])
|
31
|
+
@circle.save!
|
32
|
+
redirect_to circles_contacts_path
|
33
|
+
end
|
34
|
+
|
35
|
+
def edit
|
36
|
+
end
|
37
|
+
|
38
|
+
def update
|
39
|
+
@circle.update!(params[:circle])
|
40
|
+
redirect_to @circle
|
41
|
+
end
|
42
|
+
|
43
|
+
def destroy
|
44
|
+
@circle.destroy
|
45
|
+
redirect_to circles_contacts_path
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def set_circle
|
51
|
+
@circle = current_user.circles.find(params[:id])
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Socializer
|
2
|
+
class CommentsController < ApplicationController
|
3
|
+
before_filter :set_comment, only: [:edit, :update, :destroy]
|
4
|
+
|
5
|
+
def new
|
6
|
+
@comment = Comment.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def create
|
10
|
+
@comment = current_user.comments.build(params[:comment])
|
11
|
+
@comment.activity_verb = 'add'
|
12
|
+
# TODO: Is scope needed? Try commenting it out to see what happens
|
13
|
+
@comment.scope = Audience.privacy_level.find_value(:public)
|
14
|
+
@comment.save!
|
15
|
+
redirect_to stream_path
|
16
|
+
end
|
17
|
+
|
18
|
+
def edit
|
19
|
+
end
|
20
|
+
|
21
|
+
def update
|
22
|
+
@comment.update!(params[:comment])
|
23
|
+
redirect_to stream_path
|
24
|
+
end
|
25
|
+
|
26
|
+
def destroy
|
27
|
+
@comment.destroy
|
28
|
+
redirect_to stream_path
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def set_comment
|
34
|
+
@comment = current_user.comments.find(params[:id])
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Socializer
|
2
|
+
class GroupsController < ApplicationController
|
3
|
+
before_filter :set_group, only: [:edit, :update, :destroy]
|
4
|
+
|
5
|
+
def index
|
6
|
+
end
|
7
|
+
|
8
|
+
def public
|
9
|
+
@groups = Socializer::Group.public
|
10
|
+
end
|
11
|
+
|
12
|
+
def restricted
|
13
|
+
@groups = Socializer::Group.restricted
|
14
|
+
end
|
15
|
+
|
16
|
+
def joinable
|
17
|
+
@groups = Socializer::Group.joinable
|
18
|
+
end
|
19
|
+
|
20
|
+
def memberships
|
21
|
+
@memberships = current_user.memberships
|
22
|
+
end
|
23
|
+
|
24
|
+
def ownerships
|
25
|
+
@ownerships = current_user.groups
|
26
|
+
end
|
27
|
+
|
28
|
+
def pending_invites
|
29
|
+
@pending_invites = current_user.pending_memberships_invites
|
30
|
+
end
|
31
|
+
|
32
|
+
def show
|
33
|
+
@group = Group.find(params[:id])
|
34
|
+
@membership = Membership.find_by(group_id: @group.id)
|
35
|
+
end
|
36
|
+
|
37
|
+
def new
|
38
|
+
@group = Group.new
|
39
|
+
end
|
40
|
+
|
41
|
+
def create
|
42
|
+
@group = current_user.groups.build(params[:group])
|
43
|
+
|
44
|
+
if @group.save
|
45
|
+
redirect_to @group
|
46
|
+
else
|
47
|
+
render :new
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def edit
|
52
|
+
end
|
53
|
+
|
54
|
+
def update
|
55
|
+
@group.update!(params[:group])
|
56
|
+
redirect_to @group
|
57
|
+
end
|
58
|
+
|
59
|
+
def destroy
|
60
|
+
@group.destroy
|
61
|
+
redirect_to groups_path
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def set_group
|
67
|
+
@group = current_user.groups.find(params[:id])
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Socializer
|
2
|
+
class LikesController < ApplicationController
|
3
|
+
before_action :set_likable, only: [:create, :destroy]
|
4
|
+
|
5
|
+
# REFACTOR: should handle activity/tooltip as well as people likes
|
6
|
+
# Used to display the Like tooltip
|
7
|
+
def index
|
8
|
+
activity = Activity.find(params[:id])
|
9
|
+
@object_ids = []
|
10
|
+
|
11
|
+
activity.activity_object.likes.each do |person|
|
12
|
+
@object_ids.push person.activity_object
|
13
|
+
end
|
14
|
+
|
15
|
+
respond_to do |format|
|
16
|
+
format.html { render layout: false if request.xhr? }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def create
|
21
|
+
@likable.like!(current_user) unless current_user.likes?(@likable)
|
22
|
+
@activity = @likable.activitable
|
23
|
+
|
24
|
+
respond_to do |format|
|
25
|
+
format.js
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def destroy
|
30
|
+
@likable.unlike!(current_user) if current_user.likes?(@likable)
|
31
|
+
@activity = @likable.activitable
|
32
|
+
|
33
|
+
respond_to do |format|
|
34
|
+
format.js
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
# Use callbacks to share common setup or constraints between actions.
|
41
|
+
def set_likable
|
42
|
+
@likable = ActivityObject.find(params[:id])
|
43
|
+
end
|
44
|
+
|
45
|
+
# # Never trust parameters from the scary internet, only allow the white list through.
|
46
|
+
# def like_params
|
47
|
+
# params.require(:like).permit(:actor_id, :activity_object_id)
|
48
|
+
# end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Socializer
|
2
|
+
class MembershipsController < ApplicationController
|
3
|
+
before_filter :set_membership, only: [:approve, :confirm, :decline]
|
4
|
+
|
5
|
+
def create
|
6
|
+
@group = Group.find(params[:membership][:group_id])
|
7
|
+
@group.join(current_user)
|
8
|
+
redirect_to @group
|
9
|
+
end
|
10
|
+
|
11
|
+
def destroy
|
12
|
+
@membership = current_user.memberships.find(params[:id])
|
13
|
+
@group = @membership.group
|
14
|
+
@group.leave(current_user)
|
15
|
+
redirect_to @group
|
16
|
+
end
|
17
|
+
|
18
|
+
def approve
|
19
|
+
@membership.approve!
|
20
|
+
redirect_to @membership.group
|
21
|
+
end
|
22
|
+
|
23
|
+
def invite
|
24
|
+
invited_user = Person.find(params[:user_id])
|
25
|
+
group = Group.find(params[:group_id])
|
26
|
+
group.invite(invited_user)
|
27
|
+
redirect_to group
|
28
|
+
end
|
29
|
+
|
30
|
+
def confirm
|
31
|
+
@membership.confirm!
|
32
|
+
redirect_to @membership.group
|
33
|
+
end
|
34
|
+
|
35
|
+
def decline
|
36
|
+
@membership.decline!
|
37
|
+
redirect_to groups_pending_invites_path
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def set_membership
|
43
|
+
@membership = Membership.find(params[:id])
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Socializer
|
2
|
+
class NotesController < ApplicationController
|
3
|
+
before_filter :set_note, only: [:edit, :update, :destroy]
|
4
|
+
|
5
|
+
def new
|
6
|
+
@note = Note.new
|
7
|
+
@current_id = params[:id]
|
8
|
+
end
|
9
|
+
|
10
|
+
def create
|
11
|
+
@note = current_user.activity_object.notes.build(params[:note])
|
12
|
+
@note.object_ids = @note.object_ids.split(',')
|
13
|
+
@note.activity_verb = 'post'
|
14
|
+
@note.save!
|
15
|
+
@activity = Activity.find_by(activity_object_id: @note.guid)
|
16
|
+
respond_to do |format|
|
17
|
+
format.js
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def edit
|
22
|
+
end
|
23
|
+
|
24
|
+
def update
|
25
|
+
@note.update!(params[:note])
|
26
|
+
redirect_to stream_path
|
27
|
+
end
|
28
|
+
|
29
|
+
def destroy
|
30
|
+
@activity_guid = Activity.find_by(activity_object_id: @note.guid).guid
|
31
|
+
@note.destroy
|
32
|
+
respond_to do |format|
|
33
|
+
format.js
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def set_note
|
40
|
+
@note = current_user.activity_object.notes.find(params[:id])
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|