devise-foundationed 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ guard :rubocop, all_on_start: false, cli: ["--format", "clang"] do
4
+ watch(%r{.+\.rb$})
5
+ watch(%r{.+\.rake$})
6
+ watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
7
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Pawel Osiczko
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,84 @@
1
+ <!-- Tocer[start]: Auto-generated, don't remove. -->
2
+
3
+ ## Table of Contents
4
+
5
+ - [Devise Foundationed](#devise-foundationed)
6
+ - [Prerequisites](#prerequisites)
7
+ - [Installation](#installation)
8
+ - [Usage](#usage)
9
+ - [Development](#development)
10
+ - [Contributing](#contributing)
11
+ - [License](#license)
12
+ - [Code of Conduct](#code-of-conduct)
13
+
14
+ <!-- Tocer[finish]: Auto-generated, don't remove. -->
15
+
16
+ # Devise Foundationed
17
+
18
+ This gem tries to give you a nicer place to start with your views for your Devise model
19
+ when you're using Foundation 6 (XY Grid).
20
+
21
+ You can find usage information below, but the gist of it is you'll
22
+ `run rails g devise:views:foundationed` instead of the normal devise:views.
23
+
24
+ If you want to switch back to what Devise gives you no problem! Just remove
25
+ the devise views folder and run the normal Devise generator command.
26
+
27
+ ## Prerequisites
28
+
29
+ * This gem is meant to be run with Rails 6 which includes Webpacker.
30
+ * You need to have Asset Pipeline and/or JS configured to include Foundation.
31
+
32
+ ## Installation
33
+
34
+ Add this line to your application's Gemfile:
35
+
36
+ ```ruby
37
+ gem 'devise-foundationed'
38
+ ```
39
+
40
+ And then execute:
41
+
42
+ $ bundle
43
+
44
+ Or install it yourself as:
45
+
46
+ $ gem install devise-foundationed
47
+
48
+ ## Usage
49
+
50
+ To use the Foundation views generator you'll want to have Devise and Foundation installed
51
+ per normal installation. When you have installed Devise and generated your user model you
52
+ can copy over the views with:
53
+
54
+ rails generate devise:views:foundationed
55
+
56
+ If you've already generated the Devise views you can use the -f argument to force an override.
57
+ That will erase any of the changes you've made!
58
+
59
+ ## Development
60
+
61
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run
62
+ the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
63
+
64
+ To install this gem onto your local machine, run `bundle exec rake install`. To release
65
+ a new version, update the version number in `version.rb`, and then run `bundle exec rake release`,
66
+ which will create a git tag for the version, push git commits and tags, and push the `.gem`
67
+ file to [rubygems.org](https://rubygems.org).
68
+
69
+ ## Contributing
70
+
71
+ Bug reports and pull requests are welcome on GitHub at
72
+ [https://github.com/posiczko/devise-foundationed](https://github.com/posiczko/devise-foundationed).
73
+ This project is intended to be a safe, welcoming space for collaboration, and contributors
74
+ are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
75
+
76
+ ## License
77
+
78
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
79
+
80
+ ## Code of Conduct
81
+
82
+ Everyone interacting in the Devise::Foundationed project’s codebases, issue trackers,
83
+ chat rooms and mailing lists is expected to follow
84
+ the [code of conduct](https://github.com/posiczko/devise-foundationed/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require "gemsmith/rake/setup"
5
+ require "bundler/audit/task"
6
+ require "git/cop/rake/setup"
7
+ require "rspec/core/rake_task"
8
+ require "reek/rake/task"
9
+ require "rubocop/rake_task"
10
+
11
+ Bundler::Audit::Task.new
12
+ RSpec::Core::RakeTask.new :spec
13
+ Reek::Rake::Task.new
14
+ RuboCop::RakeTask.new
15
+ rescue LoadError => e
16
+ puts e.message
17
+ end
18
+
19
+ desc "Run code quality checks"
20
+ task code_quality: %i[bundle:audit git_cop reek rubocop]
21
+
22
+ task default: %i[code_quality spec]
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DeviseHelper
4
+ def devise_error_messages!
5
+ return "" if resource.errors.empty?
6
+
7
+ messages = resource.errors.full_messages.map { |msg|
8
+ content_tag(:li, "#{msg}.")
9
+ }.join
10
+ sentence = I18n.t("errors.messages.not_saved",
11
+ count: resource.errors.count,
12
+ resource: resource.class.model_name.human.downcase)
13
+
14
+ html = <<-HTML
15
+ <div class="alert alert-danger alert-dismissable"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">x</button>
16
+ <strong>#{sentence}</strong>
17
+ <ul>
18
+ #{messages}
19
+ </ul>
20
+ </div>
21
+ HTML
22
+
23
+ html.html_safe
24
+ end
25
+
26
+ def devise_simple_error_messages!
27
+ return "" if resource.errors.empty?
28
+
29
+ sentence = "Ooops!"
30
+ if resource.errors.count == 1
31
+ message = resource.errors.full_messages[0]
32
+ html = <<-HTML
33
+ <p>#{ sentence } #{ message }.</p>
34
+ HTML
35
+ else
36
+ messages = resource.errors.full_messages.map { |msg|
37
+ content_tag(:li, "#{msg}.")
38
+ }.join
39
+ html = <<-HTML
40
+ <p>#{sentence}</p>
41
+ <ul>
42
+ #{messages}
43
+ </ul>
44
+ HTML
45
+ end
46
+
47
+ html.html_safe
48
+ end
49
+ end
@@ -0,0 +1,25 @@
1
+ <div class="grid-x grid-margin-x">
2
+ <div class="small-4 small-offset-4 cell">
3
+ <h2 class="text-center">Resend confirmation instructions</h2>
4
+
5
+ <%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
6
+ <%= devise_error_messages! %>
7
+
8
+
9
+ <%= f.label :email do %>
10
+ <i class="fa fa-envelope"></i>
11
+ <%= f.email_field :email, autofocus: true, value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
12
+ <span class="form-error" data-form-error-for="<%= resource_name %>_email">Your email is required.</span>
13
+ <% end %>
14
+
15
+
16
+ <%= f.submit "Resend confirmation instructions", class: 'button primary expanded' %>
17
+
18
+ <% end %>
19
+
20
+ <div class="text-center">
21
+ <%= render "devise/shared/links" %>
22
+ </div>
23
+
24
+ </div>
25
+ </div>
@@ -0,0 +1,5 @@
1
+ <p>Welcome <%= @email %>!</p>
2
+
3
+ <p>You can confirm your account email through the link below:</p>
4
+
5
+ <p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>
@@ -0,0 +1,3 @@
1
+ <p>Hello <%= @resource.email %>!</p>
2
+
3
+ <p>We're contacting you to notify you that your password has been changed.</p>
@@ -0,0 +1,8 @@
1
+ <p>Hello <%= @resource.email %>!</p>
2
+
3
+ <p>Someone has requested a link to change your password. You can do this through the link below.</p>
4
+
5
+ <p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>
6
+
7
+ <p>If you didn't request this, please ignore this email.</p>
8
+ <p>Your password won't change until you access the link above and create a new one.</p>
@@ -0,0 +1,7 @@
1
+ <p>Hello <%= @resource.email %>!</p>
2
+
3
+ <p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>
4
+
5
+ <p>Click the link below to unlock your account:</p>
6
+
7
+ <p><%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %></p>
@@ -0,0 +1,28 @@
1
+ <div class="grid-x grid-margin-x">
2
+ <div class="small-4 small-offset-4 cell">
3
+ <h2 class="text-center">Change your password</h2>
4
+
5
+ <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
6
+
7
+ <%= devise_error_messages! %>
8
+ <%= f.hidden_field :reset_password_token %>
9
+
10
+ <%= f.label :password, "New password" %><br/>
11
+ <% if @minimum_password_length %>
12
+ <em>(<%= @minimum_password_length %> characters minimum)</em><br/>
13
+ <% end %>
14
+ <%= f.password_field :password, autofocus: true, autocomplete: "off" %>
15
+
16
+ <%= f.label :password_confirmation, "Confirm new password" %><br/>
17
+ <%= f.password_field :password_confirmation, autocomplete: "off" %>
18
+
19
+ <%= f.submit "Change my password", class: 'button primary large' %>
20
+
21
+ <% end %>
22
+
23
+ <div class="text-center">
24
+ <%= render "devise/shared/links" %>
25
+ </div>
26
+
27
+ </div>
28
+ </div>
@@ -0,0 +1,21 @@
1
+ <div class="grid-x grid-margin-x">
2
+ <div class="small-4 small-offset-4 cell">
3
+ <h2 class="text-center">Forgot your password?</h2>
4
+
5
+ <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
6
+
7
+ <%= devise_error_messages! %>
8
+ <br>
9
+ <p class="text-left">Please enter your email address and we will send you a link to reset your password.</p>
10
+
11
+ <%= f.email_field :email, autofocus: true, placeholder: 'Email Address' %>
12
+
13
+ <%= f.submit "Send me reset password instructions", class: 'button primary large' %>
14
+
15
+ <% end %>
16
+
17
+ <div class="text-center">
18
+ <%= render "devise/shared/links" %>
19
+ </div>
20
+ </div>
21
+ </div>
@@ -0,0 +1,61 @@
1
+ <div class="grid-x grid-margin-x">
2
+ <div class="small-4 small-offset-4 cell">
3
+ <h1 class="text-center">Account</h1>
4
+
5
+ <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put, "data-abide": true, "novalidate": true }) do |f| %>
6
+ <% unless resource.errors.empty? %>
7
+ <div class="alert callout">
8
+ <%= devise_error_messages! %>
9
+ </div>
10
+ <% end %>
11
+
12
+ <div data-abide-error class="alert callout text-center" style="display: none;">
13
+ <p><i class=""></i> There are some errors in your form.</p>
14
+ </div>
15
+
16
+ <label for="<%= resource_name %>_name">
17
+ <%= f.text_field :name, autofocus: false, placeholder: "Full Name", required: "required", pattern: "text" %>
18
+ <span class="form-error" data-form-error-for="<%= resource_name %>_name">Your name is
19
+ required.</span>
20
+ </label>
21
+
22
+ <label for="<%= resource_name %>_email">
23
+ <%= f.email_field :email, placeholder: 'Email Address', required: "required", pattern: "email" %>
24
+ <span class="form-error" data-form-error-for="<%= resource_name %>_email">Your email is required.</span>
25
+ </label>
26
+
27
+ <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
28
+ <div class="alert callout">Currently waiting confirmation
29
+ for: <%= resource.unconfirmed_email %></div>
30
+ <% end %>
31
+
32
+ <label for="<%= resource_name %>_password">
33
+ <%= f.password_field :password, autocomplete: "off", placeholder: 'Password' %>
34
+ <p class="form-text text-muted">
35
+ <small>Leave password blank if you don't want to change it</small>
36
+ </p>
37
+ </label>
38
+
39
+ <label for="<%= resource_name %>_password_confirmation">
40
+ <%= f.password_field :password_confirmation, autocomplete: "off", placeholder: 'Confirm Password', "data-equalto": "#{ resource_name }_password",
41
+ "data-validator": "min-length", "data-min-length": (@minimum_password_length || 1) %>
42
+ <span class="form-error" data-form-error-for="<%= resource_name %>_password_confirmation">Password must match and must be at least <%= pluralize(@minimum_password_length || 1, "character") %>
43
+ . </span>
44
+ </label>
45
+
46
+
47
+ <%= f.password_field :current_password, autocomplete: "off", class: 'form-control', placeholder: 'Current Password' %>
48
+ <p class="form-text text-muted">
49
+ <small>We need your current password to confirm your changes</small>
50
+ </p>
51
+
52
+ <div class="form-group">
53
+ <%= f.submit "Save Changes", class: 'button large primary expanded' %>
54
+ </div>
55
+ <% end %>
56
+
57
+ <hr>
58
+
59
+ <p class="text-center"><%= link_to "Deactivate my account", registration_path(resource_name), data: { confirm: "Are you sure? You cannot undo this." }, method: :delete %></p>
60
+ </div>
61
+ </div>
@@ -0,0 +1,64 @@
1
+ <% @minimum_password_length = resource_name.to_s.capitalize.constantize.password_length.min %>
2
+
3
+ <div class="grid-x grid-margin-x">
4
+ <div class="small-4 small-offset-4 cell">
5
+ <h1 class="text-center">Sign Up</h1>
6
+
7
+ <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { "data-abide": true, "novalidate": true }) do |f| %>
8
+
9
+ <% unless resource.errors.empty? %>
10
+ <div class="alert callout">
11
+ <%= devise_simple_error_messages! %>
12
+ </div>
13
+ <% end %>
14
+
15
+ <div data-abide-error class="alert callout text-center" style="display: none;">
16
+ <p><i class=""></i> There are some errors in your form.</p>
17
+ </div>
18
+
19
+ <!-- <label for="<%#= resource_name %>_name">-->
20
+ <%#= f.text_field :name, autofocus: true, placeholder: "Full Name", required: "required", pattern: "text" %>
21
+ <!-- <span class="form-error" data-form-error-for="<%#= resource_name %>_name">Your full name is required.</span>-->
22
+ <!-- </label>-->
23
+
24
+
25
+ <label for="<%= resource_name %>_name">
26
+ <%= f.text_field :name, autofocus: false, placeholder: "Your Name", required: "required", pattern: "text" %>
27
+ <span class="form-error" data-form-error-for="<%= resource_name %>_name">Your name is
28
+ required.</span>
29
+ </label>
30
+
31
+
32
+ <!-- <label for="user_name">-->
33
+ <%#= f.text_field :name, autofocus: true, placeholder: "Full Name", required: "true", pattern: "text" %>
34
+ <!-- <span class="form-error" data-form-error-for="user_name">Your full name is required.</span>-->
35
+ <!-- </label>-->
36
+
37
+
38
+ <label for="<%= resource_name %>_email">
39
+ <%= f.email_field :email, autofocus: false, placeholder: "Email Address", required: "required", pattern: "email" %>
40
+ <span class="form-error" data-form-error-for="<%= resource_name %>_email">Your email is required.</span>
41
+ </label>
42
+
43
+ <label for="<%= resource_name %>_password">
44
+ <%= f.password_field :password, autocomplete: "off", placeholder: 'Password', required: "required", pattern: "password" %>
45
+ <span class="form-error" data-form-error-for="<%= resource_name %>_password">Your password is required.</span>
46
+ </label>
47
+
48
+ <label for="<%= resource_name %>_password_confirmation">
49
+ <%= f.password_field :password_confirmation, autocomplete: "off", placeholder: 'Confirm Password', required: "required", pattern: "password", "data-equalto": "#{ resource_name }_password",
50
+ "data-validator": "min-length", "data-min-length": (@minimum_password_length || 1) %>
51
+ <span class="form-error" data-form-error-for="<%= resource_name %>_password_confirmation">Password must match and must be at least <%= pluralize(@minimum_password_length || 1, "character") %>
52
+ . </span>
53
+ </label>
54
+
55
+ <%#= f.submit "Sign up", class: "button primary large expanded" %>
56
+ <button class="button primary large expanded" type="submit" value="Submit">Sign up</button>
57
+
58
+ <% end %>
59
+
60
+ <div class="text-center">
61
+ <%= render "devise/shared/links" %>
62
+ </div>
63
+ </div>
64
+ </div>
@@ -0,0 +1,44 @@
1
+ <div class="grid-x grid-margin-x">
2
+ <div class="small-4 small-offset-4 cell">
3
+ <h1 class="text-center">Log in</h1>
4
+
5
+ <%= form_for(resource, as: resource_name, url: session_path(resource_name), html: { "data-abide": true, novalidate: true }) do |f| %>
6
+
7
+ <div data-abide-error class="alert callout" style="display: none;">
8
+ <p><i class="fi-alert"></i> There are some errors in your form.</p>
9
+ </div>
10
+
11
+ <label for="<%= resource_name %>_email">
12
+ <div class="input-group">
13
+ <span class="input-group-label"><i class="fa fa-envelope"></i></span>
14
+ <%= f.email_field :email, autofocus: true, placeholder: 'Email Address', class: "input-group-field", required: "required", pattern: "email" %>
15
+ <span class="form-error" data-form-error-for="<%= resource_name %>_email">Your email is required.</span>
16
+ </div>
17
+ </label>
18
+
19
+ <label for="<%= resource_name %>_password">
20
+ <div class="input-group">
21
+ <span class="input-group-label"><i class="fa fa-key"></i></span>
22
+ <%= f.password_field :password, autocomplete: "off", placeholder: 'Password', class: "input-group-field", required: "required" %>
23
+ <span class="form-error" data-form-error-for="<%= resource_name %>_password">Your password is required.</span>
24
+ </div>
25
+ </label>
26
+
27
+ <% if devise_mapping.rememberable? -%>
28
+ <fieldset>
29
+ <%= f.check_box :remember_me %>
30
+ <%= f.label :remember_me, "Remeber Me", for: :remember_me %>
31
+ </fieldset>
32
+ <% end -%>
33
+
34
+ <div class="input-group">
35
+ <%= f.submit "Log in", class: "button primary large expanded" %>
36
+ </div>
37
+
38
+ <% end %>
39
+
40
+ <div class="text-center">
41
+ <%= render "devise/shared/links" %>
42
+ </div>
43
+ </div>
44
+ </div>