muck-friends 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/README.rdoc +9 -2
  2. data/Rakefile +3 -27
  3. data/VERSION +1 -1
  4. data/app/controllers/muck/friends_controller.rb +28 -11
  5. data/app/helpers/muck_friends_helper.rb +110 -48
  6. data/app/views/activity_templates/_follow.html.erb +3 -0
  7. data/app/views/activity_templates/_friends_with.html.erb +3 -0
  8. data/app/views/friends/_all_friends.html.erb +1 -1
  9. data/app/views/friends/_friend_icon.html.erb +1 -0
  10. data/config/muck_friends_routes.rb +3 -1
  11. data/lib/active_record/acts/muck_friend.rb +14 -22
  12. data/lib/active_record/acts/muck_friend_user.rb +7 -2
  13. data/locales/en.yml +14 -7
  14. data/muck-friends.gemspec +41 -5
  15. data/test/rails_root/Rakefile +15 -0
  16. data/test/rails_root/app/views/default/friend_link.html.erb +1 -0
  17. data/test/rails_root/config/database.yml +4 -1
  18. data/test/rails_root/config/environments/cucumber.rb +22 -0
  19. data/test/rails_root/config/global_config.yml +1 -1
  20. data/test/rails_root/db/migrate/20090402234137_create_languages.rb +18 -0
  21. data/test/rails_root/db/migrate/20090426041056_create_countries.rb +15 -0
  22. data/test/rails_root/db/migrate/20090426041103_create_states.rb +18 -0
  23. data/test/rails_root/db/migrate/20090730044139_add_comment_cache.rb +9 -0
  24. data/test/rails_root/features/step_definitions/webrat_steps.rb +57 -23
  25. data/test/rails_root/features/support/env.rb +14 -3
  26. data/test/rails_root/features/support/paths.rb +27 -0
  27. data/test/rails_root/lib/tasks/cucumber.rake +32 -0
  28. data/test/rails_root/public/images/fancybox/fancy_closebox.png +0 -0
  29. data/test/rails_root/public/images/fancybox/fancy_left.png +0 -0
  30. data/test/rails_root/public/images/fancybox/fancy_progress.png +0 -0
  31. data/test/rails_root/public/images/fancybox/fancy_right.png +0 -0
  32. data/test/rails_root/public/images/fancybox/fancy_shadow_e.png +0 -0
  33. data/test/rails_root/public/images/fancybox/fancy_shadow_n.png +0 -0
  34. data/test/rails_root/public/images/fancybox/fancy_shadow_ne.png +0 -0
  35. data/test/rails_root/public/images/fancybox/fancy_shadow_nw.png +0 -0
  36. data/test/rails_root/public/images/fancybox/fancy_shadow_s.png +0 -0
  37. data/test/rails_root/public/images/fancybox/fancy_shadow_se.png +0 -0
  38. data/test/rails_root/public/images/fancybox/fancy_shadow_sw.png +0 -0
  39. data/test/rails_root/public/images/fancybox/fancy_shadow_w.png +0 -0
  40. data/test/rails_root/public/images/fancybox/fancy_title_left.png +0 -0
  41. data/test/rails_root/public/images/fancybox/fancy_title_main.png +0 -0
  42. data/test/rails_root/public/images/fancybox/fancy_title_right.png +0 -0
  43. data/test/rails_root/public/images/nothing.png +0 -0
  44. data/test/rails_root/public/javascripts/jquery/jquery.easing.js +1 -0
  45. data/test/rails_root/public/javascripts/jquery/jquery.fancybox.js +9 -0
  46. data/test/rails_root/public/javascripts/muck.js +7 -3
  47. data/test/rails_root/public/javascripts/muck_activities.js +1 -1
  48. data/test/rails_root/public/stylesheets/jquery/jquery.fancybox.css +44 -0
  49. data/test/rails_root/public/stylesheets/styles.css +8 -3
  50. data/test/rails_root/script/cucumber +5 -3
  51. data/test/rails_root/test/functional/default_controller_test.rb +177 -4
  52. data/test/rails_root/test/functional/friends_controller_test.rb +8 -8
  53. data/test/rails_root/test/unit/user_test.rb +164 -127
  54. metadata +38 -5
  55. data/app/views/activity_templates/follow.html.erb +0 -1
  56. data/app/views/activity_templates/friends_with.html.erb +0 -1
  57. data/test/rails_root/db/schema.rb +0 -153
data/README.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- = MuckFriends
1
+ = Muck Friends
2
2
 
3
3
  == Installation
4
4
 
@@ -25,7 +25,14 @@ Inside of global_config.yml add the following, changing the emails to match your
25
25
  admin_email: 'admin@example.com'
26
26
 
27
27
  # Friend configuration
