From: Tom Hughes Date: Thu, 10 Feb 2011 14:10:19 +0000 (+0000) Subject: Merge branch 'master' into openid X-Git-Tag: live~6860^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/11aff90f63d79406e9efa1343c965a19dcf5dbba?ds=sidebyside;hp=-c Merge branch 'master' into openid Conflicts: app/controllers/user_controller.rb app/views/user/login.html.erb public/stylesheets/common.css --- 11aff90f63d79406e9efa1343c965a19dcf5dbba diff --combined app/controllers/user_controller.rb index d456c1353,6935af3bc..1193ec910 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@@ -26,53 -26,22 +26,53 @@@ class UserController < ApplicationContr render :update do |page| page.replace_html "contributorTerms", :partial => "terms", :locals => { :has_decline => params[:has_decline] } end + elsif using_open_id? + # The redirect from the OpenID provider reenters here + # again and we need to pass the parameters through to + # the open_id_authentication function + @user = session.delete(:new_user) + + openid_verify(nil, @user) do |user| + end + + if @user.openid_url.nil? or @user.invalid? + render :action => 'new' + else + render :action => 'terms' + end else + session[:referer] = params[:referer] + @title = t 'user.terms.title' @user = User.new(params[:user]) if params[:user] + if params[:user] and params[:user][:openid_url] and @user.pass_crypt.empty? + # We are creating an account with OpenID and no password + # was specified so create a random one + @user.pass_crypt = ActiveSupport::SecureRandom.base64(16) + @user.pass_crypt_confirmation = @user.pass_crypt + end + if @user if @user.invalid? if @user.new_record? + # Something is wrong with a new user, so rerender the form render :action => :new else + # Error in existing user, so go to account settings flash[:errors] = @user.errors redirect_to :action => :account, :display_name => @user.display_name end elsif @user.terms_agreed? + # Already agreed to terms, so just show settings redirect_to :action => :account, :display_name => @user.display_name + elsif params[:user] and params[:user][:openid_url] + # Verify OpenID before moving on + session[:new_user] = @user + openid_verify(params[:user][:openid_url], @user) end else + # Not logged in, so redirect to the login page redirect_to :action => :login, :referer => request.request_uri end end @@@ -107,7 -76,8 +107,8 @@@ if @user.save flash[:notice] = t 'user.new.flash create success message', :email => @user.email - Notifier.deliver_signup_confirm(@user, @user.tokens.create(:referer => params[:referer])) + Notifier.deliver_signup_confirm(@user, @user.tokens.create(:referer => session.delete(:referer))) + session[:token] = @user.tokens.create.token redirect_to :action => 'login' else render :action => 'new' @@@ -139,25 -109,28 +140,31 @@@ @user.home_lat = params[:user][:home_lat] @user.home_lon = params[:user][:home_lon] + if params[:user][:preferred_editor] == "default" + @user.preferred_editor = nil + else + @user.preferred_editor = params[:user][:preferred_editor] + end + - if @user.save - set_locale + @user.openid_url = nil if params[:user][:openid_url].empty? - if @user.new_email.nil? or @user.new_email.empty? - flash[:notice] = t 'user.account.flash update success' - else - flash[:notice] = t 'user.account.flash update success confirm needed' - - begin - Notifier.deliver_email_confirm(@user, @user.tokens.create) - rescue - # Ignore errors sending email - end - end - - redirect_to :action => "account", :display_name => @user.display_name + if params[:user][:openid_url].length > 0 and + params[:user][:openid_url] != @user.openid_url + # If the OpenID has changed, we want to check that it is a + # valid OpenID and one the user has control over before saving + # it as a password equivalent for the user. + session[:new_user] = @user + openid_verify(params[:user][:openid_url], @user) + else + update_user(@user) + end + elsif using_open_id? + # The redirect from the OpenID provider reenters here + # again and we need to pass the parameters through to + # the open_id_authentication function + @user = session.delete(:new_user) + openid_verify(nil, @user) do |user| + update_user(user) end else if flash[:errors] @@@ -223,26 -196,41 +230,26 @@@ def new @title = t 'user.new.title' - - # The user is logged in already, so don't show them the signup - # page, instead send them to the home page - redirect_to :controller => 'site', :action => 'index' if session[:user] + @referer = params[:referer] || session[:referer] + + if session[:user] + # The user is logged in already, so don't show them the signup + # page, instead send them to the home page + redirect_to :controller => 'site', :action => 'index' + elsif not params['openid'].nil? + flash.now[:notice] = t 'user.new.openid association' + end end def login - @title = t 'user.login.title' + if params[:username] or using_open_id? + session[:remember_me] ||= params[:remember_me] + session[:referer] ||= params[:referer] - if params[:user] - email_or_display_name = params[:user][:email] - pass = params[:user][:password] - user = User.authenticate(:username => email_or_display_name, :password => pass) - - if user - session[:user] = user.id - session_expires_after 1.month if params[:remember_me] - - # The user is logged in, if the referer param exists, redirect - # them to that unless they've also got a block on them, in - # which case redirect them to the block so they can clear it. - if user.blocked_on_view - redirect_to user.blocked_on_view, :referer => params[:referer] - elsif params[:referer] - redirect_to params[:referer] - else - redirect_to :controller => 'site', :action => 'index' - end - elsif user = User.authenticate(:username => email_or_display_name, :password => pass, :pending => true) - flash.now[:error] = t 'user.login.account not active', :reconfirm => url_for(:action => 'confirm_resend', :display_name => user.display_name) - elsif User.authenticate(:username => email_or_display_name, :password => pass, :suspended => true) - webmaster = link_to t('user.login.webmaster'), "mailto:webmaster@openstreetmap.org" - flash.now[:error] = t 'user.login.account suspended', :webmaster => webmaster + if using_open_id? + openid_authentication(params[:openid_url]) else - flash.now[:error] = t 'user.login.auth failure' + password_authentication(params[:username], params[:password]) end elsif flash[:notice].nil? flash.now[:notice] = t 'user.login.notice' @@@ -283,14 -271,29 +290,29 @@@ user.save! referer = token.referer token.destroy - session[:user] = user.id - unless referer.nil? + if session[:token] + token = UserToken.find_by_token(session[:token]) + session.delete(:token) + else + token = nil + end + + if token.nil? or token.user != user flash[:notice] = t('user.confirm.success') - redirect_to referer + redirect_to :action => :login, :referer => referer else - flash[:notice] = t('user.confirm.success') + "

