From 655dc6787e9092a004b582b52ff8e9ccd0d40bb3 Mon Sep 17 00:00:00 2001 From: Matt Amos Date: Mon, 3 Aug 2009 17:08:40 +0000 Subject: [PATCH] Reorganised OAuth clients and tokens details page. Made clients info editable and some more stuff translatable in the OAuth pages. --- app/views/oauth_clients/_form.html.erb | 35 ++++--------- app/views/oauth_clients/edit.html.erb | 9 ++-- app/views/oauth_clients/index.html.erb | 36 ++++++------- app/views/oauth_clients/new.html.erb | 4 +- app/views/oauth_clients/show.html.erb | 26 +++++---- app/views/user/account.html.erb | 33 ------------ app/views/user/view.html.erb | 2 + config/locales/en.yml | 58 +++++++++++++++++---- test/integration/client_application_test.rb | 18 ++++--- 9 files changed, 109 insertions(+), 112 deletions(-) diff --git a/app/views/oauth_clients/_form.html.erb b/app/views/oauth_clients/_form.html.erb index e55b016e9..f8fd4347e 100644 --- a/app/views/oauth_clients/_form.html.erb +++ b/app/views/oauth_clients/_form.html.erb @@ -1,40 +1,23 @@
-
+
<%= f.text_field :name %>
-
+
<%= f.text_field :url %>
-
+
<%= f.text_field :callback_url %>
-
+
<%= f.text_field :support_url %>
+

<%= t'oauth.client_application.form.requests' %>

+<% ClientApplication.all_permissions.each do |perm| %>
- <%= f.check_box :allow_read_prefs %> -
-
-
- <%= f.check_box :allow_write_prefs %> -
-
-
- <%= f.check_box :allow_write_diary %> -
-
-
- <%= f.check_box :allow_write_api %> -
-
-
- <%= f.check_box :allow_read_gpx %> -
-
-
- <%= f.check_box :allow_write_gpx %> -
+ <%= f.check_box perm %> +
+<% end %> diff --git a/app/views/oauth_clients/edit.html.erb b/app/views/oauth_clients/edit.html.erb index 3ff72fee3..d3b2c8c8a 100644 --- a/app/views/oauth_clients/edit.html.erb +++ b/app/views/oauth_clients/edit.html.erb @@ -1,5 +1,6 @@ -

Edit your application

-<% form_for :client_application do |f| %> +

<%= t'oauth.client_application.edit.title' %>

+<% form_for :client_application, @client_application, :url => oauth_client_path(@client_application), :html => { :method => :put } do |f| %> <%= render :partial => "form", :locals => { :f => f } %> - <%= submit_tag "Edit" %> -<% end %> \ No newline at end of file +
+ <%= submit_tag t'oauth.client_application.edit.submit' %> +<% end %> diff --git a/app/views/oauth_clients/index.html.erb b/app/views/oauth_clients/index.html.erb index 8f9e0a0b1..9f11cddef 100644 --- a/app/views/oauth_clients/index.html.erb +++ b/app/views/oauth_clients/index.html.erb @@ -1,9 +1,10 @@ -
<%= flash[:notice] %>
-

OAuth Client Applications

+

<%= t'oauth.client_application.index.title' %>

<% unless @tokens.empty? %> -

The following tokens have been issued to applications in your name

+

<%= t'oauth.client_application.index.my_tokens' %>

+

<%= t'oauth.client_application.index.list_tokens' %>

- + + <% @tokens.each do |token|%> <% content_tag_for :tr, token do %> @@ -11,29 +12,22 @@ <% end %> <% end %>
ApplicationIssued 
<%= t'oauth.client_application.index.application' %><%= t'oauth.client_application.index.issued_at' %> 
<%= link_to token.client_application.name, token.client_application.url %> <% form_tag :controller => 'oauth', :action => 'revoke' do %> <%= hidden_field_tag 'token', token.token %> - <%= submit_tag "Revoke!" %> + <%= submit_tag t('oauth.client_application.index.revoke') %> <% end %>
<% end %> -

Application Developers

+

<%= t'oauth.client_application.index.my_apps' %>

<% if @client_applications.empty? %> -

- Do you have an application you would like to register for use with us using the OAuth standard? -

-

- You must register your web application before it can make OAuth requests to this service -

+

<%= t('oauth.client_application.index.no_apps', :oauth => "OAuth") %>

<% else %> -

- You have the following client applications registered: -

- <% @client_applications.each do |client|%> - <% div_for client do %> - <%= link_to client.name, :action => :show, :id => client.id %> - <% end %> - <% end %> +

<%= t'oauth.client_application.index.registered_apps' %>