28
- allow_following: true # If true then users can 'follow' each other. If false then only friend requests will be used.
28
+ # Muck Friends provides a hybrid friend/follow model. Either mode can be turned off or both can be enabled
29
+ # If only following is enabled then users will be provided the ability to follow, unfollow, and block
30
+ # If only friending is enabled then users will be provided a 'friend request' link and the ability to accept friend requests
31
+ # If both modes are are enabled then users will be able to follow other users. A mutual follow results in 'friends'. An unfollow
32
+ # leaves the other party as just a follower.
33
+ # Note that at least one mode must be enabled or imagine all life as you know it stopping instantaneously and every molecule in your body exploding at the speed of light.
34
+ enable_friending: true # If true then friending is enabled.
35
+ enable_following: true # If true then users can 'follow' each other. If false then only friend requests will be used.
29
36
  enable_friend_activity: true # If true then friend related activity will show up in the activity feed. Requires muck-activities gem
30
37
 
31
38
  == Usage
data/Rakefile CHANGED
@@ -59,33 +59,9 @@ begin
59
59
  gemspec.add_dependency "muck-users"
60
60
  gemspec.add_dependency "muck-profiles"
61
61
  end
62
- rescue LoadError
63
- puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
64
- end
65
-
66
- # rubyforge tasks
67
- begin
68
- require 'rake/contrib/sshpublisher'
69
- namespace :rubyforge do
70
-
71
- desc "Release gem and RDoc documentation to RubyForge"
72
- task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
73
-
74
- namespace :release do
75
- desc "Publish RDoc to RubyForge."
76
- task :docs => [:rdoc] do
77
- config = YAML.load(
78
- File.read(File.expand_path('~/.rubyforge/user-config.yml'))
79
- )
80
-
81
- host = "#{config['username']}@rubyforge.org"
82
- remote_dir = "/var/www/gforge-projects/muck-friends/"
83
- local_dir = 'rdoc'
84
-
85
- Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
86
- end
87
- end
62
+ Jeweler::RubyforgeTasks.new do |rubyforge|
63
+ rubyforge.doc_task = "rdoc"
88
64
  end
89
65
  rescue LoadError
90
- puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
66
+ puts "Jeweler not available. Install it with: sudo gem install jeweler"
91
67
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.1.6
@@ -14,40 +14,57 @@ class Muck::FriendsController < ApplicationController
14
14
  def create
15
15
  respond_to do |format|
16
16
  if Friend.make_friends(@user, @target)
17
- friend = current_user.reload.friend_of? @target
17
+ friend = current_user.reload.friend_of?(@target)
18
18
  format.html do
19
- if GlobalConfig.allow_following
20
- flash[:notice] = t('muck.friends.you_are_now_following', :user => @target.login)
19
+ if GlobalConfig.enable_following
20
+ flash[:notice] = t('muck.friends.you_are_now_following', :user => @target.display_name)
21
21
  else
22
22
  flash[:notice] = t('muck.friends.friend_request_sent')
23
23
  end
24
24
  redirect_to profile_path(@target)
25
25
  end
26
- format.js { render( :update ) {|page| page.replace make_id(@user, @target), get_friend_link(@user, @target)}}
26
+ format.js { render(:update) {|page| page.replace make_id(@user, @target), friend_link(@user, @target)}}
27
27
  else
28
- if GlobalConfig.allow_following
29
- message = t('muck.friends.problem_adding_follow', :user => @target.login)
28
+ if GlobalConfig.enable_following
29
+ message = t('muck.friends.problem_adding_follow', :user => @target.display_name)
30
30
  else
31
- message = t('muck.friends.problem_sending_friend_request', :user => @target.login)
31
+ message = t('muck.friends.problem_sending_friend_request', :user => @target.display_name)
32
32
  end
33
33
  format.html do
34
34
  flash[:notice] = message
35
35
  redirect_to profile_path(@target)
36
36
  end
37
- format.js {render( :update ){|page| page.alert message}}
37
+ format.js {render(:update){|page| page.alert message}}
38
38
  end
39
39
  end
40
40
  end
41
41
 
42
42
  def destroy
43
- @user.drop_friend(@target)
43
+ success = @user.drop_friend(@target)
44
+ if GlobalConfig.enable_friending
45
+ if success
46
+ message = t('muck.friends.removed_friendship', :user => @target.display_name)
47
+ else
48
+ message = t('muck.friends.removed_friendship_error', :user => @target.display_name)
49
+ end
50
+ elsif GlobalConfig.enable_following
51
+ if success
52
+ message = t('muck.friends.stopped_following', :user => @target.display_name)
53
+ else
54
+ message = t('muck.friends.removed_following_error', :user => @target.display_name)
55
+ end
56
+ end
44
57
  respond_to do |format|
45
58
  format.html do
46
- flash[:notice] = t('muck.friends.removed_friendship')
59
+ flash[:notice] = message
47
60
  redirect_to profile_path(@target)
48
61
  end
49
62
  format.js do
