From 1a21ec30cffe1dcf7c9d38538fe331524af50632 Mon Sep 17 00:00:00 2001 From: Dan Kim Date: Thu, 24 Nov 2016 18:42:37 +0300 Subject: [PATCH 01/15] Remove panels --- app/views/devise/confirmations/new.html.erb | 22 ++++----- .../mailer/confirmation_instructions.html.erb | 6 ++- .../reset_password_instructions.html.erb | 1 + app/views/devise/passwords/edit.html.erb | 33 +++++++------- app/views/devise/passwords/new.html.erb | 23 +++++----- app/views/devise/registrations/edit.html.erb | 45 +++++++++---------- app/views/devise/registrations/new.html.erb | 38 ++++++++-------- app/views/devise/sessions/new.html.erb | 45 +++++++++---------- app/views/devise/unlocks/new.html.erb | 23 +++++----- 9 files changed, 110 insertions(+), 126 deletions(-) diff --git a/app/views/devise/confirmations/new.html.erb b/app/views/devise/confirmations/new.html.erb index e89f990..cab3d80 100644 --- a/app/views/devise/confirmations/new.html.erb +++ b/app/views/devise/confirmations/new.html.erb @@ -1,18 +1,14 @@ <%= bootstrap_devise_error_messages! %> -
-
-

<%= t('.resend_confirmation_instructions', default: 'Resend confirmation instructions') %>

-
-
- <%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post, role: 'form' }) do |f| %> -
- <%= f.label :email %> - <%= f.email_field :email, autofocus: true, class: "form-control" %> -
- <%= f.submit t('.resend_confirmation_instructions', default: 'Resend confirmation instructions'), class: 'btn btn-primary' %> - <% end %> +

<%= t('.resend_confirmation_instructions', default: 'Resend confirmation instructions') %>

+ +<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post, role: 'form' }) do |f| %> +
+ <%= f.label :email %> + <%= f.email_field :email, autofocus: true, class: "form-control" %>
-
+ + <%= f.submit t('.resend_confirmation_instructions', default: 'Resend confirmation instructions'), class: 'btn btn-primary' %> +<% end %> <%= render 'devise/shared/links' %> diff --git a/app/views/devise/mailer/confirmation_instructions.html.erb b/app/views/devise/mailer/confirmation_instructions.html.erb index ae24ad6..1dd4707 100644 --- a/app/views/devise/mailer/confirmation_instructions.html.erb +++ b/app/views/devise/mailer/confirmation_instructions.html.erb @@ -2,5 +2,7 @@

<%= t('.instruction', default: 'You can confirm your account email through the link below:') %>

-

<%= link_to t('.action', default: 'Confirm my account'), - confirmation_url(@resource, confirmation_token: @token, locale: I18n.locale) %>

+

+ <%= link_to t('.action', default: 'Confirm my account'), + confirmation_url(@resource, confirmation_token: @token, locale: I18n.locale) %> +

diff --git a/app/views/devise/mailer/reset_password_instructions.html.erb b/app/views/devise/mailer/reset_password_instructions.html.erb index f757e10..01e4c91 100644 --- a/app/views/devise/mailer/reset_password_instructions.html.erb +++ b/app/views/devise/mailer/reset_password_instructions.html.erb @@ -5,4 +5,5 @@

<%= link_to t('.action', default: 'Change my password'), edit_password_url(@resource, reset_password_token: @token, locale: I18n.locale) %>

<%= t('.instruction_2', default: "If you didn't request this, please ignore this email.") %>

+

<%= t('.instruction_3', default: "Your password won't change until you access the link above and create a new one.") %>

diff --git a/app/views/devise/passwords/edit.html.erb b/app/views/devise/passwords/edit.html.erb index acb1ae6..bd1e136 100644 --- a/app/views/devise/passwords/edit.html.erb +++ b/app/views/devise/passwords/edit.html.erb @@ -1,24 +1,21 @@ <%= bootstrap_devise_error_messages! %> -
-
-

<%= t('.change_your_password', default: 'Change your password') %>

-
-
- <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put, role: 'form' }) do |f| %> - <%= f.hidden_field :reset_password_token %> -
- <%= f.label :password, t('.new_password', default: 'New password') %> - <%= f.password_field :password, autofocus: true, class: 'form-control' %> -
+

<%= t('.change_your_password', default: 'Change your password') %>

+ +<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put, role: 'form' }) do |f| %> + <%= f.hidden_field :reset_password_token %> -
- <%= f.label :password_confirmation, t('.confirm_new_password', default: 'Confirm new password') %> - <%= f.password_field :password_confirmation, class: 'form-control' %> -
+
+ <%= f.label :password, t('.new_password', default: 'New password') %> + <%= f.password_field :password, autofocus: true, class: 'form-control' %> +
- <%= f.submit t('.change_my_password', default: 'Change my password'), class: 'btn btn-primary' %> - <% end %> +
+ <%= f.label :password_confirmation, t('.confirm_new_password', default: 'Confirm new password') %> + <%= f.password_field :password_confirmation, class: 'form-control' %>
-
+ + <%= f.submit t('.change_my_password', default: 'Change my password'), class: 'btn btn-primary' %> +<% end %> + <%= render 'devise/shared/links' %> diff --git a/app/views/devise/passwords/new.html.erb b/app/views/devise/passwords/new.html.erb index 6e8cf99..8fc1bb0 100644 --- a/app/views/devise/passwords/new.html.erb +++ b/app/views/devise/passwords/new.html.erb @@ -1,17 +1,14 @@ <%= bootstrap_devise_error_messages! %> -
-
-