" + t('user.confirm.before you start') - redirect_to :action => 'account', :display_name => user.display_name + token.destroy + + session[:user] = user.id + + if referer.nil? + flash[:notice] = t('user.confirm.success') + "

" + t('user.confirm.before you start') + redirect_to :action => :account, :display_name => user.display_name + else + flash[:notice] = t('user.confirm.success') + redirect_to referer + end end end else @@@ -447,164 -450,6 +469,164 @@@ private + ## + # handle password authentication + def password_authentication(username, password) + if user = User.authenticate(:username => username, :password => password) + successful_login(user) + elsif user = User.authenticate(:username => username, :password => password, :pending => true) + failed_login t('user.login.account not active', :reconfirm => url_for(:action => 'confirm_resend', :display_name => user.display_name)) + elsif User.authenticate(:username => username, :password => password, :suspended => true) + webmaster = link_to t('user.login.webmaster'), "mailto:webmaster@openstreetmap.org" + failed_login t('user.login.account suspended', :webmaster => webmaster) + else + failed_login t('user.login.auth failure') + end + end + + ## + # handle OpenID authentication + def openid_authentication(openid_url) + # If we don't appear to have a user for this URL then ask the + # provider for some extra information to help with signup + if openid_url and User.find_by_openid_url(openid_url) + required = nil + else + required = [:nickname, :email, "http://axschema.org/namePerson/friendly", "http://axschema.org/contact/email"] + end + + # Start the authentication + authenticate_with_open_id(openid_expand_url(openid_url), :required => required) do |result, identity_url, sreg, ax| + if result.successful? + # We need to use the openid url passed back from the OpenID provider + # rather than the one supplied by the user, as these can be different. + # + # For example, you can simply enter yahoo.com in the login box rather + # than a user specific url. Only once it comes back from the provider + # provider do we know the unique address for the user. + if user = User.find_by_openid_url(identity_url) + case user.status + when "pending" then + failed_login t('user.login.account not active') + when "active", "confirmed" then + successful_login(user) + when "suspended" then + webmaster = link_to t('user.login.webmaster'), "mailto:webmaster@openstreetmap.org" + failed_login t('user.login.account suspended', :webmaster => webmaster) + else + failed_login t('user.login.auth failure') + end + else + # We don't have a user registered to this OpenID, so redirect + # to the create account page with username and email filled + # in if they have been given by the OpenID provider through + # the simple registration protocol. + nickname = sreg["nickname"] || ax["http://axschema.org/namePerson/friendly"] + email = sreg["email"] || ax["http://axschema.org/contact/email"] + redirect_to :controller => 'user', :action => 'new', :nickname => nickname, :email => email, :openid => identity_url + end + elsif result.missing? + failed_login t('user.login.openid missing provider') + elsif result.invalid? + failed_login t('user.login.openid invalid') + else + failed_login t('user.login.auth failure') + end + end + end + + ## + # verify an OpenID URL + def openid_verify(openid_url, user) + user.openid_url = openid_url + + authenticate_with_open_id(openid_expand_url(openid_url)) do |result, identity_url| + if result.successful? + # We need to use the openid url passed back from the OpenID provider + # rather than the one supplied by the user, as these can be different. + # + # For example, you can simply enter yahoo.com in the login box rather + # than a user specific url. Only once it comes back from the provider + # provider do we know the unique address for the user. + user.openid_url = identity_url + yield user + elsif result.missing? + flash.now[:error] = t 'user.login.openid missing provider' + elsif result.invalid? + flash.now[:error] = t 'user.login.openid invalid' + else + flash.now[:error] = t 'user.login.auth failure' + end + end + end + + ## + # special case some common OpenID providers by applying heuristics to + # try and come up with the correct URL based on what the user entered + def openid_expand_url(openid_url) + if openid_url.nil? + return nil + elsif openid_url.match(/(.*)gmail.com(\/?)$/) or openid_url.match(/(.*)googlemail.com(\/?)$/) + # Special case gmail.com as it is potentially a popular OpenID + # provider and, unlike yahoo.com, where it works automatically, Google + # have hidden their OpenID endpoint somewhere obscure this making it + # somewhat less user friendly. + return 'https://www.google.com/accounts/o8/id' + else + return openid_url + end + end + + ## + # process a successful login + def successful_login(user) + session[:user] = user.id + + session_expires_after 1.month if session[:remember_me] + + if user.blocked_on_view + redirect_to user.blocked_on_view, :referer => params[:referer] + elsif session[:referer] + redirect_to session[:referer] + else + redirect_to :controller => 'site', :action => 'index' + end + + session.delete(:remember_me) + session.delete(:referer) + end + + ## + # process a failed login + def failed_login(message) + flash[:error] = message + + redirect_to :action => 'login', :referer => session[:referer] + + session.delete(:remember_me) + session.delete(:referer) + end + + ## + # update a user's details + def update_user(user) + if user.save + set_locale + + if user.new_email.nil? or user.new_email.empty? + flash.now[:notice] = t 'user.account.flash update success' + else + flash.now[:notice] = t 'user.account.flash update success confirm needed' + + begin + Notifier.deliver_email_confirm(user, user.tokens.create) + rescue + # Ignore errors sending email + end + end + end + end + ## # require that the user is a administrator, or fill out a helpful error message # and return them to the user page. diff --combined app/models/user.rb index d5b75d073,d2535bbd4..79af5d71f --- a/app/models/user.rb +++ b/app/models/user.rb @@@ -10,7 -10,7 +10,7 @@@ class User < ActiveRecord::Bas has_many :friends, :include => :befriendee, :conditions => "users.status IN ('active', 'confirmed')" has_many :tokens, :class_name => "UserToken" has_many :preferences, :class_name => "UserPreference" - has_many :changesets + has_many :changesets, :order => 'created_at DESC' has_many :client_applications has_many :oauth_tokens, :class_name => "OauthToken", :order => "authorized_at desc", :include => [:client_application] @@@ -23,7 -23,6 +23,7 @@@ validates_confirmation_of :pass_crypt#, :message => ' must match the confirmation password' validates_uniqueness_of :display_name, :allow_nil => true validates_uniqueness_of :email + validates_uniqueness_of :openid_url, :allow_nil => true validates_length_of :pass_crypt, :within => 8..255 validates_length_of :display_name, :within => 3..255, :allow_nil => true validates_email_format_of :email @@@ -34,6 -33,7 +34,7 @@@ validates_numericality_of :home_lat, :allow_nil => true validates_numericality_of :home_lon, :allow_nil => true validates_numericality_of :home_zoom, :only_integer => true, :allow_nil => true + validates_inclusion_of :preferred_editor, :in => Editors::ALL_EDITORS, :allow_nil => true before_save :encrypt_password @@@ -107,7 -107,7 +108,7 @@@ (languages & array.collect { |i| i.to_s }).first end - def nearby(radius = 50, num = 10) + def nearby(radius = NEARBY_RADIUS, num = NEARBY_USERS) if self.home_lon and self.home_lat gc = OSM::GreatCircle.new(self.home_lat, self.home_lon) bounds = gc.bounds(radius) @@@ -203,4 -203,10 +204,10 @@@ return score.to_i end + + ## + # return an oauth access token for a specified application + def access_token(application_key) + return ClientApplication.find_by_key(application_key).access_token_for_user(self) + end end diff --combined app/views/user/account.html.erb index 3bfd7577e,7047b5b82..161f8f4f9 --- a/app/views/user/account.html.erb +++ b/app/views/user/account.html.erb @@@ -27,11 -27,6 +27,11 @@@ <%= f.password_field :pass_crypt_confirmation, {:value => '', :size => 30, :maxlength => 255, :autocomplete => :off} %> + + <%= t 'user.account.openid.openid' %> + <%= f.text_field :openid_url, {:class => "openid_url"} %> (<%= t 'user.account.openid.link text' %>) + + <%= t 'user.account.public editing.heading' %> @@@ -71,6 -66,11 +71,11 @@@ <%= f.text_field :languages %> + + <%= t 'user.account.preferred editor' %> + <%= f.select :preferred_editor, [[t("editor.default", :name => t("editor.#{DEFAULT_EDITOR}.name")), 'default']] + Editors::ALL_EDITORS.collect { |e| [t("editor.#{e}.description"), e] } %> + + <%= t 'user.account.image' %> diff --combined app/views/user/login.html.erb index 72c768713,66a2fab99..4515f412d --- a/app/views/user/login.html.erb +++ b/app/views/user/login.html.erb @@@ -1,85 -1,25 +1,80 @@@ -

