1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

Adding devise_views generator

This commit is contained in:
Carlos A. da Silva 2009-10-23 11:01:55 -02:00
parent 385dba551e
commit d4f2c2a5ed
9 changed files with 120 additions and 1 deletions

View file

@ -1 +1,5 @@
script/generate devise User
To create a devise resource user:
script/generate devise User
This will generate a model named User, a route map for devise called :users, and a migration file for table :users with all devise modules.

View file

@ -0,0 +1,3 @@
To copy all session, password and confirmation views from devise to your app just run the following command:
script/generate devise_views

View file

@ -0,0 +1,24 @@
class DeviseViewsGenerator < Rails::Generator::Base
def manifest
record do |m|
views_directory = File.join('app', 'views')
m.directory views_directory
{
:sessions => [:new],
:passwords => [:new, :edit],
:confirmations => [:new],
:notifier => [:confirmation_instructions, :reset_password_instructions]
}.each do |dir, templates|
m.directory File.join(views_directory, dir.to_s)
templates.each do |template|
template_path = "#{dir}/#{template}.html.erb"
m.file "#{template_path}", "#{views_directory}/#{template_path}"
end
end
end
end
end

View file

@ -0,0 +1,16 @@
<h2>Resend confirmation instructions</h2>
<% form_for resource_name, :url => confirmation_path(resource_name) do |f| %>
<%= f.error_messages %>
<p><%= f.label :email %></p>
<p><%= f.text_field :email %></p>
<p><%= f.submit "Resend confirmation instructions" %></p>
<% end %>
<%= link_to "Sign in", new_session_path(resource_name) %><br />
<%- if devise_mapping.recoverable? %>
<%= link_to "Forgot password?", new_password_path(resource_name) %><br />
<% end -%>

View file

@ -0,0 +1,5 @@
Welcome <%= @resource.email %>!
You can confirm your account through the link below:
<%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %>

View file

@ -0,0 +1,8 @@
Hello <%= @resource.email %>!
Someone has requested a link to change your password, and you can do this through the link below.
<%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %>
If you didn't request this, please ignore this email.
Your password won't change until you access the link above and create a new one.

View file

@ -0,0 +1,20 @@
<h2>Change your password</h2>
<% form_for resource_name, :url => password_path(resource_name), :html => { :method => :put } do |f| %>
<%= f.error_messages %>
<%= f.hidden_field :reset_password_token %>
<p><%= f.label :password %></p>
<p><%= f.password_field :password %></p>
<p><%= f.label :password_confirmation %></p>
<p><%= f.password_field :password_confirmation %></p>
<p><%= f.submit "Change my password" %></p>
<% end %>
<%= link_to "Sign in", new_session_path(resource_name) %><br />
<%- if devise_mapping.confirmable? %>
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
<% end -%>

View file

@ -0,0 +1,16 @@
<h2>Forgot your password?</h2>
<% form_for resource_name, :url => password_path(resource_name) do |f| %>
<%= f.error_messages %>
<p><%= f.label :email %></p>
<p><%= f.text_field :email %></p>
<p><%= f.submit "Send me reset password instructions" %></p>
<% end %>
<%= link_to "Sign in", new_session_path(resource_name) %><br />
<%- if devise_mapping.confirmable? %>
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
<% end -%>

View file

@ -0,0 +1,23 @@
<h2>Sign in</h2>
<% form_for resource_name, :url => session_path(resource_name) do |f| -%>
<p><%= f.label :email %></p>
<p><%= f.text_field :email %></p>
<p><%= f.label :password %></p>
<p><%= f.password_field :password %></p>
<% if devise_mapping.rememberable? -%>
<p><%= f.check_box :remember_me %> <%= f.label :remember_me %></p>
<% end -%>
<p><%= f.submit "Sign in" %></p>
<% end -%>
<%- if devise_mapping.recoverable? %>
<%= link_to "Forgot password?", new_password_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.confirmable? %>
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
<% end -%>