+<% @client_applications.each do |client|%> + <% div_for client do %> + <%= link_to client.name, :action => :show, :id => client.id %> + <% end %> +<% end %> <% end %> -

<%= link_to "Register your application", :action => :new %>

+

<%= link_to t('oauth.client_application.index.register_new'), :action => :new %>

diff --git a/app/views/oauth_clients/new.html.erb b/app/views/oauth_clients/new.html.erb index 34b2d2b29..75102f80c 100644 --- a/app/views/oauth_clients/new.html.erb +++ b/app/views/oauth_clients/new.html.erb @@ -1,6 +1,6 @@ -

Register a new application

+

<%= t'oauth.client_application.new.title' %>

<% form_for :client_application, :url => { :action => :create } do |f| %> <%= render :partial => "form", :locals => { :f => f } %>
- <%= submit_tag "Register" %> + <%= submit_tag t'oauth.client_application.new.submit' %> <% end %> diff --git a/app/views/oauth_clients/show.html.erb b/app/views/oauth_clients/show.html.erb index 5ec45aef5..281af5222 100644 --- a/app/views/oauth_clients/show.html.erb +++ b/app/views/oauth_clients/show.html.erb @@ -1,20 +1,28 @@ -

OAuth details for <%=@client_application.name %>

+

<%= t('oauth.client_application.show.title', :app_name => @client_application.name) %>

- Consumer Key: <%=@client_application.key %> + <%= t'oauth.client_application.show.key' %> <%=@client_application.key %>

- Consumer Secret: <%=@client_application.secret %> + <%= t'oauth.client_application.show.secret' %> <%=@client_application.secret %>

- Request Token URL http<%='s' if request.ssl? %>://<%= request.host_with_port %><%=@client_application.oauth_server.request_token_path %> + <%= t'oauth.client_application.show.url' %> http<%='s' if request.ssl? %>://<%= request.host_with_port %><%=@client_application.oauth_server.request_token_path %>

- Access Token URL http<%='s' if request.ssl? %>://<%= request.host_with_port %><%=@client_application.oauth_server.access_token_path %> + <%= t'oauth.client_application.show.access_url' %> http<%='s' if request.ssl? %>://<%= request.host_with_port %><%=@client_application.oauth_server.access_token_path %>

- Authorize URL http<%='s' if request.ssl? %>://<%= request.host_with_port %><%=@client_application.oauth_server.authorize_path %> + <%= t'oauth.client_application.show.authorize_url' %> http<%='s' if request.ssl? %>://<%= request.host_with_port %><%=@client_application.oauth_server.authorize_path %>

-

- We support hmac-sha1 (recommended) as well as plain text in ssl mode. -

\ No newline at end of file +

<%= t'oauth.client_application.show.requests' %>

+ + +

<%= t'oauth.client_application.show.support_notice' %>

+ +

<%= link_to t('oauth.client_application.show.edit'), edit_oauth_client_url(@client_application) %>

+ diff --git a/app/views/user/account.html.erb b/app/views/user/account.html.erb index 1cc6b4a29..45a129077 100644 --- a/app/views/user/account.html.erb +++ b/app/views/user/account.html.erb @@ -46,39 +46,6 @@

<%= button_to t('user.account.make all my edits public button'), :action => :go_public %> <% end %> -

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

-<% if @tokens.empty? %> -

<%= t 'oauth.token.none' %>

-<% else %> - - - <% @tokens.each do |token|%> - <% content_tag_for :tr, token do %> - - - - <% end %> - <% end %> -
<%= t 'oauth.token.application' %><%= t 'oauth.token.issued' %> 
<%= link_to token.client_application.name, token.client_application.url %><%= token.authorized_at %> - <% form_tag :controller => 'oauth', :action => 'revoke' do %> - <%= hidden_field_tag 'token', token.token %> - <%= submit_tag t('oauth.token.revoke') %> - <% end %> -
-<% end %> -

<%= t 'user.account.developers' %>

-<% if @user.client_applications.empty? %> -

<%= t 'user.account.dev_intro', :link => "OAuth" %>

-

<%= link_to t('user.account.register_app'), :controller => 'oauth_clients', :action => :new %>

-<% else %> -

<%= t 'user.account.apps_registered' %>

- -

<%= link_to t('user.account.register_another_app'), :controller => 'oauth_clients', :action => :new %>

-<% end %>

<%= link_to t('user.account.return to profile'), :controller => 'user', :action => @user.display_name %> diff --git a/app/views/user/view.html.erb b/app/views/user/view.html.erb index ff349858c..931037319 100644 --- a/app/views/user/view.html.erb +++ b/app/views/user/view.html.erb @@ -122,4 +122,6 @@
<% if @user and @this_user.id == @user.id %> <%= link_to t('user.view.change your settings'), :controller => 'user', :action => 'account', :display_name => @user.display_name %> +