<%= t('.forgot_your_password', default: 'Forgot your password?') %>

-
-
- <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post, role: "form" }) do |f| %> -
- <%= f.label :email %> - <%= f.email_field :email, autofocus: true, class: 'form-control' %> -
- <%= f.submit t('.send_me_reset_password_instructions', default: 'Send me reset password instructions'), class: 'btn btn-primary' %> - <% end %> +

<%= t('.forgot_your_password', default: 'Forgot your password?') %>

+ +<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post, role: 'form' }) do |f| %> +
+ <%= f.label :email %> + <%= f.email_field :email, autofocus: true, class: 'form-control' %>
-
+ + <%= f.submit t('.send_me_reset_password_instructions', default: 'Send me reset password instructions'), class: 'btn btn-primary' %> +<% end %> + <%= render 'devise/shared/links' %> diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index a75bb07..29b1fed 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -1,30 +1,27 @@ <%= bootstrap_devise_error_messages! %> -
-
-

<%= t('.title', resource: resource_class.model_name.human , default: "Edit #{resource_name.to_s.humanize}") %>

+ +

<%= t('.title', resource: resource_class.model_name.human , default: "Edit #{resource_name.to_s.humanize}") %>

+ +<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> +
+ <%= f.label :email %> + <%= f.email_field :email, autofocus: true, class: 'form-control' %> +
+
+ <%= f.label :password %> (<%= t('.leave_blank_if_you_don_t_want_to_change_it', default: "leave blank if you don't want to change it") %>) + <%= f.password_field :password, autocomplete: "off", class: 'form-control' %>
-
- <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> -
- <%= f.label :email %> - <%= f.email_field :email, autofocus: true, class: 'form-control' %> -
-
- <%= f.label :password %> (<%= t('.leave_blank_if_you_don_t_want_to_change_it', default: "leave blank if you don't want to change it") %>) - <%= f.password_field :password, autocomplete: "off", class: 'form-control' %> -
-
- <%= f.label :password_confirmation %> - <%= f.password_field :password_confirmation, class: 'form-control' %> -
-
- <%= f.label :current_password %> (<%= t('.we_need_your_current_password_to_confirm_your_changes', default: 'we need your current password to confirm your changes') %>) - <%= f.password_field :current_password, class: 'form-control' %> -
- <%= f.submit t('.update', default: 'Update'), class: 'btn btn-primary' %> - <% end %> +
+ <%= f.label :password_confirmation %> + <%= f.password_field :password_confirmation, class: 'form-control' %>
-
+
+ <%= f.label :current_password %> (<%= t('.we_need_your_current_password_to_confirm_your_changes', default: 'we need your current password to confirm your changes') %>) + <%= f.password_field :current_password, class: 'form-control' %> +
+ + <%= f.submit t('.update', default: 'Update'), class: 'btn btn-primary' %> +<% end %>

<%= 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 %>.

diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index 2097ba7..d4f1f14 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -1,24 +1,22 @@ <%= bootstrap_devise_error_messages! %> -
-
-

<%= t('.sign_up', default: 'Sign up') %>

+ +

<%= t('.sign_up', default: 'Sign up') %>

+ +<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { role: 'form' }) do |f| %> +
+ <%= f.label :email %> + <%= f.email_field :email, autofocus: true, class: 'form-control' %>
-
- <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { role: 'form' }) do |f| %> -
- <%= f.label :email %> - <%= f.email_field :email, autofocus: true, class: 'form-control' %> -
-
- <%= f.label :password %> - <%= f.password_field :password, class: 'form-control' %> -
-
- <%= f.label :password_confirmation %> - <%= f.password_field :password_confirmation, class: 'form-control' %> -
- <%= f.submit t('.sign_up', default: 'Sign up'), class: 'btn btn-primary' %> - <% end %> +
+ <%= f.label :password %> + <%= f.password_field :password, class: 'form-control' %>
-
+
+ <%= f.label :password_confirmation %> + <%= f.password_field :password_confirmation, class: 'form-control' %> +
+ + <%= f.submit t('.sign_up', default: 'Sign up'), class: 'btn btn-primary' %> +<% end %> + <%= render 'devise/shared/links' %> diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 53e3027..60a80e7 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -1,26 +1,25 @@ -
-
-

<%= t('.sign_in', default: 'Sign in') %>

+

<%= t('.sign_in', default: 'Sign in') %>

