From: Tom Hughes Date: Fri, 7 May 2010 21:23:20 +0000 (+0100) Subject: Merge branch 'master' into terms X-Git-Tag: live~6387^2~7 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/303e5d3eb99284ab4fa41be85f831333f2154b0d?hp=--cc Merge branch 'master' into terms Conflicts: config/application.yml lib/osm.rb public/stylesheets/common.css --- 303e5d3eb99284ab4fa41be85f831333f2154b0d diff --cc app/controllers/user_controller.rb index 43a6db790,222840a06..8fdb89b22 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@@ -16,24 -16,8 +16,24 @@@ class UserController < ApplicationContr filter_parameter_logging :password, :pass_crypt, :pass_crypt_confirmation - cache_sweeper :user_sweeper, :only => [:account, :hide, :unhide, :delete] + cache_sweeper :user_sweeper, :only => [:account, :set_status, :delete] + def terms + @title = t 'user.new.title' + @user = User.new(params[:user]) + + @legale = params[:legale] || OSM.IPToCountry(request.remote_ip) || APP_CONFIG['default_legale'] + @text = OSM.legal_text_for_country(@legale) + + if request.xhr? + render :update do |page| + page.replace_html "contributorTerms", :partial => "terms" + end + elsif @user.invalid? + render :action => 'new' + end + end + def save @title = t 'user.new.title' diff --cc config/application.yml index 7b2c603f0,a1fbd887a..d40570965 --- a/config/application.yml +++ b/config/application.yml @@@ -22,8 -22,8 +22,10 @@@ standard_settings: &standard_setting # Quova authentication details #quova_username: "" #quova_password: "" + # Spam threshold + spam_threshold: 50 + # Default legale (jurisdiction location) for contributor terms + default_legale: GB development: <<: *standard_settings diff --cc lib/osm.rb index b5f3cb1aa,46b904477..c92655aee --- a/lib/osm.rb +++ b/lib/osm.rb @@@ -508,10 -499,24 +509,30 @@@ module OS return "#{tilesql} AND #{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 ++ + def self.legal_text_for_country(country_code) + file_name = File.join(RAILS_ROOT, "config", "legales", country_code.to_s + ".yml") + file_name = File.join(RAILS_ROOT, "config", "legales", APP_CONFIG['default_legale'] + ".yml") unless File.exist? file_name + YAML::load_file(file_name) + end - end diff --cc public/stylesheets/common.css index 69bac58b5,73f0fb788..2590c2d5f --- a/public/stylesheets/common.css +++ b/public/stylesheets/common.css @@@ -562,47 -562,27 +562,68 @@@ hr color: gray; } + /* Rules for the user list */ + + #user_list { + width: 100%; + font-size: small; + } + + #user_list tr { + vertical-align: center; + } + + #user_list p { + margin-top: 0px; + margin-bottom: 0px; + } + + #user_list_actions { + float: right; + margin-top: 10px; + } + +/* Rules for the account confirmation page */ + +div#contributorTerms { + border: 1px solid black; + padding: 4px; + overflow: auto; + width: 80%; + height: 60%; +} + +div#contributorTerms p#first { + margin-top: 0px; +} + +div#contributorTerms p#last { + margin-bottom: 0px; +} + +div#contributorTerms ol { + margin-bottom: 0px; +} + +div#contributorTerms img { + display: block; + margin-left: auto; + margin-right: auto; + margin-top: 10%; +} + +form#termsForm { + width: 80%; +} + +form#termsForm div#buttons { + float: right; +} + +form#termsForm input#agree { + margin-left: 50px; +} + /* Rules for the account settings page */ #accountForm td {