50
- render( :update ){|page| page.replace make_id(@user, @target), get_friend_link(@user, @target)}
63
+ if success
64
+ render(:update){|page| page.replace make_id(@user, @target), friend_link(@user, @target)}
65
+ else
66
+ format.js {render(:update){|page| page.alert message}}
67
+ end
51
68
  end
52
69
  end
53
70
  end
@@ -1,93 +1,155 @@
1
1
  module MuckFriendsHelper
2
2
 
3
- def mutual_friends(user1, user2, limit = 6)
4
- mutual_friends = user1.friends & user2.friends
5
- render :partial => 'friends/mutual_friends', :locals => { :mutual_friends => mutual_friends }
6
- end
7
-
8
3
  def all_friends(user)
9
4
  render :partial => 'friends/all_friends', :locals => { :user => user }
10
5
  end
11
6
 
12
- def friends(user, limit = 6)
13
- return '' if user.nil?
7
+ # Renders a partial that contains the friends of the given user
8
+ # Parameters:
9
+ # user1: User whose friends are to be shown
10
+ # user2: User whose friends are to be checked to see if they are in common with user1
11
+ # limit: Number of records to show
12
+ # partial: The partial to render. Default is 'friend_simple' which renders an icon and name for each friend.
13
+ # Options include 'friend_icon' which only renders an icon or a custom partial. Place custom partials
14
+ # in app/views/friends
15
+ # no_friends_content: Content to render if no users are found. Pass ' ' to render nothing
16
+ def mutual_friends(user1, user2, limit = 6, no_friends_content = nil, partial = 'friend_simple')
17
+ return '' if user1.blank? || user2.blank?
18
+ users = user1.friends & user2.friends
19
+ users = users.first(limit)
20
+ no_friends_content ||= t('muck.friends.no_mutual_friends')
21
+ render_friends(users, partial, no_friends_content)
22
+ end
23
+
24
+ # Renders a partial that contains the friends of the given user
25
+ # Parameters:
26
+ # user: User whose friends are to be shown
27
+ # limit: Number of records to show
28
+ # partial: The partial to render. Default is 'friend_simple' which renders an icon and name for each friend.
29
+ # Options include 'friend_icon' which only renders an icon or a custom partial. Place custom partials
30
+ # in app/views/friends
31
+ # no_friends_content: Content to render if no users are found. Pass ' ' to render nothing
32
+ def friends(user, limit = 6, no_friends_content = nil, partial = 'friend_simple')
33
+ return '' if user.blank?
14
34
  users = user.friends.find(:all, :limit => limit, :order => 'friends.created_at DESC')
15
- if users
16
- render :partial => 'friends/friend_simple', :collection => users
17
- else
18
- "<p>#{t('muck.friends.no_friends')}</p>"
19
- end
35
+ no_friends_content ||= t('muck.friends.no_friends')
36
+ render_friends(users, partial, no_friends_content)
20
37
  end
21
38
 
22
- def followers(user, limit = 6)
23
- return '' if user.nil?
39
+ # Renders a partial that contains the friends of the given user
40
+ # Parameters:
41
+ # user: User whose friends are to be shown
42
+ # limit: Number of records to show
43
+ # partial: The partial to render. Default is 'friend_simple' which renders an icon and name for each friend.
44
+ # Options include 'friend_icon' which only renders an icon or a custom partial. Place custom partials
45
+ # in app/views/friends
46
+ # no_friends_content: Content to render if no users are found. Pass ' ' to render nothing
47
+ def followers(user, limit = 6, no_friends_content = nil, partial = 'friend_simple')
48
+ return '' if user.blank?
24
49
  users = user.followers.find(:all, :limit => limit, :order => 'friends.created_at DESC')
25
- if users
26
- render :partial => 'friends/friend_simple', :collection => users
27
- else
28
- "<p>#{t('muck.friends.no_followers')}</p>"
29
- end
50
+ no_friends_content ||= t('muck.friends.no_followers')
51
+ render_friends(users, partial, no_friends_content)
30
52
  end
31
53
 
32
- def followings(user, limit = 6)
54
+ # Renders a partial that contains the friends of the given user
55
+ # Parameters:
56
+ # user: User whose friends are to be shown
57
+ # limit: Number of records to show
58
+ # partial: The partial to render. Default is 'friend_simple' which renders an icon and name for each friend.
59
+ # Options include 'friend_icon' which only renders an icon or a custom partial. Place custom partials
60
+ # in app/views/friends
61
+ # no_friends_content: Content to render if no users are found. Pass ' ' to render nothing
62
+ def followings(user, limit = 6, no_friends_content = nil, partial = 'friend_simple')
33
63
  return '' if user.nil?
34
64
  users = user.followings.find(:all, :limit => limit, :order => 'friends.created_at DESC')
35
- if users
36
- render :partial => 'friends/friend_simple', :collection => users
37
- else
38
- "<p>#{t('muck.friends.not_following_anyone')}</p>"
39
- end
65
+ no_friends_content ||= t('muck.friends.not_following_anyone')
66
+ render_friends(users, partial, no_friends_content)
40
67
  end
