enjoy_cms 0.3.7.4 → 0.4.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.ruby-version +1 -1
- data/Gemfile.lock +62 -111
- data/app/assets/javascripts/{enjoy_cms → enjoy/cms}/flash.coffee +0 -0
- data/app/assets/javascripts/enjoy/cms/init.coffee +1 -0
- data/app/assets/javascripts/{enjoy_cms → enjoy/cms}/map.coffee +0 -0
- data/app/assets/javascripts/enjoy/cms.coffee +11 -0
- data/app/assets/javascripts/enjoy/rails_admin/cms.ui.coffee +26 -0
- data/app/assets/javascripts/{enjoy_cms → enjoy}/rails_admin/custom/ui.coffee +0 -0
- data/app/assets/javascripts/rails_admin/custom/ui.coffee +2 -2
- data/app/assets/stylesheets/{enjoy_cms → enjoy/cms}/flash.sass +0 -0
- data/app/assets/stylesheets/{enjoy_cms → enjoy/cms}/normalize.scss +0 -0
- data/app/assets/stylesheets/{enjoy_cms → enjoy/cms}/powered.sass +0 -0
- data/app/assets/stylesheets/{enjoy_cms.sass → enjoy/cms.sass} +3 -1
- data/app/assets/stylesheets/enjoy/rails_admin/cms.ui.sass +117 -0
- data/{lib/enjoy/controllers/sitemap_data.rb → app/assets/stylesheets/enjoy/rails_admin/custom/ui.sass} +0 -0
- data/app/assets/stylesheets/rails_admin/custom/theming.sass +2 -0
- data/app/controllers/concerns/enjoy/errors.rb +1 -1
- data/app/controllers/enjoy/registrations_controller.rb +20 -0
- data/app/controllers/enjoy/sessions_controller.rb +19 -0
- data/app/helpers/enjoy/home_helper.rb +2 -0
- data/app/helpers/enjoy/powered_helper.rb +1 -1
- data/app/models/concerns/enjoy/html_field.rb +3 -0
- data/app/views/blocks/_favicon.html.slim +60 -21
- data/app/views/devise/registrations/edit.html.slim +2 -2
- data/app/views/devise/registrations/new.html.slim +9 -3
- data/app/views/devise/sessions/new.html.slim +8 -2
- data/app/views/devise/shared/_links.html.slim +4 -4
- data/app/views/{errors → enjoy/errors}/_base.html.slim +0 -0
- data/app/views/{errors → enjoy/errors}/error_403.html.slim +0 -0
- data/app/views/{errors → enjoy/errors}/error_404.html.slim +0 -0
- data/app/views/{errors → enjoy/errors}/error_500.html.slim +0 -0
- data/app/views/{simple_captcha → enjoy/simple_captcha}/_simple_captcha.html.slim +0 -0
- data/app/views/layouts/application.html.slim +8 -4
- data/app/views/layouts/enjoy/devise/confirmations.html.slim +27 -0
- data/app/views/layouts/enjoy/devise/passwords.html.slim +27 -0
- data/app/views/layouts/enjoy/devise/registrations.html.slim +27 -0
- data/app/views/layouts/enjoy/devise/sessions.html.slim +27 -0
- data/app/views/layouts/enjoy/devise/unlocks.html.slim +27 -0
- data/app/views/rails_admin/main/_setting_value.html.haml +104 -0
- data/app/views/shared/_messages.html.slim +1 -1
- data/config/initializers/simple_captcha.rb +29 -20
- data/config/locales/en.enjoy.yml +1 -1
- data/config/locales/ru.enjoy.yml +0 -7
- data/config/locales/ru.models.yml +2 -39
- data/enjoy_cms.gemspec +7 -20
- data/lib/enjoy/configuration.rb +24 -40
- data/lib/enjoy/controller.rb +5 -3
- data/lib/enjoy/engine.rb +28 -28
- data/lib/enjoy/migration.rb +0 -19
- data/lib/enjoy/model.rb +5 -2
- data/lib/enjoy/rails_admin_ext/config.rb +112 -0
- data/lib/enjoy/rails_admin_ext/enjoy_hash.rb +0 -2
- data/lib/enjoy/rails_admin_ext/enjoy_slugs.rb +31 -0
- data/lib/enjoy/rails_admin_ext/group_patch.rb +2 -1
- data/lib/enjoy/rails_admin_settings_patch.rb +7 -0
- data/lib/enjoy/routes.rb +1 -26
- data/lib/enjoy/version.rb +1 -1
- data/lib/enjoy_cms.rb +25 -71
- data/lib/filename_to_slug.rb +20 -22
- data/lib/generators/enjoy/{ability_generator.rb → cms/ability_generator.rb} +3 -3
- data/lib/generators/enjoy/{admin_generator.rb → cms/admin_generator.rb} +2 -2
- data/lib/generators/enjoy/cms/application_generator.rb +14 -0
- data/lib/generators/enjoy/cms/assets_generator.rb +35 -0
- data/lib/generators/enjoy/{config/install_generator.rb → cms/config_generator.rb} +3 -3
- data/lib/generators/enjoy/cms/gemfile_generator.rb +13 -0
- data/lib/generators/enjoy/{layout_generator.rb → cms/layout_generator.rb} +2 -2
- data/lib/generators/enjoy/cms/paperclip_optimizer_generator.rb +13 -0
- data/lib/generators/enjoy/cms/rack_generator.rb +12 -0
- data/lib/generators/enjoy/cms/robots_generator.rb +12 -0
- data/lib/generators/enjoy/cms/scripts_generator.rb +25 -0
- data/lib/generators/enjoy/cms/templates/Gemfile.erb +69 -0
- data/lib/generators/enjoy/cms/templates/ability.erb +45 -0
- data/lib/generators/enjoy/{templates → cms/templates}/admin.erb +5 -26
- data/lib/generators/enjoy/cms/templates/application.erb +42 -0
- data/lib/generators/enjoy/cms/templates/assets/javascripts/application.coffee.erb +1 -0
- data/lib/generators/enjoy/cms/templates/assets/stylesheets/application.sass.erb +15 -0
- data/lib/generators/enjoy/cms/templates/assets/stylesheets/enjoy/rails_admin/custom/ui.sass.erb +106 -0
- data/lib/generators/enjoy/cms/templates/enjoy_cms.erb +28 -0
- data/lib/generators/enjoy/cms/templates/paperclip_optimizer.erb +80 -0
- data/lib/generators/enjoy/cms/templates/rack.erb +15 -0
- data/lib/generators/enjoy/cms/templates/robots.txt.erb +4 -0
- data/lib/generators/enjoy/cms/templates/scripts/assets_precompile.sh +3 -0
- data/lib/generators/enjoy/cms/templates/scripts/bundle_production.sh +4 -0
- data/lib/generators/enjoy/cms/templates/scripts/db_dump.sh.erb +3 -0
- data/lib/generators/enjoy/cms/templates/scripts/db_restore.sh +3 -0
- data/lib/generators/enjoy/cms/templates/scripts/full_assets_precompile.sh +4 -0
- data/lib/generators/enjoy/cms/templates/scripts/restart_thru_kill.sh +3 -0
- data/lib/generators/enjoy/cms/templates/scripts/send_hup.sh +3 -0
- data/lib/generators/enjoy/cms/templates/scripts/send_usr2.sh +3 -0
- data/lib/generators/enjoy/cms/templates/unicorn.erb +57 -0
- data/lib/generators/enjoy/cms/templates/unicorn.god.erb +59 -0
- data/lib/generators/enjoy/cms/unicorn_god_generator.rb +15 -0
- data/lib/generators/enjoy/{utils.rb → cms/utils.rb} +1 -1
- data/lib/rails_admin/custom_show_in_app.rb +13 -13
- data/template.rb +197 -543
- metadata +73 -325
- data/app/assets/javascripts/enjoy_cms/contacts.coffee +0 -11
- data/app/assets/javascripts/enjoy_cms/rails_admin/cms.ui.coffee +0 -6
- data/app/assets/javascripts/enjoy_cms.coffee +0 -7
- data/app/controllers/concerns/enjoy/blocksetable.rb +0 -37
- data/app/controllers/concerns/enjoy/decorators/contacts.rb +0 -5
- data/app/controllers/concerns/enjoy/decorators/news.rb +0 -5
- data/app/controllers/concerns/enjoy/decorators/pages.rb +0 -5
- data/app/controllers/concerns/enjoy/decorators/search.rb +0 -5
- data/app/controllers/concerns/enjoy/nav_menu.rb +0 -91
- data/app/controllers/concerns/enjoy/seo_pages.rb +0 -90
- data/app/controllers/enjoy/contacts_controller.rb +0 -7
- data/app/controllers/enjoy/news_controller.rb +0 -7
- data/app/controllers/enjoy/pages_controller.rb +0 -7
- data/app/controllers/enjoy/search_controller.rb +0 -8
- data/app/mailers/enjoy/contact_mailer.rb +0 -17
- data/app/models/concerns/enjoy/connectable.rb +0 -36
- data/app/models/concerns/enjoy/decorators/contact_message.rb +0 -5
- data/app/models/concerns/enjoy/decorators/embedded_gallery_image.rb +0 -5
- data/app/models/concerns/enjoy/decorators/gallery.rb +0 -5
- data/app/models/concerns/enjoy/decorators/gallery_image.rb +0 -5
- data/app/models/concerns/enjoy/decorators/menu.rb +0 -5
- data/app/models/concerns/enjoy/decorators/news.rb +0 -5
- data/app/models/concerns/enjoy/decorators/page.rb +0 -5
- data/app/models/concerns/enjoy/decorators/page_block.rb +0 -5
- data/app/models/concerns/enjoy/decorators/page_blockset.rb +0 -5
- data/app/models/concerns/enjoy/decorators/seo.rb +0 -5
- data/app/models/concerns/enjoy/decorators/sitemap_data.rb +0 -5
- data/app/models/concerns/enjoy/mongoid_paperclip.rb +0 -51
- data/app/models/concerns/enjoy/seoable.rb +0 -36
- data/app/models/concerns/enjoy/sitemap_data_field.rb +0 -17
- data/app/models/enjoy/contact_message.rb +0 -16
- data/app/models/enjoy/embedded_gallery_image.rb +0 -16
- data/app/models/enjoy/gallery.rb +0 -13
- data/app/models/enjoy/gallery_image.rb +0 -13
- data/app/models/enjoy/menu.rb +0 -16
- data/app/models/enjoy/news.rb +0 -16
- data/app/models/enjoy/page.rb +0 -16
- data/app/models/enjoy/page_block.rb +0 -13
- data/app/models/enjoy/page_blockset.rb +0 -13
- data/app/models/enjoy/seo.rb +0 -16
- data/app/models/enjoy/sitemap_data.rb +0 -16
- data/app/views/enjoy/contact_mailer/new_message_email.html.slim +0 -15
- data/app/views/enjoy/contacts/_form.html.slim +0 -7
- data/app/views/enjoy/contacts/_form_with_wrapper.html.slim +0 -2
- data/app/views/enjoy/contacts/_success.html.slim +0 -3
- data/app/views/enjoy/contacts/index.html.slim +0 -4
- data/app/views/enjoy/contacts/new.html.slim +0 -4
- data/app/views/enjoy/contacts/sent.html.slim +0 -3
- data/app/views/enjoy/news/index.html.slim +0 -9
- data/app/views/enjoy/news/show.html.slim +0 -8
- data/app/views/enjoy/pages/show.html.slim +0 -1
- data/app/views/enjoy/search/index.html.slim +0 -19
- data/app/views/rails_admin/main/_enjoy_connectable.html.slim +0 -56
- data/config/locales/ru.kaminari.yml +0 -17
- data/config/locales/ru.simple_captcha.yml +0 -3
- data/config/locales/ru.simple_form.yml +0 -9
- data/lib/enjoy/admin/contact_message.rb +0 -42
- data/lib/enjoy/admin/embedded_gallery_image.rb +0 -38
- data/lib/enjoy/admin/gallery.rb +0 -44
- data/lib/enjoy/admin/gallery_image.rb +0 -31
- data/lib/enjoy/admin/menu.rb +0 -27
- data/lib/enjoy/admin/news.rb +0 -89
- data/lib/enjoy/admin/page.rb +0 -96
- data/lib/enjoy/admin/page_block.rb +0 -49
- data/lib/enjoy/admin/page_blockset.rb +0 -50
- data/lib/enjoy/admin/seo.rb +0 -41
- data/lib/enjoy/admin/sitemap_data.rb +0 -29
- data/lib/enjoy/controllers/contacts.rb +0 -86
- data/lib/enjoy/controllers/news.rb +0 -36
- data/lib/enjoy/controllers/pages.rb +0 -22
- data/lib/enjoy/controllers/search.rb +0 -62
- data/lib/enjoy/elastic_search.rb +0 -31
- data/lib/enjoy/models/active_record/contact_message.rb +0 -14
- data/lib/enjoy/models/active_record/menu.rb +0 -17
- data/lib/enjoy/models/active_record/news.rb +0 -26
- data/lib/enjoy/models/active_record/page.rb +0 -20
- data/lib/enjoy/models/active_record/seo.rb +0 -17
- data/lib/enjoy/models/active_record/sitemap_data.rb +0 -11
- data/lib/enjoy/models/contact_message.rb +0 -41
- data/lib/enjoy/models/embedded_gallery_image.rb +0 -13
- data/lib/enjoy/models/gallery.rb +0 -21
- data/lib/enjoy/models/gallery_image.rb +0 -19
- data/lib/enjoy/models/menu.rb +0 -23
- data/lib/enjoy/models/mongoid/contact_message.rb +0 -23
- data/lib/enjoy/models/mongoid/embedded_gallery_image.rb +0 -24
- data/lib/enjoy/models/mongoid/gallery.rb +0 -32
- data/lib/enjoy/models/mongoid/gallery_image.rb +0 -29
- data/lib/enjoy/models/mongoid/menu.rb +0 -20
- data/lib/enjoy/models/mongoid/news.rb +0 -37
- data/lib/enjoy/models/mongoid/page.rb +0 -49
- data/lib/enjoy/models/mongoid/page_block.rb +0 -56
- data/lib/enjoy/models/mongoid/page_blockset.rb +0 -20
- data/lib/enjoy/models/mongoid/seo.rb +0 -35
- data/lib/enjoy/models/mongoid/sitemap_data.rb +0 -25
- data/lib/enjoy/models/news.rb +0 -58
- data/lib/enjoy/models/page.rb +0 -92
- data/lib/enjoy/models/page_block.rb +0 -22
- data/lib/enjoy/models/page_blockset.rb +0 -24
- data/lib/enjoy/models/seo.rb +0 -17
- data/lib/enjoy/models/sitemap_data.rb +0 -17
- data/lib/enjoy/rails_admin_ext/enjoy_connectable.rb +0 -33
- data/lib/enjoy/rails_admin_ext/menu.rb +0 -147
- data/lib/generators/enjoy/capify_generator.rb +0 -39
- data/lib/generators/enjoy/config/templates/enjoy_cms.erb +0 -27
- data/lib/generators/enjoy/migration_generator.rb +0 -18
- data/lib/generators/enjoy/templates/Capfile +0 -17
- data/lib/generators/enjoy/templates/ability.erb +0 -48
- data/lib/generators/enjoy/templates/deploy.erb +0 -47
- data/lib/generators/enjoy/templates/dl.erb +0 -30
- data/lib/generators/enjoy/templates/migration_contact_messages.rb +0 -15
- data/lib/generators/enjoy/templates/migration_news.rb +0 -26
- data/lib/generators/enjoy/templates/migration_pages.rb +0 -45
- data/lib/generators/enjoy/templates/migration_seos.rb +0 -14
- data/lib/generators/enjoy/templates/production.erb +0 -8
- data/lib/generators/enjoy/templates/unicorn.erb +0 -66
data/template.rb
CHANGED
@@ -3,7 +3,7 @@ version = rails_spec.version.to_s
|
|
3
3
|
|
4
4
|
mongoid = options[:skip_active_record]
|
5
5
|
|
6
|
-
if Gem::Version.new(version) < Gem::Version.new('4.2.
|
6
|
+
if Gem::Version.new(version) < Gem::Version.new('4.2.6')
|
7
7
|
puts "You are using an old version of Rails (#{version})"
|
8
8
|
puts "Please update"
|
9
9
|
puts "Stopping"
|
@@ -14,15 +14,23 @@ remove_file 'Gemfile'
|
|
14
14
|
create_file 'Gemfile' do <<-TEXT
|
15
15
|
source 'https://rubygems.org'
|
16
16
|
|
17
|
-
gem 'rails', '4.2.
|
17
|
+
gem 'rails', '4.2.6' #'~> 5.0.0.rc1'
|
18
18
|
#{if mongoid then "gem 'mongoid'" else "gem 'pg'" end}
|
19
19
|
|
20
20
|
gem 'sass'
|
21
21
|
gem 'sass-rails'
|
22
|
-
gem 'compass-rails'
|
23
22
|
gem 'compass'
|
23
|
+
gem 'compass-rails'
|
24
|
+
|
25
|
+
##{if mongoid then "gem 'mongoid-paperclip'" else "gem 'paperclip'" end}
|
26
|
+
#gem 'ack-paperclip-meta', github: "enjoycreative/paperclip-meta"#, path: '/home/ack/www/paperclip-meta'
|
27
|
+
|
28
|
+
gem 'rails_admin_multiple_file_upload'
|
29
|
+
#gem 'rails_admin_comments', github: "enjoycreative/rails_admin_comments" #path: '/home/ack/www/rails_admin/rails_admin_comments'
|
30
|
+
|
24
31
|
|
25
|
-
|
32
|
+
##{if mongoid then "gem 'enjoy_cms_mongoid'" else "gem 'enjoy_cms_activerecord'" end}, path: '/home/ack/www/enjoy/enjoy_cms' #'~> 0.4.0.beta1'
|
33
|
+
#{if mongoid then "gem 'enjoy_cms_mongoid'" else "gem 'enjoy_cms_activerecord'" end}, github: "enjoycreative/enjoy_cms" #'~> 0.4.0.beta1'
|
26
34
|
|
27
35
|
gem 'devise'
|
28
36
|
|
@@ -30,12 +38,11 @@ gem 'slim-rails'
|
|
30
38
|
gem 'rs_russian'
|
31
39
|
gem 'cancancan'
|
32
40
|
|
33
|
-
gem 'cloner'
|
41
|
+
# gem 'cloner'
|
34
42
|
gem 'unicorn'
|
35
43
|
gem 'x-real-ip'
|
36
44
|
|
37
|
-
|
38
|
-
#gem 'sentry-raven'
|
45
|
+
gem 'sentry-raven'
|
39
46
|
|
40
47
|
group :development do
|
41
48
|
gem 'better_errors'
|
@@ -43,21 +50,22 @@ group :development do
|
|
43
50
|
gem 'pry-rails'
|
44
51
|
gem 'spring'
|
45
52
|
|
46
|
-
gem 'capistrano', require: false
|
53
|
+
# gem 'capistrano', require: false
|
54
|
+
#
|
55
|
+
# gem 'rvm1-capistrano3', require: false
|
56
|
+
# gem 'glebtv-capistrano-unicorn', require: false
|
57
|
+
# gem 'capistrano-bundler', require: false
|
58
|
+
# gem 'capistrano-rails', require: false
|
47
59
|
|
48
|
-
gem '
|
49
|
-
gem 'glebtv-capistrano-unicorn', require: false
|
50
|
-
gem 'capistrano-bundler', require: false
|
51
|
-
gem 'capistrano-rails', require: false
|
52
|
-
|
53
|
-
gem 'hipchat'
|
60
|
+
# gem 'hipchat'
|
54
61
|
# gem 'coffee-rails-source-maps'
|
55
62
|
# gem 'compass-rails-source-maps'
|
56
63
|
|
57
|
-
gem '
|
58
|
-
|
64
|
+
gem 'ack_favicon_maker_rails', github: 'ack43/favicon_maker_rails'
|
65
|
+
|
66
|
+
#gem 'rails_email_preview', '~> 1.0.3'
|
59
67
|
|
60
|
-
gem '
|
68
|
+
gem 'image_optim_pack'
|
61
69
|
end
|
62
70
|
|
63
71
|
group :test do
|
@@ -69,25 +77,16 @@ group :test do
|
|
69
77
|
gem 'factory_girl_rails'
|
70
78
|
end
|
71
79
|
|
72
|
-
#{if mongoid then "gem 'mongo_session_store-rails4'" else "" end}
|
80
|
+
#{if mongoid then "#gem 'mongo_session_store-rails4'" else "#gem 'activerecord-session_store'" end}
|
73
81
|
|
74
82
|
gem 'slim'
|
75
83
|
gem 'sprockets'
|
76
84
|
|
77
|
-
gem 'sitemap_generator'
|
78
|
-
gem 'rails_admin_sitemap'
|
79
|
-
|
80
85
|
gem 'uglifier'
|
81
86
|
|
82
87
|
group :production do
|
83
88
|
gem "god"
|
84
89
|
end
|
85
|
-
|
86
|
-
|
87
|
-
gem 'image_optim'
|
88
|
-
gem 'image_optim_pack'
|
89
|
-
gem 'paperclip-optimizer'
|
90
|
-
|
91
90
|
TEXT
|
92
91
|
end
|
93
92
|
|
@@ -124,101 +123,27 @@ TEXT
|
|
124
123
|
end
|
125
124
|
end
|
126
125
|
|
126
|
+
remove_file 'config/initializers/session_store.rb'
|
127
127
|
if mongoid
|
128
|
-
|
129
|
-
create_file 'config/initializers/session_store.rb' do <<-TEXT
|
128
|
+
create_file 'config/initializers/session_store.rb' do <<-TEXT
|
130
129
|
# Be sure to restart your server when you modify this file.
|
131
130
|
|
132
131
|
#Rails.application.config.session_store :cookie_store, key: '_#{app_name.tableize.singularize}_session'
|
133
132
|
Rails.application.config.session_store :mongoid_store
|
134
133
|
|
135
|
-
|
136
|
-
end
|
134
|
+
TEXT
|
137
135
|
end
|
136
|
+
else
|
137
|
+
generate 'active_record_store:session_migration'
|
138
|
+
create_file 'config/initializers/session_store.rb' do <<-TEXT
|
139
|
+
# Be sure to restart your server when you modify this file.
|
140
|
+
|
141
|
+
#Rails.application.config.session_store :cookie_store, key: '_#{app_name.tableize.singularize}_session'
|
142
|
+
Rails.application.config.session_store :active_record_store
|
138
143
|
|
139
|
-
remove_file 'config/initializers/paperclip_optimizer.rb'
|
140
|
-
create_file 'config/initializers/paperclip_optimizer.rb' do <<-TEXT
|
141
|
-
# Set global optimisation options for all Paperclip models
|
142
|
-
|
143
|
-
# By default, image_optim enables all the compression binaries it supports and
|
144
|
-
# requires them to be present on your system, failing if one is actually missing.
|
145
|
-
|
146
|
-
# We disable everything by default and ignore missing ones with `skip_missing_workers`.
|
147
|
-
# This way, should a new version add support for a library we do not yet disable here,
|
148
|
-
# things won't suddenly break.
|
149
|
-
|
150
|
-
Paperclip::PaperclipOptimizer.default_options = {
|
151
|
-
skip_missing_workers: true,
|
152
|
-
advpng: true,
|
153
|
-
gifsicle: true,
|
154
|
-
jhead: true,
|
155
|
-
jpegoptim: true,
|
156
|
-
jpegrecompress: true,
|
157
|
-
jpegtran: true,
|
158
|
-
optipng: true,
|
159
|
-
pngcrush: true,
|
160
|
-
pngout: false,
|
161
|
-
pngquant: true,
|
162
|
-
svgo: false,
|
163
|
-
|
164
|
-
nice: 5,
|
165
|
-
verbose: true
|
166
|
-
}
|
167
|
-
|
168
|
-
# All available image_optim options. See https://github.com/toy/image_optim for more information
|
169
|
-
|
170
|
-
# Paperclip::PaperclipOptimizer.default_options = {
|
171
|
-
# skip_missing_workers: false, # Skip workers with missing or problematic binaries (defaults to false)
|
172
|
-
# nice: 10, # Nice level (defaults to 10)
|
173
|
-
# threads: 1, # Number of threads or disable (defaults to number of processors)
|
174
|
-
# verbose: false, # Verbose output (defaults to false)
|
175
|
-
# pack: nil, # Require image_optim_pack or disable it, by default image_optim_pack will be used if available,
|
176
|
-
# # will turn on :skip-missing-workers unless explicitly disabled (defaults to nil)
|
177
|
-
# allow_lossy: false, # Allow lossy workers and optimizations (defaults to false)
|
178
|
-
# advpng: {
|
179
|
-
# leve: 4 # Compression level: 0 - don't compress, 1 - fast, 2 - normal, 3 - extra, 4 - extreme (defaults to 4)
|
180
|
-
# },
|
181
|
-
# gifsicle: {
|
182
|
-
# interlace: true, # Interlace: true - interlace on, false - interlace off, nil - as is in original image
|
183
|
-
# # (defaults to running two instances, one with interlace off and one with on)
|
184
|
-
# level: 3, # Compression level: 1 - light and fast, 2 - normal, 3 - heavy (slower) (defaults to 3)
|
185
|
-
# careful: false # Avoid bugs with some software (defaults to false)
|
186
|
-
# },
|
187
|
-
# jhead: true, # no options
|
188
|
-
# jpegoptim: {
|
189
|
-
# strip: :all, # List of extra markers to strip: :comments, :exif, :iptc, :icc or :all (defaults to :all)
|
190
|
-
# max_quality: 100 # Maximum image quality factor 0..100 (defaults to 100)
|
191
|
-
# },
|
192
|
-
# jpegrecompress: {
|
193
|
-
# quality: 3 # JPEG quality preset: 0 - low, 1 - medium, 2 - high, 3 - veryhigh (defaults to 3)
|
194
|
-
# },
|
195
|
-
# jpegtran: {
|
196
|
-
# copy_chunks: false, # Copy all chunks (defaults to false)
|
197
|
-
# progressive: true, # Create progressive JPEG file (defaults to true)
|
198
|
-
# jpegrescan: false # Use jpegtran through jpegrescan, ignore progressive option (defaults to false)
|
199
|
-
# },
|
200
|
-
# optipng: {
|
201
|
-
# level: 6, # Optimization level preset: 0 is least, 7 is best (defaults to 6)
|
202
|
-
# interlace: false # Interlace: true - interlace on, false - interlace off, nil - as is in original image (defaults to false)
|
203
|
-
# },
|
204
|
-
# pngcrush: {
|
205
|
-
# chunks: :alla, # List of chunks to remove or :alla - all except tRNS/transparency or
|
206
|
-
# # :allb - all except tRNS and gAMA/gamma (defaults to :alla)
|
207
|
-
# fix: false, # Fix otherwise fatal conditions such as bad CRCs (defaults to false)
|
208
|
-
# brute: false # Brute force try all methods, very time-consuming and generally not worthwhile (defaults to false)
|
209
|
-
# },
|
210
|
-
# pngout: {
|
211
|
-
# copy_chunks: false, # Copy optional chunks (defaults to false)
|
212
|
-
# strategy: 0 # Strategy: 0 - xtreme, 1 - intense, 2 - longest Match, 3 - huffman Only, 4 - uncompressed (defaults to 0)
|
213
|
-
# },
|
214
|
-
# pngquant: {
|
215
|
-
# quality: 100..100, # min..max - don't save below min, use less colors below max (both in range 0..100; in yaml - !ruby/range 0..100) (defaults to 100..100)
|
216
|
-
# speed: 3 # speed/quality trade-off: 1 - slow, 3 - default, 11 - fast & rough (defaults to 3)
|
217
|
-
# },
|
218
|
-
# svgo: true # no options
|
219
|
-
# }
|
220
144
|
TEXT
|
221
145
|
end
|
146
|
+
end
|
222
147
|
|
223
148
|
remove_file 'app/controllers/application_controller.rb'
|
224
149
|
create_file 'app/controllers/application_controller.rb' do <<-TEXT
|
@@ -236,23 +161,11 @@ end
|
|
236
161
|
|
237
162
|
create_file 'README.md', "## #{app_name}\nProject generated by EnjoyCMS\nORM: #{if mongoid then 'Mongoid' else 'ActiveRecord' end}\n\n"
|
238
163
|
|
239
|
-
create_file '.ruby-version', "2.
|
164
|
+
create_file '.ruby-version', "2.3.1\n"
|
240
165
|
create_file '.ruby-gemset', "#{app_name}\n"
|
241
166
|
|
242
167
|
run 'bundle install --without production'
|
243
168
|
|
244
|
-
# generate 'rails_email_preview:install'
|
245
|
-
remove_file 'app/mailer_previews/contact_mailer_preview.rb'
|
246
|
-
create_file 'app/mailer_previews/contact_mailer_preview.rb' do <<-TEXT
|
247
|
-
class ContactMailerPreview
|
248
|
-
def new_message_email
|
249
|
-
Enjoy::ContactMailer.new_message_email(ContactMessage.all.to_a.sample)
|
250
|
-
end
|
251
|
-
end
|
252
|
-
TEXT
|
253
|
-
end
|
254
|
-
|
255
|
-
|
256
169
|
if mongoid
|
257
170
|
create_file 'config/mongoid.yml' do <<-TEXT
|
258
171
|
development:
|
@@ -291,12 +204,90 @@ end
|
|
291
204
|
say "Please create a PostgreSQL user #{app_name.downcase} with password #{app_name.downcase} and a database #{app_name.downcase}_development owned by him for development NOW.", :red
|
292
205
|
ask("Press <enter> when done.", true)
|
293
206
|
end
|
207
|
+
remove_file 'config/application.rb'
|
208
|
+
create_file 'config/application.rb' do <<-TEXT
|
209
|
+
require File.expand_path('../boot', __FILE__)
|
210
|
+
|
211
|
+
# Pick the frameworks you want:
|
212
|
+
require "active_model/railtie"
|
213
|
+
#{'#' if mongoid}require "active_record/railtie"
|
214
|
+
require "action_controller/railtie"
|
215
|
+
# require "action_mailer/railtie" # mailer is off by default
|
216
|
+
require "action_mailer/railtie"
|
217
|
+
require "action_view/railtie"
|
218
|
+
require "sprockets/railtie"
|
219
|
+
# require "rails/test_unit/railtie"
|
220
|
+
|
221
|
+
# Require the gems listed in Gemfile, including any gems
|
222
|
+
# you've limited to :test, :development, or :production.
|
223
|
+
Bundler.require(*Rails.groups)
|
224
|
+
|
225
|
+
module #{app_name.camelize}
|
226
|
+
class Application < Rails::Application
|
227
|
+
config.generators do |g|
|
228
|
+
g.test_framework :rspec
|
229
|
+
g.view_specs false
|
230
|
+
g.helper_specs false
|
231
|
+
g.feature_specs false
|
232
|
+
g.template_engine :slim
|
233
|
+
g.stylesheets false
|
234
|
+
g.javascripts false
|
235
|
+
g.helper false
|
236
|
+
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
|
237
|
+
end
|
238
|
+
|
239
|
+
config.i18n.locale = :ru
|
240
|
+
config.i18n.default_locale = :ru
|
241
|
+
config.i18n.available_locales = [:ru, :en]
|
242
|
+
config.i18n.enforce_available_locales = true
|
243
|
+
#{'config.active_record.schema_format = :sql' unless mongoid}
|
244
|
+
|
245
|
+
#{'config.autoload_paths += %W(#{config.root}/extra)'}
|
246
|
+
#{'config.eager_load_paths += %W(#{config.root}/extra)'}
|
247
|
+
|
248
|
+
config.time_zone = 'Europe/Moscow'
|
249
|
+
config.assets.paths << Rails.root.join("app", "assets", "fonts")
|
250
|
+
end
|
251
|
+
end
|
252
|
+
TEXT
|
253
|
+
end
|
254
|
+
|
255
|
+
|
256
|
+
generate "simple_form:install"
|
257
|
+
|
258
|
+
# generate 'paperclip_optimizer:install'
|
259
|
+
# remove_file 'config/initializers/paperclip_optimizer.rb'
|
260
|
+
# generate "enjoy:cms:paperclip_optimizer"
|
261
|
+
|
262
|
+
# generate 'rails_email_preview:install'
|
263
|
+
# remove_file 'app/mailer_previews/contact_mailer_preview.rb'
|
264
|
+
# create_file 'app/mailer_previews/contact_mailer_preview.rb' do <<-TEXT
|
265
|
+
# class ContactMailerPreview
|
266
|
+
# def new_message_email
|
267
|
+
# Enjoy::Feedback::ContactMailer.new_message_email(Enjoy::Feedback::ContactMessage.all.to_a.sample)
|
268
|
+
# end
|
269
|
+
# end
|
270
|
+
# TEXT
|
271
|
+
# end
|
294
272
|
|
295
273
|
unless mongoid
|
296
274
|
generate 'simple_captcha'
|
297
275
|
end
|
298
276
|
|
299
277
|
generate "devise:install"
|
278
|
+
inject_into_file 'config/initializers/devise.rb', before: /^end/ do <<-TEXT
|
279
|
+
|
280
|
+
Rails.application.config.to_prepare do
|
281
|
+
Devise::SessionsController.layout "enjoy/devise/sessions"
|
282
|
+
Devise::RegistrationsController.layout "enjoy/devise/registrations"
|
283
|
+
Devise::ConfirmationsController.layout "enjoy/devise/confirmations"
|
284
|
+
Devise::UnlocksController.layout "enjoy/devise/unlocks"
|
285
|
+
Devise::PasswordsController.layout "enjoy/devise/passwords"
|
286
|
+
end
|
287
|
+
TEXT
|
288
|
+
end
|
289
|
+
|
290
|
+
|
300
291
|
generate "devise", "User"
|
301
292
|
remove_file "config/locales/devise.en.yml"
|
302
293
|
remove_file "config/locales/en.yml"
|
@@ -331,6 +322,19 @@ inject_into_file 'app/models/user.rb', before: /^end/ do <<-TEXT
|
|
331
322
|
EVAL
|
332
323
|
end
|
333
324
|
|
325
|
+
def self.generate_first_admin_user
|
326
|
+
if User.all.count == 0
|
327
|
+
_email_pass = 'admin@#{app_name.dasherize.downcase}.ru'
|
328
|
+
if User.create(roles: ["admin"], email: _email_pass, password: _email_pass, password_confirmation: _email_pass)
|
329
|
+
puts "User with email and password '\#{_email_pass}' was created!"
|
330
|
+
else
|
331
|
+
puts 'error'
|
332
|
+
end
|
333
|
+
else
|
334
|
+
puts 'error'
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
334
338
|
rails_admin do
|
335
339
|
list do
|
336
340
|
field :email
|
@@ -338,48 +342,65 @@ inject_into_file 'app/models/user.rb', before: /^end/ do <<-TEXT
|
|
338
342
|
field :login
|
339
343
|
field :roles do
|
340
344
|
pretty_value do
|
341
|
-
bindings[:
|
345
|
+
render_object = (bindings[:controller] || bindings[:view])
|
346
|
+
render_object.content_tag(:p, bindings[:object].roles.join(", "))
|
342
347
|
end
|
343
348
|
end
|
344
349
|
end
|
345
350
|
|
346
351
|
edit do
|
347
|
-
|
348
|
-
|
349
|
-
|
352
|
+
group :login do
|
353
|
+
active false
|
354
|
+
field :email, :string do
|
355
|
+
visible do
|
356
|
+
render_object = (bindings[:controller] || bindings[:view])
|
357
|
+
render_object.current_user.admin? or (render_object.current_user.manager? and render_object.current_user == bindings[:object])
|
358
|
+
end
|
350
359
|
end
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
360
|
+
field :name, :string
|
361
|
+
field :login, :string do
|
362
|
+
visible do
|
363
|
+
render_object = (bindings[:controller] || bindings[:view])
|
364
|
+
render_object.current_user.admin?
|
365
|
+
end
|
356
366
|
end
|
357
367
|
end
|
358
|
-
field :roles, :enum do
|
359
|
-
enum do
|
360
|
-
AVAILABLE_ROLES
|
361
|
-
end
|
362
|
-
|
363
|
-
multiple do
|
364
|
-
true
|
365
|
-
end
|
366
368
|
|
367
|
-
|
368
|
-
|
369
|
+
group :roles do
|
370
|
+
active false
|
371
|
+
field :roles, :enum do
|
372
|
+
enum do
|
373
|
+
AVAILABLE_ROLES
|
374
|
+
end
|
375
|
+
|
376
|
+
multiple do
|
377
|
+
true
|
378
|
+
end
|
379
|
+
|
380
|
+
visible do
|
381
|
+
render_object = (bindings[:controller] || bindings[:view])
|
382
|
+
render_object.current_user.admin?
|
383
|
+
end
|
369
384
|
end
|
370
385
|
end
|
371
386
|
|
372
|
-
|
373
|
-
|
374
|
-
|
387
|
+
group :password do
|
388
|
+
active false
|
389
|
+
field :password do
|
390
|
+
visible do
|
391
|
+
render_object = (bindings[:controller] || bindings[:view])
|
392
|
+
render_object.current_user.admin? or render_object.current_user == bindings[:object]
|
393
|
+
end
|
375
394
|
end
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
395
|
+
field :password_confirmation do
|
396
|
+
visible do
|
397
|
+
render_object = (bindings[:controller] || bindings[:view])
|
398
|
+
render_object.current_user.admin? or render_object.current_user == bindings[:object]
|
399
|
+
end
|
380
400
|
end
|
381
401
|
end
|
382
402
|
end
|
403
|
+
|
383
404
|
end
|
384
405
|
TEXT
|
385
406
|
end
|
@@ -392,26 +413,27 @@ else
|
|
392
413
|
end
|
393
414
|
|
394
415
|
unless mongoid
|
395
|
-
generate "enjoy:migration"
|
416
|
+
generate "enjoy:cms:migration"
|
396
417
|
generate "rails_admin_settings:migration"
|
397
418
|
end
|
398
419
|
|
399
|
-
generate "enjoy:admin"
|
400
|
-
generate "enjoy:ability"
|
401
|
-
generate "enjoy:layout"
|
420
|
+
generate "enjoy:cms:admin"
|
421
|
+
generate "enjoy:cms:ability"
|
422
|
+
generate "enjoy:cms:layout"
|
423
|
+
remove_file 'app/views/layouts/application.html.erb'
|
424
|
+
|
402
425
|
|
403
426
|
unless mongoid
|
404
427
|
rake "db:migrate"
|
405
428
|
end
|
406
429
|
|
407
|
-
generate "simple_form:install"
|
408
|
-
|
409
430
|
generate "rspec:install"
|
410
431
|
|
411
432
|
remove_file 'config/routes.rb'
|
412
433
|
create_file 'config/routes.rb' do <<-TEXT
|
413
434
|
Rails.application.routes.draw do
|
414
|
-
devise_for :users
|
435
|
+
devise_for :users, controllers: {sessions: 'enjoy/sessions'}
|
436
|
+
|
415
437
|
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
|
416
438
|
mount Ckeditor::Engine => '/ckeditor'
|
417
439
|
|
@@ -433,404 +455,36 @@ ru:
|
|
433
455
|
TEXT
|
434
456
|
end
|
435
457
|
|
436
|
-
remove_file 'db/seeds.rb'
|
437
|
-
|
438
|
-
require 'securerandom'
|
439
|
-
admin_pw = SecureRandom.urlsafe_base64(6)
|
440
|
-
create_file 'db/seeds.rb' do <<-TEXT
|
441
|
-
admin_pw = "#{admin_pw}"
|
442
|
-
User.destroy_all
|
443
|
-
User.create!(email: 'admin@#{app_name.dasherize.downcase}.ru', password: admin_pw, password_confirmation: admin_pw, roles: ["admin"])
|
444
|
-
TEXT
|
445
|
-
end
|
446
|
-
|
447
|
-
create_file 'config/initializers/rack.rb' do <<-TEXT
|
448
|
-
if Rails.env.development?
|
449
|
-
module Rack
|
450
|
-
class CommonLogger
|
451
|
-
alias_method :log_without_assets, :log
|
452
|
-
#{'ASSETS_PREFIX = "/#{Rails.application.config.assets.prefix[/\A\/?(.*?)\/?\z/, 1]}/"'}
|
453
|
-
def log(env, status, header, began_at)
|
454
|
-
unless env['REQUEST_PATH'].start_with?(ASSETS_PREFIX) || env['REQUEST_PATH'].start_with?('/uploads') || env['REQUEST_PATH'].start_with?('/system')
|
455
|
-
log_without_assets(env, status, header, began_at)
|
456
|
-
end
|
457
|
-
end
|
458
|
-
end
|
459
|
-
end
|
460
|
-
end
|
461
|
-
|
462
|
-
Rack::Utils.multipart_part_limit = 0
|
463
|
-
TEXT
|
464
|
-
end
|
465
|
-
|
466
|
-
create_file 'app/assets/stylesheets/rails_admin/custom/theming.sass' do <<-TEXT
|
467
|
-
.navbar-brand
|
468
|
-
margin-left: 0 !important
|
469
|
-
|
470
|
-
.input-small
|
471
|
-
width: 150px
|
472
|
-
|
473
|
-
.container-fluid
|
474
|
-
input[type=text]
|
475
|
-
width: 380px !important
|
476
|
-
input.ra-filtering-select-input[type=text]
|
477
|
-
width: 180px !important
|
478
|
-
input.hasDatepicker
|
479
|
-
width: 180px !important
|
480
|
-
|
481
|
-
.sidebar-nav
|
482
|
-
a
|
483
|
-
padding: 6px 10px !important
|
484
|
-
.dropdown-header
|
485
|
-
padding: 10px 0px 3px 9px
|
486
|
-
|
487
|
-
.label-important
|
488
|
-
background-color: #d9534f
|
489
|
-
.alert-notice
|
490
|
-
color: #5bc0de
|
491
|
-
|
492
|
-
.page-header
|
493
|
-
display: none
|
494
|
-
.breadcrumb
|
495
|
-
margin-top: 20px
|
496
|
-
|
497
|
-
.control-group
|
498
|
-
clear: both
|
499
|
-
|
500
|
-
.container-fluid
|
501
|
-
padding-left: 0
|
502
|
-
> .row
|
503
|
-
margin: 0
|
504
|
-
|
505
|
-
.last.links
|
506
|
-
a
|
507
|
-
display: inline-block
|
508
|
-
padding: 3px
|
509
|
-
font-size: 20px
|
510
|
-
|
511
|
-
.remove_nested_fields
|
512
|
-
opacity: 1 !important
|
513
|
-
|
514
|
-
body.rails_admin .modal
|
515
|
-
margin: 0 auto !important
|
516
|
-
.modal-dialog
|
517
|
-
width: 990px !important
|
518
|
-
|
519
|
-
input[type=checkbox]
|
520
|
-
width: 30px !important
|
521
|
-
|
522
|
-
body.rails_admin
|
523
|
-
|
524
|
-
.root_links
|
525
|
-
|
526
|
-
> li
|
527
|
-
display: inline-block
|
528
|
-
|
529
|
-
.dropdown-header
|
530
|
-
border-top: 2px solid #777777
|
531
|
-
text-align: right
|
532
|
-
|
533
|
-
&:first-child
|
534
|
-
border-top: none
|
535
|
-
|
536
|
-
.bank_row .logo_field, #edit_bank img
|
537
|
-
background: #ccc !important
|
538
|
-
|
539
|
-
.ui-menu-item
|
540
|
-
border: 1px solid transparent
|
541
|
-
|
542
|
-
.content > .alert
|
543
|
-
margin-top: 20px
|
544
|
-
|
545
|
-
.badge-important
|
546
|
-
background: red
|
547
|
-
.badge-success
|
548
|
-
background: green
|
549
|
-
|
550
|
-
.sidebar-nav i
|
551
|
-
margin-right: 5px
|
552
|
-
|
553
|
-
body.rails_admin .table td.paperclip_type, body.rails_admin .table td.carrierwave_type, body.rails_admin .table td.jcrop_type
|
554
|
-
img
|
555
|
-
max-width: 150px
|
556
|
-
max-height: 100px
|
557
|
-
TEXT
|
558
|
-
end
|
559
|
-
|
560
|
-
remove_file 'public/robots.txt'
|
561
|
-
create_file 'public/robots.txt' do <<-TEXT
|
562
|
-
User-Agent: *
|
563
|
-
Allow: /
|
564
|
-
Disallow: /admin
|
565
|
-
Sitemap: /sitemap.xml.gz
|
566
|
-
TEXT
|
567
|
-
end
|
568
|
-
|
569
|
-
|
570
|
-
remove_file 'app/views/layouts/application.html.erb'
|
571
|
-
|
572
|
-
gsub_file 'app/views/layouts/application.html.slim', "= favicon_link_tag '/favicon.ico'", "= render partial: 'blocks/favicon' #= favicon_link_tag '/favicon.ico'"
|
573
|
-
|
574
|
-
|
575
|
-
remove_file 'config/application.rb'
|
576
|
-
create_file 'config/application.rb' do <<-TEXT
|
577
|
-
require File.expand_path('../boot', __FILE__)
|
578
|
-
|
579
|
-
# Pick the frameworks you want:
|
580
|
-
require "active_model/railtie"
|
581
|
-
#{'#' if mongoid}require "active_record/railtie"
|
582
|
-
require "action_controller/railtie"
|
583
|
-
require "action_mailer/railtie"
|
584
|
-
require "action_view/railtie"
|
585
|
-
require "sprockets/railtie"
|
586
|
-
# require "rails/test_unit/railtie"
|
587
|
-
|
588
|
-
# Require the gems listed in Gemfile, including any gems
|
589
|
-
# you've limited to :test, :development, or :production.
|
590
|
-
Bundler.require(*Rails.groups)
|
591
|
-
|
592
|
-
module #{app_name.camelize}
|
593
|
-
class Application < Rails::Application
|
594
|
-
config.generators do |g|
|
595
|
-
g.test_framework :rspec
|
596
|
-
g.view_specs false
|
597
|
-
g.helper_specs false
|
598
|
-
g.feature_specs false
|
599
|
-
g.template_engine :slim
|
600
|
-
g.stylesheets false
|
601
|
-
g.javascripts false
|
602
|
-
g.helper false
|
603
|
-
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
|
604
|
-
end
|
605
|
-
|
606
|
-
config.i18n.locale = :ru
|
607
|
-
config.i18n.default_locale = :ru
|
608
|
-
config.i18n.available_locales = [:ru, :en]
|
609
|
-
config.i18n.enforce_available_locales = true
|
610
|
-
#{'config.active_record.schema_format = :sql' unless mongoid}
|
611
|
-
|
612
|
-
#{'config.autoload_paths += %W(#{config.root}/extra)'}
|
613
|
-
#{'config.eager_load_paths += %W(#{config.root}/extra)'}
|
614
|
-
|
615
|
-
config.time_zone = 'Europe/Moscow'
|
616
|
-
config.assets.paths << Rails.root.join("app", "assets", "fonts")
|
617
|
-
end
|
618
|
-
end
|
619
|
-
|
620
|
-
TEXT
|
621
|
-
end
|
622
|
-
|
623
|
-
remove_file 'app/assets/stylesheets/application.css'
|
624
|
-
remove_file 'app/assets/stylesheets/application.css.sass'
|
625
|
-
create_file 'app/assets/stylesheets/application.sass' do <<-TEXT
|
626
|
-
@import 'compass'
|
627
|
-
@import 'enjoy_cms'
|
628
|
-
|
629
|
-
#wrapper
|
630
|
-
width: 960px
|
631
|
-
margin: 0 auto
|
632
|
-
#sidebar
|
633
|
-
float: left
|
634
|
-
width: 200px
|
635
|
-
#content
|
636
|
-
float: right
|
637
|
-
width: 750px
|
638
|
-
|
639
|
-
@import "compass/layout/sticky-footer"
|
640
|
-
+sticky-footer(50px)
|
641
|
-
TEXT
|
642
|
-
end
|
643
|
-
|
644
|
-
remove_file 'app/assets/javascripts/application.js'
|
645
|
-
remove_file 'app/assets/javascripts/application.js.coffee'
|
646
|
-
create_file 'app/assets/javascripts/application.coffee' do <<-TEXT
|
647
|
-
#= require enjoy_cms
|
648
|
-
TEXT
|
649
|
-
end
|
650
|
-
|
651
|
-
|
652
|
-
#god+unicorn
|
653
|
-
remove_file 'config/unicorn.rb'
|
654
|
-
create_file 'config/unicorn.rb' do <<-TEXT
|
655
|
-
rails_root = "/home/#{app_name.downcase}/www/#{app_name.downcase}"
|
656
|
-
|
657
|
-
worker_processes 2
|
658
|
-
working_directory rails_root
|
659
|
-
|
660
|
-
# This loads the application in the master process before forking
|
661
|
-
# worker processes
|
662
|
-
# Read more about it here:
|
663
|
-
# http://unicorn.bogomips.org/Unicorn/Configurator.html
|
664
|
-
preload_app true
|
665
|
-
|
666
|
-
timeout 30
|
667
|
-
|
668
|
-
# This is where we specify the socket.
|
669
|
-
# We will point the upstream Nginx module to this socket later on
|
670
|
-
listen "\#{rails_root}/tmp/sockets/unicorn.sock", :backlog => 64
|
671
|
-
|
672
|
-
pid "\#{rails_root}/tmp/pids/unicorn.pid"
|
673
|
-
|
674
|
-
# Set the path of the log files inside the log folder of the testapp
|
675
|
-
stderr_path "\#{rails_root}/log/unicorn.stderr.log"
|
676
|
-
stdout_path "\#{rails_root}/log/unicorn.stdout.log"
|
677
|
-
|
678
|
-
|
679
|
-
before_fork do |server, worker|
|
680
|
-
server.logger.info("worker=\#{worker.nr} spawning in \#{Dir.pwd}")
|
681
|
-
|
682
|
-
# graceful shutdown.
|
683
|
-
old_pid_file = "\#{rails_root}/tmp/pids/unicorn.pid.oldbin"
|
684
|
-
if File.exists?(old_pid_file) && server.pid != old_pid_file
|
685
|
-
begin
|
686
|
-
old_pid = File.read(old_pid_file).to_i
|
687
|
-
server.logger.info("sending QUIT to \#{old_pid}")
|
688
|
-
# we're killing old unicorn master right there
|
689
|
-
Process.kill("QUIT", old_pid)
|
690
|
-
rescue Errno::ENOENT, Errno::ESRCH
|
691
|
-
# someone else did our job for us
|
692
|
-
end
|
693
|
-
end
|
694
|
-
end
|
695
|
-
|
696
|
-
## no need for noSQL
|
697
|
-
# before_fork do |server, worker|
|
698
|
-
# # This option works in together with preload_app true setting
|
699
|
-
# # What is does is prevent the master process from holding
|
700
|
-
# # the database connection
|
701
|
-
# defined?(ActiveRecord::Base) and
|
702
|
-
# ActiveRecord::Base.connection.disconnect!
|
703
|
-
# end
|
458
|
+
# remove_file 'db/seeds.rb'
|
704
459
|
#
|
705
|
-
#
|
706
|
-
#
|
707
|
-
#
|
708
|
-
#
|
709
|
-
#
|
460
|
+
# require 'securerandom'
|
461
|
+
# admin_pw = SecureRandom.urlsafe_base64(6)
|
462
|
+
# create_file 'db/seeds.rb' do <<-TEXT
|
463
|
+
# admin_pw = "#{admin_pw}"
|
464
|
+
# User.destroy_all
|
465
|
+
# User.create!(email: 'admin@#{app_name.dasherize.downcase}.ru', password: admin_pw, password_confirmation: admin_pw, roles: ["admin"])
|
466
|
+
# TEXT
|
710
467
|
# end
|
711
|
-
TEXT
|
712
|
-
end
|
713
|
-
|
714
|
-
remove_file 'config/unicorn.god'
|
715
|
-
create_file 'config/unicorn.god' do <<-TEXT
|
716
|
-
# http://unicorn.bogomips.org/SIGNALS.html
|
717
|
-
|
718
|
-
rails_env = ENV['RAILS_ENV'] || 'production'
|
719
|
-
rails_root = ENV['RAILS_ROOT'] || File.dirname(File.dirname(__FILE__))
|
720
|
-
|
721
|
-
God.watch do |w|
|
722
|
-
w.name = "unicorn_qiwi_middleware"
|
723
|
-
w.interval = 30.seconds # default
|
724
|
-
|
725
|
-
# unicorn needs to be run from the rails root
|
726
|
-
w.start = "cd \#{rails_root} && unicorn -c \#{rails_root}/config/unicorn.rb -E \#{rails_env} -D"
|
727
|
-
|
728
|
-
# QUIT gracefully shuts down workers
|
729
|
-
w.stop = "kill -KILL `cat \#{rails_root}/tmp/pids/unicorn.pid`"
|
730
468
|
|
731
|
-
# USR2 causes the master to re-create itself and spawn a new worker pool
|
732
|
-
w.restart = "kill -USR2 `cat \#{rails_root}/tmp/pids/unicorn.pid`"# && cd \#{rails_root} && unicorn -c \#{rails_root}/config/unicorn.rb -E \#{rails_env} -D"
|
733
469
|
|
734
|
-
|
735
|
-
w.restart_grace = 10.seconds
|
736
|
-
w.pid_file = "\#{rails_root}/tmp/pids/unicorn.pid"
|
470
|
+
generate "enjoy:rack"
|
737
471
|
|
738
|
-
w.uid = 'ack'
|
739
|
-
w.gid = 'ack'
|
740
472
|
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
start.condition(:process_running) do |c|
|
745
|
-
c.interval = 5.seconds
|
746
|
-
c.running = false
|
747
|
-
end
|
748
|
-
end
|
473
|
+
remove_file 'app/assets/stylesheets/application.css'
|
474
|
+
remove_file 'app/assets/javascripts/application.js'
|
475
|
+
generate "enjoy:cms:assets", app_name
|
749
476
|
|
750
|
-
|
751
|
-
|
752
|
-
c.above = 150.megabytes
|
753
|
-
c.times = [3, 5] # 3 out of 5 intervals
|
754
|
-
end
|
477
|
+
remove_file 'public/robots.txt'
|
478
|
+
generate "enjoy:cms:robots"
|
755
479
|
|
756
|
-
restart.condition(:cpu_usage) do |c|
|
757
|
-
c.above = 50.percent
|
758
|
-
c.times = 5
|
759
|
-
end
|
760
|
-
end
|
761
480
|
|
762
|
-
|
763
|
-
|
764
|
-
on.condition(:flapping) do |c|
|
765
|
-
c.to_state = [:start, :restart]
|
766
|
-
c.times = 5
|
767
|
-
c.within = 5.minute
|
768
|
-
c.transition = :unmonitored
|
769
|
-
c.retry_in = 10.minutes
|
770
|
-
c.retry_times = 5
|
771
|
-
c.retry_within = 2.hours
|
772
|
-
end
|
773
|
-
end
|
774
|
-
end
|
775
|
-
TEXT
|
776
|
-
end
|
481
|
+
#god+unicorn
|
482
|
+
generate "enjoy:cms:unicorn_god", app_name
|
777
483
|
|
778
484
|
|
779
485
|
|
780
486
|
#scripts
|
781
|
-
|
782
|
-
create_file 'scripts/assets_precompile.sh' do <<-TEXT
|
783
|
-
#!/bin/sh
|
784
|
-
|
785
|
-
RAILS_ENV=production rake assets:precompile
|
786
|
-
TEXT
|
787
|
-
end
|
788
|
-
|
789
|
-
remove_file 'scripts/bundle_production.sh'
|
790
|
-
create_file 'scripts/bundle_production.sh' do <<-TEXT
|
791
|
-
#!/bin/sh
|
792
|
-
|
793
|
-
rm Gemfile.lock
|
794
|
-
bundle install --without development test
|
795
|
-
TEXT
|
796
|
-
end
|
797
|
-
|
798
|
-
remove_file 'scripts/full_assets_precompile.sh'
|
799
|
-
create_file 'scripts/full_assets_precompile.sh' do <<-TEXT
|
800
|
-
#!/bin/sh
|
801
|
-
|
802
|
-
RAILS_ENV=production rake assets:precompile
|
803
|
-
TEXT
|
804
|
-
end
|
805
|
-
|
806
|
-
remove_file 'scripts/restart_thru_kill.sh'
|
807
|
-
create_file 'scripts/restart_thru_kill.sh' do <<-TEXT
|
808
|
-
#!/bin/sh
|
809
|
-
|
810
|
-
kill $(cat ./tmp/pids/unicorn.pid)
|
811
|
-
TEXT
|
812
|
-
end
|
813
|
-
|
814
|
-
remove_file 'scripts/send_usr2.sh'
|
815
|
-
create_file 'scripts/send_usr2.sh' do <<-TEXT
|
816
|
-
#!/bin/sh
|
817
|
-
|
818
|
-
kill -USR2 $(cat ./tmp/pids/unicorn.pid)
|
819
|
-
TEXT
|
820
|
-
end
|
821
|
-
|
822
|
-
remove_file 'scripts/send_hup.sh'
|
823
|
-
create_file 'scripts/send_hup.sh' do <<-TEXT
|
824
|
-
#!/bin/sh
|
825
|
-
|
826
|
-
kill -HUP $(cat ./tmp/pids/unicorn.pid)
|
827
|
-
TEXT
|
828
|
-
end
|
829
|
-
|
830
|
-
inject_into_file 'config/initializers/assets.rb', before: /\z/ do <<-TEXT
|
831
|
-
Rails.application.config.assets.precompile += %w( ckeditor/* )
|
832
|
-
TEXT
|
833
|
-
end
|
487
|
+
generate "enjoy:cms:scripts", app_name
|
834
488
|
|
835
489
|
|
836
490
|
|