From b239ce7e9984fb0915ec90522de54a22337e53a3 Mon Sep 17 00:00:00 2001 From: Fernando Brito Date: Tue, 13 May 2014 03:27:40 -0300 Subject: [PATCH] rails_apps_composer: views --- app/helpers/application_helper.rb | 13 +++++++++++++ app/views/devise/registrations/edit.html.haml | 15 +++++++++++++++ app/views/devise/registrations/new.html.haml | 10 ++++++++++ app/views/devise/sessions/new.html.haml | 7 +++++++ app/views/devise/shared/_links.html.haml | 19 +++++++++++++++++++ 5 files changed, 64 insertions(+), 0 deletions(-) create mode 100644 app/views/devise/registrations/edit.html.haml create mode 100644 app/views/devise/registrations/new.html.haml create mode 100644 app/views/devise/sessions/new.html.haml create mode 100644 app/views/devise/shared/_links.html.haml diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be79..3e3b181 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,15 @@ module ApplicationHelper + + def display_base_errors resource + return '' if (resource.errors.empty?) or (resource.errors[:base].empty?) + messages = resource.errors[:base].map { |msg| content_tag(:p, msg) }.join + html = <<-HTML +
+ + #{messages} +
+ HTML + html.html_safe + end + end diff --git a/app/views/devise/registrations/edit.html.haml b/app/views/devise/registrations/edit.html.haml new file mode 100644 index 0000000..61dff66 --- /dev/null +++ b/app/views/devise/registrations/edit.html.haml @@ -0,0 +1,15 @@ +%h2 + Edit #{resource_name.to_s.humanize} += simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :class => 'form-vertical' }) do |f| + = f.error_notification + = display_base_errors resource + = f.input :name, :autofocus => true + = f.input :email, :required => true + = f.input :password, :autocomplete => "off", :hint => "leave it blank if you don't want to change it", :required => false + = f.input :password_confirmation, :required => false + = f.input :current_password, :hint => "we need your current password to confirm your changes", :required => true + = f.button :submit, 'Update', :class => 'btn-primary' +%h3 Cancel my account +%p + Unhappy? #{link_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete}. += link_to "Back", :back diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml new file mode 100644 index 0000000..82ba0bd --- /dev/null +++ b/app/views/devise/registrations/new.html.haml @@ -0,0 +1,10 @@ +%h2 Sign up += simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => {:class => 'form-vertical' }) do |f| + = f.error_notification + = display_base_errors resource + = f.input :name, :autofocus => true + = f.input :email, :required => true + = f.input :password, :required => true + = f.input :password_confirmation, :required => true + = f.button :submit, 'Sign up', :class => 'btn-primary' += render "devise/shared/links" diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml new file mode 100644 index 0000000..7410279 --- /dev/null +++ b/app/views/devise/sessions/new.html.haml @@ -0,0 +1,7 @@ +%h2 Sign in += simple_form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => {:class => 'form-vertical' }) do |f| + = f.input :email, :autofocus => true + = f.input :password + = f.input :remember_me, :as => :boolean if devise_mapping.rememberable? + = f.button :submit, "Sign in", :class => 'btn-primary' += render "devise/shared/links" diff --git a/app/views/devise/shared/_links.html.haml b/app/views/devise/shared/_links.html.haml new file mode 100644 index 0000000..35d07ec --- /dev/null +++ b/app/views/devise/shared/_links.html.haml @@ -0,0 +1,19 @@ +- if controller_name != 'sessions' + = link_to "Sign in", new_session_path(resource_name) + %br/ +- if devise_mapping.registerable? && controller_name != 'registrations' + = link_to "Sign up", new_registration_path(resource_name) + %br/ +- if devise_mapping.recoverable? && controller_name != 'passwords' + = link_to "Forgot your password?", new_password_path(resource_name) + %br/ +- if devise_mapping.confirmable? && controller_name != 'confirmations' + = link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) + %br/ +- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' + = link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) + %br/ +- if devise_mapping.omniauthable? + - resource_class.omniauth_providers.each do |provider| + = link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) + %br/ -- libgit2 0.21.2