devise-tailwindcssed 0.1.0

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.
data/Guardfile_rubocop ADDED
@@ -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
data/LICENSE.txt ADDED
@@ -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.
data/README.md ADDED
@@ -0,0 +1,91 @@
1
+ <!-- Tocer[start]: Auto-generated, don't remove. -->
2
+
3
+ ## Table of Contents
4
+
5
+ - [Devise Tailwindcssed](#devise-tailwindcssed)
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 Tailwindcssed
17
+
18
+ This gem tries to give you a nicer place to start with your views for your Devise model
19
+ when you are using Tailwind CSS 1.0.
20
+
21
+ You can find usage information below, but the gist of it is you'll run
22
+ `rails g devise:views:tailwindcssed` 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
+ NOTE:
28
+
29
+ * This gem is meant to be run with Rails 6 which includes asset packing tools like Webpacker. Your main project must be
30
+ set up to include TailwindCSS. For details see incomparable [Chris Oliver's tutorial](https://gorails.com/episodes/tailwindcss-1-0-with-rails-6) from [Gorails](https://gorails.com).
31
+
32
+ * This gem does not use any Tailwind CSS template. The markup is included the ERB templates.
33
+
34
+ ## Prerequisites
35
+
36
+ * This gem is meant to be run with Rails 6 which includes Webpacker.
37
+ * Your project needs to be be already set up to include Tailwind CSS (see [Chris Oliver's tutorial](https://gorails.com/episodes/tailwindcss-1-0-with-rails-6))
38
+
39
+ ## Installation
40
+
41
+ Add this line to your application's Gemfile:
42
+
43
+ ```ruby
44
+ gem 'devise-tailwindcssed'
45
+ ```
46
+
47
+ And then execute:
48
+
49
+ $ bundle
50
+
51
+ Or install it yourself as:
52
+
53
+ $ gem install devise-tailwindcssed
54
+
55
+ ## Usage
56
+
57
+ To use the Tailwind views generator you'll want to have Devise and Tailwindcss installed
58
+ per normal installation. When you have installed Devise and generated your user model you
59
+ can copy over the views with:
60
+
61
+ rails generate devise:views:tailwindcssed
62
+
63
+ If you've already generated the Devise views you can use the -f argument to force an override.
64
+ That will erase any of the changes you've made!
65
+
66
+ ## Development
67
+
68
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run
69
+ the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
70
+
71
+ To install this gem onto your local machine, run `bundle exec rake install`. To release
72
+ a new version, update the version number in `version.rb`, and then run `bundle exec rake release`,
73
+ which will create a git tag for the version, push git commits and tags, and push the `.gem`
74
+ file to [rubygems.org](https://rubygems.org).
75
+
76
+ ## Contributing
77
+
78
+ Bug reports and pull requests are welcome on GitHub at
79
+ [https://github.com/posiczko/devise-tailwindcssed](https://github.com/posiczko/devise-tailwindcssed).
80
+ This project is intended to be a safe, welcoming space for collaboration, and contributors
81
+ are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
82
+
83
+ ## License
84
+
85
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
86
+
87
+ ## Code of Conduct
88
+
89
+ Everyone interacting in the Devise::Tailwindcssed project’s codebases, issue trackers,
90
+ chat rooms and mailing lists is expected to follow
91
+ the [code of conduct](https://github.com/posiczko/devise-tailwindcssed/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -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,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ # devise helper
4
+ module DeviseHelper
5
+ def devise_error_messages!
6
+ return if resource.errors.empty?
7
+
8
+ messages = resource.errors.full_messages.map { |msg|
9
+ content_tag(:p, "- #{msg}.")
10
+ }.join
11
+ sentence = I18n.t("errors.messages.not_saved",
12
+ count: resource.errors.count,
13
+ resource: resource.class.model_name.human.downcase)
14
+
15
+ html = <<-HTML
16
+ <div class="bg-red-100 border-l-4 border-red-500 mb-4 p-4 text-red-700" role="alert">
17
+ <p class="font-bold">Oops!</p>
18
+ <p>#{sentence}</p>#{messages}
19
+ </div>
20
+ HTML
21
+
22
+ html.html_safe
23
+ end
24
+
25
+ def devise_simple_error_messages!
26
+ return if resource.errors.empty?
27
+
28
+ sentence = "Ooops!"
29
+ if resource.errors.count == 1
30
+ message = resource.errors.full_messages[0]
31
+ html = <<-HTML
32
+ <div class="bg-red-lightest border-l-4 border-red text-orange-dark p-4" role="alert">
33
+ <p class="font-bold">#{sentence}</p>
34
+ <p> #{ message }.</p>
35
+ </div>
36
+ HTML
37
+ else
38
+ messages = resource.errors.full_messages.map { |msg|
39
+ content_tag(:li, "#{msg}.")
40
+ }.join
41
+ html = <<-HTML
42
+ <div class="bg-red-100 border-l-4 border-red-500 mb-4 p-4 text-red-700" role="alert">
43
+ <p class="font-bold">#{sentence}</p>
44
+ <ul class="list-disc">
45
+ #{messages}
46
+ </ul>
47
+ </div>
48
+ HTML
49
+ end
50
+
51
+ html.html_safe
52
+ end
53
+ end
@@ -0,0 +1,35 @@
1
+ <div class="w-full max-w-xs">
2
+ <h1 class="font-hairline mb-6 text-center">Resend Confirmation Instructions</h1>
3
+
4
+ <%= form_for(resource,
5
+ as: resource_name,
6
+ url: confirmation_path(resource_name),
7
+ html: {
8
+ method: :post,
9
+ class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md"
10
+ }) do |f| %>
11
+
12
+ <%#= render "devise/shared/error_messages", resource: resource %>
13
+ <%= devise_error_messages! %>
14
+
15
+ <div class="mb-4">
16
+ <%= f.label :email, class: "block font-bold mb-2 text-gray-700 text-sm" %>
17
+ <%= f.email_field :email,
18
+ autofocus: true,
19
+ autocomplete: "email",
20
+ value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email),
21
+ class: "appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none shadow focus:shadow-outline"
22
+ %>
23
+ </div>
24
+
25
+ <div class="mb-4">
26
+ <%= f.submit "Resend Confirmation Info",
27
+ class: "button bg-blue-500 hover:bg-blue-700 font-bold text-white focus:outline-none py-2 px-4 rounded focus:shadow-outline w-full"
28
+ %>
29
+ </div>
30
+
31
+ <%= render "devise/shared/links" %>
32
+ <% end %>
33
+
34
+ <%= render "devise/shared/form_footer" %>
35
+ </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,55 @@
1
+ <div class="w-full max-w-xs">
2
+ <h2 class="font-hairline mb-6 text-center">Change Your Password</h2>
3
+
4
+ <%= form_for(resource,
5
+ as: resource_name,
6
+ url: user_password_path(resource_name),
7
+ html: {
8
+ method: :put,
9
+ class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md"
10
+ }
11
+ ) do |f| %>
12
+
13
+ <%#= render "devise/shared/error_messages", resource: resource %>
14
+
15
+ <%= devise_error_messages! %>
16
+
17
+ <%= f.hidden_field :reset_password_token %>
18
+
19
+ <div class="mb-4">
20
+ <%= f.label :password, "New Password",
21
+ class: "block font-bold mb-2 text-gray-700 text-sm"
22
+ %>
23
+ <% if @minimum_password_length %>
24
+ <small><em class="text-gray-600">(<%= @minimum_password_length %> characters minimum)</em></small>
25
+ <% end %>
26
+ <%= f.password_field :password,
27
+ autofocus: true,
28
+ autocomplete: "new-password",
29
+ class: "appearance-none border leading-tight focus:outline-none px-3 py-2 rounded shadow focus:shadow-outline text-gray-700 w-full"
30
+ %>
31
+ </div>
32
+
33
+ <div class="mb-4">
34
+ <%= f.label :password_confirmation,
35
+ "Confirm New Password",
36
+ class: "block font-bold mb-2 text-gray-700 text-sm"
37
+ %>
38
+ <%= f.password_field :password_confirmation,
39
+ autocomplete: "off",
40
+ class: "shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 mb-3 leading-tight focus:outline-none focus:shadow-outline"
41
+ %>
42
+ </div>
43
+
44
+ <div class="mb-4">
45
+ <%= f.submit "Change My Password",
46
+ class: "button bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline w-full" %>
47
+
48
+ %>
49
+ </div>
50
+
51
+ <%= render "devise/shared/links" %>
52
+ <% end %>
53
+
54
+ <%= render "devise/shared/form_footer" %>
55
+ </div>
@@ -0,0 +1,31 @@
1
+ <div class="w-full max-w-xs">
2
+ <h1 class="font-hairline mb-6 text-center">Forgot your password?</h1>
3
+
4
+ <%= form_for(resource,
5
+ as: resource_name,
6
+ url: password_path(resource_name),
7
+ html: {
8
+ method: :post,
9
+ class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md"
10
+ }) do |f| %>
11
+
12
+ <%#= render "devise/shared/error_messages", resource: resource %>
13
+ <%= devise_error_messages! %>
14
+
15
+ <div class="mb-4">
16
+ <%= f.label :email, class: "block font-bold mb-2 text-gray-700 text-sm" %>
17
+ <%= f.email_field :email, autofocus: true, autocomplete: "email",
18
+ class: "appearance-none border leading-tight focus:outline-none px-3 py-2 rounded shadow focus:shadow-outline text-gray-700 w-full"
19
+ %>
20
+ </div>
21
+
22
+ <div class="mb-4">
23
+ <%= f.submit "Send Password Reset Info",
24
+ class: "button bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline w-full" %>
25
+ </div>
26
+
27
+ <%= render "devise/shared/links" %>
28
+ <% end %>
29
+
30
+ <%= render "devise/shared/form_footer" %>
31
+ </div>
@@ -0,0 +1,60 @@
1
+ <div class="w-full max-w-xs">
2
+ <h1 class="font-hairline mb-6 text-center">Edit <%= resource_name.to_s.humanize %></h1>
3
+
4
+ <%= form_for(resource,
5
+ as: resource_name,
6
+ url: registration_path(resource_name),
7
+ html: {
8
+ method: :put,
9
+ class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md"
10
+ }
11
+ ) do |f| %>
12
+
13
+ <%#= render "devise/shared/error_messages", resource: resource %>
14
+ <%= devise_error_messages! %>
15
+
16
+ <div class="mb-4">
17
+ <%= f.label :email %><br/>
18
+ <%= f.email_field :email,
19
+ autofocus: true,
20
+ autocomplete: "email" %>
21
+ </div>
22
+
23
+ <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
24
+ <div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
25
+ <% end %>
26
+
27
+ <div class="mb-4">
28
+ <%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br/>
29
+ <%= f.password_field :password, autocomplete: "new-password" %>
30
+ <% if @minimum_password_length %>
31
+ <br/>
32
+ <em><%= @minimum_password_length %> characters minimum</em>
33
+ <% end %>
34
+ </div>
35
+
36
+ <div class="mb-4">
37
+ <%= f.label :password_confirmation %><br/>
38
+ <%= f.password_field :password_confirmation,
39
+ autocomplete: "new-password"
40
+ %>
41
+ </div>
42
+
43
+ <div class="mb-4">
44
+ <%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br/>
45
+ <%= f.password_field :current_password,
46
+ autocomplete: "current-password"
47
+ %>
48
+ </div>
49
+
50
+ <div class="actions">
51
+ <%= f.submit "Update" %>
52
+ </div>
53
+ <% end %>
54
+
55
+ <h1 class="font-hairline mb-6 text-center">Cancel My Account</h1>
56
+
57
+ <p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p>
58
+
59
+ <%= link_to "Back", :back %>
60
+ </div>
@@ -0,0 +1,52 @@
1
+ <div class="w-full max-w-xs">
2
+ <h1 class="font-hairline mb-6 text-center">Sign Up</h1>
3
+
4
+ <%= form_for(resource,
5
+ as: resource_name,
6
+ url: registration_path(resource_name),
7
+ html: {
8
+ class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md"
9
+ }
10
+ ) do |f| %>
11
+
12
+ <%= devise_error_messages! %>
13
+
14
+ <div class="mb-4">
15
+ <%= f.label :email, class: "block font-bold mb-2 text-gray-700 text-sm" %>
16
+ <%= f.email_field :email,
17
+ autocomplete: "email",
18
+ placeholder: "user@example.com",
19
+ class: "appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none shadow focus:shadow-outline" %>
20
+ </div>
21
+
22
+ <div class="mb-4">
23
+ <%= f.label :password, class: "block font-bold mb-2 text-gray-700 text-sm" %>
24
+ <% if @minimum_password_length %>
25
+ <small><em class="text-gray-600">(<%= @minimum_password_length %> charactersa minimum)</em></small>
26
+ <% end %>
27
+ <%= f.password_field :password,
28
+ autocomplete: "new-password",
29
+ class: "shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 mb-3 leading-tight focus:outline-none focus:shadow-outline"
30
+ %>
31
+ </div>
32
+
33
+ <div class="mb-4">
34
+ <%= f.label :password_confirmation, class: "block font-bold mb-2 text-gray-700 text-sm" %>
35
+ <%= f.password_field :password_confirmation,
36
+ autocomplete: "new-password",
37
+ class: "appearance-none border leading-tight focus:outline-none px-3 py-2 rounded shadow focus:shadow-outline text-gray-700 w-full"
38
+ %>
39
+ </div>
40
+
41
+ <div class="mb-4">
42
+ <%= f.submit "Sign Up",
43
+ class: "button bg-blue-500 hover:bg-blue-700 font-bold text-white focus:outline-none py-2 px-4 rounded focus:shadow-outline w-full"
44
+ %>
45
+ </div>
46
+
47
+ <%= render "devise/shared/links" %>
48
+
49
+ <% end %>
50
+
51
+ <%= render "devise/shared/form_footer" %>
52
+ </div>