From: Tom Hughes Date: Fri, 7 May 2010 21:29:09 +0000 (+0100) Subject: Merge branch 'master' into openstreetbugs X-Git-Tag: live~5163^2~214 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/160429e62d88810ec49ccc9c504edee675dca080?hp=-c Merge branch 'master' into openstreetbugs Conflicts: lib/osm.rb --- 160429e62d88810ec49ccc9c504edee675dca080 diff --combined config/environment.rb index 6158dfa8c,d8f9b2fc8..696a226e7 --- a/config/environment.rb +++ b/config/environment.rb @@@ -100,9 -100,8 +100,9 @@@ Rails::Initializer.run do |config config.active_record.schema_format = :sql # Activate observers that should always be running - # config.active_record.observers = :cacher, :garbage_collector + config.active_record.observers = :spam_observer # Make Active Record use UTC-base instead of local time config.active_record.default_timezone = :utc + end diff --combined config/locales/en.yml index 7e9046c4f,fbf8e7a04..8afaa9717 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@@ -262,17 -262,6 +262,17 @@@ en download_xml: "Download XML" view_history: "view history" edit: "edit" + bug: + open_title: "Unresolved issue: {{bug_name}}" + closed_title: "Resolved issue: {{bug_name}}" + created_at: "Created at:" + edited_at: "Edited at:" + closed_at: "Closed at:" + opened_by: "Opened by:" + description: "Description:" + comment_by: "Comment by: " + comment: "Comment:" + date: "Date:" changeset: changeset_paging_nav: showing_page: "Showing page {{page}}" @@@ -1500,6 -1489,7 +1500,7 @@@ lost password link: "Lost your password?" login_button: "Login" account not active: "Sorry, your account is not active yet.
Please click on the link in the account confirmation email to activate your account." + account suspended: Sorry, your account has been suspended due to suspicious activity.
Please contact the webmaster if you wish to discuss this. auth failure: "Sorry, could not log in with those details." logout: title: "Logout" @@@ -1560,6 -1550,8 +1561,8 @@@ ago: "({{time_in_words_ago}} ago)" email address: "Email address:" created from: "Created from:" + status: "Status:" + 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." @@@ -1584,6 -1576,7 +1587,7 @@@ create_block: "block this user" activate_user: "activate this user" deactivate_user: "deactivate this user" + confirm_user: "confirm this user" hide_user: "hide this user" unhide_user: "unhide this user" delete_user: "delete this user" @@@ -1651,6 -1644,30 +1655,30 @@@ not_a_friend: "{{name}} is not one of your friends." filter: not_an_administrator: "You need to be an administrator to perform that action." + list: + title: Users + heading: Users + showing: + one: Showing page {{page}} ({{first_item}} of {{items}}) + other: Showing page {{page}} ({{first_item}}-{{last_item}} of {{items}}) + summary: "{{name}} created from {{ip_address}} on {{date}}" + summary_no_ip: "{{name}} created on {{date}}" + confirm: Confirm Selected Users + hide: Hide Selected Users + empty: No matching users found + suspended: + title: Account Suspended + heading: Account Suspended + body: | +

+ Sorry, your account has been automatically suspended due to + suspicious activity. +

+

+ This decision will be reviewed by an administrator shortly, or + you may contact the webmaster if + you wish to discuss this. +