41
68
 
42
- # Render a list of all friend requests (if !GlobalConfig.allow_following)
69
+ # Render a list of all friend requests (if !GlobalConfig.enable_following)
43
70
  def friend_requests(user)
44
- if !GlobalConfig.allow_following
71
+ if !GlobalConfig.enable_following
45
72
  followers = user.followers
46
73
  render :partial => 'friends/friend_requests', :locals => { :followers => followers } unless followers.blank?
47
74
  end
48
75
  end
49
76
 
50
- # TODO review this code
51
- def get_friend_link(user, target)
52
-
53
- return wrap_get_friend_link(link_to( I18n.t('muck.friends.muck.friends.sign_up_to_follow'), signup_path)) if user.blank?
54
- return '' unless user != :false && target
77
+ # Render a follow/unfollow/friend request link appropriate to the current application settings and user relationship
78
+ # Requires enable_following and enable_friending be set in global_config.yml
79
+ # If enable_following is true and enable_friending is false then only follow/unfollow links will be shown
80
+ # If enable_following is false and enable_friending is true then only friend request and unfriend links will be shown
81
+ # If enable_following is true and enable_friending is true then a hybrid model will be used. Users can follow
82
+ # each other without permission but a mutual follow will result in a friendship. Defriending a user will result in the
83
+ # other user becoming a follower
84
+ def friend_link(user, target)
55
85
 
56
- dom_id = make_id(user, target)
86
+ # User not logged in
87
+ if user.blank?
88
+ if GlobalConfig.enable_following
89
+ key = 'login_or_sign_up_to_follow'
90
+ elsif GlobalConfig.enable_friending
91
+ key = 'login_or_sign_up_to_friend'
92
+ else
93
+ return ''
94
+ end
95
+ return wrap_friend_link(I18n.t("muck.friends.muck.friends.#{key}"), :login => link_to(t('muck.friends.login'), login_path), :signup => link_to(t('muck.friends.signup'), signup_path))
96
+ end
57
97
 
58
- return wrap_get_friend_link('') if user == target
59
- return wrap_get_friend_link(link_to_remote( I18n.t('muck.friends.stop_being_friends'), :url => user_friend_path(user, target), :method => :delete), dom_id) if user.friend_of? target
98
+ return '' if target.blank?
99
+ return '' if user == target
60
100
 
61
- if GlobalConfig.allow_following
62
- return wrap_get_friend_link(link_to_remote( I18n.t('muck.friends.stop_following'), :url => user_friend_path(user, target), :method => :delete), dom_id) if user.following? target
63
- else
64
- if user.following? target
65
- return wrap_get_friend_link( I18n.t('muck.friends.friend_request_pending', :link => link_to_remote(I18n.t('muck.friends.delete'), :url => user_friend_path(user, target), :method => :delete)), dom_id)
101
+ dom_id = make_id(user, target)
102
+
103
+ if GlobalConfig.enable_friending
104
+ if user.friend_of?(target)
105
+ return wrap_friend_link(link_to_remote( I18n.t('muck.friends.stop_being_friends_with', :user => target.display_name), :url => user_friend_path(user, target), :method => :delete), dom_id)
106
+ elsif user.following?(target)
107
+ return wrap_friend_link( I18n.t('muck.friends.friend_request_pending', :link => link_to_remote(I18n.t('muck.friends.delete'), :url => user_friend_path(user, target), :method => :delete)), dom_id)
108
+ end
109
+ elsif GlobalConfig.enable_following
110
+ if user.following?(target)
111
+ return wrap_friend_link(link_to_remote( I18n.t('muck.friends.stop_following', :user => target.display_name), :url => user_friend_path(user, target), :method => :delete), dom_id)
66
112
  end
67
113
  end
68
114
 
69
- return wrap_get_friend_link(link_to_remote( I18n.t('muck.friends.acccept_friend_request'), :url => user_friends_path(user, :id => target), :method => :post), dom_id) if user.followed_by? target
115
+ if GlobalConfig.enable_friending && user.followed_by?(target)
116
+ return wrap_friend_link(link_to_remote( I18n.t('muck.friends.acccept_friend_request', :user => target.display_name), :url => user_friends_path(user, :id => target), :method => :post), dom_id)
117
+ end
70
118
 
71
- if GlobalConfig.allow_following
72
- wrap_get_friend_link(link_to_remote( I18n.t('muck.friends.start_following'), :url => user_friends_path(user, :id => target), :method => :post), dom_id)
73
- else
74
- wrap_get_friend_link(link_to_remote( I18n.t('muck.friends.friend_request'), :url => user_friends_path(user, :id => target), :method => :post), dom_id)
119
+ if GlobalConfig.enable_following
120
+ wrap_friend_link(link_to_remote( I18n.t('muck.friends.start_following', :user => target.display_name), :url => user_friends_path(user, :id => target), :method => :post), dom_id)
121
+ elsif GlobalConfig.enable_friending
122
+ wrap_friend_link(link_to_remote( I18n.t('muck.friends.friend_request_prompt', :user => target.display_name), :url => user_friends_path(user, :id => target), :method => :post), dom_id)
75
123
  end