<%= t 'user.login.heading' %>

+
+ -

<%= t 'user.login.please login', :create_user_link => link_to(t('user.login.create_account'), :controller => 'user', :action => 'new', :referer => params[:referer]) %>

+
+

<%= t 'user.login.heading' %>

- <% form_tag({ :action => "login" }, { :id => "login_form" }) do %> - <%= hidden_field_tag('referer', h(params[:referer])) %> -

<%= t 'user.login.already have' %>

- - <% form_tag :action => 'login' do %> ++ <% form_tag({ :action => "login" }, { :id => "login_form" }) do %> + <%= hidden_field_tag('referer', h(params[:referer])) %> + -
-
-

<%= t 'user.login.username_heading' %>

- - - - - - - - - ++

<%= t 'user.login.with username' %>

++ +
<%= text_field_tag("username", "", { :size => 28, :maxlength => 255, :tabindex => 1 }) %>
<%= password_field_tag("password", "", { :size => 28, :maxlength => 255, :tabindex => 2 }) %>
+ + + +
<%= t 'user.login.email or username' %><%= text_field('user', 'email',{:value => "", :size => 28, :maxlength => 255, :tabindex => 1}) %>
<%= t 'user.login.password' %><%= password_field('user', 'password',{:value => "", :size => 28, :maxlength => 255, :tabindex => 2}) %> (<%= link_to t('user.login.lost password link'), :controller => 'user', :action => 'lost_password' %>)
<%= check_box_tag "remember_me", "yes", false, :tabindex => 3 %>
+ <%= submit_tag t('user.login.login_button'), :tabindex => 3 %> ++ ++