user_role: filter: not_an_administrator: "Only administrators can perform user role management, and you are not an administrator." @@@ -1758,20 -1775,6 +1786,20 @@@ back: "View all blocks" revoker: "Revoker:" needs_view: "The user needs to log in before this block will be cleared." + bugs: + rss: + description_area: "A list of bugs, reported, commented on or closed in your area [({{min_lat}}|{{min_lon}}) -- ({{max_lat}}|{{max_lon}})]" + description_item: "An rss feed for bug {{id}}" + closed: "closed bug (near {{place}})" + new: "new bug (near {{place}})" + comment: "new comment (near {{place}})" + user: + title_user: "Bugs submitted or commented on by {{user}}" + heading_user: "{{user}}'s bugs" + description_user: "Bugs submitted or commented on by {{user}}" + id: "Id" + last_changed: "Last changed" + javascripts: map: base: diff --combined config/routes.rb index d12bfbb5a,7e27ee19e..579662979 --- a/config/routes.rb +++ b/config/routes.rb @@@ -70,27 -70,6 +70,27 @@@ ActionController::Routing::Routes.draw map.connect "api/#{API_VERSION}/amf/read", :controller =>'amf', :action =>'amf_read' map.connect "api/#{API_VERSION}/amf/write", :controller =>'amf', :action =>'amf_write' map.connect "api/#{API_VERSION}/swf/trackpoints", :controller =>'swf', :action =>'trackpoints' + + # Map Bugs API + map.connect "api/#{API_VERSION}/bugs/getBugs", :controller =>'map_bugs', :action =>'get_bugs' + map.connect "api/#{API_VERSION}/bugs/addPOIexec", :controller =>'map_bugs', :action =>'add_bug' + map.connect "api/#{API_VERSION}/bugs/closePOIexec", :controller =>'map_bugs', :action =>'close_bug' + map.connect "api/#{API_VERSION}/bugs/editPOIexec", :controller =>'map_bugs', :action =>'edit_bug' + map.connect "api/#{API_VERSION}/bugs/getGPX", :controller =>'map_bugs', :action =>'gpx_bugs' + map.connect "api/#{API_VERSION}/bugs/getRSSfeed", :controller =>'map_bugs', :action =>'rss' + + map.connect "api/#{API_VERSION}/bugs", :controller => 'map_bugs', :action => 'get_bugs' + map.connect "api/#{API_VERSION}/bugs/search", :controller => 'map_bugs', :action => 'search' + map.connect "api/#{API_VERSION}/bugs/rss", :controller =>'map_bugs', :action =>'rss' + map.connect "api/#{API_VERSION}/bug/create", :controller => 'map_bugs', :action => 'add_bug' + map.connect "api/#{API_VERSION}/bug/:id/comment", :controller => 'map_bugs', :action => 'edit_bug', :id => /\d+/ + map.connect "api/#{API_VERSION}/bug/:id/close", :controller => 'map_bugs', :action => 'close_bug', :id => /\d+/ + map.connect "api/#{API_VERSION}/bug/:id", :controller => 'map_bugs', :action => 'read', :id => /\d+/, :conditions => { :method => :get } + map.connect "api/#{API_VERSION}/bug/:id", :controller => 'map_bugs', :action => 'delete', :id => /\d+/, :conditions => { :method => :delete } + + map.connect '/user/:display_name/bugs', :controller => 'map_bugs', :action => 'my_bugs' + + # Data browsing map.connect '/browse', :controller => 'changeset', :action => 'list' @@@ -104,7 -83,6 +104,7 @@@ map.changeset '/browse/changeset/:id', :controller => 'browse', :action => 'changeset', :id => /\d+/ map.connect '/browse/changesets', :controller => 'changeset', :action => 'list' map.connect '/browse/changesets/feed', :controller => 'changeset', :action => 'list', :format => :atom + map.connect '/browse/bug/:id', :controller => 'browse', :action => 'bug', :id => /\d+/ # web site map.root :controller => 'site', :action => 'index' @@@ -126,6 -104,7 +126,7 @@@ map.connect '/user/go_public', :controller => 'user', :action => 'go_public' map.connect '/user/reset-password', :controller => 'user', :action => 'reset_password' map.connect '/user/forgot-password', :controller => 'user', :action => 'lost_password' + map.connect '/user/suspended', :controller => 'user', :action => 'suspended' map.connect '/index.html', :controller => 'site', :action => 'index' map.connect '/edit.html', :controller => 'site', :action => 'edit' @@@ -180,10 -159,7 +181,7 @@@ map.connect '/user/:display_name/diary/:id/hide', :controller => 'diary_entry', :action => 'hide', :id => /\d+/ map.connect '/user/:display_name/diary/:id/hidecomment/:comment', :controller => 'diary_entry', :action => 'hidecomment', :id => /\d+/, :comment => /\d+/ map.connect '/user/:display_name/account', :controller => 'user', :action => 'account' - map.connect '/user/:display_name/activate', :controller => 'user', :action => 'activate' - map.connect '/user/:display_name/deactivate', :controller => 'user', :action => 'deactivate' - map.connect '/user/:display_name/hide', :controller => 'user', :action => 'hide' - map.connect '/user/:display_name/unhide', :controller => 'user', :action => 'unhide' + map.connect '/user/:display_name/set_status', :controller => 'user', :action => 'set_status' map.connect '/user/:display_name/delete', :controller => 'user', :action => 'delete' map.connect '/diary/new', :controller => 'diary_entry', :action => 'new' map.connect '/diary', :controller => 'diary_entry', :action => 'list' @@@ -191,7 -167,10 +189,10 @@@ map.connect '/diary/:language', :controller => 'diary_entry', :action => 'list' map.connect '/diary/:language/rss', :controller => 'diary_entry', :action => 'rss' - + # user lists + map.connect '/users', :controller => 'user', :action => 'list' + map.connect '/users/:status', :controller => 'user', :action => 'list' + # test pages map.connect '/test/populate/:table/:from/:count', :controller => 'test', :action => 'populate' map.connect '/test/populate/:table/:count', :controller => 'test', :action => 'populate', :from => 1 diff --combined lib/osm.rb index 1358c993a,46b904477..2a1ca089e --- a/lib/osm.rb +++ b/lib/osm.rb @@@ -7,6 -7,7 +7,7 @@@ module OS require 'xml/libxml' require 'digest/md5' require 'RMagick' + require 'nokogiri' # The base class for API Errors. class APIError < RuntimeError @@@ -489,7 -490,7 +490,7 @@@ # Return an SQL fragment to select a given area of the globe def self.sql_for_area(minlat, minlon, maxlat, maxlon, prefix = nil) - tilesql = QuadTile.sql_for_area(minlat, minlon, maxlat, maxlon, prefix) + tilesql = QuadTile.sql_for_area(minlat, minlon, maxlat, maxlon, prefix) minlat = (minlat * 10000000).round minlon = (minlon * 10000000).round maxlat = (maxlat * 10000000).round @@@ -498,15 -499,24 +499,34 @@@ return "#{tilesql} AND #{prefix}latitude BETWEEN #{minlat} AND #{maxlat} AND #{prefix}longitude BETWEEN #{minlon} AND #{maxlon}" end + # Return an SQL fragment to select a given area of the globe without using the quadtile index + def self.sql_for_area_no_quadtile(minlat, minlon, maxlat, maxlon, prefix = nil, without_quadtile = :false) + minlat = (minlat * 10000000).round + minlon = (minlon * 10000000).round + maxlat = (maxlat * 10000000).round + maxlon = (maxlon * 10000000).round + + return "#{prefix}latitude BETWEEN #{minlat} AND #{maxlat} AND #{prefix}longitude BETWEEN #{minlon} AND #{maxlon}" + end + + # Return a spam score for a chunk of text + def self.spam_score(text) + link_count = 0 + link_size = 0 + doc = Nokogiri::HTML(text) + + if doc.content.length > 0 + doc.xpath("//a").each do |link| + link_count += 1 + link_size += link.content.length + end + + link_proportion = link_size.to_f / doc.content.length.to_f + else + link_proportion = 0 + end + + return [link_proportion - 0.2, 0.0].max * 200 + link_count * 20 + end end