orats 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +7 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +19 -0
- data/LICENSE.txt +22 -0
- data/README.md +199 -0
- data/Rakefile +1 -0
- data/bin/orats +17 -0
- data/lib/orats.rb +5 -0
- data/lib/orats/cli.rb +89 -0
- data/lib/orats/server.rb +50 -0
- data/lib/orats/shell.rb +49 -0
- data/lib/orats/templates/commands/auth.rb +853 -0
- data/lib/orats/templates/commands/base.rb +809 -0
- data/lib/orats/templates/includes/Gemfile +46 -0
- data/lib/orats/version.rb +3 -0
- data/orats.gemspec +25 -0
- metadata +104 -0
@@ -0,0 +1,809 @@
|
|
1
|
+
# =====================================================================================================
|
2
|
+
# Template for generating an opinionated base Rails 4.0.2 project using Ruby 2.1.0
|
3
|
+
# =====================================================================================================
|
4
|
+
|
5
|
+
# ----- Helper functions and variables ----------------------------------------------------------------
|
6
|
+
|
7
|
+
require 'securerandom'
|
8
|
+
|
9
|
+
def generate_token
|
10
|
+
SecureRandom.hex(64)
|
11
|
+
end
|
12
|
+
|
13
|
+
def from_gem(source, destination = nil)
|
14
|
+
base_path = "#{File.expand_path File.dirname(__FILE__)}/../includes"
|
15
|
+
file_name = source.split('/').last
|
16
|
+
|
17
|
+
if destination.present? && file_name != destination
|
18
|
+
if destination.include? '/'
|
19
|
+
run "mkdir -p #{destination}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
run "cp #{base_path}/#{file_name} #{destination}"
|
24
|
+
end
|
25
|
+
|
26
|
+
app_name_upper = app_name.upcase
|
27
|
+
app_name_class = app_name.humanize
|
28
|
+
|
29
|
+
# ----- Create the git repo ----------------------------------------------------------------------------
|
30
|
+
|
31
|
+
puts
|
32
|
+
say_status 'git', 'Creating a new local git repo...', :yellow
|
33
|
+
puts '-'*80, ''; sleep 0.25
|
34
|
+
|
35
|
+
git :init
|
36
|
+
git add: '.'
|
37
|
+
git commit: "-m 'Initial commit'"
|
38
|
+
|
39
|
+
# ----- Modify the .gitignore file --------------------------------------------------------------------
|
40
|
+
|
41
|
+
puts
|
42
|
+
say_status 'root', 'Modifying the .gitignore file...', :yellow
|
43
|
+
puts '-'*80, ''; sleep 0.25
|
44
|
+
|
45
|
+
append_to_file '.gitignore' do <<-TEXT
|
46
|
+
|
47
|
+
# Ignore OS and editor files.
|
48
|
+
.DS_Store
|
49
|
+
*/**.DS_Store
|
50
|
+
._*
|
51
|
+
.*.sw*
|
52
|
+
*~
|
53
|
+
.idea/
|
54
|
+
|
55
|
+
# Ignore the main environment file.
|
56
|
+
.env
|
57
|
+
TEXT
|
58
|
+
end
|
59
|
+
|
60
|
+
git add: '.'
|
61
|
+
git commit: "-m 'Add common OS and editor files to the .gitignore file'"
|
62
|
+
|
63
|
+
# ----- Create a few root files -----------------------------------------------------------------------
|
64
|
+
|
65
|
+
puts
|
66
|
+
say_status 'root', 'Creating root files...', :yellow
|
67
|
+
puts '-'*80, ''; sleep 0.25
|
68
|
+
|
69
|
+
file '.ruby-version', '2.1.0'
|
70
|
+
|
71
|
+
git add: '.'
|
72
|
+
git commit: "-m 'Add .ruby-version file for common ruby version managers'"
|
73
|
+
|
74
|
+
file 'Procfile' do <<-CODE
|
75
|
+
web: puma -C config/puma.rb
|
76
|
+
worker: sidekiq -C config/sidekiq.yml
|
77
|
+
CODE
|
78
|
+
end
|
79
|
+
|
80
|
+
git add: '.'
|
81
|
+
git commit: "-m 'Add a basic Procfile to start the puma and sidekiq processes'"
|
82
|
+
|
83
|
+
# ----- Create an .env file ---------------------------------------------------------------------------
|
84
|
+
|
85
|
+
puts
|
86
|
+
say_status 'root', 'Creating .env file...', :yellow
|
87
|
+
puts '-'*80, ''; sleep 0.25
|
88
|
+
|
89
|
+
file '.env' do <<-CODE
|
90
|
+
#{app_name_upper}_TOKEN_RAILS_SECRET: #{generate_token}
|
91
|
+
|
92
|
+
#{app_name_upper}_SMTP_ADDRESS: smtp.gmail.com
|
93
|
+
#{app_name_upper}_SMTP_PORT: 587
|
94
|
+
#{app_name_upper}_SMTP_DOMAIN: gmail.com
|
95
|
+
#{app_name_upper}_SMTP_USERNAME: #{app_name}@gmail.com
|
96
|
+
#{app_name_upper}_SMTP_PASSWORD: thebestpassword
|
97
|
+
#{app_name_upper}_SMTP_AUTH: plain
|
98
|
+
#{app_name_upper}_SMTP_STARTTTLS_AUTO: true
|
99
|
+
|
100
|
+
#{app_name_upper}_ACTION_MAILER_HOST: localhost:3000
|
101
|
+
#{app_name_upper}_ACTION_MAILER_DEFAULT_EMAIL: info@#{app_name}.com
|
102
|
+
|
103
|
+
#{app_name_upper}_DATABASE_NAME: #{app_name}
|
104
|
+
#{app_name_upper}_DATABASE_HOST: localhost
|
105
|
+
#{app_name_upper}_DATABASE_POOL: 25
|
106
|
+
#{app_name_upper}_DATABASE_TIMEOUT: 5000
|
107
|
+
#{app_name_upper}_DATABASE_USERNAME: postgres
|
108
|
+
#{app_name_upper}_DATABASE_PASSWORD: supersecrets
|
109
|
+
|
110
|
+
#{app_name_upper}_CACHE_HOST: localhost
|
111
|
+
#{app_name_upper}_CACHE_PORT: 6379
|
112
|
+
#{app_name_upper}_CACHE_DATABASE: 0
|
113
|
+
|
114
|
+
#{app_name_upper}_PUMA_THREADS_MIN: 0
|
115
|
+
#{app_name_upper}_PUMA_THREADS_MAX: 1
|
116
|
+
#{app_name_upper}_PUMA_WORKERS: 0
|
117
|
+
|
118
|
+
#{app_name_upper}_SIDEKIQ_CONCURRENCY: 25
|
119
|
+
CODE
|
120
|
+
end
|
121
|
+
|
122
|
+
# ----- Modify the secret token -----------------------------------------------------------------------
|
123
|
+
|
124
|
+
gsub_file 'config/initializers/secret_token.rb', /'\w{128}'/, "ENV['#{app_name_upper}_TOKEN_RAILS_SECRET']"
|
125
|
+
|
126
|
+
|
127
|
+
# ----- Modify the application file -------------------------------------------------------------------
|
128
|
+
|
129
|
+
puts
|
130
|
+
say_status 'config', 'Modifying the application file...', :yellow
|
131
|
+
puts '-'*80, ''; sleep 0.25
|
132
|
+
|
133
|
+
inject_into_file 'config/application.rb', after: "automatically loaded.\n" do <<-CODE
|
134
|
+
config.x.track.google_analytics = ''
|
135
|
+
config.x.track.disqus_shortname = 'test-#{app_name}'
|
136
|
+
config.x.email.default_to = ENV['#{app_name_upper}_ACTION_MAILER_DEFAULT_EMAIL']
|
137
|
+
|
138
|
+
config.action_mailer.delivery_method = :smtp
|
139
|
+
config.action_mailer.smtp_settings = {
|
140
|
+
:address => ENV['#{app_name_upper}_SMTP_ADDRESS'],
|
141
|
+
:port => ENV['#{app_name_upper}_SMTP_PORT'].to_i,
|
142
|
+
:domain => ENV['#{app_name_upper}_SMTP_DOMAIN'],
|
143
|
+
:user_name => ENV['#{app_name_upper}_SMTP_USERNAME'],
|
144
|
+
:password => ENV['#{app_name_upper}_SMTP_PASSWORD'],
|
145
|
+
:authentication => ENV['#{app_name_upper}_SMTP_AUTH'].to_sym,
|
146
|
+
:enable_starttls_auto => ENV['#{app_name_upper}_SMTP_STARTTTLS_AUTO'] == 'true'
|
147
|
+
}
|
148
|
+
|
149
|
+
config.action_mailer.default_url_options = { host: ENV['#{app_name_upper}_ACTION_MAILER_HOST'] }
|
150
|
+
|
151
|
+
config.cache_store = :redis_store, { host: ENV['#{app_name_upper}_CACHE_HOST'],
|
152
|
+
port: ENV['#{app_name_upper}_CACHE_PORT'].to_i,
|
153
|
+
db: ENV['#{app_name_upper}_CACHE_DATABASE'].to_i,
|
154
|
+
namespace: '#{app_name}::cache'
|
155
|
+
}
|
156
|
+
CODE
|
157
|
+
end
|
158
|
+
|
159
|
+
gsub_file 'config/application.rb', "# config.time_zone = 'Central Time (US & Canada)'", "config.time_zone = 'Eastern Time (US & Canada)'"
|
160
|
+
|
161
|
+
append_file 'config/application.rb' do <<-'FILE'
|
162
|
+
|
163
|
+
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
|
164
|
+
if html_tag =~ /\<label/
|
165
|
+
html_tag
|
166
|
+
else
|
167
|
+
errors = Array(instance.error_message).join(',')
|
168
|
+
%(#{html_tag}<p class="validation-error"> #{errors}</p>).html_safe
|
169
|
+
end
|
170
|
+
end
|
171
|
+
FILE
|
172
|
+
end
|
173
|
+
|
174
|
+
git add: '.'
|
175
|
+
git commit: "-m 'Add tweakable settings, update the timezone and change the way validation errors are shown'"
|
176
|
+
|
177
|
+
# ----- Modify the config files -----------------------------------------------------------------------
|
178
|
+
|
179
|
+
puts
|
180
|
+
say_status 'config', 'Modifying the config files...', :yellow
|
181
|
+
puts '-'*80, ''; sleep 0.25
|
182
|
+
|
183
|
+
gsub_file 'config/database.yml', /.*\n/, ''
|
184
|
+
append_file 'config/database.yml' do <<-FILE
|
185
|
+
development: &default
|
186
|
+
adapter: postgresql
|
187
|
+
database: <%= ENV['#{app_name_upper}_DATABASE_NAME'] %>
|
188
|
+
host: <%= ENV['#{app_name_upper}_DATABASE_HOST'] %>
|
189
|
+
pool: <%= ENV['#{app_name_upper}_DATABASE_POOL'] %>
|
190
|
+
timeout: <%= ENV['#{app_name_upper}_DATABASE_TIMEOUT'] %>
|
191
|
+
username: <%= ENV['#{app_name_upper}_DATABASE_USERNAME'] %>
|
192
|
+
password: <%= ENV['#{app_name_upper}_DATABASE_PASSWORD'] %>
|
193
|
+
|
194
|
+
test:
|
195
|
+
<<: *default
|
196
|
+
database: <%= ENV['#{app_name_upper}_DATABASE_NAME'] %>_test
|
197
|
+
|
198
|
+
staging:
|
199
|
+
<<: *default
|
200
|
+
|
201
|
+
production:
|
202
|
+
<<: *default
|
203
|
+
FILE
|
204
|
+
end
|
205
|
+
|
206
|
+
git add: '.'
|
207
|
+
git commit: "-m 'Dry up the database settings'"
|
208
|
+
|
209
|
+
file 'config/puma.rb', <<-CODE
|
210
|
+
threads ENV['#{app_name_upper}_PUMA_THREADS_MIN'].to_i,ENV['#{app_name_upper}_PUMA_THREADS_MAX'].to_i
|
211
|
+
workers ENV['#{app_name_upper}_PUMA_WORKERS'].to_i
|
212
|
+
|
213
|
+
pidfile '/tmp/puma.pid'
|
214
|
+
|
215
|
+
if ENV['RAILS_ENV'] == 'production'
|
216
|
+
bind 'unix:///tmp/puma.sock'
|
217
|
+
else
|
218
|
+
port '3000'
|
219
|
+
end
|
220
|
+
|
221
|
+
restart_command 'bundle exec puma'
|
222
|
+
|
223
|
+
on_worker_boot do
|
224
|
+
require 'active_record'
|
225
|
+
config_path = File.expand_path('../database.yml', __FILE__)
|
226
|
+
|
227
|
+
ActiveRecord::Base.connection.disconnect! rescue ActiveRecord::ConnectionNotEstablished
|
228
|
+
ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'] || YAML.load_file(config_path)[ENV['RAILS_ENV']])
|
229
|
+
end
|
230
|
+
CODE
|
231
|
+
|
232
|
+
git add: '.'
|
233
|
+
git commit: "-m 'Add the puma config'"
|
234
|
+
|
235
|
+
file 'config/sidekiq.yml', <<-CODE
|
236
|
+
---
|
237
|
+
:pidfile: /tmp/sidekiq.pid
|
238
|
+
:concurrency: <%= ENV['#{app_name_upper}_SIDEKIQ_CONCURRENCY'].to_i %>
|
239
|
+
:queues:
|
240
|
+
- default
|
241
|
+
CODE
|
242
|
+
|
243
|
+
git add: '.'
|
244
|
+
git commit: "-m 'Add the sidekiq config'"
|
245
|
+
|
246
|
+
file 'config/sitemap.rb', <<-'CODE'
|
247
|
+
# Set the host name for URL creation
|
248
|
+
SitemapGenerator::Sitemap.default_host = "http://www.app_name.com"
|
249
|
+
|
250
|
+
SitemapGenerator::Sitemap.create do
|
251
|
+
# Put links creation logic here.
|
252
|
+
#
|
253
|
+
# The root path '/' and sitemap index file are added automatically for you.
|
254
|
+
# Links are added to the Sitemap in the order they are specified.
|
255
|
+
#
|
256
|
+
# Examples:
|
257
|
+
#
|
258
|
+
# add root_path
|
259
|
+
# add foobar_path, priority: 0.7, changefreq: 'daily'
|
260
|
+
#
|
261
|
+
# Iteration example:
|
262
|
+
#
|
263
|
+
# Article.published.find_each do |article|
|
264
|
+
# add article_path("#{article.id}-#{article.permalink}"), priority: 0.9, lastmod: article.updated_at
|
265
|
+
# end
|
266
|
+
end
|
267
|
+
CODE
|
268
|
+
|
269
|
+
gsub_file 'config/sitemap.rb', 'app_name', app_name
|
270
|
+
|
271
|
+
git add: '.'
|
272
|
+
git commit: "-m 'Add the sitemap config'"
|
273
|
+
|
274
|
+
file 'config/schedule.rb', <<-CODE
|
275
|
+
every 1.day, at: '4:00 am' do
|
276
|
+
rake '-s sitemap:refresh'
|
277
|
+
end
|
278
|
+
CODE
|
279
|
+
|
280
|
+
git add: '.'
|
281
|
+
git commit: "-m 'Add a sitemap rake task that occurs at 4am'"
|
282
|
+
|
283
|
+
# ----- Modify the environment files ------------------------------------------------------------------
|
284
|
+
|
285
|
+
puts
|
286
|
+
say_status 'Config', 'Modifying the environment files...', :yellow
|
287
|
+
puts '-'*80, ''; sleep 0.25
|
288
|
+
|
289
|
+
file 'config/environments/staging.rb', <<-CODE
|
290
|
+
require_relative 'production.rb'
|
291
|
+
|
292
|
+
#{app_name_class}::Application.configure do
|
293
|
+
config.x.track.google_analytics = ''
|
294
|
+
config.x.track.disqus_shortname = 'test-#{app_name}'
|
295
|
+
end
|
296
|
+
CODE
|
297
|
+
|
298
|
+
git add: '.'
|
299
|
+
git commit: "-m 'Add tweakable settings'"
|
300
|
+
|
301
|
+
inject_into_file 'config/environments/production.rb', after: "config/application.rb.\n" do <<-"CODE"
|
302
|
+
config.x.track.google_analytics = 'YOUR_UA_CODE'
|
303
|
+
config.x.track.disqus_shortname = '#{app_name}'
|
304
|
+
CODE
|
305
|
+
end
|
306
|
+
|
307
|
+
inject_into_file 'config/environments/production.rb', after: "config.log_level = :info\n" do <<-"CODE"
|
308
|
+
config.logger = Logger.new(config.paths['log'].first, 'daily')
|
309
|
+
CODE
|
310
|
+
end
|
311
|
+
|
312
|
+
inject_into_file 'config/environments/production.rb', after: "%w( search.js )\n" do <<-"CODE"
|
313
|
+
config.assets.precompile << Proc.new { |path|
|
314
|
+
if path =~ /\.(eot|svg|ttf|woff|png)\z/
|
315
|
+
true
|
316
|
+
end
|
317
|
+
}
|
318
|
+
CODE
|
319
|
+
end
|
320
|
+
|
321
|
+
git add: '.'
|
322
|
+
git commit: "-m 'Add tweakable settings, setup daily log rotation and add fonts/pngs to the asset precompiler'"
|
323
|
+
|
324
|
+
# ----- Modify the initializer files ------------------------------------------------------------------
|
325
|
+
|
326
|
+
puts
|
327
|
+
say_status 'config', 'Modifying the initializer files...', :yellow
|
328
|
+
puts '-'*80, ''; sleep 0.25
|
329
|
+
|
330
|
+
file 'config/initializers/sidekiq.rb', <<-'CODE'
|
331
|
+
Sidekiq.configure_server do |config|
|
332
|
+
config.redis = { url: "redis://#{ENV['app_name_CACHE_HOST']}:#{ENV['app_name_CACHE_PORT']}/#{ENV['app_name_CACHE_DATABASE']}", namespace: "ns_app::sidekiq_#{Rails.env}" }
|
333
|
+
end
|
334
|
+
|
335
|
+
Sidekiq.configure_client do |config|
|
336
|
+
config.redis = { url: "redis://#{ENV['app_name_CACHE_HOST']}:#{ENV['app_name_CACHE_PORT']}/#{ENV['app_name_CACHE_DATABASE']}", namespace: "ns_app::sidekiq_#{Rails.env}" }
|
337
|
+
end
|
338
|
+
CODE
|
339
|
+
|
340
|
+
gsub_file 'config/initializers/sidekiq.rb', 'app_name', app_name_upper
|
341
|
+
gsub_file 'config/initializers/sidekiq.rb', 'ns_app', app_name
|
342
|
+
|
343
|
+
git add: '.'
|
344
|
+
git commit: "-m 'Add the sidekiq initializer'"
|
345
|
+
|
346
|
+
file 'config/initializers/mini_profiler.rb', <<-CODE
|
347
|
+
if defined? Rack::MiniProfiler
|
348
|
+
# Toggle with ALT+p
|
349
|
+
Rack::MiniProfiler.config.start_hidden = true
|
350
|
+
end
|
351
|
+
CODE
|
352
|
+
|
353
|
+
git add: '.'
|
354
|
+
git commit: "-m 'Add the rack mini profiler initializer'"
|
355
|
+
|
356
|
+
# ----- Modify the routes file ------------------------------------------------------------------------
|
357
|
+
|
358
|
+
puts
|
359
|
+
say_status 'config', 'Modifying the routes file...', :yellow
|
360
|
+
puts '-'*80, ''; sleep 0.25
|
361
|
+
|
362
|
+
prepend_file 'config/routes.rb', "require 'sidekiq/web'\n\n"
|
363
|
+
|
364
|
+
git add: '.'
|
365
|
+
git commit: "-m 'Add sidekiq to the routes file'"
|
366
|
+
|
367
|
+
inject_into_file 'config/routes.rb', after: "draw do\n" do <<-CODE
|
368
|
+
concern :pageable do
|
369
|
+
get 'page/:page', action: :index, on: :collection
|
370
|
+
end
|
371
|
+
CODE
|
372
|
+
end
|
373
|
+
|
374
|
+
git add: '.'
|
375
|
+
git commit: "-m 'Add a route concern for pagination'"
|
376
|
+
|
377
|
+
# ----- Creating application tasks --------------------------------------------------------------------
|
378
|
+
|
379
|
+
puts
|
380
|
+
say_status 'Tasks', 'Creating application tasks...', :yellow
|
381
|
+
puts '-'*80, ''; sleep 0.25
|
382
|
+
|
383
|
+
file 'lib/tasks/favicon.rake', <<-'CODE'
|
384
|
+
namespace :assets do
|
385
|
+
desc 'Create favicons from a single base png'
|
386
|
+
task favicon: :environment do
|
387
|
+
require 'favicon_maker'
|
388
|
+
|
389
|
+
options = {
|
390
|
+
versions: [:apple_144, :apple_120, :apple_114, :apple_72, :apple_57, :apple_pre, :apple, :fav_png, :fav_ico],
|
391
|
+
custom_versions: {
|
392
|
+
apple_extreme_retina: {
|
393
|
+
filename: 'apple-touch-icon-228x228-precomposed.png', dimensions: '228x228', format: 'png'
|
394
|
+
},
|
395
|
+
speeddial: {
|
396
|
+
filename: 'speeddial-160px.png', dimensions: '160x160', format: 'png'
|
397
|
+
}
|
398
|
+
},
|
399
|
+
root_dir: Rails.root,
|
400
|
+
input_dir: File.join('app', 'assets', 'favicon'),
|
401
|
+
base_image: 'favicon_base.png',
|
402
|
+
output_dir: File.join('app', 'assets', 'images'),
|
403
|
+
copy: true
|
404
|
+
}
|
405
|
+
|
406
|
+
FaviconMaker::Generator.create_versions(options) do |filepath|
|
407
|
+
puts "Created favicon: #{filepath}"
|
408
|
+
end
|
409
|
+
end
|
410
|
+
end
|
411
|
+
CODE
|
412
|
+
|
413
|
+
git add: '.'
|
414
|
+
git commit: "-m 'Add a favicon generator task'"
|
415
|
+
|
416
|
+
# ----- Creating application helpers ------------------------------------------------------------------
|
417
|
+
|
418
|
+
puts
|
419
|
+
say_status 'helpers', 'Creating application helpers...', :yellow
|
420
|
+
puts '-'*80, ''; sleep 0.25
|
421
|
+
|
422
|
+
inject_into_file 'app/helpers/application_helper.rb', after: "ApplicationHelper\n" do <<-CODE
|
423
|
+
def title(page_title)
|
424
|
+
content_for(:title) { page_title }
|
425
|
+
end
|
426
|
+
|
427
|
+
def meta_description(page_meta_description)
|
428
|
+
content_for(:meta_description) { page_meta_description }
|
429
|
+
end
|
430
|
+
|
431
|
+
def heading(page_heading)
|
432
|
+
content_for(:heading) { page_heading }
|
433
|
+
end
|
434
|
+
|
435
|
+
def link_to_all_favicons
|
436
|
+
capture do
|
437
|
+
concat favicon_link_tag 'speeddial-160px.png', rel: 'icon', type: 'image/png'
|
438
|
+
concat favicon_link_tag 'favicon.ico', rel: 'icon', type: 'image/x-icon'
|
439
|
+
concat favicon_link_tag 'favicon.ico', rel: 'shortcut icon', type: 'image/x-icon'
|
440
|
+
concat favicon_link_tag 'favicon.png', rel: 'icon', type: 'image/png'
|
441
|
+
concat favicon_link_tag 'apple-touch-icon-228x228-precomposed.png', sizes: '72x72', rel: 'apple-touch-icon-precomposed', type: 'image/png'
|
442
|
+
concat favicon_link_tag 'apple-touch-icon-144x144-precomposed.png', sizes: '144x144', rel: 'apple-touch-icon-precomposed', type: 'image/png'
|
443
|
+
concat favicon_link_tag 'apple-touch-icon-120x120-precomposed.png', sizes: '120x120', rel: 'apple-touch-icon-precomposed', type: 'image/png'
|
444
|
+
concat favicon_link_tag 'apple-touch-icon-114x114-precomposed.png', sizes: '114x114', rel: 'apple-touch-icon-precomposed', type: 'image/png'
|
445
|
+
concat favicon_link_tag 'apple-touch-icon-72x72-precomposed.png', sizes: '72x72', rel: 'apple-touch-icon-precomposed', type: 'image/png'
|
446
|
+
concat favicon_link_tag 'apple-touch-icon-57x57-precomposed.png', sizes: '57x57', rel: 'apple-touch-icon-precomposed', type: 'image/png'
|
447
|
+
concat favicon_link_tag 'apple-touch-icon-precomposed.png', sizes: '57x54', rel: 'apple-touch-icon-precomposed', type: 'image/png'
|
448
|
+
concat favicon_link_tag 'apple-touch-icon.png', sizes: '57x54', rel: 'apple-touch-icon', type: 'image/png'
|
449
|
+
end
|
450
|
+
end
|
451
|
+
|
452
|
+
def humanize_boolean(input)
|
453
|
+
input ||= ''
|
454
|
+
|
455
|
+
case input.to_s.downcase
|
456
|
+
when 't', 'true'
|
457
|
+
'Yes'
|
458
|
+
else
|
459
|
+
'No'
|
460
|
+
end
|
461
|
+
end
|
462
|
+
|
463
|
+
def css_for_boolean(input)
|
464
|
+
if input
|
465
|
+
'success'
|
466
|
+
else
|
467
|
+
'danger'
|
468
|
+
end
|
469
|
+
end
|
470
|
+
CODE
|
471
|
+
end
|
472
|
+
|
473
|
+
git add: '.'
|
474
|
+
git commit: "-m 'Add favicon and boolean view helpers'"
|
475
|
+
|
476
|
+
# ----- Creating view files ---------------------------------------------------------------------------
|
477
|
+
|
478
|
+
puts
|
479
|
+
say_status 'views', 'Creating view files...', :yellow
|
480
|
+
puts '-'*80, ''; sleep 0.25
|
481
|
+
|
482
|
+
run 'rm -f app/views/layouts/application.html.erb'
|
483
|
+
|
484
|
+
file 'app/views/layouts/application.html.erb', <<-HTML
|
485
|
+
<!doctype html>
|
486
|
+
<html lang="en">
|
487
|
+
<head>
|
488
|
+
<title><%= yield :title %></title>
|
489
|
+
<meta charset="utf-8" />
|
490
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
491
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
492
|
+
<meta name="description" content="<%= yield :meta_description %>" />
|
493
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
494
|
+
<%= javascript_include_tag '//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js', 'application', 'data-turbolinks-track' => true %>
|
495
|
+
<%= csrf_meta_tags %>
|
496
|
+
<%= link_to_all_favicons %>
|
497
|
+
<!--[if lt IE 9]>
|
498
|
+
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7/html5shiv.js"></script>
|
499
|
+
<script src="//cdnjs.cloudflare.com/ajax/libs/json3/3.3.0/json3.min.js"></script>
|
500
|
+
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.js"></script>
|
501
|
+
<![endif]-->
|
502
|
+
</head>
|
503
|
+
<body>
|
504
|
+
<header>
|
505
|
+
<%= render 'layouts/navigation' %>
|
506
|
+
</header>
|
507
|
+
|
508
|
+
<main role="main" class="container">
|
509
|
+
<div class="page-header">
|
510
|
+
<h1><%= yield :heading %></h1>
|
511
|
+
</div>
|
512
|
+
<%= render 'layouts/flash' %>
|
513
|
+
<%= yield %>
|
514
|
+
</main>
|
515
|
+
|
516
|
+
<footer>
|
517
|
+
<hr />
|
518
|
+
<div class="container">
|
519
|
+
<%= render 'layouts/footer' %>
|
520
|
+
</div>
|
521
|
+
</footer>
|
522
|
+
|
523
|
+
<% render 'layouts/google_analytics' %>
|
524
|
+
</body>
|
525
|
+
</html>
|
526
|
+
HTML
|
527
|
+
|
528
|
+
git add: '.'
|
529
|
+
git commit: "-m 'Add new layout view'"
|
530
|
+
|
531
|
+
file 'app/views/layouts/_flash.html.erb', <<-'HTML'
|
532
|
+
<% flash.each do |key, msg| %>
|
533
|
+
<% unless key == :timedout %>
|
534
|
+
<%= content_tag :div, class: "alert alert-dismissable alert-#{key}" do -%>
|
535
|
+
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">
|
536
|
+
×
|
537
|
+
</button>
|
538
|
+
<%= msg %>
|
539
|
+
<% end %>
|
540
|
+
<% end %>
|
541
|
+
<% end %>
|
542
|
+
HTML
|
543
|
+
|
544
|
+
git add: '.'
|
545
|
+
git commit: "-m 'Add flash message partial'"
|
546
|
+
|
547
|
+
file 'app/views/layouts/_navigation.html.erb', <<-HTML
|
548
|
+
<nav class="navbar navbar-default">
|
549
|
+
<div class="container">
|
550
|
+
<div class="navbar-header">
|
551
|
+
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
552
|
+
<span class="sr-only">Toggle navigation</span>
|
553
|
+
<span class="icon-bar"></span>
|
554
|
+
<span class="icon-bar"></span>
|
555
|
+
<span class="icon-bar"></span>
|
556
|
+
</button>
|
557
|
+
<%= link_to '#{app_name}', '#root_path_would_go_here', class: 'navbar-brand' %>
|
558
|
+
</div>
|
559
|
+
<div class="collapse navbar-collapse">
|
560
|
+
<ul class="nav navbar-nav">
|
561
|
+
<%= render 'layouts/navigation_links' %>
|
562
|
+
</ul>
|
563
|
+
</div>
|
564
|
+
</div>
|
565
|
+
</nav>
|
566
|
+
HTML
|
567
|
+
|
568
|
+
git add: '.'
|
569
|
+
git commit: "-m 'Add navigation partial'"
|
570
|
+
|
571
|
+
file 'app/views/layouts/_navigation_links.html.erb', <<-HTML
|
572
|
+
<li class="active">
|
573
|
+
<%= link_to 'Bar', '#' %>
|
574
|
+
</li>
|
575
|
+
HTML
|
576
|
+
|
577
|
+
git add: '.'
|
578
|
+
git commit: "-m 'Add navigation links partial'"
|
579
|
+
|
580
|
+
file 'app/views/layouts/_footer.html.erb', <<-HTML
|
581
|
+
<p class="text-muted">© #{Time.now.year.to_s} #{app_name} - All rights reserved</p>
|
582
|
+
HTML
|
583
|
+
|
584
|
+
git add: '.'
|
585
|
+
git commit: "-m 'Add footer partial'"
|
586
|
+
|
587
|
+
file 'app/views/layouts/_google_analytics.html.erb', <<-HTML
|
588
|
+
HTML
|
589
|
+
|
590
|
+
git add: '.'
|
591
|
+
git commit: "-m 'Add google analytics partial'"
|
592
|
+
|
593
|
+
# ----- Creating public files -------------------------------------------------------------------------
|
594
|
+
|
595
|
+
puts
|
596
|
+
say_status 'public', 'Creating public files...', :yellow
|
597
|
+
puts '-'*80, ''; sleep 0.25
|
598
|
+
|
599
|
+
run 'rm -f public/404.html'
|
600
|
+
run 'rm -f public/422.html'
|
601
|
+
run 'rm -f public/500.html'
|
602
|
+
|
603
|
+
file 'public/404.html', <<-HTML
|
604
|
+
<!DOCTYPE html>
|
605
|
+
<html>
|
606
|
+
<head>
|
607
|
+
<title>Error 404</title>
|
608
|
+
<meta charset="utf-8" />
|
609
|
+
<style>
|
610
|
+
</style>
|
611
|
+
</head>
|
612
|
+
|
613
|
+
<body>
|
614
|
+
<h1>Error 404</h1>
|
615
|
+
</body>
|
616
|
+
</html>
|
617
|
+
HTML
|
618
|
+
|
619
|
+
file 'public/422.html', <<-HTML
|
620
|
+
<!DOCTYPE html>
|
621
|
+
<html>
|
622
|
+
<head>
|
623
|
+
<title>Error 422</title>
|
624
|
+
<meta charset="utf-8" />
|
625
|
+
<style>
|
626
|
+
</style>
|
627
|
+
</head>
|
628
|
+
|
629
|
+
<body>
|
630
|
+
<h1>Error 422</h1>
|
631
|
+
</body>
|
632
|
+
</html>
|
633
|
+
HTML
|
634
|
+
|
635
|
+
file 'public/500.html', <<-HTML
|
636
|
+
<!DOCTYPE html>
|
637
|
+
<html>
|
638
|
+
<head>
|
639
|
+
<title>Error 500</title>
|
640
|
+
<meta charset="utf-8" />
|
641
|
+
<style>
|
642
|
+
</style>
|
643
|
+
</head>
|
644
|
+
|
645
|
+
<body>
|
646
|
+
<h1>Error 500</h1>
|
647
|
+
</body>
|
648
|
+
</html>
|
649
|
+
HTML
|
650
|
+
|
651
|
+
file 'public/502.html', <<-HTML
|
652
|
+
<!DOCTYPE html>
|
653
|
+
<html>
|
654
|
+
<head>
|
655
|
+
<title>Error 502</title>
|
656
|
+
<meta charset="utf-8" />
|
657
|
+
<style>
|
658
|
+
</style>
|
659
|
+
</head>
|
660
|
+
|
661
|
+
<body>
|
662
|
+
<h1>Error 502</h1>
|
663
|
+
</body>
|
664
|
+
</html>
|
665
|
+
HTML
|
666
|
+
|
667
|
+
git add: '.'
|
668
|
+
git commit: "-m 'Add public 404, 422, 500 and 502 error pages'"
|
669
|
+
|
670
|
+
# ----- Modifying sass files --------------------------------------------------------------------------
|
671
|
+
|
672
|
+
puts
|
673
|
+
say_status 'assets', 'Modifying sass files...', :yellow
|
674
|
+
puts '-'*80, ''; sleep 0.25
|
675
|
+
|
676
|
+
run 'mv app/assets/stylesheets/application.css app/assets/stylesheets/application.css.scss'
|
677
|
+
|
678
|
+
git add: '.'
|
679
|
+
git commit: "-m 'Rename application.css to application.scss'"
|
680
|
+
git add: '-u'
|
681
|
+
|
682
|
+
inject_into_file 'app/assets/stylesheets/application.css.scss',
|
683
|
+
" *= require font-awesome\n",
|
684
|
+
before: " *= require_self\n"
|
685
|
+
|
686
|
+
git add: '.'
|
687
|
+
git commit: "-m 'Add font-awesome to the application.scss file'"
|
688
|
+
|
689
|
+
append_file 'app/assets/stylesheets/application.css.scss' do <<-SCSS
|
690
|
+
|
691
|
+
// Core variables and mixins
|
692
|
+
@import "bootstrap/variables";
|
693
|
+
@import "bootstrap/mixins";
|
694
|
+
|
695
|
+
// Reset
|
696
|
+
@import "bootstrap/normalize";
|
697
|
+
@import "bootstrap/print";
|
698
|
+
|
699
|
+
// Core CSS
|
700
|
+
@import "bootstrap/scaffolding";
|
701
|
+
@import "bootstrap/type";
|
702
|
+
@import "bootstrap/code";
|
703
|
+
@import "bootstrap/grid";
|
704
|
+
@import "bootstrap/tables";
|
705
|
+
@import "bootstrap/forms";
|
706
|
+
@import "bootstrap/buttons";
|
707
|
+
|
708
|
+
// Components
|
709
|
+
@import "bootstrap/component-animations";
|
710
|
+
// @import "bootstrap/glyphicons";
|
711
|
+
@import "bootstrap/dropdowns";
|
712
|
+
@import "bootstrap/button-groups";
|
713
|
+
@import "bootstrap/input-groups";
|
714
|
+
@import "bootstrap/navs";
|
715
|
+
@import "bootstrap/navbar";
|
716
|
+
@import "bootstrap/breadcrumbs";
|
717
|
+
@import "bootstrap/pagination";
|
718
|
+
@import "bootstrap/pager";
|
719
|
+
@import "bootstrap/labels";
|
720
|
+
@import "bootstrap/badges";
|
721
|
+
@import "bootstrap/jumbotron";
|
722
|
+
@import "bootstrap/thumbnails";
|
723
|
+
@import "bootstrap/alerts";
|
724
|
+
@import "bootstrap/progress-bars";
|
725
|
+
@import "bootstrap/media";
|
726
|
+
@import "bootstrap/list-group";
|
727
|
+
@import "bootstrap/panels";
|
728
|
+
@import "bootstrap/wells";
|
729
|
+
@import "bootstrap/close";
|
730
|
+
|
731
|
+
// Components w/ JavaScript
|
732
|
+
@import "bootstrap/modals";
|
733
|
+
@import "bootstrap/tooltip";
|
734
|
+
@import "bootstrap/popovers";
|
735
|
+
@import "bootstrap/carousel";
|
736
|
+
|
737
|
+
// Utility classes
|
738
|
+
@import "bootstrap/utilities";
|
739
|
+
@import "bootstrap/responsive-utilities";
|
740
|
+
|
741
|
+
.alert-notice {
|
742
|
+
@extend .alert-success;
|
743
|
+
}
|
744
|
+
|
745
|
+
.alert-alert {
|
746
|
+
@extend .alert-danger;
|
747
|
+
}
|
748
|
+
|
749
|
+
img {
|
750
|
+
@extend .img-responsive;
|
751
|
+
margin: 0 auto;
|
752
|
+
}
|
753
|
+
|
754
|
+
.validation-error {
|
755
|
+
margin-top: 2px;
|
756
|
+
color: $brand-danger;
|
757
|
+
font-size: $font-size-small;
|
758
|
+
}
|
759
|
+
SCSS
|
760
|
+
end
|
761
|
+
|
762
|
+
# ----- Modifying javascript and coffeescript files ------------------------------------------------------------------
|
763
|
+
|
764
|
+
puts
|
765
|
+
say_status 'assets', 'Modifying javascript and coffeescript files...', :yellow
|
766
|
+
puts '-'*80, ''; sleep 0.25
|
767
|
+
|
768
|
+
gsub_file 'app/assets/javascripts/application.js', "//= require jquery\n", ''
|
769
|
+
|
770
|
+
git add: '.'
|
771
|
+
git commit: "-m 'Remove jquery from the application.js file because it is loaded from a CDN'"
|
772
|
+
|
773
|
+
inject_into_file 'app/assets/javascripts/application.js',
|
774
|
+
"//= require jquery.turbolinks\n",
|
775
|
+
before: "//= require_tree .\n"
|
776
|
+
|
777
|
+
git add: '.'
|
778
|
+
git commit: "-m 'Add jquery-turbolinks to the application.js file'"
|
779
|
+
|
780
|
+
inject_into_file 'app/assets/javascripts/application.js', before: "//= require_tree .\n" do <<-CODE
|
781
|
+
//= require bootstrap/affix
|
782
|
+
//= require bootstrap/alert
|
783
|
+
//= require bootstrap/button
|
784
|
+
//= require bootstrap/carousel
|
785
|
+
//= require bootstrap/collapse
|
786
|
+
//= require bootstrap/dropdown
|
787
|
+
//= require bootstrap/modal
|
788
|
+
//= require bootstrap/popover
|
789
|
+
//= require bootstrap/scrollspy
|
790
|
+
//= require bootstrap/tab
|
791
|
+
//= require bootstrap/tooltip
|
792
|
+
//= require bootstrap/transition
|
793
|
+
CODE
|
794
|
+
end
|
795
|
+
|
796
|
+
git add: '.'
|
797
|
+
git commit: "-m 'Add bootstrap to the application.js file'"
|
798
|
+
|
799
|
+
# ----- Modifying gem file ----------------------------------------------------------------------------
|
800
|
+
|
801
|
+
puts
|
802
|
+
say_status 'root', 'Copying Gemfile...', :yellow
|
803
|
+
puts '-'*80, ''; sleep 0.25
|
804
|
+
|
805
|
+
run 'rm -f Gemfile'
|
806
|
+
from_gem 'Gemfile', 'Gemfile'
|
807
|
+
|
808
|
+
git add: '.'
|
809
|
+
git commit: "-m 'Add basic gems to the Gemfile'"
|