<%= t 'user.login.with openid' %>

++ ++ + - - ++ ++ ++ + + - - ++ ++ ++ + +
(<%= link_to t('user.login.lost password link'), :controller => 'user', :action => 'lost_password' %>) ++ <%= ++ link_to_function(image_tag("openid_large.png", :alt => t("user.login.openid_providers.openid.title")), nil, :title => t("user.login.openid_providers.openid.title")) do |page| ++ page[:login_form][:openid_url].value = "http://" ++ page[:login_openid_buttons].hide ++ page[:login_openid_url].show ++ page[:login_openid_submit].show ++ end ++ %> ++ <%= openid_button "yahoo", "me.yahoo.com" %><%= openid_button "google", "gmail.com" %>
<%= check_box_tag "remember_me", "yes", false, :tabindex => 3 %><%= openid_button "myopenid", "myopenid.com" %><%= openid_button "wordpress", "wordpress.com" %><%= openid_button "myspace", "myspace.com" %>
+ - <%= submit_tag t('user.login.login_button'), :tabindex => 4 %> -
- -
-
- -
-

<%= t 'user.login.openid_heading' %>

-
- <%= - link_to_function(image_tag("openid_large.png", :alt => t("user.login.openid_providers.openid.title")), nil, :title => t("user.login.openid_providers.openid.title")) do |page| - page[:login_form][:openid_url].value = "http://" - page[:openid_buttons].hide - page[:openid_url].show - page[:openid_url_hint].show - page[:openid_submit].show - end - %> - <%= openid_button "yahoo", "me.yahoo.com" %> - <%= openid_button "google", "gmail.com" %> - <%= openid_button "myopenid", "myopenid.com" %> - <%= openid_button "wordpress", "wordpress.com" %> - <%= openid_button "myspace", "myspace.com" %> -
- + - ++ + - - - - + + + + + + +
+ <%= t 'user.login.openid', :logo => openid_logo %> + <%= text_field_tag("openid_url", "", { :size => 28, :maxlength => 255, :tabindex => 3, :class => "openid_url" }) %>
++ <%= text_field_tag("openid_url", "", { :size => 28, :maxlength => 255, :tabindex => 3, :class => "openid_url" }) %> + (<%= t 'user.account.openid.link text' %>) +
<%= check_box_tag "remember_me", "yes", false, :tabindex => 5 %>
+ - <%= submit_tag t('user.login.login_button'), :tabindex => 6, :id => "openid_submit" %> -
++ <%= submit_tag t('user.login.login_button'), :tabindex => 6, :id => "login_openid_submit" %> + <% end %> ++ +
- <% end %> ++ +
+

<%= t 'user.login.new to osm' %>

+

<%= t 'user.login.to make changes' %>

+

<%= t 'user.login.create account minute' %>

+

<%= button_to t('user.login.register now'), :action => :new, :referer => params[:referer] %>

