From: Mikel Maron Date: Fri, 6 Jan 2012 21:25:09 +0000 (-0500) Subject: Add some more social features X-Git-Tag: live~6486 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/d878db0a9bca47afb7f7b0bc5bf6e9917718f05b Add some more social features Add a view showing changesets by nearby users, and views showing diary entries by friends and nearby users. --- diff --git a/app/controllers/changeset_controller.rb b/app/controllers/changeset_controller.rb index b736e332b..495fcee97 100644 --- a/app/controllers/changeset_controller.rb +++ b/app/controllers/changeset_controller.rb @@ -276,6 +276,15 @@ class ChangesetController < ApplicationController end end + if params[:nearby] + if @user + changesets = changesets.where(:user_id => @user.nearby) + elsif request.format == :html + require_user + return + end + end + if params[:bbox] bbox = BoundingBox.from_bbox_params(params) elsif params[:minlon] and params[:minlat] and params[:maxlon] and params[:maxlat] @@ -295,6 +304,10 @@ class ChangesetController < ApplicationController @title = t 'changeset.list.title_friend' @heading = t 'changeset.list.heading_friend' @description = t 'changeset.list.description_friend' + elsif params[:nearby] and @user + @title = t 'changeset.list.title_nearby' + @heading = t 'changeset.list.heading_nearby' + @description = t 'changeset.list.description_nearby' elsif user and bbox @title = t 'changeset.list.title_user_bbox', :user => user.display_name, :bbox => bbox.to_s @heading = t 'changeset.list.heading_user_bbox', :user => user.display_name, :bbox => bbox.to_s diff --git a/app/controllers/diary_entry_controller.rb b/app/controllers/diary_entry_controller.rb index 0444f5a89..5e4b68b73 100644 --- a/app/controllers/diary_entry_controller.rb +++ b/app/controllers/diary_entry_controller.rb @@ -98,6 +98,34 @@ class DiaryEntryController < ApplicationController }, :order => 'created_at DESC', :per_page => 20) + elsif params[:friends] + if @user + @title = t 'diary_entry.list.title_friends' + @entry_pages, @entries = paginate(:diary_entries, :include => :user, + :conditions => { + :user_id => @user.friend_users.public, + :visible => true + }, + :order => 'created_at DESC', + :per_page => 20) + else + require_user + return + end + elsif params[:nearby] + if @user + @title = t 'diary_entry.list.title_nearby' + @entry_pages, @entries = paginate(:diary_entries, :include => :user, + :conditions => { + :user_id => @user.nearby, + :visible => true + }, + :order => 'created_at DESC', + :per_page => 20) + else + require_user + return + end else @title = t 'diary_entry.list.title' @entry_pages, @entries = paginate(:diary_entries, :include => :user, diff --git a/app/views/user/view.html.erb b/app/views/user/view.html.erb index c13a276f7..bd3a371aa 100644 --- a/app/views/user/view.html.erb +++ b/app/views/user/view.html.erb @@ -118,7 +118,8 @@ <% if friends.empty? %> <%= t 'user.view.no friends' %> <% else %> - <%= link_to t('user.view.friends_changesets'), {:controller => 'browse', :action => 'friends'} %>

+ <%= link_to t('user.view.friends_changesets'), {:controller => 'browse', :action => 'friends'} %>
+ <%= link_to t('user.view.friends_diaries'), {:controller => 'diary', :action => 'friends'} %>

<%= render :partial => "contact", :collection => friends %>
@@ -129,6 +130,8 @@ <% if nearby.empty? %> <%= t 'user.view.no nearby users' %> <% else %> + <%= link_to t('user.view.nearby_changesets'), {:controller => 'browse', :action => 'nearby'} %>
+ <%= link_to t('user.view.nearby_diaries'), {:controller => 'diary', :action => 'nearby'} %>

<%= render :partial => "contact", :collection => nearby %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index e9685ab49..0347d6fd7 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -308,18 +308,19 @@ en: title_bbox: "Changesets within %{bbox}" title_user_bbox: "Changesets by %{user} within %{bbox}" title_friend: "Changesets by your friends" - + title_nearby: "Changesets by nearby users" heading: "Changesets" heading_user: "Changesets" heading_bbox: "Changesets" heading_user_bbox: "Changesets" heading_friend: "Changesets" - + heading_nearby: "Changesets" description: "Recent changes" description_user: "Changesets by %{user}" description_bbox: "Changesets within %{bbox}" description_user_bbox: "Changesets by %{user} within %{bbox}" description_friend: "Changesets by your friends" + description_nearby: "Changesets by nearby users" timeout: sorry: "Sorry, the list of changesets you requested took too long to retrieve." diary_entry: @@ -327,6 +328,8 @@ en: title: New Diary Entry list: title: "Users' diaries" + title_friends: "Friends' diaries" + title_nearby: "Nearby Users' diaries" user_title: "%{user}'s diary" in_language_title: "Diary Entries in %{language}" new: New Diary Entry @@ -1697,6 +1700,9 @@ en: delete_user: "delete this user" confirm: "Confirm" friends_changesets: "Browse all changesets by friends" + friends_diaries: "Browse all diary entries by friends" + nearby_changesets: "Browse all changesets by nearby users" + nearby_diaries: "Browse all diary entries by nearby users" popup: your location: "Your location" nearby mapper: "Nearby mapper" diff --git a/config/routes.rb b/config/routes.rb index a60caeb2f..fa7dd5ba0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -87,6 +87,7 @@ OpenStreetMap::Application.routes.draw do match '/user/:display_name/edits' => 'changeset#list' match '/user/:display_name/edits/feed' => 'changeset#feed', :format => :atom match '/browse/friends' => 'changeset#list', :friends => true + match '/browse/nearby' => 'changeset#list', :nearby => true match '/browse/changesets' => 'changeset#list' match '/browse/changesets/feed' => 'changeset#feed', :format => :atom match '/browse' => 'changeset#list' @@ -154,6 +155,8 @@ OpenStreetMap::Application.routes.draw do # diary pages match '/diary/new' => 'diary_entry#new' + match '/diary/friends' => 'diary_entry#list', :friends => true + match '/diary/nearby' => 'diary_entry#list', :nearby => true match '/user/:display_name/diary/rss' => 'diary_entry#rss', :format => :rss match '/diary/:language/rss' => 'diary_entry#rss', :format => :rss match '/diary/rss' => 'diary_entry#rss', :format => :rss