diff --git a/app/assets/images/icons/map_edit.png b/app/assets/images/icons/map_edit.png new file mode 100755 index 0000000000..93d4d7e5ff Binary files /dev/null and b/app/assets/images/icons/map_edit.png differ diff --git a/app/assets/images/icons/page.png b/app/assets/images/icons/page.png new file mode 100755 index 0000000000..03ddd799fa Binary files /dev/null and b/app/assets/images/icons/page.png differ diff --git a/app/assets/images/icons/page_add.png b/app/assets/images/icons/page_add.png new file mode 100755 index 0000000000..d5bfa0719b Binary files /dev/null and b/app/assets/images/icons/page_add.png differ diff --git a/app/assets/stylesheets/common.css.scss b/app/assets/stylesheets/common.css.scss index 294d648c2a..af5f67ba01 100644 --- a/app/assets/stylesheets/common.css.scss +++ b/app/assets/stylesheets/common.css.scss @@ -335,6 +335,49 @@ h2 { top: 15px; } +/* Rules for User profile page */ +#usermap { + width: 50%; + float: right; +} +.sidebar_section { + margin-top: 10px; + border-top: 1px solid #BBB; + padding-top: 10px; +} +#user_info { + width: 50%; + float: left; +} + +li.activity, .vcard { + list-style-type: none; + margin-bottom: 4px; + padding: 3px; +} + +li.activity { + padding: 0 0 5px 0; + overflow: hidden; + position: relative; +} +.activity_body { + border-bottom: 1px solid #CCC; + overflow: hidden; + padding: 0 0 5px 0; +} +.activity_image, .profile_image { + float: left; + padding-right: 5px +} +.activity_info { + padding: 5px 0 0 0; +} +ul#activities_list, ul#friends { + padding: 0; + margin: 0; +} + /* Rules for OpenLayers maps */ #map { @@ -760,13 +803,14 @@ table.browse_details th { -moz-border-radius: 15px; } -#login_login { +#login_wrapper div#login_login { background-color: #f5f5ff; border: 1px solid #f3f3ff; border-radius: 15px; -moz-border-radius: 15px; } + #login_login h1 { margin-top: 5px; } @@ -849,9 +893,7 @@ p#contributorGuidance { #accountForm .user_map { position: relative; - width: 500px; - height: 400px; - border: 1px solid #ccc; + height: 300px; } #accountImage td { @@ -877,18 +919,13 @@ p#contributorGuidance { /* Rules for the user view */ .user_view .user_map { - position: relative; - width: 400px; - height: 400px; - border: 1px solid #ccc; + height: 300px; } .user_view .user_map p#no_home_location { - position: absolute; top: 0px; bottom: 0px; width: 90%; - height: 30%; margin: auto 5% } @@ -1124,3 +1161,11 @@ abbr.geo { } } } + +.addendum { + font-weight:normal; + vertical-align:middle; + padding:0 10px; + font-size:11px; + color:#888; +} diff --git a/app/assets/stylesheets/ltr.css.scss b/app/assets/stylesheets/ltr.css.scss index bbfebdbc1f..53d7f476ed 100644 --- a/app/assets/stylesheets/ltr.css.scss +++ b/app/assets/stylesheets/ltr.css.scss @@ -191,7 +191,6 @@ form#termsForm input#agree { } .user_view .user_map { - float: right; } /* Rules for rails validation error boxes */ diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index bccd5d5cb4..e1b0765614 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -14,7 +14,7 @@ class UserController < ApplicationController before_filter :require_allow_read_gpx, :only => [:api_gpx_files] before_filter :require_cookies, :only => [:login, :confirm] before_filter :require_administrator, :only => [:set_status, :delete, :list] - before_filter :lookup_this_user, :only => [:set_status, :delete] + before_filter :lookup_this_user, :only => [:set_status, :delete, :users] cache_sweeper :user_sweeper, :only => [:account, :set_status, :delete] @@ -394,6 +394,15 @@ def view else render_unknown_user params[:display_name] end + respond_to do |format| + format.html {} + format.json { render :json => @this_user.to_json, :content_type => "application/json", :status => 200 } + end + end + + # Get a list of nearby users that can become friends + def users + @this_user = User.find_by_display_name(params[:display_name]) end def make_friend diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 37dcf90e09..ed1e0c39dc 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -101,6 +101,16 @@ def user_image(user, options = {}) image_tag user.image.url(:large), options end + def user_image_url(user, options = {}) + options[:class] ||= "user_image" + + if user.image + image_path user.image.url(:large) + else + image_path "anon_large.png" + end + end + def user_thumbnail(user, options = {}) options[:class] ||= "user_thumbnail" diff --git a/app/helpers/user_helper.rb b/app/helpers/user_helper.rb index acaecff48f..eb09d144d9 100644 --- a/app/helpers/user_helper.rb +++ b/app/helpers/user_helper.rb @@ -1,4 +1,11 @@ module UserHelper + + # Returns true if this_user (or @this_user) is the currently logged_in user + def current_user(this_user = nil) + this_user ||= @this_user + @user && this_user.id == @user.id + end + def openid_logo image_tag "openid_small.png", :alt => t('user.login.openid_logo_alt'), :class => "openid_logo" end @@ -11,4 +18,14 @@ def openid_button(name, url) :title => t("user.login.openid_providers.#{name}.title") ) end + + def contribution_terms_status(user) + if not @this_user.terms_agreed.nil? + return t 'user.view.ct accepted', :ago =>time_ago_in_words(@this_user.terms_agreed) + elsif not @this_user.terms_seen? + return t 'user.view.ct undecided' + else + return t 'user.view.ct declined' + end + end end diff --git a/app/models/changeset.rb b/app/models/changeset.rb index b76d0c5a7e..30e36d4b19 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -52,6 +52,37 @@ def set_closed_time_now end end + # Determines the best 'summary' of the changeset, either from comments or automatically + def summary + unless (self.tags['comment'].nil?) + return self.tags['comment'].nil? + else + "#{self.num_changes} modifications made in this changeset." + end + end + + def activity_actor + return self.user + end + + # Returns a list of nodes that represent city/town/village that is nearby the center of changeset's bounding box. + def related_places(radius = 5) + bb = self.bbox.to_unscaled + + gc = OSM::GreatCircle.new(bb.centre_lat, bb.centre_lon) + sql_for_distance = gc.sql_for_distance_scaled('latitude', 'longitude') + + sql=<<-EOF + SELECT n.*, #{sql_for_distance} AS distance + FROM current_nodes n + INNER JOIN current_node_tags tag_place ON (tag_place.node_id = n.id AND tag_place.k = 'place' AND tag_place.v IN ('city', 'village', 'town')) + WHERE n.visible=TRUE AND + #{sql_for_distance} < #{radius} + ORDER BY distance + EOF + return Node.find_by_sql(sql) + end + def self.from_xml(xml, create=false) begin p = XML::Parser.string(xml, :options => XML::Parser::Options::NOERROR) diff --git a/app/models/diary_entry.rb b/app/models/diary_entry.rb index 64a412d28c..60fbf9e025 100644 --- a/app/models/diary_entry.rb +++ b/app/models/diary_entry.rb @@ -1,4 +1,8 @@ class DiaryEntry < ActiveRecord::Base + # including for #truncate. Makes a similar API for diaries & changesets. + include ActionView::Helpers::TextHelper + + belongs_to :user belongs_to :language, :foreign_key => 'language_code' @@ -37,4 +41,9 @@ def body def set_defaults self.body_format = "markdown" unless self.attribute_present?(:body_format) end + + # Determines the best 'summary' of the diary + def summary + truncate(self.body, :length => 50) + end end diff --git a/app/models/user.rb b/app/models/user.rb index 636f834243..127290762d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,6 +1,7 @@ class User < ActiveRecord::Base require 'xml/libxml' + has_many :traces, :conditions => { :visible => true } has_many :diary_entries, :order => 'created_at DESC' has_many :diary_comments, :order => 'created_at DESC' @@ -133,6 +134,11 @@ def nearby(radius = NEARBY_RADIUS, num = NEARBY_USERS) return nearby end + # Returns array of users who could be your friends but aren't yet + def nearby_nonfriends(radius = NEARBY_RADIUS, num = NEARBY_USERS) + return self.nearby(radius,num) - self.friend_users + end + def distance(nearby_user) return OSM::GreatCircle.new(self.home_lat, self.home_lon).distance(nearby_user.home_lat, nearby_user.home_lon) end @@ -222,6 +228,40 @@ def access_token(application_key) return ClientApplication.find_by_key(application_key).access_token_for_user(self) end + +public + + # Helpers for outputting only public data via JSON + cattr_accessor :public_fields + @@public_fields = [:id, :display_name] + + alias_method :ar_to_json, :to_json + + def to_json(options = {}) + options[:only] = @@public_fields + options[:methods] = [:terms_agreed, :terms_seen, :statistics] + ar_to_json(options) + end + + # Returns a hash of statistics. + # Currently this is limited, will extend for usage history. + def statistics + { + :changesets => self.changesets.count, + :friends => self.friends.count + } + end + + def recent_changesets(limit = 5) + self.changesets.includes(:changeset_tags).limit(limit) + end + + def recent_activities(limit = 10) + nearby_changesets = [] + self.nearby.each {|user| nearby_changesets += user.recent_changesets.to_a} + (self.recent_changesets + self.diary_entries + nearby_changesets).sort {|a,b| b.created_at <=> a.created_at}[0..limit - 1] + end + private def set_defaults diff --git a/app/views/changeset/_changesets.html.erb b/app/views/changeset/_changesets.html.erb index 2bd40dafc3..0ce65a3c76 100644 --- a/app/views/changeset/_changesets.html.erb +++ b/app/views/changeset/_changesets.html.erb @@ -1,4 +1,4 @@ <% showusername = true if showusername.nil? %> - <%= render :partial => 'changeset', :locals => {:showusername => showusername}, :collection => @edits unless @edits.nil? %> + <%= render :partial => 'changeset/changeset', :locals => {:showusername => showusername}, :collection => @edits unless @edits.nil? %>
diff --git a/app/views/diary_entry/_diary_entry.html.erb b/app/views/diary_entry/_diary_entry.html.erb index eae60e8221..8a48ca3599 100644 --- a/app/views/diary_entry/_diary_entry.html.erb +++ b/app/views/diary_entry/_diary_entry.html.erb @@ -1,11 +1,11 @@ -<%= link_to h(diary_entry.title), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id %>
+