76
124
 
77
125
  end
78
126
 
79
127
  def accept_follower_link(user, target)
80
128
  dom_id = make_id(user, target)
81
- wrap_get_friend_link(link_to_remote( I18n.t('muck.friends.accept'), { :url => user_friends_path(user, :id => target), :method => :post}, {:id => "accept-#{target.id}", :class => 'notification-link'}), dom_id)
129
+ wrap_friend_link(link_to_remote( I18n.t('muck.friends.accept'), { :url => user_friends_path(user, :id => target), :method => :post}, {:id => "accept-#{target.id}", :class => 'notification-link'}), dom_id)
82
130
  end
83
131
 
84
132
  def ignore_friend_request_link(user, target)
85
133
  dom_id = make_id(user, target)
86
- wrap_get_friend_link(link_to_remote( I18n.t('muck.friends.ignore'), { :url => user_friend_path(user, target), :method => :delete }, {:id => "ignore-#{target.id}", :class => 'notification-link'}), dom_id)
134
+ wrap_friend_link(link_to_remote( I18n.t('muck.friends.ignore'), { :url => user_friend_path(user, target), :method => :delete }, {:id => "ignore-#{target.id}", :class => 'notification-link'}), dom_id)
87
135
  end
88
136
 
89
137
  protected
90
- def wrap_get_friend_link(link, dom_id = '')
138
+
139
+ # Handles render friend partials
140
+ def render_friends(users, partial, no_friends_content)
141
+ if users
142
+ render :partial => "friends/#{partial}", :collection => users
143
+ else
144
+ if no_friends_content.length > 0
145
+ no_friends_content
146
+ else
147
+ "<p class=\"no_friends_found\">#{no_friends_content}</p>"
148
+ end
149
+ end
150
+ end
151
+
152
+ def wrap_friend_link(link, dom_id = '')
91
153
  content_tag(:span, link, :id => dom_id, :class => 'friendship-description')
92
154
  end
93
155
 
@@ -0,0 +1,3 @@
1
+ <% activity_for(activity, :activity_css_class => 'activity_follow') do %>
2
+ <%= activity.content %>
3
+ <% end -%>
@@ -0,0 +1,3 @@
1
+ <% activity_for(activity, :activity_css_class => 'activity_friends_with') do %>
2
+ <%= activity.content %>
3
+ <% end -%>
@@ -1,6 +1,6 @@
1
1
  <h2><%= t('muck.friends.friends') %></h2>
2
2
  <%= friends(user) %>
3
- <% if GlobalConfig.allow_following -%>
3
+ <% if GlobalConfig.enable_following -%>
4
4
  <h2><%= t('muck.friends.followers') %></h2>
5
5
  <%= followers(user) %>
6
6
  <h2><%= t('muck.friends.following') %></h2>
@@ -0,0 +1 @@
1
+ <%= icon friend_simple %>
@@ -1,4 +1,6 @@
1
1
  ActionController::Routing::Routes.draw do |map|
2
2
  map.resources :friends, :controller => 'muck/friends'
3
- map.resources :users, :has_many => [:friends]
3
+ map.resources :users do |users|
4
+ users.resources :friends, :controller => 'muck/friends'
5
+ end
4
6
  end
@@ -22,7 +22,7 @@ module ActiveRecord
22
22
  # class methods
23
23
  module SingletonMethods
24
24
 
25
- # When allow_following is true this will setup a follower. When allow_following is false
25
+ # When enable_following is true this will setup a follower. When enable_following is false
26
26
  # the system only allows friends and so this becomes a friend request
27
27
  def add_follower(inviter, invited)
28
28
  return false if inviter.blank? || invited.blank? || inviter == invited
@@ -55,12 +55,10 @@ module ActiveRecord
55
55
  def stop_being_friends(user, target)
56
56
  return false if user.blank? || target.blank?
57
57
  transaction do
58
- begin
59
- Friend.find(:first, :conditions => {:inviter_id => target.id, :invited_id => user.id}).destroy
60
- Friend.find(:first, :conditions => {:inviter_id => user.id, :invited_id => target.id}).destroy
61
- rescue Exception
62
- return false
63
- end
58
+ friend = Friend.find(:first, :conditions => {:inviter_id => target.id, :invited_id => user.id})
59
+ friend.destroy if friend
60
+ friend = Friend.find(:first, :conditions => {:inviter_id => user.id, :invited_id => target.id})
61
+ friend.destroy if friend
64
62
  end
65
63
  true
66
64
  end