+ + +<%= form_for(resource, as: resource_name, url: session_path(resource_name), html: { role: 'form' }) do |f| %> +
+ <%= f.label :email %> + <%= f.email_field :email, autofocus: true, class: 'form-control' %>
-
- <%= form_for(resource, as: resource_name, url: session_path(resource_name), html: { role: 'form' }) do |f| %> -
- <%= f.label :email %> - <%= f.email_field :email, autofocus: true, class: 'form-control' %> -
-
- <%= f.label :password %> - <%= f.password_field :password, autocomplete: 'off', class: 'form-control' %> -
- <% if devise_mapping.rememberable? %> -
- <%= f.label :remember_me do %> - <%= f.check_box :remember_me %> <%= t('.remember_me', default: 'Remember me') %> - <% end %> -
- <% end %> - <%= f.submit t('.sign_in', default: 'Sign in'), class: 'btn btn-primary' %> - <% end %> +
+ <%= f.label :password %> + <%= f.password_field :password, autocomplete: 'off', class: 'form-control' %>
-
+ + <% if devise_mapping.rememberable? %> +
+ <%= f.label :remember_me do %> + <%= f.check_box :remember_me %> <%= t('.remember_me', default: 'Remember me') %> + <% end %> +
+ <% end %> + + <%= f.submit t('.sign_in', default: 'Sign in'), class: 'btn btn-primary' %> +<% end %> + <%= render 'devise/shared/links' %> diff --git a/app/views/devise/unlocks/new.html.erb b/app/views/devise/unlocks/new.html.erb index 792cd2e..646c470 100644 --- a/app/views/devise/unlocks/new.html.erb +++ b/app/views/devise/unlocks/new.html.erb @@ -1,16 +1,13 @@ <%= bootstrap_devise_error_messages! %> -
-
-

<%= t('.resend_unlock_instructions', default: 'Resend unlock instructions') %>

+ +

<%= t('.resend_unlock_instructions', default: 'Resend unlock instructions') %>

