Skip to content

Commit 8393857

Browse files
committed
Modify the way Friends are added
1 parent 8689337 commit 8393857

18 files changed

+104
-104
lines changed

app/abilities/ability.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def initialize(user)
4242
can [:create, :subscribe, :unsubscribe], DiaryEntry
4343
can :update, DiaryEntry, :user => user
4444
can [:create], DiaryComment
45-
can [:make_friend, :remove_friend], Friendship
45+
can [:follow, :unfollow], Friendship
4646
can [:create, :reply, :show, :inbox, :outbox, :muted, :mark, :unmute, :destroy], Message
4747
can [:close, :reopen], Note
4848
can [:show, :update], :preference

app/controllers/diary_entries_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def index
2828
end
2929
elsif params[:friends]
3030
if current_user
31-
@title = t ".title_friends"
31+
@title = t ".title_followed"
3232
entries = DiaryEntry.where(:user => current_user.friends)
3333
else
3434
require_user

app/controllers/friendships_controller.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ class FriendshipsController < ApplicationController
99

1010
authorize_resource
1111

12-
before_action :check_database_writable, :only => [:make_friend, :remove_friend]
13-
before_action :lookup_friend, :only => [:make_friend, :remove_friend]
12+
before_action :check_database_writable, :only => [:follow, :unfollow]
13+
before_action :lookup_friend, :only => [:follow, :unfollow]
1414

15-
def make_friend
15+
def follow
1616
if request.post?
1717
friendship = Friendship.new
1818
friendship.befriender = current_user
1919
friendship.befriendee = @friend
2020
if current_user.friends_with?(@friend)
21-
flash[:warning] = t ".already_a_friend", :name => @friend.display_name
21+
flash[:warning] = t ".already_followed", :name => @friend.display_name
2222
elsif current_user.friendships.where(:created_at => Time.now.utc - 1.hour..).count >= current_user.max_friends_per_hour
2323
flash[:error] = t ".limit_exceeded"
2424
elsif friendship.save
@@ -34,13 +34,13 @@ def make_friend
3434
end
3535
end
3636

37-
def remove_friend
37+
def unfollow
3838
if request.post?
3939
if current_user.friends_with?(@friend)
4040
Friendship.where(:befriender => current_user, :befriendee => @friend).delete_all
4141
flash[:notice] = t ".success", :name => @friend.display_name
4242
else
43-
flash[:error] = t ".not_a_friend", :name => @friend.display_name
43+
flash[:error] = t ".not_followed", :name => @friend.display_name
4444
end
4545

4646
referer = safe_referer(params[:referer]) if params[:referer]

app/helpers/changesets_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def changeset_details(changeset)
3232

3333
def changeset_index_title(params, user)
3434
if params[:friends] && user
35-
t "changesets.index.title_friend"
35+
t "changesets.index.title_followed"
3636
elsif params[:nearby] && user
3737
t "changesets.index.title_nearby"
3838
elsif params[:display_name]

app/mailers/user_mailer.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def friendship_notification(friendship)
123123
with_recipient_locale friendship.befriendee do
124124
@friendship = friendship
125125
@viewurl = user_url(@friendship.befriender)
126-
@friendurl = make_friend_url(@friendship.befriender)
126+
@followurl = follow_url(@friendship.befriender)
127127
@author = @friendship.befriender.display_name
128128

129129
attach_user_avatar(@friendship.befriender)

app/views/dashboards/_contact.html.erb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<% user_data = {
22
:lon => contact.home_lon,
33
:lat => contact.home_lat,
4-
:icon => image_path(type == "friend" ? "marker-blue.png" : "marker-green.png"),
4+
:icon => image_path(type == "following" ? "marker-blue.png" : "marker-green.png"),
55
:description => render(:partial => "popup", :object => contact, :locals => { :type => type })
66
} %>
77
<%= tag.div :class => "clearfix row", :data => { :user => user_data } do %>
@@ -36,9 +36,9 @@
3636
<li><%= link_to t("users.show.send message"), new_message_path(contact) %></li>
3737
<li>
3838
<% if current_user.friends_with?(contact) %>
39-
<%= link_to t("users.show.remove as friend"), remove_friend_path(:display_name => contact.display_name, :referer => request.fullpath), :method => :post %>
39+
<%= link_to t("users.show.unfollow"), unfollow_path(:display_name => contact.display_name, :referer => request.fullpath), :method => :post %>
4040
<% else %>
41-
<%= link_to t("users.show.add as friend"), make_friend_path(:display_name => contact.display_name, :referer => request.fullpath), :method => :post %>
41+
<%= link_to t("users.follow"), follow_path(:display_name => contact.display_name, :referer => request.fullpath), :method => :post %>
4242
<% end %>
4343
</li>
4444
</ul>

