draft_generators 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +6 -0
  3. data/.document +5 -0
  4. data/.rspec +1 -0
  5. data/.rubocop.yml +637 -0
  6. data/Gemfile +16 -0
  7. data/LICENSE.txt +20 -0
  8. data/README.markdown +24 -0
  9. data/Rakefile +51 -0
  10. data/VERSION +1 -0
  11. data/draft_generators.gemspec +120 -0
  12. data/lib/devise_customization_service.rb +95 -0
  13. data/lib/draft_generators.rb +8 -0
  14. data/lib/generators/draft/devise/devise_generator.rb +92 -0
  15. data/lib/generators/draft/devise/views/templates/confirmations/new.html.erb +49 -0
  16. data/lib/generators/draft/devise/views/templates/mailer/confirmation_instructions.html.erb +5 -0
  17. data/lib/generators/draft/devise/views/templates/mailer/email_changed.html.erb +7 -0
  18. data/lib/generators/draft/devise/views/templates/mailer/password_change.html.erb +3 -0
  19. data/lib/generators/draft/devise/views/templates/mailer/reset_password_instructions.html.erb +8 -0
  20. data/lib/generators/draft/devise/views/templates/mailer/unlock_instructions.html.erb +7 -0
  21. data/lib/generators/draft/devise/views/templates/passwords/edit.html.erb +83 -0
  22. data/lib/generators/draft/devise/views/templates/passwords/new.html.erb +49 -0
  23. data/lib/generators/draft/devise/views/templates/registrations/edit.html.erb +159 -0
  24. data/lib/generators/draft/devise/views/templates/registrations/new.html.erb +113 -0
  25. data/lib/generators/draft/devise/views/templates/registrations_with_sentinels/edit.html.erb +160 -0
  26. data/lib/generators/draft/devise/views/templates/registrations_with_sentinels/new.html.erb +102 -0
  27. data/lib/generators/draft/devise/views/templates/sessions/new.html.erb +51 -0
  28. data/lib/generators/draft/devise/views/templates/shared/_links.html.erb +25 -0
  29. data/lib/generators/draft/devise/views/templates/unlocks/new.html.erb +49 -0
  30. data/lib/generators/draft/devise/views/views_generator.rb +41 -0
  31. data/lib/generators/draft/layout/USAGE +49 -0
  32. data/lib/generators/draft/layout/layout_generator.rb +66 -0
  33. data/lib/generators/draft/layout/templates/_bootstrapcdn_assets.html.erb +10 -0
  34. data/lib/generators/draft/layout/templates/_flashes.html.erb +23 -0
  35. data/lib/generators/draft/layout/templates/_navbar.html.erb +75 -0
  36. data/lib/generators/draft/layout/templates/layout.html.erb +40 -0
  37. data/lib/generators/draft/model/USAGE +14 -0
  38. data/lib/generators/draft/model/model_generator.rb +42 -0
  39. data/lib/generators/draft/resource/USAGE +11 -0
  40. data/lib/generators/draft/resource/resource_generator.rb +172 -0
  41. data/lib/generators/draft/resource/templates/controllers/controller.rb +97 -0
  42. data/lib/generators/draft/resource/templates/controllers/read_only_controller.rb +13 -0
  43. data/lib/generators/draft/resource/templates/specs/crud_spec.rb +300 -0
  44. data/lib/generators/draft/resource/templates/specs/factories.rb +32 -0
  45. data/lib/generators/draft/resource/templates/views/association_new_form.html.erb +67 -0
  46. data/lib/generators/draft/resource/templates/views/create_row.html.erb +13 -0
  47. data/lib/generators/draft/resource/templates/views/destroy_row.html.erb +13 -0
  48. data/lib/generators/draft/resource/templates/views/edit_form.html.erb +72 -0
  49. data/lib/generators/draft/resource/templates/views/edit_form_with_errors.html.erb +85 -0
  50. data/lib/generators/draft/resource/templates/views/index.html.erb +102 -0
  51. data/lib/generators/draft/resource/templates/views/new_form.html.erb +73 -0
  52. data/lib/generators/draft/resource/templates/views/new_form_with_errors.html.erb +86 -0
  53. data/lib/generators/draft/resource/templates/views/show.html.erb +90 -0
  54. data/lib/generators/draft/resource/templates/views/update_row.html.erb +9 -0
  55. data/lib/generators/draft/scaffold/scaffold_controller_generator.rb +16 -0
  56. data/lib/generators/draft/scaffold/scaffold_erb_generator.rb +25 -0
  57. data/lib/generators/draft/scaffold/scaffold_generator.rb +15 -0
  58. data/lib/generators/draft/scaffold/templates/_card.html.erb +37 -0
  59. data/lib/generators/draft/scaffold/templates/_form.html.erb +44 -0
  60. data/lib/generators/draft/scaffold/templates/_list_item.html.erb +13 -0
  61. data/lib/generators/draft/scaffold/templates/_table_row.html.erb +23 -0
  62. data/lib/generators/draft/scaffold/templates/edit.html.erb +17 -0
  63. data/lib/generators/draft/scaffold/templates/index.html.erb +71 -0
  64. data/lib/generators/draft/scaffold/templates/new.html.erb +17 -0
  65. data/lib/generators/draft/scaffold/templates/show.html.erb +5 -0
  66. data/lib/rails_tag_service.rb +47 -0
  67. metadata +197 -0