+ +<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post, html: { role: 'form' } }) do |f| %> +
+ <%= f.label :email %> + <%= f.email_field :email, autofocus: true, class: 'form-control' %>
-
- <%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post, html: { role: "form" } }) do |f| %> -
- <%= f.label :email %> - <%= f.email_field :email, autofocus: true, class: 'form-control' %> -
- <%= f.submit t('.resend_unlock_instructions', default: 'Resend unlock instructions'), class: 'btn btn-primary'%> - <% end %> -
-
+ <%= f.submit t('.resend_unlock_instructions', default: 'Resend unlock instructions'), class: 'btn btn-primary'%> +<% end %> + <%= render 'devise/shared/links' %> From 15d6b21d50b8c17a6efb866361821a1dc6ec82cf Mon Sep 17 00:00:00 2001 From: Dan Kim Date: Wed, 2 Nov 2016 14:14:18 +0300 Subject: [PATCH 02/15] Remove unused classes from styles --- app/assets/stylesheets/devise_bootstrap_views.scss | 10 ---------- .../stylesheets/devise_bootstrap_views_less.less | 10 ---------- 2 files changed, 20 deletions(-) diff --git a/app/assets/stylesheets/devise_bootstrap_views.scss b/app/assets/stylesheets/devise_bootstrap_views.scss index d6409ef..e69de29 100644 --- a/app/assets/stylesheets/devise_bootstrap_views.scss +++ b/app/assets/stylesheets/devise_bootstrap_views.scss @@ -1,10 +0,0 @@ -.float-none { - float: none; -} - -.panel-heading { - padding: 15px; - h4 { - margin: 0px; - } -} diff --git a/app/assets/stylesheets/devise_bootstrap_views_less.less b/app/assets/stylesheets/devise_bootstrap_views_less.less index d6409ef..e69de29 100644 --- a/app/assets/stylesheets/devise_bootstrap_views_less.less +++ b/app/assets/stylesheets/devise_bootstrap_views_less.less @@ -1,10 +0,0 @@ -.float-none { - float: none; -} - -.panel-heading { - padding: 15px; - h4 { - margin: 0px; - } -} From 03e572cf2ca028b82201a5ecf77ea240638e1a4d Mon Sep 17 00:00:00 2001 From: Dan Kim Date: Wed, 2 Nov 2016 14:14:32 +0300 Subject: [PATCH 03/15] Update code style --- devise-bootstrap-views.gemspec | 16 ++++++++-------- lib/devise-bootstrap-views.rb | 3 +-- lib/devise_bootstrap_views_helper.rb | 2 -- .../bootstrap_templates_generator.rb | 2 +- .../devise/views/locale/locale_generator.rb | 2 +- lib/version.rb | 2 +- 6 files changed, 12 insertions(+), 15 deletions(-) diff --git a/devise-bootstrap-views.gemspec b/devise-bootstrap-views.gemspec index 9f02567..8ae3706 100644 --- a/devise-bootstrap-views.gemspec +++ b/devise-bootstrap-views.gemspec @@ -4,20 +4,20 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'version' Gem::Specification.new do |spec| - spec.name = "devise-bootstrap-views" + spec.name = 'devise-bootstrap-views' spec.version = DeviseBootstrapViews::VERSION - spec.authors = ["Yinghai Zhao"] - spec.email = ["zyinghai@gmail.com"] + spec.authors = ['Yinghai Zhao'] + spec.email = ['zyinghai@gmail.com'] spec.summary = %q{Devise Bootstrap views with i18n support.} spec.description = %q{Devise Bootstrap views with i18n support.} - spec.homepage = "" - spec.license = "MIT" + spec.homepage = '' + spec.license = 'MIT' spec.files = `git ls-files -z`.split("\x0") spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) - spec.require_paths = ["lib"] + spec.require_paths = ['lib'] - spec.add_development_dependency "bundler", "~> 1.6" - spec.add_development_dependency "rake" + spec.add_development_dependency 'bundler', '~> 1.6' + spec.add_development_dependency 'rake' end diff --git a/lib/devise-bootstrap-views.rb b/lib/devise-bootstrap-views.rb index 724ddf8..6f6aff0 100644 --- a/lib/devise-bootstrap-views.rb +++ b/lib/devise-bootstrap-views.rb @@ -1,5 +1,6 @@ require 'rails' require 'devise_bootstrap_views_helper' + module DeviseBootstrapViews class Engine < ::Rails::Engine end @@ -24,5 +25,3 @@ def self.pattern_from(args) end end end - - diff --git a/lib/devise_bootstrap_views_helper.rb b/lib/devise_bootstrap_views_helper.rb index 6bde7ef..8198846 100644 --- a/lib/devise_bootstrap_views_helper.rb +++ b/lib/devise_bootstrap_views_helper.rb @@ -1,5 +1,3 @@ -# -*- encoding : utf-8 -*- - module DeviseBootstrapViewsHelper def bootstrap_devise_error_messages! return '' if resource.errors.empty? diff --git a/lib/generators/devise/views/bootstrap_templates/bootstrap_templates_generator.rb b/lib/generators/devise/views/bootstrap_templates/bootstrap_templates_generator.rb index 154e1f6..14d3a17 100644 --- a/lib/generators/devise/views/bootstrap_templates/bootstrap_templates_generator.rb +++ b/lib/generators/devise/views/bootstrap_templates/bootstrap_templates_generator.rb @@ -3,7 +3,7 @@ module Views class BootstrapTemplatesGenerator < Rails::Generators::Base source_root File.expand_path('../../../../../../app/views', __FILE__) def copy_views - directory("devise", Rails.root.join("app", "views", "devise")) + directory('devise', Rails.root.join('app', 'views', 'devise')) end end end diff --git a/lib/generators/devise/views/locale/locale_generator.rb b/lib/generators/devise/views/locale/locale_generator.rb index 4a45a3c..32f4f1b 100644 --- a/lib/generators/devise/views/locale/locale_generator.rb +++ b/lib/generators/devise/views/locale/locale_generator.rb @@ -6,7 +6,7 @@ def download_locale download_url = URI.parse("#{repo_url}#{name}.yml") downloaded_file = Net::HTTP.get(download_url).force_encoding('UTF-8') File.write(Rails.root.join( - "config", "locales", "devise.views.#{name}.yml"), downloaded_file) + 'config', 'locales', "devise.views.#{name}.yml"), downloaded_file) end end end diff --git a/lib/version.rb b/lib/version.rb index 1628c7e..aee5b56 100644 --- a/lib/version.rb +++ b/lib/version.rb @@ -1,3 +1,3 @@ module DeviseBootstrapViews - VERSION = "0.0.9" + VERSION = '0.0.9' end From 12bf0162359d6df46f745f996189b9ee80b7f154 Mon Sep 17 00:00:00 2001 From: Dan Kim Date: Wed, 2 Nov 2016 14:17:00 +0300 Subject: [PATCH 04/15] Clean up .gitignore --- .gitignore | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 31cafb5..7153d6a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,22 +1,11 @@ +/.bundle/ +/.yardoc +/Gemfile.lock +/_yardoc/ +/coverage/ +/doc/ +/pkg/ +/spec/reports/ +/tmp/ + *.gem -*.rbc -.bundle -.config -.yardoc -Gemfile.lock -InstalledFiles -_yardoc -coverage -doc/ -lib/bundler/man -pkg -rdoc -spec/reports -test/tmp -test/version_tmp -tmp -*.bundle -*.so -*.o -*.a -mkmf.log From 7599aab26473cee70ee1857722f42c64df0565a3 Mon Sep 17 00:00:00 2001 From: Dan Kim Date: Wed, 2 Nov 2016 14:21:52 +0300 Subject: [PATCH 05/15] Update README --- README.md | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 29803b1..6a3bd40 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ Here are some of the highlights: -* Devise views with Bootstrap 3. -* Used Bootstrap responsive columns. -* I18n Support. +* Devise views with Bootstrap 4 +* Used Bootstrap responsive columns +* I18n Support WARNING: This gem copies lots of its code from [devise-i18n-views](https://github.com/mcasimir/devise-i18n-views) gem. @@ -22,18 +22,10 @@ And then execute: $ bundle -Add some minor css fix to your rails asset pipeline manifest - - # SASS - *= require devise_bootstrap_views - - # LESS - *= require devise_bootstrap_views_less - -Then you need to install the required translations in your `config/locales`. The [devise-i18n-views](https://github.com/mcasimir/devise-i18n-views) project is no longer maintained after being merged into [devise-i18n](https://github.com/tigrish/devise-i18n), which is currently the best source for updated Devise translations. You can manually download locale dictionaries from [devise-i18n/rails/locales](https://github.com/tigrish/devise-i18n/tree/master/rails/locales) or generate them by running `devise:views:locale `: +Then you can install the required translations in your `config/locales`. Use [devise-i18n](https://github.com/tigrish/devise-i18n) — the best source for updated Devise translations. You can manually generate locale files by executing `rails generate devise:views:locale `: ``` sh -rails g devise:views:locale it +rails generate devise:views:locale it ``` will generate `config/locales/devise.views.it.yml`. @@ -43,7 +35,7 @@ will generate `config/locales/devise.views.it.yml`. The `devise:views:bootstrap_templates` generator will copy all views to your application, so you can modify the files as you wish: ``` sh -rails g devise:views:bootstrap_templates +rails generate devise:views:bootstrap_templates ``` ## Example From 48967ee3f3910a28a1405cc17e4e386ac20b7a0f Mon Sep 17 00:00:00 2001 From: Dan Kim Date: Wed, 2 Nov 2016 14:25:09 +0300 Subject: [PATCH 06/15] Gemspec: add homepage, summary and description, lock rake version --- devise-bootstrap-views.gemspec | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/devise-bootstrap-views.gemspec b/devise-bootstrap-views.gemspec index 8ae3706..51d28f8 100644 --- a/devise-bootstrap-views.gemspec +++ b/devise-bootstrap-views.gemspec @@ -8,9 +8,9 @@ Gem::Specification.new do |spec| spec.version = DeviseBootstrapViews::VERSION spec.authors = ['Yinghai Zhao'] spec.email = ['zyinghai@gmail.com'] - spec.summary = %q{Devise Bootstrap views with i18n support.} - spec.description = %q{Devise Bootstrap views with i18n support.} - spec.homepage = '' + spec.summary = %q{Bootstrap views for Devise.} + spec.description = %q{Bootstrap views for Devise with I18n support.} + spec.homepage = 'https://github.com/hisea/devise-bootstrap-views' spec.license = 'MIT' spec.files = `git ls-files -z`.split("\x0") @@ -19,5 +19,5 @@ Gem::Specification.new do |spec| spec.require_paths = ['lib'] spec.add_development_dependency 'bundler', '~> 1.6' - spec.add_development_dependency 'rake' + spec.add_development_dependency 'rake', '~> 11.0' end From 7a9051685daa60904aa79080d1b524ce2a1692c2 Mon Sep 17 00:00:00 2001 From: Dan Kim Date: Wed, 2 Nov 2016 14:34:37 +0300 Subject: [PATCH 07/15] Add padding to shared links --- app/views/devise/shared/_links.html.erb | 40 +++++++++++++------------ 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/app/views/devise/shared/_links.html.erb b/app/views/devise/shared/_links.html.erb index 8e3cd00..d833869 100644 --- a/app/views/devise/shared/_links.html.erb +++ b/app/views/devise/shared/_links.html.erb @@ -1,25 +1,27 @@ -<% if controller_name != 'sessions' %> - <%= link_to t('.sign_in', default: 'Sign in'), new_session_path(resource_name) %>
-<% end %> +
+ <% if controller_name != 'sessions' %> + <%= link_to t('.sign_in', default: 'Sign in'), new_session_path(resource_name) %>
+ <% end %> -<% if devise_mapping.registerable? && controller_name != 'registrations' %> - <%= link_to t('.sign_up', default: 'Sign up'), new_registration_path(resource_name) %>
-<% end %> + <% if devise_mapping.registerable? && controller_name != 'registrations' %> + <%= link_to t('.sign_up', default: 'Sign up'), new_registration_path(resource_name) %>
+ <% end %> -<% if devise_mapping.recoverable? && controller_name != 'passwords' %> - <%= link_to t('.forgot_your_password', default: 'Forgot your password?'), new_password_path(resource_name) %>
-<% end %> + <% if devise_mapping.recoverable? && controller_name != 'passwords' %> + <%= link_to t('.forgot_your_password', default: 'Forgot your password?'), new_password_path(resource_name) %>
+ <% 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) %>
-<% 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) %>
+ <% 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) %>
-<% 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) %>
+ <% 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) %>
+ <% 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) %>
+ <% end %> <% end %> -<% end %> +
From 58e9730cccbcc16a12434576bde7feb256438562 Mon Sep 17 00:00:00 2001 From: Dan Kim Date: Wed, 2 Nov 2016 14:38:05 +0300 Subject: [PATCH 08/15] Add padding to submit buttons --- app/views/devise/confirmations/new.html.erb | 4 +++- app/views/devise/passwords/edit.html.erb | 4 +++- app/views/devise/passwords/new.html.erb | 4 +++- app/views/devise/registrations/edit.html.erb | 4 +++- app/views/devise/registrations/new.html.erb | 4 +++- app/views/devise/sessions/new.html.erb | 4 +++- app/views/devise/unlocks/new.html.erb | 5 ++++- 7 files changed, 22 insertions(+), 7 deletions(-) diff --git a/app/views/devise/confirmations/new.html.erb b/app/views/devise/confirmations/new.html.erb index cab3d80..b6b41d7 100644 --- a/app/views/devise/confirmations/new.html.erb +++ b/app/views/devise/confirmations/new.html.erb @@ -8,7 +8,9 @@ <%= f.email_field :email, autofocus: true, class: "form-control" %>
- <%= f.submit t('.resend_confirmation_instructions', default: 'Resend confirmation instructions'), class: 'btn btn-primary' %> +
+ <%= f.submit t('.resend_confirmation_instructions', default: 'Resend confirmation instructions'), class: 'btn btn-primary' %> +
<% end %> <%= render 'devise/shared/links' %> diff --git a/app/views/devise/passwords/edit.html.erb b/app/views/devise/passwords/edit.html.erb index bd1e136..b495a94 100644 --- a/app/views/devise/passwords/edit.html.erb +++ b/app/views/devise/passwords/edit.html.erb @@ -15,7 +15,9 @@ <%= f.password_field :password_confirmation, class: 'form-control' %>
- <%= f.submit t('.change_my_password', default: 'Change my password'), class: 'btn btn-primary' %> +
+ <%= f.submit t('.change_my_password', default: 'Change my password'), class: 'btn btn-primary' %> +
<% end %> <%= render 'devise/shared/links' %> diff --git a/app/views/devise/passwords/new.html.erb b/app/views/devise/passwords/new.html.erb index 8fc1bb0..3829f9f 100644 --- a/app/views/devise/passwords/new.html.erb +++ b/app/views/devise/passwords/new.html.erb @@ -8,7 +8,9 @@ <%= f.email_field :email, autofocus: true, class: 'form-control' %>
- <%= f.submit t('.send_me_reset_password_instructions', default: 'Send me reset password instructions'), class: 'btn btn-primary' %> +
+ <%= f.submit t('.send_me_reset_password_instructions', default: 'Send me reset password instructions'), class: 'btn btn-primary' %> +
<% end %> <%= render 'devise/shared/links' %> diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 29b1fed..49e4581 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -20,7 +20,9 @@ <%= f.password_field :current_password, class: 'form-control' %>
- <%= f.submit t('.update', default: 'Update'), class: 'btn btn-primary' %> +
+ <%= f.submit t('.update', default: 'Update'), class: 'btn btn-primary' %> +
<% end %>