@@ -69,33 +67,27 @@ module ActiveRecord
69
67
  def revert_to_follower(user, target)
70
68
  return false if user.blank? || target.blank?
71
69
  transaction do
72
- begin
73
- Friend.find(:first, :conditions => {:inviter_id => target.id, :invited_id => user.id}).update_attribute(:status, MuckFriends::PENDING)
74
- Friend.find(:first, :conditions => {:inviter_id => user.id, :invited_id => target.id}).destroy
75
- rescue Exception
76
- return false
77
- end
70
+ Friend.find(:first, :conditions => {:inviter_id => user.id, :invited_id => target.id}).destroy
71
+ friend = Friend.find(:first, :conditions => {:inviter_id => target.id, :invited_id => user.id})
72
+ return friend.update_attribute(:status, MuckFriends::PENDING) if friend
78
73
  end
79
74
  true
80
75
  end
81
76
 
82
77
  def stop_following(user, target)
83
78
  return false if user.blank? || target.blank?
84
- transaction do
85
- begin
86
- Friend.find(:first, :conditions => {:inviter_id => user.id, :invited_id => target.id}).destroy
87
- rescue Exception
88
- return false
89
- end
90
- end
91
- true
79
+ Friend.find(:first, :conditions => {:inviter_id => user.id, :invited_id => target.id}).destroy
92
80
  end
93
81
 
94
82
  def block_user(user, target)
95
83
  return false if user.blank? || target.blank?
96
84
  Friend.find(:first, :conditions => {:inviter_id => target.id, :invited_id => user.id}).update_attribute(:status, MuckFriends::BLOCKED)
97
85
  friend = Friend.find(:first, :conditions => {:inviter_id => user.id, :invited_id => target.id})
98
- friend.destroy if friend
86
+ if friend
87
+ friend.destroy
88
+ else
89
+ true
90
+ end
99
91
  end
100
92
 
101
93
  def unblock_user(user, target)
@@ -62,18 +62,23 @@ module ActiveRecord
62
62
  Friend.add_follower(self, user)
63
63
  end
64
64
 
65
+ # Call to stop following another user
65
66
  def stop_following(user)
66
67
  Friend.stop_following(self, user)
67
68
  end
68
-
69
+
70
+ # Call to remove friend or follower. If following is enabled
71
+ # the user specified by 'user' will become a follower of
72
+ # self.
69
73
  def drop_friend(user)
70
- if GlobalConfig.allow_following
74
+ if GlobalConfig.enable_following
71
75
  Friend.revert_to_follower(self, user)
72
76
  else
73
77
  Friend.stop_being_friends(self, user)
74
78
  end
75
79
  end
76
80
 
81
+ # Block a user. This prevents them from getting updates.
77
82
  def block_user(user)
78
83
  Friend.block_user(self, user)
79
84
  end
data/locales/en.yml CHANGED
@@ -15,19 +15,26 @@ en:
15
15
  not_following_anyone: "You aren't currently following anyone"
16
16
  no_followers: "You don't currently have any followers"
17
17
  no_friends: "You don't currently have any friends"
18
+ no_mutual_friends: "No mutual friends found"
18
19
  you_are_now_following: "You are now following {{user}}"
19
20
  friend_request_sent: "Friend Request Sent"
20
21
  problem_adding_follow: "There was a problem adding {{user}} to your follow list. Please try again."
21
22
  problem_sending_friend_request: "There was a problem sending a friend request to {{user}}. Please try again."
22
- removed_friendship: "Removed friend relationship"
23
+ removed_friendship: "Removed {{user}} from your friends"
24
+ stopped_following: "Successfully stopped following {{user}}"
25
+ removed_friendship_error: "There was a problem removing {{user}} from your list of friends"
26
+ removed_following_error: "A problem occured while trying to unfollow {{user}}"
23
27
  view_all: "View All"
24
- sign_up_to_follow: "Sign-up to Follow"
25
- stop_being_friends: "Stop Being Friends"
26
- stop_following: "Stop Following"
28
+ login_or_sign_up_to_follow: "{{login}} or {{signup}} to follow this user"
29
+ login_or_sign_up_to_friend: "{{login}} or {{signup}} to send friend requests"
30
+ login: login
31
+ signup: signup
32
+ stop_being_friends_with: "Unfriend {{user}}"
33
+ stop_following: "Stop Following {{user}}"
27
34
  friend_request_pending: "Friend request pending {{link}}"
28
- acccept_friend_request: "Accept Friend Request"
29
- start_following: "Start Following"
30
- friend_request: "Friend Request"
35
+ acccept_friend_request: "Accept Friend Request From {{user}}"
36
+ start_following: "Follow {{user}}"
37
+ friend_request_prompt: "Send {{user}} a Friend Request"
31
38
  delete: "(delete)"
32
39
  accept: "(accept)"
33
40
  ignore: "(ignore)"