app/views/dashboards/show.html.erb

+5-5
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@
2727
</div>
2828

2929
<div class="col-md">
30-
<h2><%= t ".my friends" %></h2>
30+
<h2><%= t ".followings" %></h2>
3131

3232
<% if friends.empty? %>
33-
<%= t ".no friends" %>
33+
<%= t ".no followings" %>
3434
<% else %>
3535
<nav class='secondary-actions mb-3'>
3636
<ul class='clearfix'>
37-
<li><%= link_to t(".friends_changesets"), friend_changesets_path %></li>
38-
<li><%= link_to t(".friends_diaries"), friends_diary_entries_path %></li>
37+
<li><%= link_to t(".followed_changesets"), friend_changesets_path %></li>
38+
<li><%= link_to t(".followed_diaries"), friends_diary_entries_path %></li>
3939
</ul>
4040
</nav>
4141
<div>
42-
<%= render :partial => "contact", :collection => friends, :locals => { :type => "friend" } %>
42+
<%= render :partial => "contact", :collection => friends, :locals => { :type => "following" } %>
4343
</div>
4444
<% end %>
4545

Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<p><%= t ".hi", :to_user => @friendship.befriendee.display_name %></p>
22

3-
<p><%= t ".had_added_you", :user => @friendship.befriender.display_name %></p>
3+
<p><%= t ".followed_you", :user => @friendship.befriender.display_name %></p>
44

55
<%= message_body do %>
66
<p><%= t ".see_their_profile_html", :userurl => link_to(@viewurl, @viewurl) %></p>
77

88
<% unless @friendship.befriendee.friends_with?(@friendship.befriender) -%>
9-
<p><%= t ".befriend_them_html", :befriendurl => link_to(@friendurl, @friendurl) %></p>
9+
<p><%= t ".follow_them_html", :followurl => link_to(@followurl, @followurl) %></p>
1010
<% end -%>
1111
<% end %>
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<%= t ".hi", :to_user => @friendship.befriendee.display_name %>
22

3-
<%= t '.had_added_you', :user => @friendship.befriender.display_name %>
3+
<%= t '.followed_you', :user => @friendship.befriender.display_name %>
44

55
<%= t '.see_their_profile', :userurl => @viewurl %>
66

77
<% unless @friendship.befriendee.friends_with?(@friendship.befriender) -%>
8-
<%= t '.befriend_them', :befriendurl => @friendurl %>
8+
<%= t '.follow_them', :followurl => @followurl %>
99
<% end -%>

app/views/users/show.html.erb

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@
8484
<% if current_user %>
8585
<li>
8686
<% if current_user.friends_with?(@user) %>
87-
<%= link_to t(".remove as friend"), remove_friend_path(:display_name => @user.display_name), :method => :post %>
87+
<%= link_to t(".unfollow"), unfollow_path(:display_name => @user.display_name), :method => :post %>
8888
<% else %>
89-
<%= link_to t(".add as friend"), make_friend_path(:display_name => @user.display_name), :method => :post %>
89+
<%= link_to t(".follow"), follow_path(:display_name => @user.display_name), :method => :post %>
9090
<% end %>
9191
</li>
9292
<% end %>

config/locales/en.yml

