Created
March 29, 2010 10:29
-
-
Save tarellel/347718 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| gem 'devise_invitable' | |
| gem 'devise' | |
| gem 'warden' | |
| gem 'formtastic' | |
| gem 'haml' | |
| rake('gems:install', :sudo => true) | |
| generate 'devise_install' | |
| generate 'devise User' | |
| append_file('config/environments/development.rb', "\nconfig.action_mailer.default_url_options = {:host => 'localhost:3000'}") | |
| route 'map.root :controller => :home' | |
| generate 'controller Home' | |
| run 'touch app/views/home/index.html.haml' | |
| run "rm -f public/index.html" | |
| if yes?("Include 'Lockable' module?") | |
| gsub_file(Dir['db/migrate/*devise_create_users.rb'][0], /# /, "") | |
| gsub_file 'app/models/user.rb', /^\s+devise.*$/ do |match| | |
| "#{match}, :lockable" | |
| end | |
| file 'app/views/unlocks/new.html.haml', <<-END | |
| %h2 Resend unlock instructions | |
| - semantic_form_for resource_name, resource, :url => unlock_path(resource_name) do |form| | |
| = form.error_messages | |
| = form.inputs :email | |
| - form.buttons do | |
| = form.commit_button "Resend unlock instructions" | |
| = render :partial => "shared/devise_links" | |
| END | |
| file 'app/views/devise_mailer/unlock_instructions.html.haml', <<-END | |
| = "Hello \#{@resource.email}!" | |
| Your account has been locked due to an excessive amount of unsuccessful sign in attempts. | |
| Click the link below to unlock your account: | |
| = link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) | |
| END | |
| end | |
| if yes?("Include the 'Invitable' module?") | |
| file "db/migrate/#{Time.now.utc.strftime('%Y%m%d%H%M%S')}_devise_add_invitable_fields.rb", <<-END | |
| class DeviseAddInvitableFields < ActiveRecord::Migration | |
| def self.up | |
| change_column :users, :encrypted_password, :string, :null => true | |
| change_column :users, :password_salt, :string, :null => true | |
| add_column :users, :invitation_token, :string, :limit => 20 | |
| add_column :users, :invitation_sent_at, :datetime | |
| add_index :users, :invitation_token, :unique => true | |
| remove_column :users, :confirmation_token | |
| remove_column :users, :confirmed_at | |
| remove_column :users, :confirmation_sent_at | |
| end | |
| def self.down | |
| change_column :users, :encrypted_password, :string, :null => false | |
| change_column :users, :password_salt, :string, :null => false | |
| remove_column :users, :invitation_token | |
| remove_column :users, :invitation_sent_at | |
| remove_index :users, :invitation_token | |
| add_column :users, :confirmation_token, :string, :limit => 20 | |
| add_column :users, :confirmed_at, :datetime | |
| add_column :users, :confirmation_sent_at, :datetime | |
| add_index :users, :confirmation_token, :unique => true | |
| end | |
| end | |
| END | |
| gsub_file 'app/models/user.rb', /^\s+devise.*$/ do |match| | |
| "#{match}, :invitable" | |
| end | |
| file 'app/views/devise_mailer/invitation.html.haml', <<-END | |
| = "Hello \#{@resource.email}!" | |
| = "Someone has invited you to \#{root_url}, you can accept it through the link below." | |
| = link_to 'Accept invitation', accept_invitation_url(@resource, :invitation_token => @resource.invitation_token) | |
| If you don't want to accept the invitation, please ignore this email. | |
| Your account won't be created until you access the link above and set your password. | |
| END | |
| file 'app/views/invitations/new.html.haml', <<-END | |
| %h2 Send invitation | |
| - semantic_form_for resource_name, resource, :url => invitation_path(resource_name) do |form| | |
| = form.error_messages | |
| = form.inputs :email | |
| - form.buttons do | |
| = form.commit_button "Send an invitation" | |
| = link_to "Home", after_sign_in_path_for(resource_name) | |
| END | |
| file 'app/views/invitations/edit.html.haml', <<-END | |
| %h2 Set your password | |
| - semantic_form_for resource_name, resource, :url => invitation_path(resource_name), :html => {:method => :put} do |form| | |
| = form.error_messages | |
| - form.inputs do | |
| = form.input :invitation_token, :as => :hidden | |
| = form.input :password, :as => :password | |
| = form.input :password_confirmation, :as => :password | |
| - form.buttons do | |
| = form.commit_button "Set my password" | |
| END | |
| gsub_file('app/models/user.rb', /,\s:confirmable/, "") | |
| else | |
| file 'app/views/confirmations/new.html.haml', <<-END | |
| %h2 Resend confirmation instructions | |
| - semantic_form_for resource_name, resource, :url => confirmation_path(resource_name) do |form| | |
| = form.error_messages | |
| - form.inputs do | |
| = form.input :email | |
| - form.buttons do | |
| = form.commit_button "Resend confirmation instructions" | |
| = render :partial => "shared/devise_links" | |
| END | |
| file 'app/views/devise_mailer/confirmation_instructions.html.haml', <<-END | |
| = "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) | |
| END | |
| end | |
| rake('db:migrate') if yes?('Migrate the database now?') | |
| file 'app/views/devise_mailer/reset_password_instructions.html.haml', <<-END | |
| = "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. | |
| END | |
| file 'app/views/passwords/edit.html.haml', <<-END | |
| %h2 Change your password | |
| - semantic_form_for resource_name, resource, :url => password_path(resource_name), :html => {:method => :put} do |form| | |
| = form.error_messages | |
| - form.inputs do | |
| = form.input :reset_password_token, :as => :hidden | |
| = form.input :password, :as => :password | |
| = form.input :password_confirmation, :as => :password | |
| - form.buttons do | |
| = form.commit_button "Change my password" | |
| = render :partial => "shared/devise_links" | |
| END | |
| file 'app/views/passwords/new.html.haml', <<-END | |
| %h2 Forgot your password? | |
| - semantic_form_for resource_name, resource, :url => password_path(resource_name) do |form| | |
| = form.error_messages | |
| = form.inputs :email | |
| - form.buttons do | |
| = form.commit_button "Send me reset password instructions" | |
| = render :partial => "shared/devise_links" | |
| END | |
| file 'app/views/sessions/new.html.haml', <<-END | |
| %h2 Sign in | |
| - if devise_mapping.authenticatable? | |
| - semantic_form_for resource_name, resource, :url => session_path(resource_name) do |form| | |
| = form.error_messages | |
| - form.inputs do | |
| = form.input :email | |
| = form.input :password, :as => :password | |
| - if devise_mapping.rememberable? | |
| = form.input :remember_me, :as => :boolean | |
| - form.buttons do | |
| = form.commit_button "Sign in" | |
| = render :partial => "shared/devise_links" | |
| END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment