1
0
mirror of https://github.com/projekteuler/projekteuler.git synced 2026-01-27 02:28:50 +01:00

Add devise-bootstrap-views

This commit is contained in:
2015-01-31 12:53:53 +01:00
parent 0677e19b93
commit be6ba28845
18 changed files with 345 additions and 0 deletions

View File

@@ -11,6 +11,7 @@
* file per style scope.
*
*= require_tree .
*= require devise_bootstrap_views
*= require_self
*/

View File

@@ -1,2 +1,18 @@
module ApplicationHelper
def bootstrap_class_for flash_type
{ success: "alert-success", error: "alert-danger", alert: "alert-warning", notice: "alert-info" }[flash_type.to_sym] || flash_type.to_s
end
def flash_messages(opts = {})
flash.each do |msg_type, message|
concat(content_tag(:div, message, class: "alert #{bootstrap_class_for(msg_type)} alert-dismissible", role: 'alert') do
concat(content_tag(:button, class: 'close', data: { dismiss: 'alert' }) do
concat content_tag(:span, '×'.html_safe, 'aria-hidden' => true)
concat content_tag(:span, 'Close', class: 'sr-only')
end)
concat message
end)
end
nil
end
end

View File

@@ -0,0 +1,18 @@
<%= bootstrap_devise_error_messages! %>
<div class="panel panel-default">
<div class="panel-heading">
<h4><%= t('.resend_confirmation_instructions', :default => 'Resend confirmation instructions') %></h4>
</div>
<div class="panel-body">
<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post, role: "form" }) do |f| %>
<div class="form-group">
<%= f.label :email %>
<%= f.email_field :email, autofocus: true, class: "form-control" %>
</div>
<%= f.submit t('.resend_confirmation_instructions', :default => 'Resend confirmation instructions'), class: "btn btn-primary" %>
<% end %>
</div>
</div>
<%= render "devise/shared/links" %>

View File

@@ -0,0 +1,6 @@
<p><%= t('.greeting', :recipient => @resource.email, :default => "Welcome #{@resource.email}!") %></p>
<p><%= t('.instruction', :default => "You can confirm your account email through the link below:") %></p>
<p><%= link_to t('.action', :default => "Confirm my account"),
confirmation_url(@resource, :confirmation_token => @token, locale: I18n.locale) %></p>

View File

@@ -0,0 +1,8 @@
<p><%= t('.greeting', :recipient => @resource.email, :default => "Hello #{@resource.email}!") %></p>
<p><%= t('.instruction', :default => "Someone has requested a link to change your password, and you can do this through the link below.") %></p>
<p><%= link_to t('.action', :default => "Change my password"), edit_password_url(@resource, :reset_password_token => @token, locale: I18n.locale) %></p>
<p><%= t('.instruction_2', :default => "If you didn't request this, please ignore this email.") %></p>
<p><%= t('.instruction_3', :default => "Your password won't change until you access the link above and create a new one.") %></p>

View File

@@ -0,0 +1,7 @@
<p><%= t('.greeting', :recipient => @resource.email, :default => "Hello #{@resource.email}!") %></p>
<p><%= t('.message', :default => "Your account has been locked due to an excessive amount of unsuccessful sign in attempts.") %></p>
<p><%= t('.instruction', :default => "Click the link below to unlock your account:") %></p>
<p><%= link_to t('.action', :default => "Unlock my account"), unlock_url(@resource, :unlock_token => @resource.unlock_token, locale: I18n.locale) %></p>

View File

@@ -0,0 +1,24 @@
<%= bootstrap_devise_error_messages! %>
<div class="panel panel-default">
<div class="panel-heading">
<h4><%= t('.change_your_password', :default => 'Change your password') %></h4>
</div>
<div class="panel-body">
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put, role: "form" }) do |f| %>
<%= f.hidden_field :reset_password_token %>
<div class="form-group">
<%= f.label :password, t('.new_password', :default => 'New password') %>
<%= f.password_field :password, autofocus: true, class: "form-control" %>
</div>
<div class="form-group">
<%= f.label :password_confirmation, t('.confirm_new_password', :default => 'Confirm new password') %>
<%= f.password_field :password_confirmation, class: "form-control" %>
</div>
<%= f.submit t('.change_my_password', :default => 'Change my password'), class: "btn btn-primary" %>
<% end %>
</div>
</div>
<%= render "devise/shared/links" %>

View File

@@ -0,0 +1,17 @@
<%= bootstrap_devise_error_messages! %>
<div class="panel panel-default">
<div class="panel-heading">
<h4><%= t('.forgot_your_password', :default => 'Forgot your password?') %></h4>
</div>
<div class="panel-body">
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post, role: "form" }) do |f| %>
<div class="form-group">
<%= f.label :email %>
<%= f.email_field :email, autofocus: true, class: "form-control" %>
</div>
<%= f.submit t('.send_me_reset_password_instructions', :default => "Send me reset password instructions"), class: "btn btn-primary" %>
<% end %>
</div>
</div>
<%= render "devise/shared/links" %>

View File

@@ -0,0 +1,30 @@
<%= bootstrap_devise_error_messages! %>
<div class="panel panel-default">
<div class="panel-heading">
<h4><%= t('.title', :resource => resource_class.model_name.human , :default => 'Edit #{resource_name.to_s.humanize}') %></h4>
</div>
<div class="panel-body">
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
<div class="form-group">
<%= f.label :email %>
<%= f.email_field :email, autofocus: true, class: "form-control" %>
</div>
<div class="form-group">
<%= f.label :password %> <i>(<%= t('.leave_blank_if_you_don_t_want_to_change_it', :default => "leave blank if you don't want to change it") %>)</i><br />
<%= f.password_field :password, :autocomplete => "off", class: "form-control" %>
</div>
<div class="form-group">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, class: "form-control" %>
</div>
<div class="form-group">
<%= f.label :current_password %> <i>(<%= t('.we_need_your_current_password_to_confirm_your_changes', :default => 'we need your current password to confirm your changes') %>)</i>
<%= f.password_field :current_password, class: "form-control" %>
</div>
<%= f.submit t('.update', :default => "Update"), class: "btn btn-primary" %></div>
<% end %>
</div>
<p><%= t('.unhappy', :default => 'Unhappy') %>? <%= link_to t('.cancel_my_account', :default => "Cancel my account"), registration_path(resource_name), :data => { :confirm => t('.are_you_sure', :default => "Are you sure?") }, :method => :delete %>.</p>
<%= link_to "Back", :back %>

View File

@@ -0,0 +1,24 @@
<%= bootstrap_devise_error_messages! %>
<div class="panel panel-default">
<div class="panel-heading">
<h4><%= t('.sign_up', :default => "Sign up") %></h4>
</div>
<div class="panel-body">
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), html: { role: "form" }) do |f| %>
<div class="form-group">
<%= f.label :email %>
<%= f.email_field :email, autofocus: true, class: "form-control" %>
</div>
<div class="form-group">
<%= f.label :password %><br />
<%= f.password_field :password, class: "form-control" %>
</div>
<div class="form-group">
<%= f.label :password_confirmation %>
<%= f.password_field :password_confirmation, class: "form-control" %>
</div>
<%= f.submit t('.sign_up', :default => "Sign up"), class: "btn btn-primary" %>
<% end %>
</div>
</div>
<%= render "devise/shared/links" %>

View File

@@ -0,0 +1,26 @@
<div class="panel panel-default">
<div class="panel-heading">
<h4><%= t('.sign_in', :default => "Sign in") %></h4>
</div>
<div class="panel-body">
<%= form_for(resource, as: resource_name, url: session_path(resource_name), html: { role: "form" }) do |f| %>
<div class="form-group">
<%= f.label :email %>
<%= f.email_field :email, autofocus: true, class: "form-control" %>
</div>
<div class="form-group">
<%= f.label :password %>
<%= f.password_field :password, autocomplete: "off", class: "form-control" %>
</div>
<% if devise_mapping.rememberable? %>
<div class="checkbox">
<label>
<%= f.check_box :remember_me %>
<%= f.label :remember_me %>
</div>
<% end %>
<%= f.submit t('.sign_in', :default => "Sign in"), class: "btn btn-primary" %>
<% end %>
</div>
</div>
<%= render "devise/shared/links" %>

View File

@@ -0,0 +1,25 @@
<%- if controller_name != 'sessions' %>
<%= link_to t(".sign_in", :default => "Sign in"), new_session_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to t(".sign_up", :default => "Sign up"), new_registration_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
<%= link_to t(".forgot_your_password", :default => "Forgot your password?"), new_password_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= link_to t('.didn_t_receive_confirmation_instructions', :default => "Didn't receive confirmation instructions?"), new_confirmation_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
<%= link_to t('.didn_t_receive_unlock_instructions', :default => "Didn't receive unlock instructions?"), new_unlock_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to t('.sign_in_with_provider', :provider => provider.to_s.titleize, :default => "Sign in with #{provider.to_s.titleize}"), omniauth_authorize_path(resource_name, provider) %><br />
<% end -%>
<% end -%>

View File

@@ -0,0 +1,16 @@
<%= bootstrap_devise_error_messages! %>
<div class="panel panel-default">
<div class="panel-heading">
<h4><%= t('.resend_unlock_instructions', :default => "Resend unlock instructions") %></h4>
</div>
<div class="panel-body">
<%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post, html: { role: "form" } }) do |f| %>
<div class="form-group">
<%= f.label :email %>
<%= f.email_field :email, autofocus: true, class: "form-control" %>
</div>
<%= f.submit t('.resend_unlock_instructions', :default => "Resend unlock instructions"), class: "btn btn-primary"%>
<% end %>
</div>
</div>
<%= render "devise/shared/links" %>

View File

@@ -28,9 +28,17 @@
<%= link_to Problem.model_name.human(count: 2), problems_path %>
<%= link_to Translation.model_name.human(count: 2), translations_path %>
<% end %>
<%= nav class: 'navbar-right' do %>
<% if admin_signed_in? %>
<%= link_to(t('application.sign_out'), destroy_admin_session_path, method: :delete) %>
<% else %>
<%= link_to(t('application.sign_in'), new_admin_session_path) %>
<% end %>
<% end %>
<% end %>
<% end %>
<div class="container">
<%= flash_messages %>
<div class="row">
<div class="col-md-12" role="main">
<%= yield %>