+27-27
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ en:
9191
support_url: Support URL
9292
allow_read_prefs: read their user preferences
9393
allow_write_prefs: modify their user preferences
94-
allow_write_diary: create diary entries, comments and make friends
94+
allow_write_diary: create diary entries and comments
9595
allow_write_api: modify the map
9696
allow_read_gpx: read their private GPS traces
9797
allow_write_gpx: upload GPS traces
@@ -445,7 +445,7 @@ en:
445445
title: "Changesets"
446446
title_user: "Changesets by %{user}"
447447
title_user_link_html: "Changesets by %{user_link}"
448-
title_friend: "Changesets by my friends"
448+
title_followed: "Changesets by followings"
449449
title_nearby: "Changesets by nearby users"
450450
empty: "No changesets found."
451451
empty_area: "No changesets in this area."
@@ -509,17 +509,17 @@ en:
509509
popup:
510510
your location: "Your location"
511511
nearby mapper: "Nearby mapper"
512-
friend: "Friend"
512+
following: "Following"
513513
show:
514514
title: My Dashboard
515515
no_home_location_html: "%{edit_profile_link} and set your home location to see nearby users."
516516
edit_your_profile: Edit your profile
517-
my friends: My friends
518-
no friends: You have not added any friends yet.
517+
followings: Followings
518+
no followings: You have not followed any user yet.
519519
nearby users: "Other nearby users"
520520
no nearby users: "There are no other users who admit to mapping nearby yet."
521-
friends_changesets: "friends' changesets"
522-
friends_diaries: "friends' diary entries"
521+
followed_changesets: "changesets"
522+
followed_diaries: "diary entries"
523523
nearby_changesets: "nearby user changesets"
524524
nearby_diaries: "nearby user diary entries"
525525
diary_entries:
@@ -530,7 +530,7 @@ en:
530530
use_map_link: Use Map
531531
index:
532532
title: "Users' Diaries"
533-
title_friends: "Friends' Diaries"
533+
title_followed: "Followings' Diaries"
534534
title_nearby: "Nearby Users' Diaries"
535535
user_title: "%{user}'s Diary"
536536
in_language_title: "Diary Entries in %{language}"
@@ -652,18 +652,18 @@ en:
652652
title: File not found
653653
description: Couldn't find a file/directory/API operation by that name on the OpenStreetMap server (HTTP 404)
654654
friendships:
655-
make_friend:
656-
heading: "Add %{user} as a friend?"
657-
button: "Add as friend"
658-
success: "%{name} is now your friend!"
659-
failed: "Sorry, failed to add %{name} as a friend."
660-
already_a_friend: "You are already friends with %{name}."
661-
limit_exceeded: "You have friended a lot of users recently. Please wait a while before trying to friend any more."
662-
remove_friend:
663-
heading: "Unfriend %{user}?"
664-
button: "Unfriend"
665-
success: "%{name} was removed from your friends."
666-
not_a_friend: "%{name} is not one of your friends."
655+
follow:
656+
heading: "Do you want to follow %{user}?"
657+
button: "Follow User"
658+
success: "You are now following %{name}!"
659+
failed: "Sorry, your request to follow %{name} has failed."
660+
already_followed: "You already follow %{name}."
661+
limit_exceeded: "You have followed a lot of users recently. Please wait a while before trying to follow any more."
662+
unfollow:
663+
heading: "Do you want to unfollow %{user}?"
664+
button: "Unfollow"
665+
success: "You successfully unfollowed %{name}."
666+
not_followed: "You are not following %{name}."
667667
geocoder:
668668
search:
669669
title:
@@ -1603,12 +1603,12 @@ en:
16031603
footer_html: "You can also read the message at %{readurl} and you can send a message to the author at %{replyurl}"
16041604
friendship_notification:
16051605
hi: "Hi %{to_user},"
1606-
subject: "[OpenStreetMap] %{user} added you as a friend"
1607-
had_added_you: "%{user} has added you as a friend on OpenStreetMap."
1606+
subject: "[OpenStreetMap] %{user} followed you"
1607+
followed_you: "%{user} is now following you on OpenStreetMap."
16081608
see_their_profile: "You can see their profile at %{userurl}."
16091609
see_their_profile_html: "You can see their profile at %{userurl}."
1610-
befriend_them: "You can also add them as a friend at %{befriendurl}."
1611-
befriend_them_html: "You can also add them as a friend at %{befriendurl}."
1610+
follow_them: "You can also follow them at %{followurl}."
1611+
follow_them_html: "You can also follow them at %{followurl}."
16121612
gpx_description:
16131613
description_with_tags: "It looks like your file %{trace_name} with the description %{trace_description} and the following tags: %{tags}"
16141614
description_with_tags_html: "It looks like your file %{trace_name} with the description %{trace_description} and the following tags: %{tags}"
@@ -2601,7 +2601,7 @@ en:
26012601
openid: Sign-in using OpenStreetMap
26022602
read_prefs: Read user preferences
26032603
write_prefs: Modify user preferences
2604-
write_diary: Create diary entries, comments and make friends
2604+
write_diary: Create diary entries and comments
26052605
write_api: Modify the map
26062606
read_gpx: Read private GPS traces
26072607
write_gpx: Upload GPS traces
@@ -2749,8 +2749,8 @@ en:
27492749
edits: Edits
27502750
traces: Traces
27512751
notes: Map Notes
2752-
remove as friend: Unfriend
2753-
add as friend: Add Friend
2752+
unfollow: Unfollow
2753+
follow: Follow
27542754
mapper since: "Mapper since:"
27552755
last map edit: "Last map edit:"
27562756
no activity yet: "No activity yet"

config/routes.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,8 @@
280280
resource :profile, :only => [:edit, :update]
281281

282282
# friendships
283-
match "/user/:display_name/make_friend" => "friendships#make_friend", :via => [:get, :post], :as => "make_friend"
284-
match "/user/:display_name/remove_friend" => "friendships#remove_friend", :via => [:get, :post], :as => "remove_friend"
283+
match "/user/:display_name/follow" => "friendships#follow", :via => [:get, :post], :as => "follow"
284+
match "/user/:display_name/unfollow" => "friendships#unfollow", :via => [:get, :post], :as => "unfollow"
285285

286286
# user lists
287287
match "/users" => "users#index", :via => [:get, :post]

0 commit comments

Comments
 (0)