orats 0.6.5 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +231 -58
- data/lib/orats/cli.rb +63 -25
- data/lib/orats/commands/common.rb +47 -22
- data/lib/orats/commands/{outdated → diff}/compare.rb +5 -4
- data/lib/orats/commands/diff/exec.rb +86 -0
- data/lib/orats/commands/{outdated → diff}/parse.rb +5 -1
- data/lib/orats/commands/inventory.rb +121 -0
- data/lib/orats/commands/{play.rb → playbook.rb} +5 -5
- data/lib/orats/commands/project/exec.rb +74 -0
- data/lib/orats/commands/{new → project}/rails.rb +57 -81
- data/lib/orats/commands/{new → project}/server.rb +6 -4
- data/lib/orats/templates/auth.rb +26 -481
- data/lib/orats/templates/base.rb +74 -716
- data/lib/orats/templates/includes/common/LICENSE +22 -0
- data/lib/orats/templates/includes/new/rails/.env +43 -0
- data/lib/orats/templates/includes/{Gemfile → new/rails/Gemfile} +1 -1
- data/lib/orats/templates/includes/new/rails/Procfile +3 -0
- data/lib/orats/templates/includes/new/rails/README.md +3 -0
- data/lib/orats/templates/includes/{app → new/rails/app}/assets/favicon/favicon_base.png +0 -0
- data/lib/orats/templates/includes/new/rails/app/helpers/application_helper.rb +53 -0
- data/lib/orats/templates/includes/new/rails/app/models/account.rb +40 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/confirmations/new.html.erb +26 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/mailer/reset_password_instructions.html.erb +10 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/mailer/unlock_instructions.html.erb +8 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/passwords/edit.html.erb +28 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/passwords/new.html.erb +26 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/registrations/edit.html.erb +51 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/registrations/new.html.erb +31 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/sessions/new.html.erb +39 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/shared/_links.html.erb +38 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/unlocks/new.html.erb +26 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_disqus_comments_snippet.html.erb +19 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_disqus_count_snippet.html.erb +12 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_flash.html.erb +10 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_footer.html.erb +2 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_google_analytics_snippet.html.erb +13 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_google_analytics_tracker.html.erb +4 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_navigation.html.erb +18 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_navigation_auth.html.erb +15 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_navigation_links.html.erb +3 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/application.html.erb +48 -0
- data/lib/orats/templates/includes/new/rails/app/views/pages/home.html.erb +81 -0
- data/lib/orats/templates/includes/new/rails/config/database.yml +19 -0
- data/lib/orats/templates/includes/new/rails/config/environments/staging.rb +5 -0
- data/lib/orats/templates/includes/new/rails/config/initializers/devise_async.rb +1 -0
- data/lib/orats/templates/includes/new/rails/config/initializers/mini_profiler.rb +4 -0
- data/lib/orats/templates/includes/new/rails/config/initializers/sidekiq.rb +16 -0
- data/lib/orats/templates/includes/new/rails/config/puma.rb +25 -0
- data/lib/orats/templates/includes/new/rails/config/secrets.yml +12 -0
- data/lib/orats/templates/includes/new/rails/config/sidekiq.yml +5 -0
- data/lib/orats/templates/includes/new/rails/config/sitemap.rb +20 -0
- data/lib/orats/templates/includes/new/rails/config/whenever.rb +7 -0
- data/lib/orats/templates/includes/new/rails/lib/backup/config.rb +116 -0
- data/lib/orats/templates/includes/new/rails/lib/backup/models/backup.rb +55 -0
- data/lib/orats/templates/includes/new/rails/lib/tasks/orats/backup.rake +18 -0
- data/lib/orats/templates/includes/new/rails/lib/tasks/orats/favicon.rake +48 -0
- data/lib/orats/templates/includes/new/rails/public/404.html +13 -0
- data/lib/orats/templates/includes/new/rails/public/422.html +13 -0
- data/lib/orats/templates/includes/new/rails/public/500.html +13 -0
- data/lib/orats/templates/includes/new/rails/public/502.html +13 -0
- data/lib/orats/templates/includes/new/rails/test/fixtures/accounts.yml +27 -0
- data/lib/orats/templates/includes/new/rails/test/models/account_test.rb +46 -0
- data/lib/orats/templates/includes/{Galaxyfile → playbook/Galaxyfile} +0 -0
- data/lib/orats/templates/includes/playbook/site.yml +53 -0
- data/lib/orats/templates/playbook.rb +115 -0
- data/lib/orats/version.rb +1 -1
- data/test/integration/cli_test.rb +122 -75
- data/test/test_helper.rb +16 -8
- metadata +63 -14
- data/lib/orats/commands/new/ansible.rb +0 -98
- data/lib/orats/commands/new/exec.rb +0 -60
- data/lib/orats/commands/outdated/exec.rb +0 -46
- data/lib/orats/templates/play.rb +0 -185
@@ -1,11 +1,12 @@
|
|
1
1
|
module Orats
|
2
2
|
module Commands
|
3
|
-
module
|
3
|
+
module Project
|
4
4
|
module Rails
|
5
5
|
def check_exit_conditions
|
6
6
|
exit_if_process :not_found, 'rails', 'git'
|
7
7
|
exit_if_process :not_running, 'postgres', 'redis'
|
8
8
|
exit_if_path_exists
|
9
|
+
exit_if_invalid_template
|
9
10
|
end
|
10
11
|
|
11
12
|
def rails_template(command, flags = '')
|
@@ -18,10 +19,10 @@ module Orats
|
|
18
19
|
def custom_rails_template
|
19
20
|
log_task 'Run custom rails template'
|
20
21
|
|
21
|
-
@options[:
|
22
|
-
: file_to_string(@options[:
|
22
|
+
@options[:custom].include?('://') ? url_to_string(@options[:custom])
|
23
|
+
: file_to_string(@options[:custom])
|
23
24
|
|
24
|
-
rails_template '', "--skip --template #{@options[:
|
25
|
+
rails_template '', "--skip --template #{@options[:custom]}"
|
25
26
|
end
|
26
27
|
|
27
28
|
def gsub_postgres_info
|
@@ -43,7 +44,8 @@ module Orats
|
|
43
44
|
|
44
45
|
def gsub_project_path
|
45
46
|
log_task 'Update the project path'
|
46
|
-
gsub_file "#{@active_path}/.env", ': /
|
47
|
+
gsub_file "#{@active_path}/.env", ': /home/yourname/dev/testproj',
|
48
|
+
": #{File.expand_path(@active_path)}"
|
47
49
|
|
48
50
|
git_commit 'Update the project path'
|
49
51
|
end
|
@@ -83,6 +85,8 @@ module Orats
|
|
83
85
|
end
|
84
86
|
|
85
87
|
def generate_home_page
|
88
|
+
kill_spring_servers
|
89
|
+
|
86
90
|
log_task 'Add pages controller with static page'
|
87
91
|
run_from @active_path, 'bundle exec rails g controller Pages home'
|
88
92
|
|
@@ -95,89 +99,61 @@ module Orats
|
|
95
99
|
|
96
100
|
gsub_file "#{@active_path}/test/controllers/pages_controller_test.rb",
|
97
101
|
'"should get home"', "'expect home page'"
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
%>
|
106
|
-
|
107
|
-
<div class="row">
|
108
|
-
<div class="col-sm-9">
|
109
|
-
<p class="lead">
|
110
|
-
You have successfully generated a project with <%= link_to 'orats', 'https://github.com/nickjj/orats' %> v#{VERSION}.
|
111
|
-
</p>
|
112
|
-
|
113
|
-
<hr />
|
114
|
-
|
115
|
-
<p>
|
116
|
-
<%= image_tag 'https://badge.fury.io/rb/orats.png', alt: 'Gem badge' %> is the latest version of orats.
|
117
|
-
</p>
|
118
|
-
|
119
|
-
<hr />
|
120
|
-
|
121
|
-
<h3>Custom rake tasks</h3>
|
122
|
-
<pre>
|
123
|
-
<code>
|
124
|
-
# backup the database to S3 or any other location
|
125
|
-
bundle exec rake orats:backup
|
126
|
-
|
127
|
-
# generate a new set of favicons to the public directory
|
128
|
-
bundle exec rake orats:favicons
|
129
|
-
</code>
|
130
|
-
</pre>
|
131
|
-
|
132
|
-
<hr />
|
133
|
-
|
134
|
-
<h3>Trying to figure out what to do next?</h3>
|
135
|
-
<p>
|
136
|
-
Visit the wiki guide for <%= link_to 'what to look at after making a new project', 'https://github.com/nickjj/orats/wiki/What-to-look-at-after-making-a-new-project' %>.
|
137
|
-
</p>
|
138
|
-
|
139
|
-
<hr />
|
140
|
-
|
141
|
-
<h3>Looking to deploy your application?</h3>
|
142
|
-
<p>
|
143
|
-
Visit the wiki guide for <%= link_to 'get your application on a server ', 'https://github.com/nickjj/orats/wiki/Get-your-application-on-a-server' %>.
|
144
|
-
</p>
|
145
|
-
|
146
|
-
<hr />
|
147
|
-
|
148
|
-
<h3>Want to get rid of the pages controller?</h3>
|
149
|
-
<p>
|
150
|
-
No problem, just follow these steps:
|
151
|
-
<ul>
|
152
|
-
<li>
|
153
|
-
Run <code>bundle exec rails d controller Pages</code>
|
154
|
-
</li>
|
155
|
-
<li>
|
156
|
-
Remove the root route from <code>config/routes.rb</code>
|
157
|
-
</li>
|
158
|
-
<li>
|
159
|
-
Remove the link in the navigation partial at <code>app/views/layouts/_navigation_links.html.erb</code>
|
160
|
-
</li>
|
161
|
-
<li>
|
162
|
-
Restart the server
|
163
|
-
</li>
|
164
|
-
</ul>
|
165
|
-
</p>
|
166
|
-
</div>
|
167
|
-
|
168
|
-
<div class="col-sm-3">
|
169
|
-
<%= image_tag '/apple-touch-icon-228x228-precomposed.png', size: '228x228', alt: 'A ruby image I found on Google' %>
|
170
|
-
</div>
|
171
|
-
</div>
|
172
|
-
S
|
173
|
-
end
|
102
|
+
|
103
|
+
run_from @active_path, "rm app/views/pages/home.html.erb"
|
104
|
+
Commands::Common.copy_from_local_gem 'new/rails/app/views/pages/home.html.erb',
|
105
|
+
"#{@active_path}/app/views/pages/home.html.erb"
|
106
|
+
gsub_file "#{@active_path}/app/views/pages/home.html.erb",
|
107
|
+
'vVERSION', VERSION
|
108
|
+
|
174
109
|
git_commit 'Add pages controller with home page'
|
175
110
|
end
|
176
111
|
|
112
|
+
def generate_favicons
|
113
|
+
log_task 'Add favicons'
|
114
|
+
run_rake 'orats:favicons'
|
115
|
+
git_commit 'Add favicons'
|
116
|
+
end
|
117
|
+
|
177
118
|
def create_and_migrate_database
|
178
119
|
run_rake 'db:create:all db:migrate'
|
179
120
|
git_commit 'Add the database schema file'
|
180
121
|
end
|
122
|
+
|
123
|
+
def migrate_and_seed_database
|
124
|
+
run_rake 'db:migrate db:seed'
|
125
|
+
git_commit 'Update the database schema file'
|
126
|
+
end
|
127
|
+
|
128
|
+
def template_exist?(template)
|
129
|
+
Exec::PROJECT_TEMPLATES.include?(template.to_sym)
|
130
|
+
end
|
131
|
+
|
132
|
+
private
|
133
|
+
|
134
|
+
def exit_if_invalid_template
|
135
|
+
if @options[:template].length > 0
|
136
|
+
log_task 'Check if template exists'
|
137
|
+
|
138
|
+
unless template_exist?(@options[:template])
|
139
|
+
log_error 'error', 'Cannot find template', 'message',
|
140
|
+
"'#{@options[:template]}' is not a valid template name",
|
141
|
+
true do
|
142
|
+
log_status_bottom 'tip',
|
143
|
+
'run `orats templates` to get a list of valid templates',
|
144
|
+
:white
|
145
|
+
end
|
146
|
+
|
147
|
+
exit 1
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def kill_spring_servers
|
153
|
+
# rails generators will lock up if a spring server is running,
|
154
|
+
# so kill them before continuing
|
155
|
+
system 'pkill -f spring'
|
156
|
+
end
|
181
157
|
end
|
182
158
|
end
|
183
159
|
end
|
@@ -3,18 +3,20 @@ require 'timeout'
|
|
3
3
|
|
4
4
|
module Orats
|
5
5
|
module Commands
|
6
|
-
module
|
6
|
+
module Project
|
7
7
|
module Server
|
8
|
+
START_COMMAND = 'bundle exec foreman start'
|
9
|
+
|
8
10
|
def server_start
|
9
11
|
@options[:skip_server_start] ? message = 'Start your' : message = 'Starting'
|
10
12
|
|
11
13
|
puts '', '='*80
|
12
14
|
log_status_top 'action', "#{message} server with the following commands", :cyan
|
13
15
|
log_status_bottom 'command', "cd #{@active_path}", :magenta, true
|
14
|
-
log_status_bottom 'command',
|
16
|
+
log_status_bottom 'command', START_COMMAND, :magenta
|
15
17
|
puts '='*80, ''
|
16
18
|
|
17
|
-
attempt_to_start
|
19
|
+
attempt_to_start unless @options[:skip_server_start]
|
18
20
|
end
|
19
21
|
|
20
22
|
private
|
@@ -28,7 +30,7 @@ module Orats
|
|
28
30
|
|
29
31
|
puts
|
30
32
|
|
31
|
-
run_from @active_path,
|
33
|
+
run_from @active_path, START_COMMAND
|
32
34
|
end
|
33
35
|
|
34
36
|
def port_taken?
|
data/lib/orats/templates/auth.rb
CHANGED
@@ -43,6 +43,15 @@ end
|
|
43
43
|
}
|
44
44
|
end
|
45
45
|
|
46
|
+
def copy_from_local_gem(source, dest = '')
|
47
|
+
dest = source if dest.empty?
|
48
|
+
|
49
|
+
base_path = "#{File.expand_path File.dirname(__FILE__)}/includes/new/rails"
|
50
|
+
|
51
|
+
run "mkdir -p #{File.dirname(dest)}" unless Dir.exist?(File.dirname(dest))
|
52
|
+
run "cp -f #{base_path}/#{source} #{dest}"
|
53
|
+
end
|
54
|
+
|
46
55
|
# ---
|
47
56
|
|
48
57
|
def delete_app_css
|
@@ -119,7 +128,7 @@ end
|
|
119
128
|
def add_devise_initializers
|
120
129
|
log_task __method__
|
121
130
|
|
122
|
-
|
131
|
+
copy_from_local_gem 'config/initializers/devise_async.rb'
|
123
132
|
generate 'devise:install'
|
124
133
|
git_commit 'Add the devise and devise async initializers'
|
125
134
|
end
|
@@ -242,50 +251,7 @@ end
|
|
242
251
|
def add_account_model
|
243
252
|
log_task __method__
|
244
253
|
|
245
|
-
|
246
|
-
<<-'S'
|
247
|
-
class Account < ActiveRecord::Base
|
248
|
-
ROLES = %w[admin guest]
|
249
|
-
|
250
|
-
devise :database_authenticatable, :registerable, :recoverable, :rememberable,
|
251
|
-
:trackable, :timeoutable, :lockable, :validatable, :async
|
252
|
-
|
253
|
-
before_validation :ensure_password, on: :create
|
254
|
-
|
255
|
-
after_save :invalidate_cache
|
256
|
-
|
257
|
-
validates :role, inclusion: { in: ROLES }
|
258
|
-
|
259
|
-
def self.serialize_from_session(key, salt)
|
260
|
-
# store the current_account in the cache so we do not perform a db lookup on each authenticated page
|
261
|
-
single_key = key.is_a?(Array) ? key.first : key
|
262
|
-
|
263
|
-
Rails.cache.fetch("account:#{single_key}") do
|
264
|
-
Account.where(id: single_key).entries.first
|
265
|
-
end
|
266
|
-
end
|
267
|
-
|
268
|
-
def self.generate_password(length = 10)
|
269
|
-
Devise.friendly_token.first(length)
|
270
|
-
end
|
271
|
-
|
272
|
-
def is?(role_check)
|
273
|
-
role.to_sym == role_check
|
274
|
-
end
|
275
|
-
|
276
|
-
private
|
277
|
-
|
278
|
-
def ensure_password
|
279
|
-
# only generate a password if it does not exist
|
280
|
-
self.password ||= Account.generate_password
|
281
|
-
end
|
282
|
-
|
283
|
-
def invalidate_cache
|
284
|
-
Rails.cache.delete("account:#{id}")
|
285
|
-
end
|
286
|
-
end
|
287
|
-
S
|
288
|
-
end
|
254
|
+
copy_from_local_gem 'app/models/account.rb'
|
289
255
|
git_commit 'Add account model'
|
290
256
|
end
|
291
257
|
|
@@ -312,92 +278,14 @@ end
|
|
312
278
|
|
313
279
|
def add_account_fixtures
|
314
280
|
log_task __method__
|
315
|
-
|
316
|
-
<<-S
|
317
|
-
foo:
|
318
|
-
id: 1
|
319
|
-
email: foo@bar.com
|
320
|
-
encrypted_password: passwordisnotreallyencrypted
|
321
|
-
role: admin
|
322
|
-
created_at: 2012-01-01 01:45:17
|
323
|
-
current_sign_in_at: 2013-03-15 11:22:33
|
324
|
-
|
325
|
-
no_role:
|
326
|
-
id: 2
|
327
|
-
email: joey@almostcool.com
|
328
|
-
encrypted_password: hackthegibson
|
329
|
-
created_at: 1995-09-15 08:10:12
|
330
|
-
|
331
|
-
bad_role:
|
332
|
-
id: 3
|
333
|
-
email: hello@world.com
|
334
|
-
encrypted_password: reallysecure
|
335
|
-
role: ahhhh
|
336
|
-
created_at: 2011-09-20 10:10:10
|
337
|
-
|
338
|
-
beep:
|
339
|
-
id: 4
|
340
|
-
email: beep@beep.com
|
341
|
-
encrypted_password: beepbeepbeep
|
342
|
-
created_at: 2010-03-6 05:15:45
|
343
|
-
S
|
344
|
-
end
|
281
|
+
copy_from_local_gem 'test/fixtures/accounts.yml'
|
345
282
|
git_commit 'Add account fixtures'
|
346
283
|
end
|
347
284
|
|
348
285
|
def add_account_unit_tests
|
349
286
|
log_task __method__
|
350
287
|
|
351
|
-
|
352
|
-
<<-S
|
353
|
-
require 'test_helper'
|
354
|
-
|
355
|
-
class AccountTest < ActiveSupport::TestCase
|
356
|
-
def setup
|
357
|
-
@account = accounts(:foo)
|
358
|
-
end
|
359
|
-
|
360
|
-
def teardown
|
361
|
-
@account = nil
|
362
|
-
end
|
363
|
-
|
364
|
-
test 'expect new account' do
|
365
|
-
assert @account.valid?
|
366
|
-
assert_not_nil @account.email
|
367
|
-
assert_not_nil @account.encrypted_password
|
368
|
-
end
|
369
|
-
|
370
|
-
test 'expect guest to be default role' do
|
371
|
-
no_role = accounts(:no_role)
|
372
|
-
assert_equal 'guest', no_role.role
|
373
|
-
end
|
374
|
-
|
375
|
-
test 'expect invalid role to not save' do
|
376
|
-
bad_role = accounts(:bad_role)
|
377
|
-
assert_not bad_role.valid?
|
378
|
-
end
|
379
|
-
|
380
|
-
test 'expect e-mail to be unique' do
|
381
|
-
duplicate = Account.create(email: 'foo@bar.com')
|
382
|
-
|
383
|
-
assert_not duplicate.valid?
|
384
|
-
end
|
385
|
-
|
386
|
-
test 'expect random password if password is empty' do
|
387
|
-
@account.password = ''
|
388
|
-
@account.encrypted_password = ''
|
389
|
-
@account.save
|
390
|
-
|
391
|
-
random_password = Account.generate_password
|
392
|
-
assert_equal 10, random_password.length
|
393
|
-
end
|
394
|
-
|
395
|
-
test 'expect random password of 20 characters' do
|
396
|
-
assert_equal 20, Account.generate_password(20).length
|
397
|
-
end
|
398
|
-
end
|
399
|
-
S
|
400
|
-
end
|
288
|
+
copy_from_local_gem 'test/models/account_test.rb'
|
401
289
|
git_commit 'Add account unit tests'
|
402
290
|
end
|
403
291
|
|
@@ -436,368 +324,25 @@ end
|
|
436
324
|
def add_devise_views
|
437
325
|
log_task __method__
|
438
326
|
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
<%= f.label :email %>
|
452
|
-
<%= f.email_field :email, class: 'form-control', maxlength: 254, autofocus: true,
|
453
|
-
data: {
|
454
|
-
'rule-required' => 'true',
|
455
|
-
'rule-maxlength' => '254'
|
456
|
-
} %>
|
457
|
-
</div>
|
458
|
-
<%= button_tag type: 'submit', class: 'btn btn-primary' do %>
|
459
|
-
Send
|
460
|
-
<% end %>
|
461
|
-
<% end %>
|
462
|
-
</div>
|
463
|
-
<div class="col-sm-6 col-sm-offset-2">
|
464
|
-
<%= render 'devise/shared/links' %>
|
465
|
-
</div>
|
466
|
-
</div>
|
467
|
-
S
|
468
|
-
end
|
469
|
-
|
470
|
-
file 'app/views/devise/mailer/confirmation_instructions.html.erb' do
|
471
|
-
<<-S
|
472
|
-
<p>Welcome <%= @email %>!</p>
|
473
|
-
|
474
|
-
<p>You can confirm your account email through the link below:</p>
|
475
|
-
|
476
|
-
<p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>
|
477
|
-
S
|
478
|
-
end
|
479
|
-
|
480
|
-
file 'app/views/devise/mailer/reset_password_instructions.html.erb' do
|
481
|
-
<<-S
|
482
|
-
<p>Hello <%= @resource.email %>!</p>
|
483
|
-
|
484
|
-
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
|
485
|
-
|
486
|
-
<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>
|
487
|
-
|
488
|
-
<p>If you didn't request this, please ignore this email.</p>
|
489
|
-
<p>Your password won't change until you access the link above and create a new one.</p>
|
490
|
-
S
|
491
|
-
end
|
492
|
-
|
493
|
-
file 'app/views/devise/mailer/unlock_instructions.html.erb' do
|
494
|
-
<<-S
|
495
|
-
<p>Hello <%= @resource.email %>!</p>
|
496
|
-
|
497
|
-
<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>
|
498
|
-
|
499
|
-
<p>Click the link below to unlock your account:</p>
|
500
|
-
|
501
|
-
<p><%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %></p>
|
502
|
-
S
|
503
|
-
end
|
504
|
-
|
505
|
-
file 'app/views/devise/passwords/edit.html.erb' do
|
506
|
-
<<-S
|
507
|
-
<%
|
508
|
-
title 'Change your password'
|
509
|
-
meta_description '...'
|
510
|
-
heading 'Change your password'
|
511
|
-
%>
|
512
|
-
|
513
|
-
<div class="row">
|
514
|
-
<div class="col-sm-4">
|
515
|
-
<%= form_for resource, as: resource_name, url: password_path(resource_name), html: { method: :put } do |f| %>
|
516
|
-
<%= f.hidden_field :reset_password_token %>
|
517
|
-
<div class="form-group">
|
518
|
-
<%= f.label :password, 'New password' %>
|
519
|
-
<%= f.password_field :password, maxlength: 128, class: 'form-control', autofocus: true,
|
520
|
-
data: {
|
521
|
-
'rule-required' => 'true',
|
522
|
-
'rule-minlength' => '8',
|
523
|
-
'rule-maxlength' => '128'
|
524
|
-
} %>
|
525
|
-
</div>
|
526
|
-
<%= button_tag type: 'submit', class: 'btn btn-primary' do %>
|
527
|
-
Send
|
528
|
-
<% end %>
|
529
|
-
<% end %>
|
530
|
-
</div>
|
531
|
-
<div class="col-sm-6 col-sm-offset-2">
|
532
|
-
<%= render 'devise/shared/links' %>
|
533
|
-
</div>
|
534
|
-
</div>
|
535
|
-
S
|
536
|
-
end
|
537
|
-
|
538
|
-
file 'app/views/devise/passwords/new.html.erb' do
|
539
|
-
<<-S
|
540
|
-
<%
|
541
|
-
title 'Forgot your password?'
|
542
|
-
meta_description '...'
|
543
|
-
heading 'Forgot your password?'
|
544
|
-
%>
|
545
|
-
|
546
|
-
<div class="row">
|
547
|
-
<div class="col-sm-4">
|
548
|
-
<%= form_for resource, as: resource_name, url: password_path(resource_name), html: { method: :post } do |f| %>
|
549
|
-
<div class="form-group">
|
550
|
-
<%= f.label :email %>
|
551
|
-
<%= f.email_field :email, class: 'form-control', autofocus: true, maxlength: 254,
|
552
|
-
data: {
|
553
|
-
'rule-required' => 'true',
|
554
|
-
'rule-maxlength' => '254'
|
555
|
-
} %>
|
556
|
-
</div>
|
557
|
-
<%= button_tag type: 'submit', class: 'btn btn-primary' do %>
|
558
|
-
Send
|
559
|
-
<% end %>
|
560
|
-
<% end %>
|
561
|
-
</div>
|
562
|
-
<div class="col-sm-6 col-sm-offset-2">
|
563
|
-
<%= render 'devise/shared/links' %>
|
564
|
-
</div>
|
565
|
-
</div>
|
566
|
-
S
|
567
|
-
end
|
568
|
-
|
569
|
-
file 'app/views/devise/registrations/edit.html.erb' do
|
570
|
-
<<-S
|
571
|
-
<%
|
572
|
-
title 'Edit your account'
|
573
|
-
meta_description '...'
|
574
|
-
heading 'Edit your account'
|
575
|
-
%>
|
576
|
-
|
577
|
-
<div class="row">
|
578
|
-
<div class="col-sm-6">
|
579
|
-
<%= form_for resource, as: resource_name, url: registration_path(resource_name), html: { method: :patch } do |f| %>
|
580
|
-
<div class="form-group">
|
581
|
-
<%= f.label :current_password %>
|
582
|
-
<span class="help-block form-help-adjust-margin">
|
583
|
-
<small>
|
584
|
-
Supply your current password to make any changes
|
585
|
-
</small>
|
586
|
-
</span>
|
587
|
-
<%= f.password_field :current_password, maxlength: 128, class: 'form-control',
|
588
|
-
data: {
|
589
|
-
'rule-required' => 'true',
|
590
|
-
'rule-minlength' => '8',
|
591
|
-
'rule-maxlength' => '128'
|
592
|
-
} %>
|
593
|
-
</div>
|
594
|
-
<div class="form-group">
|
595
|
-
<%= f.label :email %>
|
596
|
-
<%= f.email_field :email, class: 'form-control', maxlength: 254, autofocus: true %>
|
597
|
-
</div>
|
598
|
-
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
|
599
|
-
<h3>Currently waiting confirmation for: <%= resource.unconfirmed_email %></h3>
|
600
|
-
<% end %>
|
601
|
-
<div class="form-group">
|
602
|
-
<%= f.label :password %>
|
603
|
-
<span class="help-block form-help-adjust-margin">
|
604
|
-
<small>
|
605
|
-
Leave this blank if you do not want to change it
|
606
|
-
</small>
|
607
|
-
</span>
|
608
|
-
<%= f.password_field :password, class: 'form-control' %>
|
609
|
-
</div>
|
610
|
-
<%= button_tag type: 'submit', class: 'btn btn-primary' do %>
|
611
|
-
Save
|
612
|
-
<% end %>
|
613
|
-
<% end %>
|
614
|
-
</div>
|
615
|
-
<div class="col-sm-6">
|
616
|
-
<p>
|
617
|
-
Unhappy? <%= button_to 'Cancel my account', registration_path(resource_name), method: :delete %>
|
618
|
-
</p>
|
619
|
-
</div>
|
620
|
-
</div>
|
621
|
-
S
|
622
|
-
end
|
623
|
-
|
624
|
-
file 'app/views/devise/registrations/new.html.erb' do
|
625
|
-
<<-S
|
626
|
-
<%
|
627
|
-
title 'Register a new account'
|
628
|
-
meta_description '...'
|
629
|
-
heading 'Register a new account'
|
630
|
-
%>
|
631
|
-
|
632
|
-
<div class="row">
|
633
|
-
<div class="col-sm-4">
|
634
|
-
<%= form_for resource, as: resource_name, url: registration_path(resource_name) do |f| %>
|
635
|
-
<div class="form-group">
|
636
|
-
<%= f.label :email %>
|
637
|
-
<%= f.email_field :email, class: 'form-control', maxlength: 254, autofocus: true %>
|
638
|
-
</div>
|
639
|
-
<div class="form-group">
|
640
|
-
<%= f.label :password %>
|
641
|
-
<%= f.password_field :password, maxlength: 128, class: 'form-control',
|
642
|
-
data: {
|
643
|
-
'rule-required' => 'true',
|
644
|
-
'rule-minlength' => '8',
|
645
|
-
'rule-maxlength' => '128'
|
646
|
-
} %>
|
647
|
-
</div>
|
648
|
-
<%= button_tag type: 'submit', class: 'btn btn-primary' do %>
|
649
|
-
Register
|
650
|
-
<% end %>
|
651
|
-
<% end %>
|
652
|
-
</div>
|
653
|
-
<div class="col-sm-6 col-sm-offset-2">
|
654
|
-
<%= render 'devise/shared/links' %>
|
655
|
-
</div>
|
656
|
-
</div>
|
657
|
-
S
|
658
|
-
end
|
659
|
-
|
660
|
-
file 'app/views/devise/sessions/new.html.erb' do
|
661
|
-
<<-S
|
662
|
-
<%
|
663
|
-
title 'Sign in'
|
664
|
-
meta_description '...'
|
665
|
-
heading 'Sign in'
|
666
|
-
%>
|
667
|
-
|
668
|
-
<div class="row">
|
669
|
-
<div class="col-sm-4">
|
670
|
-
<%= form_for resource, as: resource_name, url: session_path(resource_name) do |f| %>
|
671
|
-
<div class="form-group">
|
672
|
-
<%= f.label :email %>
|
673
|
-
<%= f.email_field :email, maxlength: 254, class: 'form-control', autofocus: true %>
|
674
|
-
</div>
|
675
|
-
<div class="form-group">
|
676
|
-
<%= f.label :password %>
|
677
|
-
<%= f.password_field :password, maxlength: 128, class: 'form-control',
|
678
|
-
data: {
|
679
|
-
'rule-required' => 'true',
|
680
|
-
'rule-minlength' => '8',
|
681
|
-
'rule-maxlength' => '128'
|
682
|
-
} %>
|
683
|
-
</div>
|
684
|
-
<% if devise_mapping.rememberable? -%>
|
685
|
-
<div class="checkbox">
|
686
|
-
<%= f.label :remember_me do %>
|
687
|
-
<%= f.check_box :remember_me %> Stay signed in
|
688
|
-
<% end %>
|
689
|
-
</div>
|
690
|
-
<% end -%>
|
691
|
-
<%= button_tag type: 'submit', class: 'btn btn-primary' do %>
|
692
|
-
Sign in
|
693
|
-
<% end %>
|
694
|
-
<% end %>
|
695
|
-
</div>
|
696
|
-
<div class="col-sm-6 col-sm-offset-2">
|
697
|
-
<h4 class="success-color">Having trouble accessing your account?</h4>
|
698
|
-
<%= render 'devise/shared/links' %>
|
699
|
-
</div>
|
700
|
-
</div>
|
701
|
-
S
|
702
|
-
end
|
703
|
-
|
704
|
-
file 'app/views/devise/unlocks/new.html.erb' do
|
705
|
-
<<-S
|
706
|
-
<%
|
707
|
-
title 'Re-send unlock instructions'
|
708
|
-
meta_description '...'
|
709
|
-
heading 'Re-send unlock instructions'
|
710
|
-
%>
|
711
|
-
|
712
|
-
<div class="row">
|
713
|
-
<div class="col-sm-4">
|
714
|
-
<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
|
715
|
-
<div class="form-group">
|
716
|
-
<%= f.label :email %>
|
717
|
-
<%= f.email_field :email, class: 'form-control', maxlength: 254, autofocus: true,
|
718
|
-
data: {
|
719
|
-
'rule-required' => 'true',
|
720
|
-
'rule-maxlength' => '254'
|
721
|
-
} %>
|
722
|
-
</div>
|
723
|
-
<%= button_tag type: 'submit', class: 'btn btn-primary' do %>
|
724
|
-
Send
|
725
|
-
<% end %>
|
726
|
-
<% end %>
|
727
|
-
</div>
|
728
|
-
<div class="col-sm-6 col-sm-offset-2">
|
729
|
-
<%= render 'devise/shared/links' %>
|
730
|
-
</div>
|
731
|
-
</div>
|
732
|
-
S
|
733
|
-
end
|
734
|
-
|
735
|
-
file 'app/views/devise/shared/_links.html.erb' do
|
736
|
-
<<-'S'
|
737
|
-
<%= content_tag(:h4, 'Or do something else') if controller_name != 'sessions' %>
|
738
|
-
<ul>
|
739
|
-
<%- if controller_name != 'sessions' %>
|
740
|
-
<li>
|
741
|
-
<%= link_to 'Sign in', new_session_path(resource_name) %>
|
742
|
-
</li>
|
743
|
-
<% end -%>
|
744
|
-
|
745
|
-
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
|
746
|
-
<li>
|
747
|
-
<%= link_to 'Sign up', new_registration_path(resource_name) %>
|
748
|
-
</li>
|
749
|
-
<% end -%>
|
750
|
-
|
751
|
-
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
|
752
|
-
<li>
|
753
|
-
<%= link_to 'Forgot your password?', new_password_path(resource_name) %>
|
754
|
-
</li>
|
755
|
-
<% end -%>
|
756
|
-
|
757
|
-
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
|
758
|
-
<li>
|
759
|
-
<%= link_to 'Re-send confirmation instructions?', new_confirmation_path(resource_name) %>
|
760
|
-
</li>
|
761
|
-
<% end -%>
|
762
|
-
|
763
|
-
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
|
764
|
-
<li>
|
765
|
-
<%= link_to 'Are you locked out of your account?', new_unlock_path(resource_name) %>
|
766
|
-
</li>
|
767
|
-
<% end -%>
|
768
|
-
|
769
|
-
<%- if devise_mapping.omniauthable? %>
|
770
|
-
<%- resource_class.omniauth_providers.each do |provider| %>
|
771
|
-
<li><%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %></li>
|
772
|
-
<% end -%>
|
773
|
-
<% end -%>
|
774
|
-
</ul>
|
775
|
-
S
|
776
|
-
end
|
327
|
+
copy_from_local_gem 'app/views/devise/confirmations/new.html.erb'
|
328
|
+
copy_from_local_gem 'app/views/devise/mailer/confirmation_instructions.html.erb'
|
329
|
+
copy_from_local_gem 'app/views/devise/mailer/confirmation_instructions.html.erb'
|
330
|
+
copy_from_local_gem 'app/views/devise/mailer/reset_password_instructions.html.erb'
|
331
|
+
copy_from_local_gem 'app/views/devise/mailer/unlock_instructions.html.erb'
|
332
|
+
copy_from_local_gem 'app/views/devise/passwords/edit.html.erb'
|
333
|
+
copy_from_local_gem 'app/views/devise/passwords/new.html.erb'
|
334
|
+
copy_from_local_gem 'app/views/devise/registrations/edit.html.erb'
|
335
|
+
copy_from_local_gem 'app/views/devise/registrations/new.html.erb'
|
336
|
+
copy_from_local_gem 'app/views/devise/sessions/new.html.erb'
|
337
|
+
copy_from_local_gem 'app/views/devise/unlocks/new.html.erb'
|
338
|
+
copy_from_local_gem 'app/views/devise/shared/_links.html.erb'
|
777
339
|
git_commit 'Add devise views'
|
778
340
|
end
|
779
341
|
|
780
342
|
def add_auth_links_to_the_navbar
|
781
343
|
log_task __method__
|
782
344
|
|
783
|
-
|
784
|
-
<% if current_account %>
|
785
|
-
<li>
|
786
|
-
<%= link_to 'Settings', edit_account_registration_path %>
|
787
|
-
</li>
|
788
|
-
<li>
|
789
|
-
<%= link_to 'Sign out', destroy_account_session_path, method: :delete %>
|
790
|
-
</li>
|
791
|
-
<% else %>
|
792
|
-
<li>
|
793
|
-
<%= link_to 'Sign in', new_account_session_path %>
|
794
|
-
</li>
|
795
|
-
<li>
|
796
|
-
<%= link_to 'Register', new_account_registration_path %>
|
797
|
-
</li>
|
798
|
-
<% end %>
|
799
|
-
S
|
800
|
-
|
345
|
+
copy_from_local_gem 'app/views/layouts/_navigation_auth.html.erb'
|
801
346
|
inject_into_file 'app/views/layouts/_navigation.html.erb', after: "</ul>\n" do
|
802
347
|
<<-S
|
803
348
|
<ul class="nav navbar-nav nav-auth">
|