+<%= link_to t('user.view.my_oauth_details'), :controller => 'oauth_clients', :action => 'index' %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index d98ac61d6..8c685df65 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -793,11 +793,52 @@ en: allow_write_api: "modify the map." allow_read_gpx: "read your private GPS traces." allow_write_gpx: "upload GPS traces." - token: - none: "You have not authorised any clients to act on your behalf. You do not have to do anything now to authorise them, as they will ask for authorisation when they need it. After that time you can return here to revoke those permissions if you do not want the clients to have your authorisation any more." - application: "Application" - issued: "Issued" - revoke: "Revoke!" + new: + title: "Register a new application" + submit: "Register" + edit: + title: "Edit your application" + submit: "Edit" + show: + title: "OAuth details for {{app_name}}" + key: "Consumer Key:" + secret: "Consumer Secret:" + url: "Request Token URL:" + access_url: "Access Token URL:" + authorize_url: "Authorise URL:" + support_notice: "We support hmac-sha1 (recommended) as well as plain text in ssl mode." + edit: "Edit Details" + requests: "Requesting the following permissions from the user:" + allow_read_prefs: "read their user preferences." + allow_write_prefs: "modify their user preferences." + allow_write_diary: "create diary entries, comments and make friends." + allow_write_api: "modify the map." + allow_read_gpx: "read their private GPS traces." + allow_write_gpx: "upload GPS traces." + index: + title: "My OAuth Details" + my_tokens: "My Authorised Applications" + list_tokens: "The following tokens have been issued to applications in your name:" + application: "Application Name" + issued_at: "Issued At" + revoke: "Revoke!" + my_apps: "My Client Applications" + no_apps: "Do you have an application you would like to register for use with us using the {{oauth}} standard? You must register your web application before it can make OAuth requests to this service." + registered_apps: "You have the following client applications registered:" + register_new: "Register your application" + form: + name: "Name" + required: "Required" + url: "Main Application URL" + callback_url: "Callback URL" + support_url: "Support URL" + requests: "Request the following permissions from the user:" + allow_read_prefs: "read their user preferences." + allow_write_prefs: "modify their user preferences." + allow_write_diary: "create diary entries, comments and make friends." + allow_write_api: "modify the map." + allow_read_gpx: "read their private GPS traces." + allow_write_gpx: "upload GPS traces." user: login: title: "Login" @@ -870,6 +911,7 @@ en: nearby users: "Nearby users: " no nearby users: "There are no users who admit to mapping nearby yet." change your settings: change your settings + my_oauth_details: "View my OAuth details" friend_map: your location: Your location nearby mapper: "Nearby mapper: " @@ -896,12 +938,6 @@ en: return to profile: Return to profile flash update success confirm needed: "User information updated successfully. Check your email for a note to confirm your new email address." flash update success: "User information updated successfully." - my apps: "My client applications" - developers: "Application Developers" - dev_intro: "Have you written an application which you would like to register to make {{link}} requests to the OpenStreetMap server?" - register_app: "Register your application" - apps_registered: "You have the following client applications registered:" - register_another_app: "Register another application" confirm: heading: Confirm a user account press confirm button: "Press the confirm button below to activate your account." diff --git a/test/integration/client_application_test.rb b/test/integration/client_application_test.rb index 0af226085..cc2cbc217 100644 --- a/test/integration/client_application_test.rb +++ b/test/integration/client_application_test.rb @@ -7,15 +7,21 @@ class ClientApplicationTest < ActionController::IntegrationTest # run through the procedure of creating a client application and checking # that it shows up on the user's account page. def test_create_application - post '/login', {'user[email]' => "test@example.com", 'user[password]' => "test", :referer => '/user/test/account'} + post '/login', {'user[email]' => "test@example.com", 'user[password]' => "test", :referer => '/user/test2'} assert_response :redirect follow_redirect! assert_response :success - assert_template 'user/account' + assert_template 'user/view' # check that the form to allow new client application creations exists assert_in_body do - assert_select "h2", "Application Developers" + assert_select "a[href='/oauth_clients']" + end + + # now we follow the link to the oauth client list + get '/oauth_clients' + assert_response :success + assert_in_body do assert_select "a[href='/oauth_clients/new']" end @@ -46,10 +52,10 @@ class ClientApplicationTest < ActionController::IntegrationTest assert_equal 'Registered the information successfully', flash[:notice] # now go back to the account page and check its listed under this user - get '/user/test/account' + get '/oauth_clients' assert_response :success - assert_template 'user/account' - assert_in_body { assert_select "li>div>a", "My New App" } + assert_template 'oauth_clients/index' + assert_in_body { assert_select "div>a", "My New App" } end ## -- 2.43.2