<%= link_to h(diary_entry.title), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id %>

<%= diary_entry.body.to_html %>
<% if diary_entry.latitude and diary_entry.longitude %> - <%= render :partial => "location", :object => diary_entry %> + <%= render :partial => "diary_entry/location", :object => diary_entry %>
<% end %> diff --git a/app/views/user/_activities.html.erb b/app/views/user/_activities.html.erb new file mode 100644 index 0000000000..76b1bf005c --- /dev/null +++ b/app/views/user/_activities.html.erb @@ -0,0 +1,6 @@ + + diff --git a/app/views/user/_activity_changeset.html.erb b/app/views/user/_activity_changeset.html.erb new file mode 100644 index 0000000000..a90a1bdca7 --- /dev/null +++ b/app/views/user/_activity_changeset.html.erb @@ -0,0 +1,30 @@ +<%- activity_link = {:controller => 'browse', :action => 'changeset', :id => activity.id } %> + +
+ + <%= image_tag("icons/map_edit.png") %> + <% if @user == activity.activity_actor %> + You + <% else %> + <%= link_to activity.activity_actor.display_name, {:controller => 'user', :action => 'view', :display_name => activity.activity_actor.display_name} %> + <% end %> + made + <%= link_to linkify(activity.num_changes.to_s) + ' changes', activity_link %> + <% if ! activity.related_places.empty? %> + near <%= link_to activity.related_places[0].tags['name'], {:controller => 'browse', :action => 'node', :id => activity.related_places[0].id} %> + <% end %> + + +
+ + <% if activity.closed_at > DateTime.now -%> + <%= t'changeset.changeset.still_editing' %> + <% else -%> + <%= t('user.view.ago', :time_in_words_ago => time_ago_in_words(activity.closed_at)) %> + <% end -%> + <% if activity.bbox %>| + <%= link_to "show map", :controller => "site", :action => "index", :minlon => activity.bbox.min_lon, :minlat => activity.bbox.min_lat, :maxlon => activity.bbox.max_lon, :maxlat => activity.bbox.max_lat, :box => "yes" %> + <% end %> + +
+
diff --git a/app/views/user/_activity_diaryentry.html.erb b/app/views/user/_activity_diaryentry.html.erb new file mode 100644 index 0000000000..4db18d5a54 --- /dev/null +++ b/app/views/user/_activity_diaryentry.html.erb @@ -0,0 +1,9 @@ +
+ <%- activity_link = {:controller => 'diary_entry', :action => 'view', + :display_name => activity.user.display_name, :id => activity.id} -%> + <%= link_to image_tag("icons/page.png", :class => "activity_image") + activity.title, activity_link %>
+ <%= activity.summary %> + + <%= link_to t('user.view.ago', :time_in_words_ago => time_ago_in_words(activity.created_at)), activity_link %> + +
diff --git a/app/views/user/_contact.html.erb b/app/views/user/_contact.html.erb index 9bac0dc2d6..c2bfdb4b59 100644 --- a/app/views/user/_contact.html.erb +++ b/app/views/user/_contact.html.erb @@ -1,35 +1,41 @@ - - - <%= user_thumbnail contact %> - - - <%= link_to h(contact.display_name), :controller => 'user', :action => 'view', :display_name => contact.display_name %> +
  • + <%= user_thumbnail contact, :class => "profile_image" %> + +
    + <%= link_to h(contact.display_name), :controller => 'user', :action => 'view', :display_name => contact.display_name, :class => "fn" %> <% if @this_user.home_lon and @this_user.home_lat and contact.home_lon and contact.home_lat %> + <% distance = @this_user.distance(contact) %> <% if distance < 1 %> (<%= t 'user.view.m away', :count => (distance * 1000).round %>) <% else %> (<%= t 'user.view.km away', :count => distance.round %>) <% end %> - <% end %> - - - - + + <% end %> +
    <% changeset = contact.changesets.first %> <% if changeset %> - <%= t('user.view.latest edit', :ago => t('user.view.ago', :time_in_words_ago => time_ago_in_words(changeset.created_at))) %> + <% comment = changeset.tags['comment'].to_s != '' ? changeset.tags['comment'] : t('changeset.changeset.no_comment') %> + "<%= link_to(comment, {:controller => 'browse', :action => 'changeset', :id => changeset.id}, {:title => t('changeset.changeset.view_changeset_details')}) %>" + <%= t('user.view.ago', :time_in_words_ago => time_ago_in_words(changeset.created_at)) %> <% else %> <%= t'changeset.changeset.no_edits' %> <% end %> - - - + + <% diary = contact.diary_entries.first %> + <% if diary %> +
    + <%= link_to(diary.title, {:controller => 'diary_entry', :action => 'view', :id => diary.id}) %> + <%= t('user.view.ago', :time_in_words_ago => time_ago_in_words(diary.created_at)) %> + <% end %> + +
    <%= link_to t('user.view.send message'), :controller => 'message', :action => 'new', :display_name => contact.display_name %> | <% if @user.is_friends_with?(contact) %> @@ -37,5 +43,5 @@ <% else %> <%= link_to t('user.view.add as friend'), :controller => 'user', :action => 'make_friend', :display_name => contact.display_name, :referer => request.fullpath %> <% end %> - - +
    +
  • \ No newline at end of file diff --git a/app/views/user/_map.html.erb b/app/views/user/_map.html.erb index 2d886527cc..74790b577a 100644 --- a/app/views/user/_map.html.erb +++ b/app/views/user/_map.html.erb @@ -38,7 +38,7 @@ end marker = addMarkerToMap( new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>) <% if not setting_location %> - , null, '<%=escape_javascript(render(:partial => "popup", :object => @user, :locals => { :type => "your location" })) %>' + , new OpenLayers.Icon("<%= user_image_url(@user) %>", {x: 100, y:100}, {x:-50,y:-50}) , '<%=escape_javascript(render(:partial => "popup", :object => @user, :locals => { :type => "your location" })) %>' <% end %> ); <% end %> diff --git a/app/views/user/account.html.erb b/app/views/user/account.html.erb index 4889664911..c9e3987b4b 100644 --- a/app/views/user/account.html.erb +++ b/app/views/user/account.html.erb @@ -1,4 +1,6 @@ -

    <%= t 'user.account.my settings' %>

    +

    <%= t 'user.account.my settings' %> + <%= link_to t('user.view.oauth settings'), :controller => 'oauth_clients', :action => 'index' %> +

    <%= error_messages_for 'user' %> <%= form_for :user, :html => { :multipart => true } do |f| %> diff --git a/app/views/user/users.html.erb b/app/views/user/users.html.erb new file mode 100644 index 0000000000..93a5087267 --- /dev/null +++ b/app/views/user/users.html.erb @@ -0,0 +1,11 @@ +

    <%= t 'user.view.nearby users' %>

    + <%- nearby = @user.nearby_nonfriends -%> + <% 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'} %>

    + + <% end %> diff --git a/app/views/user/view.html.erb b/app/views/user/view.html.erb index e8034510be..117b843add 100644 --- a/app/views/user/view.html.erb +++ b/app/views/user/view.html.erb @@ -1,131 +1,133 @@ -<%= user_image @this_user %> +<% friends = @this_user.friends.collect { |f| f.befriendee } %> +<% nearby = @this_user.nearby - friends %> -

    <%= @this_user.display_name %><%= role_icons(@this_user) %>

    +
    +
    +

    <%= user_thumbnail @this_user, :class => "profile_image" %> + <%= h(@this_user.display_name) %><%= role_icons(@this_user) %> + + <%= link_to t('user.view.my settings'), :controller => 'user', :action => 'account', :display_name => @user.display_name if current_user %> + + <%- if current_user -%> + | <%= link_to t('diary_entry.list.title_friends', :count => friends.count), {:as => 'friend_changesets'} %> + <%- end -%> + + | <%= link_to t('user.view.block_history'), :controller => 'user_blocks', :action => 'blocks_on', :display_name => @this_user.display_name %> + <% if @user and @user.moderator? %> + | <%= link_to t('user.view.blocks by me'), :controller => 'user_blocks', :action => 'blocks_by', :display_name => @user.display_name %> + <% end %> +
    + <%= @this_user.changesets.count %> <%= link_to t('user.view.edits'), :controller => 'changeset', :action => 'list', :display_name => @this_user.display_name %> + <% if friends.empty? && @user && @this_user.id == @user %> + | <%= t 'user.view.no friends' %> + <% else %> + | <%= friends.count %> <%= current_user ? link_to( t('user.popup.friend', :count => friends.count).downcase, {:as => 'friend_changesets'}) : t('user.popup.friend', :count => friends.count).downcase %> + <% end %> + | joined <%= t('user.view.ago', :time_in_words_ago => time_ago_in_words(@this_user.creation_time)) %> | + <%= contribution_terms_status(@this_user) %>
    +
    +

    + +
    <%= @this_user.description %>
    -
    - <% if @user and @this_user.id == @user.id %> - <%= link_to t('user.view.my diary'), :controller => 'diary_entry', :action => 'list', :display_name => @user.display_name %> - | - <%= link_to t('user.view.new diary entry'), :controller => 'diary_entry', :action => 'new' %> - | - <%= link_to t('user.view.my comments' ), :controller => 'diary_entry', :action => 'comments', :display_name => @this_user.display_name %> - | - <%= link_to t('user.view.my edits'), :controller => 'changeset', :action => 'list', :display_name => @user.display_name %> - | - <%= link_to t('user.view.my traces'), :controller => 'trace', :action=>'mine' %> - | - <%= link_to t('user.view.my settings'), :controller => 'user', :action => 'account', :display_name => @user.display_name %> - | - <%= link_to t('user.view.oauth settings'), :controller => 'oauth_clients', :action => 'index' %> - | - <%= link_to t('user.view.blocks on me'), :controller => 'user_blocks', :action => 'blocks_on', :display_name => @user.display_name %> - <% if @user and @user.moderator? %> - | <%= link_to t('user.view.blocks by me'), :controller => 'user_blocks', :action => 'blocks_by', :display_name => @user.display_name %> - <% end %> - <% else %> +
    <%= link_to image_tag("icons/page_add.png") + " " + t('user.view.new diary entry'), :controller => 'diary_entry', :action => 'new', :display_name => @user.display_name if current_user %>
    + + <% if @user && !current_user %> - <%= link_to t('user.view.send message'), :controller => 'message', :action => 'new', :display_name => @this_user.display_name %> - | - <%= link_to t('user.view.diary'), :controller => 'diary_entry', :action => 'list', :display_name => @this_user.display_name %> - | - <%= link_to t('user.view.comments'), :controller => 'diary_entry', :action => 'comments', :display_name => @this_user.display_name %> - | - <%= link_to t('user.view.edits'), :controller => 'changeset', :action => 'list', :display_name => @this_user.display_name %> - | - <%= link_to t('user.view.traces'), :controller => 'trace', :action => 'list', :display_name => @this_user.display_name %> - | +
    <%= link_to t('user.view.send message'), :controller => 'message', :action => 'new', :display_name => @this_user.display_name %> + <% if @user and @user.is_friends_with?(@this_user) %> <%= link_to t('user.view.remove as friend'), :controller => 'user', :action => 'remove_friend', :display_name => @this_user.display_name %> <% else %> <%= link_to t('user.view.add as friend'), :controller => 'user', :action => 'make_friend', :display_name => @this_user.display_name %> <% end %> - | - <%= link_to t('user.view.block_history'), :controller => 'user_blocks', :action => 'blocks_on', :display_name => @this_user.display_name %> + <% if @this_user.moderator? %> - | <%= link_to t('user.view.moderator_history'), :controller => 'user_blocks', :action => 'blocks_by', :display_name => @this_user.display_name %> +
    <%= link_to t('user.view.moderator_history'), :controller => 'user_blocks', :action => 'blocks_by', :display_name => @this_user.display_name %> <% end %> <% if @user and @user.moderator? %> - | <%= link_to t('user.view.create_block'), :controller => 'user_blocks', :action => 'new', :display_name => @this_user.display_name %> +
    <%= link_to t('user.view.create_block'), :controller => 'user_blocks', :action => 'new', :display_name => @this_user.display_name %> <% end %> - <% end %> - <% if @user and @user.administrator? %> -
    + <% end %> +
    + + <% if @user and @user.administrator? && !current_user -%> + - -

    <%= t 'user.view.mapper since' %> <%= l @this_user.creation_time, :format => :friendly %> <%= t 'user.view.ago', :time_in_words_ago => time_ago_in_words(@this_user.creation_time) %>

    - -

    <%= t 'user.view.ct status' %> -<% if not @this_user.terms_agreed.nil? -%> -<%= t 'user.view.ct accepted', :ago =>time_ago_in_words(@this_user.terms_agreed) %> -<% elsif not @this_user.terms_seen? -%> -<%= t 'user.view.ct undecided' %> -<% else -%> -<%= t 'user.view.ct declined' %> -<% end -%> -

    - -<% if @user and @user.administrator? -%> -

    <%= t 'user.view.email address' %> <%= @this_user.email %>

    - <% unless @this_user.creation_ip.nil? -%> -

    <%= t 'user.view.created from' %> <%= @this_user.creation_ip %>

    +
    <%= link_to t('user.view.delete_user'), {:controller => 'user', :action => 'delete', :display_name => @this_user.display_name}, {:confirm => t('user.view.confirm')} %> +
    <% end -%> -

    <%= t 'user.view.status' %> <%= @this_user.status.capitalize %>

    -

    <%= t 'user.view.spam score' %> <%= @this_user.spam_score %>

    -<% end -%> -

    <%= t 'user.view.description' %>

    +

    Recent Activity <%= atom_link_to params.merge({ :page => nil, :action => :feed, :controller => :changeset }) %>

    + + <%= render :partial => "user/activities", :locals => {:activities => @this_user.recent_activities } %> + + <%- if current_user && @this_user.recent_activities.blank? -%> + <%= raw(word_wrap( t('user.view.start editing'), :line_width => 20)) %>
    +
    + <%- end -%> -
    <%= @this_user.description.to_html %>
    + more <%= link_to t('user.view.edits'), :controller => 'changeset', :action => 'list', :display_name => @this_user.display_name %> + <%- unless @this_user.traces.count == 0 -%> + | <%= link_to( t('user.view.traces'), :controller => 'trace', :action => 'list', :display_name => @this_user.display_name) %> + <%- end -%> + <%- unless @this_user.diary_entries.count == 0 -%> + | <%= link_to( t('user.view.diary'), :controller => 'diary_entry', :action => 'list', :display_name => @this_user.display_name) %> + <%- end -%> + +
    -<% if @user and @this_user.id == @user.id %> -
    +
    + <% if current_user %> +
    "> <% if @this_user.home_lat.nil? or @this_user.home_lon.nil? %> -

    <%= raw(t 'user.view.if set location', :settings_link => (link_to t('user.view.settings_link_text'), :controller => 'user', :action => 'account', :display_name => @user.display_name)) %>

    +

    <%= raw(t 'user.view.if set location', :settings_link => (link_to t('user.view.settings_link_text'), :controller => 'user', :action => 'account', :display_name => @this_user.display_name)) %>

    <% else %> - <%= render :partial => 'map', :locals => { :setting_location => false, :show_other_users => true } %> + <%= render :partial => 'map', :locals => { + :setting_location => false, + :show_other_users => true + } %> <% end %>
    - - <% friends = @this_user.friends.collect { |f| f.befriendee } %> - <% nearby = @this_user.nearby - friends %> - -

    <%= t 'user.view.your friends' %>

    - - <% if friends.empty? %> - <%= t 'user.view.no friends' %> - <% else %> - <%= link_to t('user.view.friends_changesets'), friend_changesets_path %>
    - <%= link_to t('user.view.friends_diaries'), friend_diaries_path %>

    -
    - <%= render :partial => "contact", :collection => friends %> -
    <% end %> + +

    <%= t 'user.view.nearby users' %>

    <% if nearby.empty? %> <%= t 'user.view.no nearby users' %> <% else %> - <%= link_to t('user.view.nearby_changesets'), nearby_changesets_path %>
    - <%= link_to t('user.view.nearby_diaries'), nearby_diaries_path %>

    <%= render :partial => "contact", :collection => nearby %>
    <% end %> -<% end %> + diff --git a/config/locales/en.yml b/config/locales/en.yml index e1f7f416a0..687068860e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1731,11 +1731,11 @@ en: remove as friend: remove as friend add as friend: add as friend mapper since: "Mapper since:" - ago: "(%{time_in_words_ago} ago)" + ago: "%{time_in_words_ago} ago" ct status: "Contributor terms:" - ct undecided: Undecided - ct declined: Declined - ct accepted: Accepted %{ago} ago + ct undecided: Undecided on CT + ct declined: Declined CT + ct accepted: Accepted CT %{ago} ago latest edit: "Latest edit %{ago}:" email address: "Email address:" created from: "Created from:" @@ -1743,10 +1743,12 @@ en: spam score: "Spam Score:" description: Description user location: User location - if set location: "If you set your location, a pretty map and stuff will appear here. You can set your home location on your %{settings_link} page." + start editing: "You have not yet edited OpenStreetMap. You can read the beginner's guide to learn how to start mapping." + if set location: "If you set your location, a pretty map and stuff will appear here.
    You can set your home location on your %{settings_link} page." settings_link_text: settings your friends: Your friends no friends: You have not added any friends yet. + find friends: Find friends km away: "%{count}km away" m away: "%{count}m away" nearby users: "Other nearby users" diff --git a/config/routes.rb b/config/routes.rb index 6b81645378..3163ddf78c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -94,6 +94,7 @@ match '/browse/changesets' => 'changeset#list', :via => :get match '/browse/changesets/feed' => 'changeset#feed', :via => :get, :format => :atom match '/browse' => 'changeset#list', :via => :get + match '/browse/users' => 'user#users', :nearby => true # web site root :to => 'site#index', :via => [:get, :post] diff --git a/lib/osm.rb b/lib/osm.rb index 8902e6c9e2..3cb346033a 100644 --- a/lib/osm.rb +++ b/lib/osm.rb @@ -365,6 +365,11 @@ def bounds(radius) def sql_for_distance(lat_field, lon_field) "6372.795 * 2 * asin(sqrt(power(sin((radians(#{lat_field}) - #{@lat}) / 2), 2) + cos(#{@lat}) * cos(radians(#{lat_field})) * power(sin((radians(#{lon_field}) - #{@lon})/2), 2)))" end + + # get the SQL to use to calculate distance (assumes that lat_field and lon_field contain scaled integers) + def sql_for_distance_scaled(lat_field, lon_field) + "6372.795 * 2 * asin(sqrt(power(sin((radians(#{lat_field} / #{GeoRecord::SCALE}.0) - #{@lat}) / 2), 2) + cos(#{@lat}) * cos(radians(#{lat_field} / #{GeoRecord::SCALE}.0)) * power(sin((radians(#{lon_field} / #{GeoRecord::SCALE}.0) - #{@lon})/2), 2)))" + end end class GeoRSS