++ +
+
++ +
+ +<%= + update_page_tag do |page| - page[:openid_url].hide - page[:openid_url_hint].hide - page[:openid_submit].hide ++ page[:login_openid_url].hide ++ page[:login_openid_submit].hide + end +%> diff --combined config/locales/en.yml index ebd53720b,497959a14..1fa2831ea --- a/config/locales/en.yml +++ b/config/locales/en.yml @@@ -79,6 -79,17 +79,17 @@@ en with_id: "{{id}}" with_version: "{{id}}, v{{version}}" with_name: "{{name}} ({{id}})" + editor: + default: "Default (currently {{name}})" + potlatch: + name: "Potlatch 1" + description: "Potlatch 1 (in-browser editor)" + potlatch2: + name: "Potlatch 2" + description: "Potlatch 2 (in-browser editor)" + remote: + name: "Remote Control" + description: "Remote Control (JOSM or Merkaartor)" browse: changeset: title: "Changeset" @@@ -912,6 -923,7 +923,7 @@@ gps_traces_tooltip: Manage GPS traces user_diaries: User Diaries user_diaries_tooltip: View user diaries + edit_with: Edit with {{editor}} tag_line: The Free Wiki World Map intro_1: "OpenStreetMap is a free editable map of the whole world. It is made by people like you." intro_2: "OpenStreetMap allows you to view, edit and use geographical data in a collaborative way from anywhere on Earth." @@@ -924,19 -936,20 +936,20 @@@ osm_read_only: "The OpenStreetMap database is currently in read-only mode while essential database maintenance work is carried out." donate: "Support OpenStreetMap by {{link}} to the Hardware Upgrade Fund." donate_link_text: donating - help_and_wiki: "{{help}} & {{wiki}}" help: Help + help_centre: Help Centre help_url: http://help.openstreetmap.org/ help_title: Help site for the project wiki: Wiki wiki_url: http://wiki.openstreetmap.org/ wiki_title: Wiki site for the project + documentation: Documentation + documentation_title: Documentation for the project copyright: "Copyright & License" - news_blog: "News blog" - news_blog_tooltip: "News blog about OpenStreetMap, free geographical data, etc." - shop: Shop - shop_tooltip: Shop with branded OpenStreetMap merchandise - shop_url: http://wiki.openstreetmap.org/wiki/Merchandise + community_blogs: "Community Blogs" + community_blogs_title: "Blogs from members of the OpenStreetMap community" + foundation: Foundation + foundation_title: The OpenStreetMap Foundation license: alt: CC by-sa 2.0 title: OpenStreetMap data is licensed under the Creative Commons Attribution-Share Alike 2.0 Generic License @@@ -1226,6 -1239,7 +1239,7 @@@ license_url: "http://creativecommons.org/licenses/by-sa/2.0/" project_name: "OpenStreetMap project" project_url: "http://openstreetmap.org" + remote_failed: "Editing failed - make sure JOSM or Merkaartor is loaded and the remote control option is enabled" edit: not_public: "You have not set your edits to be public." not_public_description: "You can no longer edit the map unless you do so. You can set your edits as public from your {{user_page}}." @@@ -1235,6 -1249,8 +1249,8 @@@ anon_edits_link_text: "Find out why this is the case." flash_player_required: 'You need a Flash player to use Potlatch, the OpenStreetMap Flash editor. You can download Flash Player from Adobe.com. Several other options are also available for editing OpenStreetMap.' potlatch_unsaved_changes: "You have unsaved changes. (To save in Potlatch, you should deselect the current way or point, if editing in live mode, or click save if you have a save button.)" + potlatch2_unsaved_changes: "You have unsaved changes. (To save in Potlatch 2, you should click save.)" + no_iframe_support: "Your browser doesn't support HTML iframes, which are necessary for this feature." sidebar: search_results: Search Results close: Close @@@ -1245,7 -1261,7 +1261,7 @@@ submit_text: "Go" search_help: "examples: 'Alkmaar', 'Regent Street, Cambridge', 'CB2 5AQ', or 'post offices near Lünen' more examples..." key: - map_key: "Map key" + map_key: "Map Key" map_key_tooltip: "Key for the map" table: entry: @@@ -1492,43 -1508,23 +1508,45 @@@ login: title: "Login" heading: "Login" -- please login: "Please login or {{create_user_link}}." -- create_account: "create an account" email or username: "Email Address or Username:" password: "Password:" + openid: "{{logo}} OpenID:" - username_heading: "Login with username and password:" - openid_heading: "Login with OpenID:" remember: "Remember me:" lost password link: "Lost your password?" login_button: "Login" + register now: Register now - already have: Already have an OpenStreetMap account? Please login. ++ with username: "Already have an OpenStreetMap account? Please login with your username and password:" ++ with openid: "Alternatively please use your OpenID to login:" + new to osm: New to OpenStreetMap? + to make changes: To make changes to the OpenStreetMap data, you must have an account. + create account minute: Create an account. It only takes a minute. account not active: "Sorry, your account is not active yet.
Please use the link in the account confirmation email to activate your account, or request a new confirmation email." account suspended: Sorry, your account has been suspended due to suspicious activity.
Please contact the {{webmaster}} if you wish to discuss this. webmaster: webmaster auth failure: "Sorry, could not log in with those details." notice: "Find out more about OpenStreetMap's upcoming license change (translations) (discussion)" + openid missing provider: "Sorry, could not contact your OpenID provider" + openid invalid: "Sorry, your OpenID seems to be malformed" + openid_logo_alt: "Log in with an OpenID" + openid_providers: + openid: + title: Login with an OpenID URL + alt: Login with an OpenID URL + yahoo: + title: Login with a Yahoo! OpenID + alt: Login with a Yahoo! OpenID + google: + title: Login with a Google OpenID + alt: Login with a Google OpenID + myopenid: + title: Login with a myOpenID OpenID + alt: Login with a myOpenID OpenID + wordpress: + title: Login with a Wordpress.com OpenID + alt: Login with a Wordpress.com OpenID + myspace: + title: Login with a MySpace OpenID + alt: Login with a MySpace OpenID logout: title: "Logout" heading: "Logout from OpenStreetMap" @@@ -1561,21 -1557,8 +1579,21 @@@ not displayed publicly: 'Not displayed publicly (see privacy policy)' display name: "Display Name:" display name description: "Your publicly displayed username. You can change this later in the preferences." + openid: "{{logo}} OpenID:" password: "Password:" confirm password: "Confirm Password:" + use openid: "Alternatively, use {{logo}} OpenID to login" + openid no password: "With OpenID a password is not required, but some extra tools or server may still need one." + openid association: | +