<%= 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 %>.

diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index d4f1f14..8887298 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -16,7 +16,9 @@ <%= f.password_field :password_confirmation, class: 'form-control' %>
- <%= f.submit t('.sign_up', default: 'Sign up'), class: 'btn btn-primary' %> +
+ <%= f.submit t('.sign_up', default: 'Sign up'), class: 'btn btn-primary' %> +
<% end %> <%= render 'devise/shared/links' %> diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 60a80e7..425b7d7 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -19,7 +19,9 @@
<% end %> - <%= f.submit t('.sign_in', default: 'Sign in'), class: 'btn btn-primary' %> +
+ <%= f.submit t('.sign_in', default: 'Sign in'), class: 'btn btn-primary' %> +
<% end %> <%= render 'devise/shared/links' %> diff --git a/app/views/devise/unlocks/new.html.erb b/app/views/devise/unlocks/new.html.erb index 646c470..4f0cd59 100644 --- a/app/views/devise/unlocks/new.html.erb +++ b/app/views/devise/unlocks/new.html.erb @@ -7,7 +7,10 @@ <%= f.label :email %> <%= f.email_field :email, autofocus: true, class: 'form-control' %>
- <%= f.submit t('.resend_unlock_instructions', default: 'Resend unlock instructions'), class: 'btn btn-primary'%> + +
+ <%= f.submit t('.resend_unlock_instructions', default: 'Resend unlock instructions'), class: 'btn btn-primary'%> +
<% end %> <%= render 'devise/shared/links' %> From 9b89a5895e1f96de6bd50bb312cc478d03a712f7 Mon Sep 17 00:00:00 2001 From: Dan Kim Date: Wed, 2 Nov 2016 14:41:39 +0300 Subject: [PATCH 09/15] Add styles to "Remember me" checkbox --- app/views/devise/sessions/new.html.erb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 425b7d7..ccb6611 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -12,9 +12,10 @@
<% if devise_mapping.rememberable? %> -
- <%= f.label :remember_me do %> - <%= f.check_box :remember_me %> <%= t('.remember_me', default: 'Remember me') %> +
+ <%= f.label :remember_me, class: 'form-check-label' do %> + <%= f.check_box :remember_me, class: 'form-check-input' %> + <%= t('.remember_me', default: 'Remember me') %> <% end %>
<% end %> From 65ca2d9177aa9aa589f31fa07140eeeab99b26d3 Mon Sep 17 00:00:00 2001 From: Dan Kim Date: Wed, 2 Nov 2016 17:48:44 +0300 Subject: [PATCH 10/15] Update alert for error messages --- lib/devise_bootstrap_views_helper.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/devise_bootstrap_views_helper.rb b/lib/devise_bootstrap_views_helper.rb index 8198846..c80870b 100644 --- a/lib/devise_bootstrap_views_helper.rb +++ b/lib/devise_bootstrap_views_helper.rb @@ -2,16 +2,20 @@ module DeviseBootstrapViewsHelper def bootstrap_devise_error_messages! return '' if resource.errors.empty? - messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join - sentence = I18n.t('errors.messages.not_saved', + messages = resource.errors.full_messages.map { |message| content_tag(:li, message) }.join + sentence = I18n.t( + 'errors.messages.not_saved', count: resource.errors.count, - resource: resource.class.model_name.human.downcase) + resource: resource.class.model_name.human.downcase + ) html = <<-HTML -
- -
#{sentence}
-
    #{messages}