@@ -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,7 @@
1
+ <p>Hello <%= @email %>!</p>
2
+
3
+ <% if @resource.try(:unconfirmed_email?) %>
4
+ <p>We're contacting you to notify you that your email is being changed to <%= @resource.unconfirmed_email %>.</p>
5
+ <% else %>
6
+ <p>We're contacting you to notify you that your email has been changed to <%= @resource.email %>.</p>
7
+ <% end %>
@@ -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,83 @@
1
+ <div class="row">
2
+ <div class="offset-md-3 col-md-6">
3
+ <div class="card mb-3">
4
+ <h5 class="card-header">
5
+ Change your password
6
+ </h5>
7
+
8
+ <div class="card-body">
9
+ <% was_validated = resource.errors.any? %>
10
+
11
+ <% form_html_options = { method: :put, novalidate: true, class: "mb-3" } %>
12
+
13
+ <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: form_html_options) do |f| %>
14
+ <%= f.hidden_field :reset_password_token %>
15
+
16
+ <div class="form-group">
17
+ <% password_was_invalid = resource.errors.include?(:password) %>
18
+
19
+ <% password_class = "form-control" %>
20
+
21
+ <% if was_validated %>
22
+ <% if password_was_invalid %>
23
+ <% password_class << " is-invalid" %>
24
+ <% else %>
25
+ <% password_class << " is-valid" %>
26
+ <% end %>
27
+ <% end %>
28
+
29
+ <%= f.label :password, "New password" %>
30
+
31
+ <%= f.password_field :password, class: password_class, autofocus: true, autocomplete: "off" %>
32
+
33
+ <% if password_was_invalid %>
34
+ <% resource.errors.full_messages_for(:password).each do |message| %>
35
+ <div class="invalid-feedback d-flex">
36
+ <%= message %>
37
+ </div>
38
+ <% end %>
39
+ <% end %>
40
+
41
+ <% if @minimum_password_length %>
42
+ <small class="form-text text-muted">
43
+ <%= @minimum_password_length %> characters minimum.
44
+ </small>
45
+ <% end %>
46
+ </div>
47
+
48
+ <div class="form-group">
49
+ <% password_confirmation_was_invalid = resource.errors.include?(:password_confirmation) %>
50
+
51
+ <% password_confirmation_class = "form-control" %>
52
+
53
+ <% if was_validated %>
54
+ <% if password_confirmation_was_invalid %>
55
+ <% password_confirmation_class << " is-invalid" %>
56
+ <% else %>
57
+ <% password_confirmation_class << " is-valid" %>
58
+ <% end %>
59
+ <% end %>
60
+
61
+ <%= f.label :password_confirmation %>
62
+
63
+ <%= f.password_field :password_confirmation, class: password_confirmation_class, autocomplete: "off" %>
64
+
65
+ <% if password_confirmation_was_invalid %>
66
+ <% resource.errors.full_messages_for(:password_confirmation).each do |message| %>
67
+ <div class="invalid-feedback d-flex">
68
+ <%= message %>
69
+ </div>
70
+ <% end %>
71
+ <% end %>
72
+ </div>
73
+
74
+ <%= f.submit "Change my password", class: "btn btn-block btn-outline-primary" %>
75
+
76
+ <hr>
77
+
78
+ <%= render "devise/shared/links" %>
79
+ <% end %>
80
+ </div>
81
+ </div>
82
+ </div>
83
+ </div>
@@ -0,0 +1,49 @@
1
+ <div class="row">
2
+ <div class="offset-md-3 col-md-6">
3
+ <div class="card mb-3">
4
+ <h5 class="card-header">
5
+ Forgot your password?
6
+ </h5>
7
+
8
+ <div class="card-body">
9
+ <% was_validated = resource.errors.any? %>
10
+
11
+ <% form_html_options = { method: :post, novalidate: true, class: "mb-3" } %>
12
+
13
+ <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: form_html_options) do |f| %>
14
+ <div class="form-group">
15
+ <% email_was_invalid = resource.errors.include?(:email) %>
16
+
17
+ <% email_class = "form-control" %>
18
+
19
+ <% if was_validated %>
20
+ <% if email_was_invalid %>
21
+ <% email_class << " is-invalid" %>
22
+ <% else %>
23
+ <% email_class << " is-valid" %>
24
+ <% end %>
25
+ <% end %>
26
+
27
+ <%= f.label :email %>
28
+
29
+ <%= f.email_field :email, autofocus: true, class: email_class %>
30
+
31
+ <% if email_was_invalid %>
32
+ <% resource.errors.full_messages_for(:email).each do |message| %>
33
+ <div class="invalid-feedback d-flex">
34
+ <%= message %>
35
+ </div>
36
+ <% end %>
37
+ <% end %>
38
+ </div>
39
+
40
+ <%= f.submit "Send me reset password instructions", class: "btn btn-block btn-outline-primary" %>
41
+
42
+ <hr>
43
+
44
+ <%= render "devise/shared/links" %>
45
+ <% end %>
46
+ </div>
47
+ </div>
48
+ </div>
49
+ </div>
@@ -0,0 +1,159 @@
1
+ <div class="row">
2
+ <div class="offset-md-3 col-md-6">
3
+ <div class="card mb-3">
4
+ <h5 class="card-header">
5
+ Edit <%= resource_name.to_s.titleize %>
6
+ </h5>
7
+
8
+ <div class="card-body">
9
+ <% was_validated = resource.errors.any? %>
10
+
11
+ <% form_html_options = { method: :put, novalidate: true, class: "mb-3" } %>
12
+
13
+ <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: form_html_options) do |f| %>
14
+ <% if flash[:notice].present? %>
15
+ <div class="alert alert-info" role="alert">
16
+ <%= flash[:notice] %>
17
+ </div>
18
+ <% end %>
19
+
20
+ <% if flash[:alert].present? %>
21
+ <div class="alert alert-danger" role="alert">
22
+ <%= flash[:alert] %>
23
+ </div>
24
+ <% end %>
25
+
26
+ <div class="form-group">
27
+ <% email_was_invalid = resource.errors.include?(:email) %>
28
+
29
+ <% email_class = "form-control" %>
30
+
31
+ <% if was_validated %>
32
+ <% if email_was_invalid %>
33
+ <% email_class << " is-invalid" %>
34
+ <% else %>
35
+ <% email_class << " is-valid" %>
36
+ <% end %>
37
+ <% end %>
38
+
39
+ <%= f.label :email %>
40
+
41
+ <%= f.email_field :email, autofocus: true, class: email_class %>
42
+
43
+ <% if email_was_invalid %>
44
+ <% resource.errors.full_messages_for(:email).each do |message| %>
45
+ <div class="invalid-feedback d-flex">
46
+ <%= message %>
47
+ </div>
48
+ <% end %>
49
+ <% end %>
50
+
51
+ <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
52
+ <small class="form-text text-muted">
53
+ Currently awaiting confirmation for <%= resource.unconfirmed_email %>.
54
+ </small>
55
+ <% end %>
56
+ </div>
57
+
58
+ <div class="form-group">
59
+ <% password_was_invalid = resource.errors.include?(:password) %>
60
+
61
+ <% password_class = "form-control" %>
62
+
63
+ <% if was_validated %>
64
+ <% if password_was_invalid %>
65
+ <% password_class << " is-invalid" %>
66
+ <% else %>
67
+ <% password_class << " is-valid" %>
68
+ <% end %>
69
+ <% end %>
70
+
71
+ <%= f.label :password %>
72
+
73
+ <%= f.password_field :password, class: password_class, autocomplete: "off" %>
74
+
75
+ <% if password_was_invalid %>
76
+ <% resource.errors.full_messages_for(:password).each do |message| %>
77
+ <div class="invalid-feedback d-flex">
78
+ <%= message %>
79
+ </div>
80
+ <% end %>
81
+ <% end %>
82
+
83
+ <small class="form-text text-muted">
84
+ Leave blank if you don't want to change it.
85
+
86
+ <% if @minimum_password_length %>
87
+ <%= @minimum_password_length %> characters minimum.
88
+ <% end %>
89
+ </small>
90
+ </div>
91
+
92
+ <div class="form-group">
93
+ <% password_confirmation_was_invalid = resource.errors.include?(:password_confirmation) %>
94
+
95
+ <% password_confirmation_class = "form-control" %>
96
+
97
+ <% if was_validated %>
98
+ <% if password_confirmation_was_invalid %>
99
+ <% password_confirmation_class << " is-invalid" %>
100
+ <% else %>
101
+ <% password_confirmation_class << " is-valid" %>
102
+ <% end %>
103
+ <% end %>
104
+
105
+ <%= f.label :password_confirmation %>
106
+
107
+ <%= f.password_field :password_confirmation, class: password_confirmation_class, autocomplete: "off" %>
108
+
109
+ <% if password_confirmation_was_invalid %>
110
+ <% resource.errors.full_messages_for(:password_confirmation).each do |message| %>
111
+ <div class="invalid-feedback d-flex">
112
+ <%= message %>
113
+ </div>
114
+ <% end %>
115
+ <% end %>
116
+ </div>
117
+
118
+ <div class="form-group">
119
+ <% current_password_was_invalid = resource.errors.include?(:current_password) %>
120
+
121
+ <% current_password_class = "form-control" %>
122
+
123
+ <% if was_validated %>
124
+ <% if current_password_was_invalid %>
125
+ <% current_password_class << " is-invalid" %>
126
+ <% else %>
127
+ <% current_password_class << " is-valid" %>
128
+ <% end %>
129
+ <% end %>
130
+
131
+ <%= f.label :current_password %>
132
+
133
+ <%= f.password_field :current_password, class: current_password_class, autocomplete: "off" %>
134
+
135
+ <% if current_password_was_invalid %>
136
+ <% resource.errors.full_messages_for(:current_password).each do |message| %>
137
+ <div class="invalid-feedback d-flex">
138
+ <%= message %>
139
+ </div>
140
+ <% end %>
141
+ <% end %>
142
+
143
+ <small class="form-text text-muted">
144
+ We need your current password to confirm your changes.
145
+ </small>
146
+ </div>
147
+
148
+ <%= f.submit "Update", class: "btn btn-block btn-outline-primary" %>
149
+ <% end %>
150
+
151
+ <%= link_to "Back", :back, class: "btn btn-block btn-outline-secondary" %>
152
+ </div>
153
+
154
+ <div class="card-footer">
155
+ <%= link_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, class: "btn btn-block btn-link", method: :delete %>
156
+ </div>
157
+ </div>
158
+ </div>
159
+ </div>
@@ -0,0 +1,113 @@
1
+ <div class="row">
2
+ <div class="offset-md-3 col-md-6">
3
+ <div class="card mb-3">
4
+ <h5 class="card-header">
5
+ <%= resource_name != "user" ? resource_name.to_s.titleize : "" %> Sign Up
6
+ </h5>
7
+
8
+ <div class="card-body">
9
+ <% if flash[:notice].present? %>
10
+ <div class="alert alert-info" role="alert">
11
+ <%= flash[:notice] %>
12
+ </div>
13
+ <% end %>
14
+
15
+ <% if flash[:alert].present? %>
16
+ <div class="alert alert-danger" role="alert">
17
+ <%= flash[:alert] %>
18
+ </div>
19
+ <% end %>
20
+
21
+ <% was_validated = resource.errors.any? %>
22
+
23
+ <% form_html_options = { novalidate: true, class: "mb-3" } %>
24
+
25
+ <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: form_html_options) do |f| %>
26
+ <div class="form-group">
27
+ <% email_was_invalid = resource.errors.include?(:email) %>
28
+
29
+ <% email_class = "form-control" %>
30
+
31
+ <% if was_validated %>
32
+ <% if email_was_invalid %>
33
+ <% email_class << " is-invalid" %>
34
+ <% else %>
35
+ <% email_class << " is-valid" %>
36
+ <% end %>
37
+ <% end %>
38
+
39
+ <%= f.label :email %>
40
+
41
+ <%= f.email_field :email, class: email_class, autofocus: true %>
42
+
43
+ <% if email_was_invalid %>
44
+ <% resource.errors.full_messages_for(:email).each do |message| %>
45
+ <div class="invalid-feedback d-flex">
46
+ <%= message %>
47
+ </div>
48
+ <% end %>
49
+ <% end %>
50
+ </div>
51
+
52
+ <div class="form-group">
53
+ <% password_was_invalid = resource.errors.include?(:password) %>
54
+
55
+ <% password_class = "form-control" %>
56
+
57
+ <% if was_validated %>
58
+ <% if password_was_invalid %>
59
+ <% password_class << " is-invalid" %>
60
+ <% else %>
61
+ <% password_class << " is-valid" %>
62
+ <% end %>
63
+ <% end %>
64
+
65
+ <%= f.label :password %>
66
+
67
+ <%= f.password_field :password, class: password_class %>
68
+
69
+ <% if password_was_invalid %>
70
+ <% resource.errors.full_messages_for(:password).each do |message| %>
71
+ <div class="invalid-feedback d-flex">
72
+ <%= message %>
73
+ </div>
74
+ <% end %>
75
+ <% end %>
76
+ </div>
77
+
78
+ <div class="form-group">
79
+ <% password_confirmation_was_invalid = resource.errors.include?(:password_confirmation) %>
80
+
81
+ <% password_confirmation_class = "form-control" %>
82
+
83
+ <% if was_validated %>
84
+ <% if password_confirmation_was_invalid %>
85
+ <% password_confirmation_class << " is-invalid" %>
86
+ <% else %>
87
+ <% password_confirmation_class << " is-valid" %>
88
+ <% end %>
89
+ <% end %>
90
+
91
+ <%= f.label :password_confirmation %>
92
+
93
+ <%= f.password_field :password_confirmation, class: password_confirmation_class %>
94
+
95
+ <% if password_confirmation_was_invalid %>
96
+ <% resource.errors.full_messages_for(:password_confirmation).each do |message| %>
97
+ <div class="invalid-feedback d-flex">
98
+ <%= message %>
99
+ </div>
100
+ <% end %>
101
+ <% end %>
102
+ </div>
103
+
104
+ <%= f.button class: "btn btn-outline-primary btn-block" %>
105
+
106
+ <hr>
107
+
108
+ <%= render "devise/shared/links" %>
109
+ <% end %>
110
+ </div>
111
+ </div>
112
+ </div>
113
+ </div>