Your OpenID is not associated with a OpenStreetMap account yet.

+ continue: Continue flash create success message: "Thanks for signing up. We've sent a confirmation note to {{email}} and as soon as you confirm your account you'll be able to get mapping.

If you use an antispam system which sends confirmation requests then please make sure you whitelist webmaster@openstreetmap.org as we are unable to reply to any confirmation requests." terms accepted: "Thanks for accepting the new contributor terms!" @@@ -1615,6 -1598,7 +1633,7 @@@ add as friend: add as friend mapper since: "Mapper since:" ago: "({{time_in_words_ago}} ago)" + latest edit: "Latest edit {{ago}}:" email address: "Email address:" created from: "Created from:" status: "Status:" @@@ -1658,10 -1642,6 +1677,10 @@@ current email address: "Current Email Address:" new email address: "New Email Address:" email never displayed publicly: "(never displayed publicly)" + openid: + openid: "OpenID:" + link: "http://wiki.openstreetmap.org/wiki/OpenID" + link text: "what is this?" public editing: heading: "Public editing:" enabled: "Enabled. Not anonymous and can edit data." @@@ -1682,6 -1662,7 +1701,7 @@@ link text: "what is this?" profile description: "Profile Description:" preferred languages: "Preferred Languages:" + preferred editor: "Preferred Editor:" image: "Image:" new image: "Add an image" keep image: "Keep the current image" diff --combined config/locales/is.yml index fe7c8c05b,dd90f8986..be2f08452 --- a/config/locales/is.yml +++ b/config/locales/is.yml @@@ -601,13 -601,8 +601,8 @@@ is make_a_donation: text: Fjárframlagssíða title: Hjálpaðu OpenStreetMap verkefninu með fjárframlagi - news_blog: Fréttablogg - news_blog_tooltip: Blogg um OpenStreetMap, frjáls kortagögn o.fl. osm_offline: OpenStreetMap gagnagrunnurinn er niðri vegna viðhalds. osm_read_only: Ekki er hægt að skrifa í OpenStreetMap gagnagrunninn í augnablikinu vegna viðhalds. - shop: Verslun - shop_tooltip: Verslun með vörum tengdum OpenStreetMap - shop_url: http://wiki.openstreetmap.org/index.php?title=Merchandise&uselang=is sign_up: búa til aðgang sign_up_tooltip: Búaðu til aðgang til að geta breytt kortinu tag_line: Frjálsa wiki heimskortið @@@ -900,7 -895,6 +895,6 @@@ unclassified: Héraðsvegur unsurfaced: Óbundið slitlag wood: Náttúrulegur skógur - heading: Kortaskýringar fyrir þys {{zoom_level}} search: search: Leita search_help: "dæmi: „Akureyri“, „Laugavegur, Reykjavík“ eða „post offices near Lünen“. Sjá einnig leitarhjálpina." @@@ -1017,8 -1011,6 +1011,8 @@@ current email address: "Núverandi netfang:" delete image: Eyða þessari mynd email never displayed publicly: (aldrei sýnt opinberlega) + openid: + link text: "hvað er openID?" flash update success: Stillingarnar þínar voru uppfærðar. flash update success confirm needed: Stillingarnar þínar voru uppfærðar. Póstur var sendur á netfangið þitt sem þú þarft að bregðast við til að netfangið þitt verði staðfest. home location: "Staðsetning:" @@@ -1051,7 -1043,6 +1045,6 @@@ update home location on click: Uppfæra staðsetninguna þegar ég smelli á kortið confirm: button: Staðfesta - failure: Notandi hefur þegar verið staðfestur með þessum lykli. heading: Staðfesta notanda press confirm button: Hér getur þú staðfest að þú viljir búa til notanda.. success: Notandinn þinn hefur verið staðfestur. @@@ -1079,28 -1070,6 +1072,28 @@@ remember: "Muna innskráninguna:" title: Innskrá webmaster: vefstjóra + openid_heading: "Innskráning með OpenID:" + username_heading: "Innskráning með OpenStreetMap aðgang:" + openid_logo_alt: "Innskrá með OpenID" + openid_providers: + openid: + title: Innskrá með OpenID slóð + alt: Innskrá með OpenID slóð + yahoo: + title: Innsrká með Yahoo! OpenID + alt: Innsrká með Yahoo! OpenID + google: + title: Innsrká með Google OpenID + alt: Innsrká með Google OpenID + myopenid: + title: Innsrká með myOpenID OpenID + alt: Innsrká með myOpenID OpenID + wordpress: + title: Innsrká með Wordpress.com OpenID + alt: Innsrká með Wordpress.com OpenID + myspace: + title: Innsrká með MySpace OpenID + alt: Innsrká með MySpace OpenID logout: heading: Útskrá logout_button: Útskrá @@@ -1132,21 -1101,6 +1125,21 @@@ no_auto_account_create: Því miður getum við eki búið til reikning fyrir þig sjálfkrafa. not displayed publicly: Ekki sýnt opinberlega (sjá meðferð persónuupplýsinga) password: "Lykilorð:" + openID associate: "Tengja OpenID við þennan aðgang" + openID: "OpenID:" + openID description: '(Valfrjálst) Ef þú ert með OpenID getur þú tengt það við nýja aðganginn þinn.' + openID nopassword: "Með OpenID þarft þú ekki að gefa upp lykilorð við innskráningu. Í stað þess notar þú OpenID." + openID association: | + Þetta OpenID er ekki tengt við neinn OpenStreetMap aðgang. + + signup: Nýskrá title: Nýskrá no_such_user: body: Það er ekki til notandi með nafninu {{user}}. Kannski slóstu nafnið rangt inn eða fylgdir ógildum tengli. diff --combined public/stylesheets/common.css index 36966f3ba,c830f406b..3051f52d1 --- a/public/stylesheets/common.css +++ b/public/stylesheets/common.css @@@ -34,20 -34,22 +34,22 @@@ hr #left { position: absolute; - top: -8px; - min-width: 150px; + top: 0px; + min-width: 170px; } /* Rules for the OpenStreetMap logo in the top left corner */ #logo { - width: 150px; - min-width: 150px; - padding: 10px; - margin: 10px; + width: 170px; + min-width: 170px; + padding: 5px; + margin: 5px; height: 150px; background: #fff; border: 1px solid #ccd; + border-radius: 5px; + -moz-border-radius: 5px; } #logo h1 { @@@ -65,12 -67,15 +67,15 @@@ #intro { width: 170px; - margin: 10px; + padding: 5px; + margin: 5px; border: 1px solid #ccc; font-size: 11px; + border-radius: 5px; + -moz-border-radius: 5px; } - #intro p { margin: 10px; } + #intro p { margin: 5px; } /* * Rules for alert boxes shown in the left sidebar when important @@@ -79,14 -84,16 +84,16 @@@ */ #alert { - width: 150px; - margin: 10px; - padding: 10px; + width: 170px; + margin: 5px; + padding: 5px; border: 1px solid #ccc; background: #d00; line-height: 1.2em; text-align: left; font-size: 14px; + border-radius: 5px; + -moz-border-radius: 5px; } /* @@@ -96,23 -103,25 +103,25 @@@ */ .notice { - width: 150px; - margin: 10px; - padding: 10px; + width: 170px; + margin: 5px; + padding: 5px; border: 1px solid #ccc; background: #ea0; line-height: 1.2em; text-align: left; font-size: 14px; + border-radius: 5px; + -moz-border-radius: 5px; } /* Rules for the menu displayed in the left sidebar */ .left_menu { - width: 150px; - min-width: 150px; - margin: 10px; - padding: 10px; + width: 170px; + min-width: 170px; + margin: 5px; + padding: 5px; border: 1px solid #ccc; left: 0px; background: #ddd; @@@ -120,6 -129,8 +129,8 @@@ text-align: Left; font-size: 14px; font-weight: bold; + border-radius: 5px; + -moz-border-radius: 5px; } .left_menu td { @@@ -135,8 -146,9 +146,9 @@@ } .left_menu ul { - padding-left: 10px; + padding-left: 0px; margin: 0px; + list-style-type: none; } .left_menu li { @@@ -166,16 -178,18 +178,18 @@@ */ .optionalbox { - width: 150px; - min-width: 150px; - margin: 10px; - padding: 10px; + width: 170px; + min-width: 170px; + margin: 5px; + padding: 5px; border: 1px solid #ccc; left: 0px; line-height: 1.2em; text-align: left; font-size: 12px; background: #eee; + border-radius: 5px; + -moz-border-radius: 5px; } .optionalbox h1 { @@@ -206,11 -220,13 +220,13 @@@ } #search_field input[type="text"] { - width: 116px; + width: 136px; } #search_field input[type="submit"] { width: 26px; + padding-left: 0px; + padding-right: 0px; } .search_help { @@@ -223,14 -239,16 +239,16 @@@ /* Rules for donation request box */ .donate { - width: 150px; - margin: 10px; - padding: 10px; + width: 170px; + margin: 5px; + padding: 5px; border: 1px solid #ccc; background: #cbeea7; line-height: 1.2em; text-align: center; font-size: 14px; + border-radius: 5px; + -moz-border-radius: 5px; } /* Rules for Creative Commons logo button */ @@@ -271,6 -289,10 +289,10 @@@ border: 1px solid #ccc; text-decoration: none; color: #333; + border-top-right-radius: 5px; + -moz-border-radius-topright: 5px; + border-top-left-radius: 5px; + -moz-border-radius-topleft: 5px; } #tabnav a:link.active, #tabnav a:visited.active @@@ -344,6 -366,27 +366,27 @@@ text-align: right; } + /* Rules for edit menu */ + + #editmenu { + display: none; + z-index: 10000; + position: absolute; + background-color: #ffffff; + border: 1px solid black; + } + + #editmenu ul { + margin-top: 10px; + margin-bottom: 10px; + padding-left: 10px; + padding-right: 10px; + } + + #editmenu li { + list-style-type: none; + } + /* Rules for attribution text under the main map shown on printouts */ #attribution { @@@ -570,7 -613,7 +613,7 @@@ } #user_list tr { - vertical-align: center; + vertical-align: middle; } #user_list p { @@@ -583,35 -626,34 +626,38 @@@ margin-top: 10px; } - /* Rules for the login form */ + /* Rules for the login page */ - .loginBox { - float: left; - border-style: solid; - border-width: 1px; - padding-left: 10px; - padding-right: 10px; - padding-bottom: 10px; + #login_wrapper { + float: left; /* ensures the child divs are the same size, and only as wide as they need to be */ } - .loginBox table { - width: 100%; + #login_wrapper div { + margin: 5px; + padding: 15px; + border-radius: 15px; + -moz-border-radius: 15px; } - .loginBox img { - border: 0; + #login_wrapper input[type=submit] { + float: right; } - .loginBox #openid_buttons img { - vertical-align: middle; + #login_login { + background-color: #f0f0f0; } - .loginBox input[type="submit"] { - float: right; + #login_login h1 { + margin-top: 5px; } - #openid_buttons { - margin-bottom: 20px; ++#login_openid_buttons img { ++ border: 0; ++} ++ + #login_signup form.button-to div { + margin: 0px; + padding: 0px; } /* Rules for the account confirmation page */ @@@ -715,6 -757,8 +761,8 @@@ form#termsForm input#agree padding: 7px; background-color: #fff0f0; margin-bottom: 20px; + border-radius: 5px; + -moz-border-radius: 5px; } #warning { @@@ -722,6 -766,8 +770,8 @@@ padding: 7px; background-color: #fff6f0; margin-bottom: 20px; + border-radius: 5px; + -moz-border-radius: 5px; } #notice { @@@ -729,6 -775,8 +779,8 @@@ padding: 7px; background-color: #f0fff0; margin-bottom: 20px; + border-radius: 5px; + -moz-border-radius: 5px; } /* Rules for highlighting fields with rails validation errors */ @@@ -790,11 -838,6 +842,11 @@@ input[type="submit"] border: 1px solid black; } +input.openid_url { - background: url('../images/openid_input.png') repeat-y left; ++ background: url('../images/openid_input.png') repeat-y left white; + padding-left: 16px; +} + /* Rules for user images */ img.user_image { @@@ -837,10 -880,3 +889,10 @@@ abbr.geo .table1 { background: #fff; } + +/* Rules for OpenID logo */ + +.openid_logo { + vertical-align: text-bottom; + border: 0; +} diff --combined test/test_helper.rb index 507f9e7fc,6a618c8d3..b91c0779f --- a/test/test_helper.rb +++ b/test/test_helper.rb @@@ -3,43 -3,6 +3,43 @@@ require File.expand_path(File.dirname(_ require 'test_help' load 'composite_primary_keys/fixtures.rb' +# This monkey patch is to make tests where a rack module alters +# the response work with rails 2 - it can be dropped when we move +# to rails 3. +module ActionController + module Integration + class Session + def process_with_capture(method, path, parameters = nil, headers = nil) + status = process_without_capture(method, path, parameters, headers) + @controller = ActionController::Base.last_controller + @request = @controller.request + @response.session = @controller.response.session + @response.template = @controller.response.template + @response.redirected_to = @response.location + status + end + + alias_method_chain :process, :capture + end + + module ControllerCapture + module ClassMethods + mattr_accessor :last_controller + + def clear_last_instantiation! + self.last_controller = nil + end + + def new_with_capture(*args) + controller = new_without_capture(*args) + self.last_controller ||= controller + controller + end + end + end + end +end + class ActiveSupport::TestCase # Transactional fixtures accelerate your tests by wrapping each test method # in a transaction that's rolled back on completion. This ensures that the @@@ -158,6 -121,10 +158,10 @@@ @request.env["HTTP_AUTHORIZATION"] = "Basic %s" % Base64.encode64("#{user}:#{pass}") end + def error_format(format) + @request.env["HTTP_X_ERROR_FORMAT"] = format + end + def content(c) @request.env["RAW_POST_DATA"] = c.to_s end @@@ -178,15 -145,6 +182,15 @@@ def assert_no_missing_translations(msg="") assert_select "span[class=translation_missing]", false, "Missing translation #{msg}" end + + def openid_request(openid_request_uri) + openid_response = Net::HTTP.get_response(URI.parse(openid_request_uri)) + openid_response_uri = URI(openid_response['Location']) + openid_response_qs = Rack::Utils.parse_query(openid_response_uri.query) + + return openid_response_qs + end + # Add more helper methods to be used by all tests here... end