+
+ +

#{sentence}

+
    #{messages}
HTML From da9a1bffe724bf6902d9de76115ab7c12333bb04 Mon Sep 17 00:00:00 2001 From: Dan Kim Date: Thu, 24 Nov 2016 18:37:18 +0300 Subject: [PATCH 11/15] Update code style --- Rakefile | 3 +-- devise-bootstrap-views.gemspec | 4 ++-- lib/devise-bootstrap-views.rb | 2 -- .../bootstrap_templates/bootstrap_templates_generator.rb | 3 ++- lib/generators/devise/views/locale/locale_generator.rb | 5 +++-- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Rakefile b/Rakefile index 809eb56..c702cfc 100644 --- a/Rakefile +++ b/Rakefile @@ -1,2 +1 @@ -require "bundler/gem_tasks" - +require 'bundler/gem_tasks' diff --git a/devise-bootstrap-views.gemspec b/devise-bootstrap-views.gemspec index 51d28f8..0804826 100644 --- a/devise-bootstrap-views.gemspec +++ b/devise-bootstrap-views.gemspec @@ -8,8 +8,8 @@ Gem::Specification.new do |spec| spec.version = DeviseBootstrapViews::VERSION spec.authors = ['Yinghai Zhao'] spec.email = ['zyinghai@gmail.com'] - spec.summary = %q{Bootstrap views for Devise.} - spec.description = %q{Bootstrap views for Devise with I18n support.} + spec.summary = 'Bootstrap views for Devise.' + spec.description = 'Bootstrap views for Devise with I18n support.' spec.homepage = 'https://github.com/hisea/devise-bootstrap-views' spec.license = 'MIT' diff --git a/lib/devise-bootstrap-views.rb b/lib/devise-bootstrap-views.rb index 6f6aff0..f7c0e2a 100644 --- a/lib/devise-bootstrap-views.rb +++ b/lib/devise-bootstrap-views.rb @@ -17,8 +17,6 @@ class Railtie < ::Rails::Railtie #:nodoc: end end - protected - def self.pattern_from(args) array = Array(args || []) array.blank? ? '*' : "{#{array.join ','}}" diff --git a/lib/generators/devise/views/bootstrap_templates/bootstrap_templates_generator.rb b/lib/generators/devise/views/bootstrap_templates/bootstrap_templates_generator.rb index 14d3a17..6c935b0 100644 --- a/lib/generators/devise/views/bootstrap_templates/bootstrap_templates_generator.rb +++ b/lib/generators/devise/views/bootstrap_templates/bootstrap_templates_generator.rb @@ -2,8 +2,9 @@ module Devise module Views class BootstrapTemplatesGenerator < Rails::Generators::Base source_root File.expand_path('../../../../../../app/views', __FILE__) + def copy_views - directory('devise', Rails.root.join('app', 'views', 'devise')) + directory('devise', Rails.root.join('app', 'views', 'devise')) end end end diff --git a/lib/generators/devise/views/locale/locale_generator.rb b/lib/generators/devise/views/locale/locale_generator.rb index 32f4f1b..a56c0b3 100644 --- a/lib/generators/devise/views/locale/locale_generator.rb +++ b/lib/generators/devise/views/locale/locale_generator.rb @@ -5,8 +5,9 @@ def download_locale repo_url = 'https://raw.githubusercontent.com/tigrish/devise-i18n/master/rails/locales/' download_url = URI.parse("#{repo_url}#{name}.yml") downloaded_file = Net::HTTP.get(download_url).force_encoding('UTF-8') - File.write(Rails.root.join( - 'config', 'locales', "devise.views.#{name}.yml"), downloaded_file) + File.write( + Rails.root.join('config', 'locales', "devise.views.#{name}.yml"), downloaded_file + ) end end end From bf7ccf240a03599feaed4d895970ee6a5beed44c Mon Sep 17 00:00:00 2001 From: Yinghai Zhao Date: Tue, 20 Dec 2016 13:33:54 -0500 Subject: [PATCH 12/15] Update versions. --- lib/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/version.rb b/lib/version.rb index aee5b56..3566991 100644 --- a/lib/version.rb +++ b/lib/version.rb @@ -1,3 +1,3 @@ module DeviseBootstrapViews - VERSION = '0.0.9' + VERSION = '1.0.0.alpha1' end From 7eb5a14fe4e4bf8ed79553a14e44d6562b3a3ab2 Mon Sep 17 00:00:00 2001 From: Marco Perrando Date: Wed, 5 Apr 2017 12:22:31 +0200 Subject: [PATCH 13/15] Fix: "remember me" not translated. The "remember me" string is not translated in the new session form. --- app/views/devise/sessions/new.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index ccb6611..f0fb8e9 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -15,7 +15,7 @@
<%= f.label :remember_me, class: 'form-check-label' do %> <%= f.check_box :remember_me, class: 'form-check-input' %> - <%= t('.remember_me', default: 'Remember me') %> + <%= t('activerecord.attributes.user.remember_me', default: 'Remember me') %> <% end %>
<% end %> From 140a2ec72baac2ef62a84dce093b39e459d1bd43 Mon Sep 17 00:00:00 2001 From: Dan Kim Date: Mon, 20 Aug 2018 02:22:52 +0300 Subject: [PATCH 14/15] Update versions. --- lib/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/version.rb b/lib/version.rb index c100496..3566991 100644 --- a/lib/version.rb +++ b/lib/version.rb @@ -1,3 +1,3 @@ module DeviseBootstrapViews - VERSION = "0.0.11" + VERSION = '1.0.0.alpha1' end From 720c7334adbb6feaf8fc98bec5d48d6b6df4e22f Mon Sep 17 00:00:00 2001 From: Dan Kim Date: Mon, 20 Aug 2018 02:27:00 +0300 Subject: [PATCH 15/15] Update README --- README.md | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index d354d9c..4552505 100644 --- a/README.md +++ b/README.md @@ -2,26 +2,32 @@ Here are some of the highlights: -* Devise views with Bootstrap 4 -* Used Bootstrap responsive columns -* I18n Support +- Devise views with Bootstrap 4 +- Used Bootstrap responsive columns +- I18n Support + +***WARNING*** -WARNING: This gem copies lots of its code from [devise-i18n-views](https://github.com/mcasimir/devise-i18n-views) gem. ## Screenshot + ![Screenshot](https://raw.githubusercontent.com/hisea/devise-bootstrap-views/master/Screenshot.png) ## Installation -Add these lines in the head tag of your application.html.erb: +Make sure Bootstrap 4 is installed, either as a Ruby gem or using CDN: + +```html + +``` - - Add this line to your application's Gemfile: - gem 'devise-bootstrap-views' +```ruby +gem 'devise-bootstrap-views', '~> 1.0' +``` And then execute: @@ -30,10 +36,10 @@ And then execute: Then you can install the required translations in your `config/locales`. Use [devise-i18n](https://github.com/tigrish/devise-i18n) — the best source for updated Devise translations. You can manually generate locale files by executing `rails generate devise:views:locale `: ``` sh -rails generate devise:views:locale it +rails generate devise:views:locale de ``` -will generate `config/locales/devise.views.it.yml`. +will generate `config/locales/devise.views.de.yml`. ## Customizing Views @@ -43,21 +49,13 @@ The `devise:views:bootstrap_templates` generator will copy all views to your app rails generate devise:views:bootstrap_templates ``` -``` sh -rails g devise:views:bootstrap_haml_templates -``` - -``` sh -rails g devise:views:bootstrap_slim_templates -``` +## Remove Devise Bootstrap views -## Remove devise-bootstrap-views -If you would like to remove devise-bootstrap-views, please follow the steps below +If you would like to remove `devise-bootstrap-views`, please follow the steps below: 1. Remove `gem devise-bootstrap-views` from Gemfile -2. Delete Gemfile.lock -3. Command `bundle install` -4. Remove the contexts below from your stylesheets +2. Command `bundle install` +3. Remove the contexts below from your stylesheets ```sh # SASS @@ -67,11 +65,11 @@ If you would like to remove devise-bootstrap-views, please follow the steps belo *= require devise_bootstrap_views_less ``` -5. Remove devise view files +4. Remove devise view files ```sh rails destroy devise:views ``` -6. Generate devise view files again +5. Generate devise view files again ```sh rails g devise:views ```