data/muck-friends.gemspec CHANGED
@@ -1,12 +1,15 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
1
4
  # -*- encoding: utf-8 -*-
2
5
 
3
6
  Gem::Specification.new do |s|
4
7
  s.name = %q{muck-friends}
5
- s.version = "0.1.5"
8
+ s.version = "0.1.6"
6
9
 
7
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
11
  s.authors = ["Justin Ball"]
9
- s.date = %q{2009-08-08}
12
+ s.date = %q{2009-08-12}
10
13
  s.description = %q{Friend engine for the muck system.}
11
14
  s.email = %q{justinball@gmail.com}
12
15
  s.extra_rdoc_files = [
@@ -21,13 +24,14 @@ Gem::Specification.new do |s|
21
24
  "app/controllers/muck/friends_controller.rb",
22
25
  "app/helpers/muck_friends_helper.rb",
23
26
  "app/models/friend_mailer.rb",
24
- "app/views/activity_templates/follow.html.erb",
25
- "app/views/activity_templates/friends_with.html.erb",
27
+ "app/views/activity_templates/_follow.html.erb",
28
+ "app/views/activity_templates/_friends_with.html.erb",
26
29
  "app/views/friend_mailer/follow.text.html.erb",
27
30
  "app/views/friend_mailer/follow.text.plain.erb",
28
31
  "app/views/friend_mailer/friend_request.text.html.erb",
29
32
  "app/views/friend_mailer/friend_request.text.plain.erb",
30
33
  "app/views/friends/_all_friends.html.erb",
34
+ "app/views/friends/_friend_icon.html.erb",
31
35
  "app/views/friends/_friend_requests.html.erb",
32
36
  "app/views/friends/_friend_simple.html.erb",
33
37
  "app/views/friends/_mutual_friends.html.erb",
@@ -104,6 +108,7 @@ Gem::Specification.new do |s|
104
108
  "test/rails_root/app/views/default/all_friends.html.erb",
105
109
  "test/rails_root/app/views/default/followers.html.erb",
106
110
  "test/rails_root/app/views/default/followings.html.erb",
111
+ "test/rails_root/app/views/default/friend_link.html.erb",
107
112
  "test/rails_root/app/views/default/friend_requests.html.erb",
108
113
  "test/rails_root/app/views/default/friends.html.erb",
109
114
  "test/rails_root/app/views/default/mutual_friends.html.erb",
@@ -112,6 +117,7 @@ Gem::Specification.new do |s|
112
117
  "test/rails_root/config/boot.rb",
113
118
  "test/rails_root/config/database.yml",
114
119
  "test/rails_root/config/environment.rb",
120
+ "test/rails_root/config/environments/cucumber.rb",
115
121
  "test/rails_root/config/environments/development.rb",
116
122
  "test/rails_root/config/environments/production.rb",
117
123
  "test/rails_root/config/environments/test.rb",
@@ -124,11 +130,17 @@ Gem::Specification.new do |s|
124
130
  "test/rails_root/db/.keep",
125
131
  "test/rails_root/db/migrate/20090320174818_create_muck_permissions_and_roles.rb",
126
132
  "test/rails_root/db/migrate/20090402033319_add_muck_activities.rb",
133
+ "test/rails_root/db/migrate/20090402234137_create_languages.rb",
134
+ "test/rails_root/db/migrate/20090426041056_create_countries.rb",
135
+ "test/rails_root/db/migrate/20090426041103_create_states.rb",
127
136
  "test/rails_root/db/migrate/20090512013727_create_profiles.rb",
128
137
  "test/rails_root/db/migrate/20090602041838_create_users.rb",
129
138
  "test/rails_root/db/migrate/20090608073052_create_friends.rb",
139
+ "test/rails_root/db/migrate/20090730044139_add_comment_cache.rb",
130
140
  "test/rails_root/features/step_definitions/webrat_steps.rb",
131
141
  "test/rails_root/features/support/env.rb",
142
+ "test/rails_root/features/support/paths.rb",
143
+ "test/rails_root/lib/tasks/cucumber.rake",
132
144
  "test/rails_root/public/.htaccess",
133
145
  "test/rails_root/public/404.html",
134
146
  "test/rails_root/public/422.html",
@@ -138,11 +150,27 @@ Gem::Specification.new do |s|
138
150
  "test/rails_root/public/images/arrow_left.gif",
139
151
  "test/rails_root/public/images/arrow_right.gif",
140
152
  "test/rails_root/public/images/blue/preview.gif",
153
+ "test/rails_root/public/images/fancybox/fancy_closebox.png",
154
+ "test/rails_root/public/images/fancybox/fancy_left.png",
155
+ "test/rails_root/public/images/fancybox/fancy_progress.png",
156
+ "test/rails_root/public/images/fancybox/fancy_right.png",
157
+ "test/rails_root/public/images/fancybox/fancy_shadow_e.png",
158
+ "test/rails_root/public/images/fancybox/fancy_shadow_n.png",
159
+ "test/rails_root/public/images/fancybox/fancy_shadow_ne.png",
160
+ "test/rails_root/public/images/fancybox/fancy_shadow_nw.png",
161
+ "test/rails_root/public/images/fancybox/fancy_shadow_s.png",
162
+ "test/rails_root/public/images/fancybox/fancy_shadow_se.png",
163
+ "test/rails_root/public/images/fancybox/fancy_shadow_sw.png",
164
+ "test/rails_root/public/images/fancybox/fancy_shadow_w.png",
165
+ "test/rails_root/public/images/fancybox/fancy_title_left.png",
166
+ "test/rails_root/public/images/fancybox/fancy_title_main.png",
167
+ "test/rails_root/public/images/fancybox/fancy_title_right.png",
141
168
  "test/rails_root/public/images/icons/accept.png",
142
169
  "test/rails_root/public/images/icons/add.png",
143
170
  "test/rails_root/public/images/icons/delete.png",
144
171
  "test/rails_root/public/images/icons/vote.png",
145
172
  "test/rails_root/public/images/loading.gif",
173
+ "test/rails_root/public/images/nothing.png",
146
174
  "test/rails_root/public/images/profile_default.jpg",
147
175
  "test/rails_root/public/images/rails.png",
148
176
  "test/rails_root/public/images/red/preview.gif",
@@ -155,6 +183,8 @@ Gem::Specification.new do |s|
155
183
  "test/rails_root/public/javascripts/effects.js",
156
184
  "test/rails_root/public/javascripts/fancyzoom.min.js",
157
185
  "test/rails_root/public/javascripts/jquery/jquery-ui.js",
186
+ "test/rails_root/public/javascripts/jquery/jquery.easing.js",
187
+ "test/rails_root/public/javascripts/jquery/jquery.fancybox.js",
158
188
  "test/rails_root/public/javascripts/jquery/jquery.form.js",
159
189
  "test/rails_root/public/javascripts/jquery/jquery.jgrowl.js",
160
190
  "test/rails_root/public/javascripts/jquery/jquery.js",
@@ -218,6 +248,7 @@ Gem::Specification.new do |s|
218
248
  "test/rails_root/public/stylesheets/jquery/cupertino/images/ui-icons_cd0a0a_256x240.png",
219
249
  "test/rails_root/public/stylesheets/jquery/cupertino/images/ui-icons_ffffff_256x240.png",
220
250
  "test/rails_root/public/stylesheets/jquery/cupertino/jquery-ui-1.7.1.custom.css",
251
+ "test/rails_root/public/stylesheets/jquery/jquery.fancybox.css",
221
252
  "test/rails_root/public/stylesheets/jquery/redmond/images/ui-bg_flat_0_aaaaaa_40x100.png",
222
253
  "test/rails_root/public/stylesheets/jquery/redmond/images/ui-bg_flat_55_fbec88_40x100.png",
223
254
  "test/rails_root/public/stylesheets/jquery/redmond/images/ui-bg_glass_75_d0e5f5_1x400.png",
@@ -333,6 +364,7 @@ Gem::Specification.new do |s|
333
364
  "test/rails_root/app/models/user_session.rb",
334
365
  "test/rails_root/config/boot.rb",
335
366
  "test/rails_root/config/environment.rb",
367
+ "test/rails_root/config/environments/cucumber.rb",
336
368
  "test/rails_root/config/environments/development.rb",
337
369
  "test/rails_root/config/environments/production.rb",
338
370
  "test/rails_root/config/environments/test.rb",
@@ -343,12 +375,16 @@ Gem::Specification.new do |s|
343
375
  "test/rails_root/config/routes.rb",
344
376
  "test/rails_root/db/migrate/20090320174818_create_muck_permissions_and_roles.rb",
345
377
  "test/rails_root/db/migrate/20090402033319_add_muck_activities.rb",
378
+ "test/rails_root/db/migrate/20090402234137_create_languages.rb",
379
+ "test/rails_root/db/migrate/20090426041056_create_countries.rb",
380
+ "test/rails_root/db/migrate/20090426041103_create_states.rb",
346
381
  "test/rails_root/db/migrate/20090512013727_create_profiles.rb",
347
382
  "test/rails_root/db/migrate/20090602041838_create_users.rb",
348
383
  "test/rails_root/db/migrate/20090608073052_create_friends.rb",
349
- "test/rails_root/db/schema.rb",
384
+ "test/rails_root/db/migrate/20090730044139_add_comment_cache.rb",
350
385
  "test/rails_root/features/step_definitions/webrat_steps.rb",
351
386
  "test/rails_root/features/support/env.rb",
387
+ "test/rails_root/features/support/paths.rb",
352
388
  "test/rails_root/public/dispatch.rb",
353
389
  "test/rails_root/script/create_project.rb",
354
390
  "test/rails_root/test/factories.rb",