Skip to content

Commit

Permalink
Cleaned up provider generator.
Browse files Browse the repository at this point in the history
Routes are now auto generated
Fixed some erb errors
got rid of empty helpers
  • Loading branch information
pelle committed Jul 14, 2009
1 parent f92ba23 commit 1b704fd
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 31 deletions.
10 changes: 0 additions & 10 deletions README.rdoc
Expand Up @@ -46,16 +46,6 @@ By default the generator generates RSpec and ERB templates. The generator can in

These can of course be used individually as well.

=== Routes

You need to add the following to your routes (config/routes.rb)

map.resources :oauth_clients
map.authorize '/oauth/authorize',:controller=>'oauth',:action=>'authorize'
map.request_token '/oauth/request_token',:controller=>'oauth',:action=>'request_token'
map.access_token '/oauth/access_token',:controller=>'oauth',:action=>'access_token'
map.test_request '/oauth/test_request',:controller=>'oauth',:action=>'test_request'

=== User Model

Add the following lines to your user model:
Expand Down
8 changes: 0 additions & 8 deletions generators/oauth_provider/USAGE
Expand Up @@ -7,14 +7,6 @@ It requires an authentication framework such as acts_as_authenticated, restful_a
If you generated the migration file (true by default), make sure you run
rake db:migrate

You need to add the following routes to your config/routes.rb file:

map.oauth '/oauth',:controller=>'oauth',:action=>'index'
map.authorize '/oauth/authorize',:controller=>'oauth',:action=>'authorize'
map.request_token '/oauth/request_token',:controller=>'oauth',:action=>'request_token'
map.access_token '/oauth/access_token',:controller=>'oauth',:action=>'access_token'
map.test_request '/oauth/test_request',:controller=>'oauth',:action=>'test_request'

include the following in your user.rb

has_many :client_applications
Expand Down
8 changes: 5 additions & 3 deletions generators/oauth_provider/oauth_provider_generator.rb
Expand Up @@ -36,7 +36,6 @@ def manifest
# Controller, helper, views, and test directories.
m.directory File.join('app/models', class_path)
m.directory File.join('app/controllers', controller_class_path)
m.directory File.join('app/helpers', controller_class_path)
m.directory File.join('app/views', controller_class_path, controller_file_name)
m.directory File.join('app/views', controller_class_path, 'oauth_clients')

Expand All @@ -47,10 +46,13 @@ def manifest
m.template 'oauth_nonce.rb', File.join('app/models',"oauth_nonce.rb")

m.template 'controller.rb',File.join('app/controllers',controller_class_path,"#{controller_file_name}_controller.rb")
m.template 'helper.rb',File.join('app/helpers',controller_class_path,"#{controller_file_name}_helper.rb")

m.template 'clients_controller.rb',File.join('app/controllers',controller_class_path,"#{controller_file_name}_clients_controller.rb")
m.template 'clients_helper.rb',File.join('app/helpers',controller_class_path,"#{controller_file_name}_clients_helper.rb")
m.route_name 'oauth', '/oauth',:controller=>'oauth',:action=>'index'
m.route_name 'authorize', '/oauth/authorize',:controller=>'oauth',:action=>'authorize'
m.route_name 'request_token', '/oauth/request_token',:controller=>'oauth',:action=>'request_token'
m.route_name 'access_token', '/oauth/access_token',:controller=>'oauth',:action=>'access_token'
m.route_name 'test_request', '/oauth/test_request',:controller=>'oauth',:action=>'test_request'
m.route_resources "#{controller_file_name}_clients".to_sym

if !options[:test_unit]
Expand Down
2 changes: 1 addition & 1 deletion generators/oauth_provider/templates/_form.html.erb
@@ -1,4 +1,4 @@
<%= error_messages_for :client_application %>
<%%= error_messages_for :client_application %>
<div class="field">
<label for="client_application_name">Name*</label><br/>
<%%= f.text_field :name %>
Expand Down
2 changes: 0 additions & 2 deletions generators/oauth_provider/templates/clients_helper.rb

This file was deleted.

4 changes: 2 additions & 2 deletions generators/oauth_provider/templates/edit.html.erb
Expand Up @@ -3,5 +3,5 @@
<%%= render :partial => "form", :locals => { :f => f } %>
<%%= submit_tag "Edit" %>
<%% end %>
<%= link_to 'Show', oauth_client_path(@client_application) %> |
<%= link_to 'Back', oauth_clients_path %>
<%%= link_to 'Show', oauth_client_path(@client_application) %> |
<%%= link_to 'Back', oauth_clients_path %>
2 changes: 0 additions & 2 deletions generators/oauth_provider/templates/helper.rb

This file was deleted.

4 changes: 2 additions & 2 deletions generators/oauth_provider/templates/show.html.erb
Expand Up @@ -23,5 +23,5 @@
<p>
We support hmac-sha1 (recommended) as well as plain text in ssl mode.
</p>
<%= link_to 'Edit', edit_oauth_client_path(@client_application) %> |
<%= link_to 'Back', oauth_clients_path %>
<%%= link_to 'Edit', edit_oauth_client_path(@client_application) %> |
<%%= link_to 'Back', oauth_clients_path %>
1 change: 0 additions & 1 deletion lib/oauth/controllers/provider_controller.rb
Expand Up @@ -12,7 +12,6 @@ def self.included(controller)
end
end


def request_token
@token = current_client_application.create_request_token
if @token
Expand Down

0 comments on commit 1b704fd

Please sign in to comment.