thredded_create_app 0.1.24 → 0.1.25
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.
- checksums.yaml +4 -4
- data/lib/thredded_create_app/generator.rb +2 -0
- data/lib/thredded_create_app/tasks/add_devise.rb +21 -2
- data/lib/thredded_create_app/tasks/add_devise/registrations_controller.rb +6 -0
- data/lib/thredded_create_app/tasks/add_display_name_to_users.rb +1 -1
- data/lib/thredded_create_app/tasks/add_invisible_captcha.rb +46 -0
- data/lib/thredded_create_app/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 430f66d017397f54efe538a5e76d36c41d29652638f1d26e12d6a3a38d2dadf0
|
|
4
|
+
data.tar.gz: 700e31ea5dc7eea339eab91a27a9b4e325c68f42a3177c394a3451ab1272ce24
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 13e718573d7b06d1e2fea2187d6e0ce2a1ac60bfc9ae19d5fd48f7d4d0c81ec2029957b4bf4c21dc2efbc7aaea7bceb8105166d0c8425fb5de469bc3eb6c0410
|
|
7
|
+
data.tar.gz: ae9bc03d56d750a1e50b1e86c45950cf7a89241126a6dad6cbe9d41ddaf991d705e8867b8c73e4bd264471efeec093d37d255c7d0841dd1f9783754bcdcfb17a
|
|
@@ -11,6 +11,7 @@ require 'thredded_create_app/tasks/add_roadie'
|
|
|
11
11
|
require 'thredded_create_app/tasks/add_rails_email_preview'
|
|
12
12
|
require 'thredded_create_app/tasks/add_thredded'
|
|
13
13
|
require 'thredded_create_app/tasks/add_display_name_to_users'
|
|
14
|
+
require 'thredded_create_app/tasks/add_invisible_captcha'
|
|
14
15
|
require 'thredded_create_app/tasks/setup_database'
|
|
15
16
|
require 'thredded_create_app/tasks/setup_app_skeleton'
|
|
16
17
|
require 'thredded_create_app/tasks/production_configs'
|
|
@@ -71,6 +72,7 @@ module ThreddedCreateApp
|
|
|
71
72
|
Tasks::AddRoadie,
|
|
72
73
|
Tasks::AddThredded,
|
|
73
74
|
Tasks::AddDisplayNameToUsers,
|
|
75
|
+
Tasks::AddInvisibleCaptcha,
|
|
74
76
|
Tasks::SetupAppSkeleton,
|
|
75
77
|
Tasks::ProductionConfigs,
|
|
76
78
|
Tasks::AddMemcachedSupport,
|
|
@@ -4,6 +4,11 @@ require 'thredded_create_app/tasks/base'
|
|
|
4
4
|
module ThreddedCreateApp
|
|
5
5
|
module Tasks
|
|
6
6
|
class AddDevise < Base
|
|
7
|
+
def initialize(simple_form: true, **args)
|
|
8
|
+
super
|
|
9
|
+
@simple_form = simple_form
|
|
10
|
+
end
|
|
11
|
+
|
|
7
12
|
def summary
|
|
8
13
|
'Add devise with I18n and configure a User model'
|
|
9
14
|
end
|
|
@@ -65,6 +70,8 @@ module ThreddedCreateApp
|
|
|
65
70
|
end
|
|
66
71
|
|
|
67
72
|
def setup_controllers
|
|
73
|
+
copy 'add_devise/registrations_controller.rb',
|
|
74
|
+
'app/controllers/users/registrations_controller.rb'
|
|
68
75
|
copy 'add_devise/sessions_controller.rb',
|
|
69
76
|
'app/controllers/users/sessions_controller.rb'
|
|
70
77
|
replace 'config/routes.rb',
|
|
@@ -73,6 +80,7 @@ module ThreddedCreateApp
|
|
|
73
80
|
devise_for :users,
|
|
74
81
|
skip: %i[sessions],
|
|
75
82
|
controllers: {
|
|
83
|
+
registrations: 'users/registrations',
|
|
76
84
|
sessions: 'users/sessions',
|
|
77
85
|
},
|
|
78
86
|
path_names: { sign_up: 'register' }
|
|
@@ -95,9 +103,20 @@ module ThreddedCreateApp
|
|
|
95
103
|
', :back %>', ', back_url %>'
|
|
96
104
|
# Remove "Password confirmation" from sign up.
|
|
97
105
|
# See https://github.com/plataformatec/devise/wiki/Disable-password-confirmation-during-registration
|
|
106
|
+
password_field =
|
|
107
|
+
if @simple_form
|
|
108
|
+
" <%= f.input :password_confirmation, required: true %>\n"
|
|
109
|
+
else
|
|
110
|
+
<<-ERB
|
|
111
|
+
<div class="field">
|
|
112
|
+
<%= f.label :password_confirmation %><br />
|
|
113
|
+
<%= f.password_field :password_confirmation, autocomplete: "off" %>
|
|
114
|
+
</div>
|
|
115
|
+
|
|
116
|
+
ERB
|
|
117
|
+
end
|
|
98
118
|
replace 'app/views/devise/registrations/new.html.erb',
|
|
99
|
-
|
|
100
|
-
''
|
|
119
|
+
password_field, ''
|
|
101
120
|
end
|
|
102
121
|
|
|
103
122
|
def setup_emails
|
|
@@ -109,7 +109,7 @@ module ThreddedCreateApp
|
|
|
109
109
|
|
|
110
110
|
def simple_form_input_html(autofocus)
|
|
111
111
|
<<-HTML
|
|
112
|
-
|
|
112
|
+
<%= f.input :display_name, required: true#{', autofocus: true' if autofocus} %>
|
|
113
113
|
HTML
|
|
114
114
|
end
|
|
115
115
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'thredded_create_app/tasks/base'
|
|
4
|
+
module ThreddedCreateApp
|
|
5
|
+
module Tasks
|
|
6
|
+
class AddInvisibleCaptcha < Base
|
|
7
|
+
def initialize(simple_form: true, **_args)
|
|
8
|
+
super
|
|
9
|
+
@simple_form = simple_form
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def summary
|
|
13
|
+
'Add an invisible captcha to the sign up form'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def before_bundle
|
|
17
|
+
add_gem 'invisible_captcha'
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def after_bundle
|
|
21
|
+
inject_into_file 'app/controllers/users/registrations_controller.rb',
|
|
22
|
+
after: "::Devise::RegistrationsController\n",
|
|
23
|
+
content: <<-RUBY
|
|
24
|
+
invisible_captcha only: %i[create], honeypot: :name
|
|
25
|
+
RUBY
|
|
26
|
+
|
|
27
|
+
form_view_path = 'app/views/devise/registrations/new.html.erb'
|
|
28
|
+
form_view_captcha = '<%= invisible_captcha :name %>'
|
|
29
|
+
if @simple_form
|
|
30
|
+
inject_into_file form_view_path,
|
|
31
|
+
after: %(<div class="form-inputs">\n),
|
|
32
|
+
content: " #{form_view_captcha}\n"
|
|
33
|
+
else
|
|
34
|
+
inject_into_file form_view_path,
|
|
35
|
+
after: %(error_messages! %>\n\n),
|
|
36
|
+
content: " #{form_view_captcha}\n\n"
|
|
37
|
+
end
|
|
38
|
+
inject_into_file form_view_path,
|
|
39
|
+
before: ') do |f|',
|
|
40
|
+
content: ", html: {autocomplete: 'off'}"
|
|
41
|
+
|
|
42
|
+
git_commit 'Add invisible_captcha to the sign up form'
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: thredded_create_app
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.25
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gleb Mazovetskiy
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-07-
|
|
11
|
+
date: 2018-07-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: highline
|
|
@@ -131,10 +131,12 @@ files:
|
|
|
131
131
|
- lib/thredded_create_app/generator.rb
|
|
132
132
|
- lib/thredded_create_app/logging.rb
|
|
133
133
|
- lib/thredded_create_app/tasks/add_devise.rb
|
|
134
|
+
- lib/thredded_create_app/tasks/add_devise/registrations_controller.rb
|
|
134
135
|
- lib/thredded_create_app/tasks/add_devise/sessions_controller.rb
|
|
135
136
|
- lib/thredded_create_app/tasks/add_devise/spec/features/devise_spec.rb
|
|
136
137
|
- lib/thredded_create_app/tasks/add_display_name_to_users.rb
|
|
137
138
|
- lib/thredded_create_app/tasks/add_display_name_to_users/add_display_name_to_users.rb.erb
|
|
139
|
+
- lib/thredded_create_app/tasks/add_invisible_captcha.rb
|
|
138
140
|
- lib/thredded_create_app/tasks/add_jquery.rb
|
|
139
141
|
- lib/thredded_create_app/tasks/add_memcached_support.rb
|
|
140
142
|
- lib/thredded_create_app/tasks/add_rails_config.rb
|