]> git.openstreetmap.org Git - rails.git/commitdiff
Add some more social features
authorMikel Maron <mikel_maron@yahoo.com>
Fri, 6 Jan 2012 21:25:09 +0000 (16:25 -0500)
committerTom Hughes <tom@compton.nu>
Sat, 7 Jan 2012 11:54:07 +0000 (11:54 +0000)
Add a view showing changesets by nearby users, and views showing
diary entries by friends and nearby users.

app/controllers/changeset_controller.rb
app/controllers/diary_entry_controller.rb
app/views/user/view.html.erb
config/locales/en.yml
config/routes.rb

index b736e332b04431d3e6e0cc1cb76484c406fd313f..495fcee975a276a885382a231de9e7fef840b38b 100644 (file)
@@ -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
index 0444f5a89d7b269299fb2ae9fa51702be052a0e6..5e4b68b73e15b0d3b961b7173695fea50c5dc201 100644 (file)
@@ -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,
index c13a276f7dc57afb909a90a3bed2e0c7bdc0d811..bd3a371aaac9ca5dd9fb305236c9da00c3a9ded0 100644 (file)
   <% if friends.empty? %>
     <%= t 'user.view.no friends' %>
   <% else %>
-               <%= link_to t('user.view.friends_changesets'), {:controller => 'browse', :action => 'friends'} %><br/><br/>
+    <%= link_to t('user.view.friends_changesets'), {:controller => 'browse', :action => 'friends'} %><br/>
+    <%= link_to t('user.view.friends_diaries'), {:controller => 'diary', :action => 'friends'} %><br/><br/>
     <table id="friends">
       <%= render :partial => "contact", :collection => friends %>
     </table>
   <% if nearby.empty? %>
     <%= t 'user.view.no nearby users' %>
   <% else %>
+    <%= link_to t('user.view.nearby_changesets'), {:controller => 'browse', :action => 'nearby'} %><br/>
+    <%= link_to t('user.view.nearby_diaries'), {:controller => 'diary', :action => 'nearby'} %><br/><br/>
     <table id="nearbyusers">
       <%= render :partial => "contact", :collection => nearby %>
     </table>
index e9685ab49ea72b0a4d31e078826b8adfb0312b6d..0347d6fd70262e350631f72fdb5b51da464e0740 100644 (file)
@@ -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"
index a60caeb2f087937d946186f8575fec98446df56f..fa7dd5ba04faca6ec0406a0c1fb6c04d5945c7bc 100644 (file)
@@ -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