enjoy_cms 0.1.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/.rspec +1 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +249 -0
- data/LICENSE.txt +22 -0
- data/README.md +137 -0
- data/Rakefile +1 -0
- data/app/assets/javascripts/enjoy_cms.coffee +6 -0
- data/app/assets/javascripts/enjoy_cms/flash.js.coffee +3 -0
- data/app/assets/javascripts/enjoy_cms/map.js.coffee +22 -0
- data/app/assets/javascripts/head.load.js +707 -0
- data/app/assets/javascripts/jquery.placeholder.js +157 -0
- data/app/assets/stylesheets/enjoy_cms.sass +5 -0
- data/app/assets/stylesheets/enjoy_cms/flash.sass +63 -0
- data/app/assets/stylesheets/enjoy_cms/normalize.scss +406 -0
- data/app/assets/stylesheets/enjoy_cms/powered.sass +18 -0
- data/app/controllers/concerns/enjoy/errors.rb +93 -0
- data/app/controllers/concerns/enjoy/fancybox.rb +14 -0
- data/app/controllers/concerns/enjoy/localizeable.rb +33 -0
- data/app/controllers/concerns/enjoy/nav_menu.rb +64 -0
- data/app/controllers/concerns/enjoy/no_cache.rb +12 -0
- data/app/controllers/concerns/enjoy/seo_pages.rb +83 -0
- data/app/controllers/enjoy/contacts_controller.rb +5 -0
- data/app/controllers/enjoy/home_controller.rb +6 -0
- data/app/controllers/enjoy/news_controller.rb +5 -0
- data/app/controllers/enjoy/pages_controller.rb +5 -0
- data/app/controllers/enjoy/search_controller.rb +6 -0
- data/app/helpers/enjoy/gzip_helper.rb +27 -0
- data/app/helpers/enjoy/powered_helper.rb +12 -0
- data/app/mailers/enjoy/contact_mailer.rb +17 -0
- data/app/models/concerns/enjoy/boolean_field.rb +17 -0
- data/app/models/concerns/enjoy/enableable.rb +8 -0
- data/app/models/concerns/enjoy/geocodeable.rb +4 -0
- data/app/models/concerns/enjoy/mappable.rb +95 -0
- data/app/models/concerns/enjoy/mongoid_paperclip.rb +37 -0
- data/app/models/concerns/enjoy/seoable.rb +36 -0
- data/app/models/concerns/enjoy/sitemap_data.rb +23 -0
- data/app/models/concerns/enjoy/sort_field.rb +20 -0
- data/app/models/concerns/enjoy/sortable.rb +8 -0
- data/app/models/enjoy/contact_message.rb +12 -0
- data/app/models/enjoy/embedded_element.rb +15 -0
- data/app/models/enjoy/embedded_gallery_image.rb +15 -0
- data/app/models/enjoy/gallery.rb +10 -0
- data/app/models/enjoy/gallery_image.rb +10 -0
- data/app/models/enjoy/menu.rb +12 -0
- data/app/models/enjoy/news.rb +12 -0
- data/app/models/enjoy/page.rb +12 -0
- data/app/models/enjoy/seo.rb +13 -0
- data/app/views/blocks/_favicon.html.slim +21 -0
- data/app/views/blocks/_footer.html.slim +1 -0
- data/app/views/blocks/_seo_block.html.slim +18 -0
- data/app/views/blocks/_seo_block_with_obj.html.slim +27 -0
- data/app/views/devise/registrations/edit.html.slim +21 -0
- data/app/views/devise/registrations/new.html.slim +21 -0
- data/app/views/devise/sessions/new.html.slim +22 -0
- data/app/views/devise/shared/_links.html.slim +11 -0
- data/app/views/enjoy/contact_mailer/new_message_email.html.slim +15 -0
- data/app/views/enjoy/contacts/index.html.slim +10 -0
- data/app/views/enjoy/contacts/new.html.slim +10 -0
- data/app/views/enjoy/contacts/sent.html.slim +4 -0
- data/app/views/enjoy/home/index.html.slim +1 -0
- data/app/views/enjoy/news/index.html.slim +9 -0
- data/app/views/enjoy/news/show.html.slim +8 -0
- data/app/views/enjoy/pages/show.html.slim +1 -0
- data/app/views/enjoy/search/index.html.slim +19 -0
- data/app/views/errors/_base.html.slim +3 -0
- data/app/views/errors/error_403.html.slim +1 -0
- data/app/views/errors/error_404.html.slim +1 -0
- data/app/views/errors/error_500.html.slim +1 -0
- data/app/views/layouts/application.html.slim +25 -0
- data/app/views/rails_admin/main/_check_boxes.html.slim +27 -0
- data/app/views/rails_admin/main/_enum_check_boxes.html.slim +5 -0
- data/app/views/rails_admin/main/_enum_radio_buttons.html.slim +5 -0
- data/app/views/rails_admin/main/_form_raw.html.slim +1 -0
- data/app/views/shared/_admin_link.html.slim +3 -0
- data/app/views/shared/_messages.html.slim +7 -0
- data/app/views/shared/_meta.html.slim +19 -0
- data/app/views/shared/_obj.html.slim +21 -0
- data/app/views/shared/_og.html.slim +4 -0
- data/app/views/simple_captcha/_simple_captcha.html.slim +12 -0
- data/config/initializers/simple_captcha.rb +29 -0
- data/config/locales/en.enjoy.yml +29 -0
- data/config/locales/en.enjoy_admin.yml +6 -0
- data/config/locales/ru.cancan.yml +4 -0
- data/config/locales/ru.devise.yml +65 -0
- data/config/locales/ru.enjoy.yml +39 -0
- data/config/locales/ru.enjoy_admin.yml +6 -0
- data/config/locales/ru.kaminari.yml +17 -0
- data/config/locales/ru.models.yml +103 -0
- data/config/locales/ru.mongoid.yml +450 -0
- data/config/locales/ru.rails_admin.yml +148 -0
- data/config/locales/ru.simple_captcha.yml +3 -0
- data/config/locales/ru.simple_form.yml +9 -0
- data/config/routes.rb +14 -0
- data/enjoy_cms.gemspec +53 -0
- data/lib/enjoy/admin.rb +350 -0
- data/lib/enjoy/admin/contact_message.rb +36 -0
- data/lib/enjoy/admin/embedded_element.rb +11 -0
- data/lib/enjoy/admin/embedded_gallery_image.rb +15 -0
- data/lib/enjoy/admin/gallery.rb +20 -0
- data/lib/enjoy/admin/gallery_image.rb +18 -0
- data/lib/enjoy/admin/menu.rb +27 -0
- data/lib/enjoy/admin/news.rb +57 -0
- data/lib/enjoy/admin/page.rb +81 -0
- data/lib/enjoy/admin/seo.rb +17 -0
- data/lib/enjoy/configuration.rb +73 -0
- data/lib/enjoy/controller.rb +31 -0
- data/lib/enjoy/controllers/contacts.rb +70 -0
- data/lib/enjoy/controllers/news.rb +36 -0
- data/lib/enjoy/controllers/pages.rb +22 -0
- data/lib/enjoy/controllers/search.rb +62 -0
- data/lib/enjoy/elastic_search.rb +31 -0
- data/lib/enjoy/engine.rb +46 -0
- data/lib/enjoy/migration.rb +34 -0
- data/lib/enjoy/model.rb +22 -0
- data/lib/enjoy/models/active_record/contact_message.rb +14 -0
- data/lib/enjoy/models/active_record/menu.rb +17 -0
- data/lib/enjoy/models/active_record/news.rb +26 -0
- data/lib/enjoy/models/active_record/page.rb +20 -0
- data/lib/enjoy/models/active_record/seo.rb +17 -0
- data/lib/enjoy/models/contact_message.rb +37 -0
- data/lib/enjoy/models/embedded_element.rb +12 -0
- data/lib/enjoy/models/embedded_gallery_image.rb +16 -0
- data/lib/enjoy/models/gallery.rb +29 -0
- data/lib/enjoy/models/gallery_image.rb +23 -0
- data/lib/enjoy/models/menu.rb +28 -0
- data/lib/enjoy/models/mongoid/contact_message.rb +20 -0
- data/lib/enjoy/models/mongoid/embedded_element.rb +13 -0
- data/lib/enjoy/models/mongoid/embedded_gallery_image.rb +19 -0
- data/lib/enjoy/models/mongoid/gallery.rb +23 -0
- data/lib/enjoy/models/mongoid/gallery_image.rb +21 -0
- data/lib/enjoy/models/mongoid/menu.rb +15 -0
- data/lib/enjoy/models/mongoid/news.rb +29 -0
- data/lib/enjoy/models/mongoid/page.rb +25 -0
- data/lib/enjoy/models/mongoid/seo.rb +28 -0
- data/lib/enjoy/models/news.rb +58 -0
- data/lib/enjoy/models/page.rb +90 -0
- data/lib/enjoy/models/seo.rb +22 -0
- data/lib/enjoy/patch.rb +58 -0
- data/lib/enjoy/rails_admin_menu.rb +145 -0
- data/lib/enjoy/simple_form_patch.rb +12 -0
- data/lib/enjoy/tasks.rb +13 -0
- data/lib/enjoy/version.rb +3 -0
- data/lib/enjoy_cms.rb +109 -0
- data/lib/filename_to_slug.rb +34 -0
- data/lib/generators/enjoy/ability_generator.rb +14 -0
- data/lib/generators/enjoy/admin_generator.rb +21 -0
- data/lib/generators/enjoy/capify_generator.rb +39 -0
- data/lib/generators/enjoy/layout_generator.rb +14 -0
- data/lib/generators/enjoy/migration_generator.rb +18 -0
- data/lib/generators/enjoy/templates/Capfile +17 -0
- data/lib/generators/enjoy/templates/ability.erb +26 -0
- data/lib/generators/enjoy/templates/admin.erb +89 -0
- data/lib/generators/enjoy/templates/deploy.erb +47 -0
- data/lib/generators/enjoy/templates/dl.erb +30 -0
- data/lib/generators/enjoy/templates/migration_contact_messages.rb +15 -0
- data/lib/generators/enjoy/templates/migration_news.rb +26 -0
- data/lib/generators/enjoy/templates/migration_pages.rb +45 -0
- data/lib/generators/enjoy/templates/migration_seos.rb +14 -0
- data/lib/generators/enjoy/templates/production.erb +8 -0
- data/lib/generators/enjoy/templates/unicorn.erb +66 -0
- data/lib/generators/enjoy/utils.rb +21 -0
- data/lib/manual_slug.rb +10 -0
- data/lib/manual_slug/active_record.rb +32 -0
- data/lib/manual_slug/mongoid.rb +36 -0
- data/lib/rails_admin/custom_show_in_app.rb +43 -0
- data/release.sh +13 -0
- data/template.rb +824 -0
- metadata +579 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
module ManualSlug::Mongoid
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
include ::Mongoid::Slug
|
4
|
+
|
5
|
+
def text_slug
|
6
|
+
self._slugs.empty? ? '' : self._slugs.last
|
7
|
+
end
|
8
|
+
def text_slug=(slug)
|
9
|
+
if slug.blank?
|
10
|
+
self._slugs = []
|
11
|
+
else
|
12
|
+
self._slugs.delete(slug)
|
13
|
+
self._slugs << slug
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module ClassMethods
|
18
|
+
def manual_slug(field, options = {}, callback = true)
|
19
|
+
options.merge!(permanent: true, history: true)
|
20
|
+
slug field, options
|
21
|
+
|
22
|
+
# we will create slugs manually when needed
|
23
|
+
skip_callback :create, :before, :build_slug
|
24
|
+
|
25
|
+
before_validation do
|
26
|
+
self._slugs = self._slugs.map{ |s| s.strip }.reject {|s| s.blank? } if self._slugs
|
27
|
+
|
28
|
+
if self._slugs.blank?
|
29
|
+
self.build_slug
|
30
|
+
end
|
31
|
+
|
32
|
+
true
|
33
|
+
end if callback
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module RailsAdmin
|
2
|
+
module Config
|
3
|
+
module Actions
|
4
|
+
class CustomShowInApp < RailsAdmin::Config::Actions::Base
|
5
|
+
RailsAdmin::Config::Actions.register(self)
|
6
|
+
|
7
|
+
register_instance_option :member do
|
8
|
+
true
|
9
|
+
end
|
10
|
+
|
11
|
+
register_instance_option :visible? do
|
12
|
+
authorized? && (bindings[:controller].main_app.url_for(bindings[:object]) rescue false)
|
13
|
+
end
|
14
|
+
|
15
|
+
register_instance_option :controller do
|
16
|
+
Proc.new do
|
17
|
+
if @object.class.name == 'Enjoy::Page'
|
18
|
+
if @object.fullpath.blank?
|
19
|
+
redirect_to main_app.page_url(@object)
|
20
|
+
else
|
21
|
+
redirect_to @object.fullpath
|
22
|
+
end
|
23
|
+
elsif @object.class.name == 'Enjoy::News'
|
24
|
+
redirect_to main_app.news_url(@object)
|
25
|
+
elsif @object.class.name == 'Obj'
|
26
|
+
redirect_to main_app.object_url(@object.category, @object)
|
27
|
+
else
|
28
|
+
redirect_to main_app.url_for(@object)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
register_instance_option :link_icon do
|
34
|
+
'icon-eye-open'
|
35
|
+
end
|
36
|
+
|
37
|
+
register_instance_option :pjax? do
|
38
|
+
false
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/release.sh
ADDED
data/template.rb
ADDED
@@ -0,0 +1,824 @@
|
|
1
|
+
rails_spec = (Gem.loaded_specs["railties"] || Gem.loaded_specs["rails"])
|
2
|
+
version = rails_spec.version.to_s
|
3
|
+
|
4
|
+
mongoid = options[:skip_active_record]
|
5
|
+
|
6
|
+
if Gem::Version.new(version) < Gem::Version.new('4.2.4')
|
7
|
+
puts "You are using an old version of Rails (#{version})"
|
8
|
+
puts "Please update"
|
9
|
+
puts "Stopping"
|
10
|
+
exit 1
|
11
|
+
end
|
12
|
+
|
13
|
+
remove_file 'Gemfile'
|
14
|
+
create_file 'Gemfile' do <<-TEXT
|
15
|
+
source 'https://rubygems.org'
|
16
|
+
|
17
|
+
gem 'rails', '4.2.4' #'~> 5.0.0.beta1'
|
18
|
+
#{if mongoid then "gem 'mongoid', '~> 5.0.0'" else "gem 'pg'" end}
|
19
|
+
|
20
|
+
gem 'sass', '~> 3.4.0'
|
21
|
+
gem 'sass-rails'
|
22
|
+
gem 'compass-rails', '~> 2.0.0'
|
23
|
+
gem 'compass', '~> 1.0.0'
|
24
|
+
|
25
|
+
#{if mongoid then "gem 'Enjoy_mongoid'" else "gem 'Enjoy_activerecord'" end}, '~> 0.1.0.beta1', git: 'https://github.com/enjoycreative/Enjoy'
|
26
|
+
|
27
|
+
gem 'devise'
|
28
|
+
|
29
|
+
gem 'slim-rails'
|
30
|
+
gem 'rs_russian'
|
31
|
+
gem 'cancancan'
|
32
|
+
|
33
|
+
gem 'cloner'
|
34
|
+
gem 'unicorn'
|
35
|
+
gem 'x-real-ip'
|
36
|
+
|
37
|
+
gem 'sentry-raven'
|
38
|
+
|
39
|
+
group :development do
|
40
|
+
gem 'better_errors'
|
41
|
+
gem 'binding_of_caller'
|
42
|
+
gem 'pry-rails'
|
43
|
+
gem 'spring'
|
44
|
+
|
45
|
+
gem 'capistrano', require: false
|
46
|
+
|
47
|
+
gem 'rvm1-capistrano3', require: false
|
48
|
+
gem 'glebtv-capistrano-unicorn', require: false
|
49
|
+
gem 'capistrano-bundler', require: false
|
50
|
+
gem 'capistrano-rails', require: false
|
51
|
+
|
52
|
+
gem 'hipchat'
|
53
|
+
# gem 'coffee-rails-source-maps'
|
54
|
+
# gem 'compass-rails-source-maps'
|
55
|
+
|
56
|
+
gem 'favicon_maker', '0.3'
|
57
|
+
gem 'favicon_maker_rails'
|
58
|
+
|
59
|
+
gem 'rails_email_preview', '~> 0.2.29'
|
60
|
+
end
|
61
|
+
|
62
|
+
group :test do
|
63
|
+
gem 'rspec-rails'
|
64
|
+
gem 'database_cleaner'
|
65
|
+
gem 'email_spec'
|
66
|
+
#{if mongoid then "gem 'mongoid-rspec'" else "" end}
|
67
|
+
gem 'ffaker'
|
68
|
+
gem 'factory_girl_rails'
|
69
|
+
end
|
70
|
+
|
71
|
+
#{if mongoid then "gem 'mongo_session_store-rails4'" else "" end}
|
72
|
+
|
73
|
+
gem 'slim'
|
74
|
+
gem 'sprockets'
|
75
|
+
|
76
|
+
|
77
|
+
gem 'sitemap_generator'
|
78
|
+
gem 'rails_admin_sitemap'
|
79
|
+
|
80
|
+
gem 'uglifier'
|
81
|
+
|
82
|
+
group :production do
|
83
|
+
gem "god"
|
84
|
+
end
|
85
|
+
|
86
|
+
TEXT
|
87
|
+
end
|
88
|
+
|
89
|
+
remove_file '.gitignore'
|
90
|
+
create_file '.gitignore' do <<-TEXT
|
91
|
+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
92
|
+
#
|
93
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
94
|
+
# or operating system, you probably want to add a global ignore instead:
|
95
|
+
# git config --global core.excludesfile '~/.gitignore_global'
|
96
|
+
.idea
|
97
|
+
.idea/*
|
98
|
+
|
99
|
+
/.bundle
|
100
|
+
/log/*.log
|
101
|
+
/tmp/*
|
102
|
+
/public/assets
|
103
|
+
/public/ckeditor_assets
|
104
|
+
TEXT
|
105
|
+
end
|
106
|
+
|
107
|
+
create_file 'extra/.gitkeep', ''
|
108
|
+
|
109
|
+
if mongoid
|
110
|
+
remove_file 'config/initializers/embedded_findable.rb'
|
111
|
+
create_file 'config/initializers/embedded_findable.rb' do <<-TEXT
|
112
|
+
module Mongoid
|
113
|
+
|
114
|
+
# Helps to override find method in an embedded document.
|
115
|
+
# Usage :
|
116
|
+
# - add to your model "include Mongoid::EmbeddedFindable"
|
117
|
+
# - override find method with:
|
118
|
+
# def self.find(id)
|
119
|
+
# find_through(Book, 'chapter', id)
|
120
|
+
# end
|
121
|
+
module EmbeddedFindable
|
122
|
+
|
123
|
+
extend ActiveSupport::Concern
|
124
|
+
|
125
|
+
included do
|
126
|
+
|
127
|
+
# Search an embedded document by id.
|
128
|
+
#
|
129
|
+
# Document is stored within embedding_class collection, and can be accessed through provided relation.
|
130
|
+
# Also supports chained relationships (if the searched document is nested in several embedded documents)
|
131
|
+
#
|
132
|
+
# Example, with a chapter embedded in a book, the book being embedded in a library.
|
133
|
+
# use find_through(Library, "books", book_id) in Book class
|
134
|
+
# and find_through(Library, "books.chapters", chapter_id) in Chapter class
|
135
|
+
def self.find_through(embedding_class, relation, id = nil)
|
136
|
+
return nil if id.nil? || id.blank?
|
137
|
+
|
138
|
+
id = BSON::ObjectId.from_string(id) if id.is_a?(String)
|
139
|
+
relation = relation.to_s unless relation.is_a?(String)
|
140
|
+
|
141
|
+
relation_parts = relation.split('.')
|
142
|
+
parent = embedding_class.send(:all)
|
143
|
+
|
144
|
+
while relation_parts.length > 0
|
145
|
+
item = if parent.is_a?(Mongoid::Criteria) || parent.is_a?(Array)
|
146
|
+
parent.where("\#{relation_parts.join('.')}._id" => id).first
|
147
|
+
else
|
148
|
+
parent
|
149
|
+
end
|
150
|
+
return nil if item.nil?
|
151
|
+
parent = item.send(relation_parts.shift)
|
152
|
+
end
|
153
|
+
|
154
|
+
if parent.is_a?(Mongoid::Criteria) || parent.is_a?(Array)
|
155
|
+
parent.where('_id' => id).first
|
156
|
+
else
|
157
|
+
parent
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
end
|
162
|
+
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
166
|
+
TEXT
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
if mongoid
|
171
|
+
remove_file 'config/initializers/cookies_serializer.rb'
|
172
|
+
create_file 'config/initializers/cookies_serializer.rb' do <<-TEXT
|
173
|
+
# Be sure to restart your server when you modify this file.
|
174
|
+
# json serializer breaks Devise + Mongoid. DO NOT ENABLE
|
175
|
+
# See https://github.com/plataformatec/devise/pull/2882
|
176
|
+
# Rails.application.config.action_dispatch.cookies_serializer = :json
|
177
|
+
Rails.application.config.action_dispatch.cookies_serializer = :marshal
|
178
|
+
TEXT
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
if mongoid
|
183
|
+
remove_file 'config/initializers/session_store.rb'
|
184
|
+
create_file 'config/initializers/session_store.rb' do <<-TEXT
|
185
|
+
# Be sure to restart your server when you modify this file.
|
186
|
+
|
187
|
+
#Rails.application.config.session_store :cookie_store, key: '_#{app_name.tableize.singularize}_session'
|
188
|
+
Rails.application.config.session_store :mongoid_store
|
189
|
+
|
190
|
+
TEXT
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
remove_file 'app/controllers/application_controller.rb'
|
195
|
+
create_file 'app/controllers/application_controller.rb' do <<-TEXT
|
196
|
+
class ApplicationController < ActionController::Base
|
197
|
+
include Enjoy::Controller
|
198
|
+
end
|
199
|
+
TEXT
|
200
|
+
end
|
201
|
+
|
202
|
+
create_file 'config/navigation.rb' do <<-TEXT
|
203
|
+
# empty file to please simple_navigation, we are not using it
|
204
|
+
# See https://github.com/enjoycreative/Enjoy/blob/master/app/controllers/concerns/enjoy/menu.rb
|
205
|
+
TEXT
|
206
|
+
end
|
207
|
+
|
208
|
+
create_file 'README.md', "## #{app_name}\nProject generated by Enjoy\nORM: #{if mongoid then 'Mongoid' else 'ActiveRecord' end}\n\n"
|
209
|
+
|
210
|
+
create_file '.ruby-version', "2.2.3\n"
|
211
|
+
create_file '.ruby-gemset', "#{app_name}\n"
|
212
|
+
|
213
|
+
run 'bundle install --without production'
|
214
|
+
|
215
|
+
# generate 'rails_email_preview:install'
|
216
|
+
remove_file 'app/mailer_previews/contact_mailer_preview.rb'
|
217
|
+
create_file 'app/mailer_previews/contact_mailer_preview.rb' do <<-TEXT
|
218
|
+
class ContactMailerPreview
|
219
|
+
def new_message_email
|
220
|
+
Enjoy::ContactMailer.new_message_email(ContactMessage.all.to_a.sample)
|
221
|
+
end
|
222
|
+
end
|
223
|
+
TEXT
|
224
|
+
end
|
225
|
+
|
226
|
+
|
227
|
+
if mongoid
|
228
|
+
create_file 'config/mongoid.yml' do <<-TEXT
|
229
|
+
development:
|
230
|
+
clients:
|
231
|
+
default:
|
232
|
+
database: #{app_name.downcase}
|
233
|
+
hosts:
|
234
|
+
- localhost:27017
|
235
|
+
production:
|
236
|
+
clients:
|
237
|
+
default:
|
238
|
+
database: #{app_name.downcase}
|
239
|
+
hosts:
|
240
|
+
- localhost:27017
|
241
|
+
test:
|
242
|
+
clients:
|
243
|
+
default:
|
244
|
+
database: #{app_name.downcase}_test
|
245
|
+
hosts:
|
246
|
+
- localhost:27017
|
247
|
+
TEXT
|
248
|
+
end
|
249
|
+
else
|
250
|
+
remove_file 'config/database.yml'
|
251
|
+
create_file 'config/database.yml' do <<-TEXT
|
252
|
+
development:
|
253
|
+
adapter: postgresql
|
254
|
+
encoding: unicode
|
255
|
+
database: #{app_name.downcase}_development
|
256
|
+
pool: 5
|
257
|
+
username: #{app_name.downcase}
|
258
|
+
password: #{app_name.downcase}
|
259
|
+
template: template0
|
260
|
+
TEXT
|
261
|
+
end
|
262
|
+
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
|
263
|
+
ask("Press <enter> when done.", true)
|
264
|
+
end
|
265
|
+
|
266
|
+
unless mongoid
|
267
|
+
generate 'simple_captcha'
|
268
|
+
end
|
269
|
+
|
270
|
+
generate "devise:install"
|
271
|
+
generate "devise", "User"
|
272
|
+
remove_file "config/locales/devise.en.yml"
|
273
|
+
remove_file "config/locales/en.yml"
|
274
|
+
|
275
|
+
gsub_file 'app/models/user.rb', '# :confirmable, :lockable, :timeoutable and :omniauthable', '# :confirmable, :registerable, :timeoutable and :omniauthable'
|
276
|
+
gsub_file 'app/models/user.rb', ':registerable,', ' :lockable,'
|
277
|
+
if mongoid
|
278
|
+
gsub_file 'app/models/user.rb', '# field :failed_attempts', 'field :failed_attempts'
|
279
|
+
gsub_file 'app/models/user.rb', '# field :unlock_token', 'field :unlock_token'
|
280
|
+
gsub_file 'app/models/user.rb', '# field :locked_at', 'field :locked_at'
|
281
|
+
|
282
|
+
inject_into_file 'app/models/user.rb', before: /^end/ do <<-TEXT
|
283
|
+
|
284
|
+
field :name, type: String
|
285
|
+
field :login, type: String
|
286
|
+
field :roles, type: Array, default: []
|
287
|
+
|
288
|
+
before_save do
|
289
|
+
self.roles ||= []
|
290
|
+
self.roles.reject! { |r| r.blank? }
|
291
|
+
end
|
292
|
+
|
293
|
+
AVAILABLE_ROLES = ["admin", "manager", "client"]
|
294
|
+
|
295
|
+
AVAILABLE_ROLES.each do |r|
|
296
|
+
class_eval <<-EVAL
|
297
|
+
def \#{r}?
|
298
|
+
self.roles and self.roles.include?("\#{r}")
|
299
|
+
end
|
300
|
+
|
301
|
+
scope :\#{r.pluralize}, -> { any_in(roles: "\#{r}") }
|
302
|
+
EVAL
|
303
|
+
end
|
304
|
+
|
305
|
+
rails_admin do
|
306
|
+
list do
|
307
|
+
field :email
|
308
|
+
field :name
|
309
|
+
field :login
|
310
|
+
field :roles do
|
311
|
+
pretty_value do
|
312
|
+
bindings[:view].content_tag(:p, bindings[:object].roles.join(", "))
|
313
|
+
end
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
edit do
|
318
|
+
field :email, :string do
|
319
|
+
visible do
|
320
|
+
bindings[:controller].current_user.admin? or (bindings[:controller].current_user.manager? bindings[:controller].current_user == bindings[:object])
|
321
|
+
end
|
322
|
+
end
|
323
|
+
field :name, :string
|
324
|
+
field :login, :string do
|
325
|
+
visible do
|
326
|
+
bindings[:controller].current_user.admin?
|
327
|
+
end
|
328
|
+
end
|
329
|
+
field :roles, :enum do
|
330
|
+
enum do
|
331
|
+
AVAILABLE_ROLES
|
332
|
+
end
|
333
|
+
|
334
|
+
multiple do
|
335
|
+
true
|
336
|
+
end
|
337
|
+
|
338
|
+
visible do
|
339
|
+
bindings[:controller].current_user.admin?
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
field :password do
|
344
|
+
visible do
|
345
|
+
bindings[:controller].current_user.admin? or bindings[:controller].current_user == bindings[:object]
|
346
|
+
end
|
347
|
+
end
|
348
|
+
field :password_confirmation do
|
349
|
+
visible do
|
350
|
+
bindings[:controller].current_user.admin? or bindings[:controller].current_user == bindings[:object]
|
351
|
+
end
|
352
|
+
end
|
353
|
+
end
|
354
|
+
end
|
355
|
+
TEXT
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
359
|
+
if mongoid
|
360
|
+
generate "ckeditor:install", "--orm=mongoid", "--backend=paperclip"
|
361
|
+
else
|
362
|
+
generate "ckeditor:install", "--orm=active_record", "--backend=paperclip"
|
363
|
+
end
|
364
|
+
|
365
|
+
unless mongoid
|
366
|
+
generate "enjoy:migration"
|
367
|
+
generate "rails_admin_settings:migration"
|
368
|
+
end
|
369
|
+
|
370
|
+
generate "enjoy:admin"
|
371
|
+
generate "enjoy:ability"
|
372
|
+
generate "enjoy:layout"
|
373
|
+
|
374
|
+
unless mongoid
|
375
|
+
rake "db:migrate"
|
376
|
+
end
|
377
|
+
|
378
|
+
generate "simple_form:install"
|
379
|
+
|
380
|
+
generate "rspec:install"
|
381
|
+
|
382
|
+
remove_file 'config/routes.rb'
|
383
|
+
create_file 'config/routes.rb' do <<-TEXT
|
384
|
+
Rails.application.routes.draw do
|
385
|
+
devise_for :users
|
386
|
+
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
|
387
|
+
mount Ckeditor::Engine => '/ckeditor'
|
388
|
+
|
389
|
+
mount Enjoy::Engine => '/'
|
390
|
+
end
|
391
|
+
TEXT
|
392
|
+
end
|
393
|
+
|
394
|
+
create_file 'config/locales/ru.yml' do <<-TEXT
|
395
|
+
ru:
|
396
|
+
attributes:
|
397
|
+
is_default: По умолчанию
|
398
|
+
mongoid:
|
399
|
+
models:
|
400
|
+
item: Товар
|
401
|
+
attributes:
|
402
|
+
item:
|
403
|
+
price: Цена
|
404
|
+
TEXT
|
405
|
+
end
|
406
|
+
|
407
|
+
remove_file 'db/seeds.rb'
|
408
|
+
|
409
|
+
require 'securerandom'
|
410
|
+
admin_pw = SecureRandom.urlsafe_base64(6)
|
411
|
+
create_file 'db/seeds.rb' do <<-TEXT
|
412
|
+
admin_pw = "#{admin_pw}"
|
413
|
+
User.destroy_all
|
414
|
+
User.create!(email: 'admin@#{app_name.dasherize.downcase}.ru', password: admin_pw, password_confirmation: admin_pw, roles: ["admin"])
|
415
|
+
TEXT
|
416
|
+
end
|
417
|
+
|
418
|
+
create_file 'config/initializers/rack.rb' do <<-TEXT
|
419
|
+
if Rails.env.development?
|
420
|
+
module Rack
|
421
|
+
class CommonLogger
|
422
|
+
alias_method :log_without_assets, :log
|
423
|
+
#{'ASSETS_PREFIX = "/#{Rails.application.config.assets.prefix[/\A\/?(.*?)\/?\z/, 1]}/"'}
|
424
|
+
def log(env, status, header, began_at)
|
425
|
+
unless env['REQUEST_PATH'].start_with?(ASSETS_PREFIX) || env['REQUEST_PATH'].start_with?('/uploads') || env['REQUEST_PATH'].start_with?('/system')
|
426
|
+
log_without_assets(env, status, header, began_at)
|
427
|
+
end
|
428
|
+
end
|
429
|
+
end
|
430
|
+
end
|
431
|
+
end
|
432
|
+
|
433
|
+
Rack::Utils.multipart_part_limit = 0
|
434
|
+
TEXT
|
435
|
+
end
|
436
|
+
|
437
|
+
create_file 'app/assets/stylesheets/rails_admin/custom/theming.sass' do <<-TEXT
|
438
|
+
.navbar-brand
|
439
|
+
margin-left: 0 !important
|
440
|
+
|
441
|
+
.input-small
|
442
|
+
width: 150px
|
443
|
+
|
444
|
+
.container-fluid
|
445
|
+
input[type=text]
|
446
|
+
width: 380px !important
|
447
|
+
input.ra-filtering-select-input[type=text]
|
448
|
+
width: 180px !important
|
449
|
+
input.hasDatepicker
|
450
|
+
width: 180px !important
|
451
|
+
|
452
|
+
.sidebar-nav
|
453
|
+
a
|
454
|
+
padding: 6px 10px !important
|
455
|
+
.dropdown-header
|
456
|
+
padding: 10px 0px 3px 9px
|
457
|
+
|
458
|
+
.label-important
|
459
|
+
background-color: #d9534f
|
460
|
+
.alert-notice
|
461
|
+
color: #5bc0de
|
462
|
+
|
463
|
+
.page-header
|
464
|
+
display: none
|
465
|
+
.breadcrumb
|
466
|
+
margin-top: 20px
|
467
|
+
|
468
|
+
.control-group
|
469
|
+
clear: both
|
470
|
+
|
471
|
+
.container-fluid
|
472
|
+
padding-left: 0
|
473
|
+
> .row
|
474
|
+
margin: 0
|
475
|
+
|
476
|
+
.last.links
|
477
|
+
a
|
478
|
+
display: inline-block
|
479
|
+
padding: 3px
|
480
|
+
font-size: 20px
|
481
|
+
|
482
|
+
.remove_nested_fields
|
483
|
+
opacity: 1 !important
|
484
|
+
|
485
|
+
body.rails_admin .modal
|
486
|
+
margin: 0 auto !important
|
487
|
+
.modal-dialog
|
488
|
+
width: 990px !important
|
489
|
+
|
490
|
+
input[type=checkbox]
|
491
|
+
width: 30px !important
|
492
|
+
|
493
|
+
body.rails_admin
|
494
|
+
|
495
|
+
.root_links
|
496
|
+
|
497
|
+
> li
|
498
|
+
display: inline-block
|
499
|
+
|
500
|
+
.dropdown-header
|
501
|
+
border-top: 2px solid #777777
|
502
|
+
text-align: right
|
503
|
+
|
504
|
+
&:first-child
|
505
|
+
border-top: none
|
506
|
+
|
507
|
+
.bank_row .logo_field, #edit_bank img
|
508
|
+
background: #ccc !important
|
509
|
+
|
510
|
+
.ui-menu-item
|
511
|
+
border: 1px solid transparent
|
512
|
+
|
513
|
+
.content > .alert
|
514
|
+
margin-top: 20px
|
515
|
+
|
516
|
+
.badge-important
|
517
|
+
background: red
|
518
|
+
.badge-success
|
519
|
+
background: green
|
520
|
+
|
521
|
+
.sidebar-nav i
|
522
|
+
margin-right: 5px
|
523
|
+
|
524
|
+
body.rails_admin .table td.paperclip_type, body.rails_admin .table td.carrierwave_type, body.rails_admin .table td.jcrop_type
|
525
|
+
img
|
526
|
+
max-width: 150px
|
527
|
+
max-height: 100px
|
528
|
+
TEXT
|
529
|
+
end
|
530
|
+
|
531
|
+
remove_file 'public/robots.txt'
|
532
|
+
create_file 'public/robots.txt' do <<-TEXT
|
533
|
+
User-Agent: *
|
534
|
+
Allow: /
|
535
|
+
Disallow: /admin
|
536
|
+
Sitemap: /sitemap.xml.gz
|
537
|
+
TEXT
|
538
|
+
end
|
539
|
+
|
540
|
+
|
541
|
+
remove_file 'app/views/layouts/application.html.erb'
|
542
|
+
|
543
|
+
gsub_file 'app/views/layouts/application.html.slim', "= favicon_link_tag '/favicon.ico'", "= render partial: 'blocks/favicon' #= favicon_link_tag '/favicon.ico'"
|
544
|
+
|
545
|
+
|
546
|
+
remove_file 'config/application.rb'
|
547
|
+
create_file 'config/application.rb' do <<-TEXT
|
548
|
+
require File.expand_path('../boot', __FILE__)
|
549
|
+
|
550
|
+
# Pick the frameworks you want:
|
551
|
+
require "active_model/railtie"
|
552
|
+
#{'#' if mongoid}require "active_record/railtie"
|
553
|
+
require "action_controller/railtie"
|
554
|
+
require "action_mailer/railtie"
|
555
|
+
require "action_view/railtie"
|
556
|
+
require "sprockets/railtie"
|
557
|
+
# require "rails/test_unit/railtie"
|
558
|
+
|
559
|
+
# Require the gems listed in Gemfile, including any gems
|
560
|
+
# you've limited to :test, :development, or :production.
|
561
|
+
Bundler.require(*Rails.groups)
|
562
|
+
|
563
|
+
module #{app_name.camelize}
|
564
|
+
class Application < Rails::Application
|
565
|
+
config.generators do |g|
|
566
|
+
g.test_framework :rspec
|
567
|
+
g.view_specs false
|
568
|
+
g.helper_specs false
|
569
|
+
g.feature_specs false
|
570
|
+
g.template_engine :slim
|
571
|
+
g.stylesheets false
|
572
|
+
g.javascripts false
|
573
|
+
g.helper false
|
574
|
+
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
|
575
|
+
end
|
576
|
+
|
577
|
+
config.i18n.locale = :ru
|
578
|
+
config.i18n.default_locale = :ru
|
579
|
+
config.i18n.available_locales = [:ru, :en]
|
580
|
+
config.i18n.enforce_available_locales = true
|
581
|
+
#{'config.active_record.schema_format = :sql' unless mongoid}
|
582
|
+
|
583
|
+
#{'config.autoload_paths += %W(#{config.root}/extra)'}
|
584
|
+
#{'config.eager_load_paths += %W(#{config.root}/extra)'}
|
585
|
+
|
586
|
+
config.time_zone = 'Europe/Moscow'
|
587
|
+
config.assets.paths << Rails.root.join("app", "assets", "fonts")
|
588
|
+
end
|
589
|
+
end
|
590
|
+
|
591
|
+
TEXT
|
592
|
+
end
|
593
|
+
|
594
|
+
remove_file 'app/assets/stylesheets/application.css'
|
595
|
+
remove_file 'app/assets/stylesheets/application.css.sass'
|
596
|
+
create_file 'app/assets/stylesheets/application.sass' do <<-TEXT
|
597
|
+
@import 'compass'
|
598
|
+
@import 'Enjoy'
|
599
|
+
|
600
|
+
#wrapper
|
601
|
+
width: 960px
|
602
|
+
margin: 0 auto
|
603
|
+
#sidebar
|
604
|
+
float: left
|
605
|
+
width: 200px
|
606
|
+
#content
|
607
|
+
float: right
|
608
|
+
width: 750px
|
609
|
+
|
610
|
+
@import "compass/layout/sticky-footer"
|
611
|
+
+sticky-footer(50px)
|
612
|
+
TEXT
|
613
|
+
end
|
614
|
+
|
615
|
+
remove_file 'app/assets/javascripts/application.js'
|
616
|
+
remove_file 'app/assets/javascripts/application.js.coffee'
|
617
|
+
create_file 'app/assets/javascripts/application.coffee' do <<-TEXT
|
618
|
+
#= require Enjoy
|
619
|
+
TEXT
|
620
|
+
end
|
621
|
+
|
622
|
+
|
623
|
+
#god+unicorn
|
624
|
+
remove_file 'config/unicorn.rb'
|
625
|
+
create_file 'config/unicorn.rb' do <<-TEXT
|
626
|
+
rails_root = "/home/#{app_name.downcase}/www/#{app_name.downcase}"
|
627
|
+
|
628
|
+
worker_processes 2
|
629
|
+
working_directory rails_root
|
630
|
+
|
631
|
+
# This loads the application in the master process before forking
|
632
|
+
# worker processes
|
633
|
+
# Read more about it here:
|
634
|
+
# http://unicorn.bogomips.org/Unicorn/Configurator.html
|
635
|
+
preload_app true
|
636
|
+
|
637
|
+
timeout 30
|
638
|
+
|
639
|
+
# This is where we specify the socket.
|
640
|
+
# We will point the upstream Nginx module to this socket later on
|
641
|
+
listen "\#{rails_root}/tmp/sockets/unicorn.sock", :backlog => 64
|
642
|
+
|
643
|
+
pid "\#{rails_root}/tmp/pids/unicorn.pid"
|
644
|
+
|
645
|
+
# Set the path of the log files inside the log folder of the testapp
|
646
|
+
stderr_path "\#{rails_root}/log/unicorn.stderr.log"
|
647
|
+
stdout_path "\#{rails_root}/log/unicorn.stdout.log"
|
648
|
+
|
649
|
+
|
650
|
+
before_fork do |server, worker|
|
651
|
+
server.logger.info("worker=\#{worker.nr} spawning in \#{Dir.pwd}")
|
652
|
+
|
653
|
+
# graceful shutdown.
|
654
|
+
old_pid_file = "\#{rails_root}/tmp/pids/unicorn.pid.oldbin"
|
655
|
+
if File.exists?(old_pid_file) && server.pid != old_pid_file
|
656
|
+
begin
|
657
|
+
old_pid = File.read(old_pid_file).to_i
|
658
|
+
server.logger.info("sending QUIT to \#{old_pid}")
|
659
|
+
# we're killing old unicorn master right there
|
660
|
+
Process.kill("QUIT", old_pid)
|
661
|
+
rescue Errno::ENOENT, Errno::ESRCH
|
662
|
+
# someone else did our job for us
|
663
|
+
end
|
664
|
+
end
|
665
|
+
end
|
666
|
+
|
667
|
+
## no need for noSQL
|
668
|
+
# before_fork do |server, worker|
|
669
|
+
# # This option works in together with preload_app true setting
|
670
|
+
# # What is does is prevent the master process from holding
|
671
|
+
# # the database connection
|
672
|
+
# defined?(ActiveRecord::Base) and
|
673
|
+
# ActiveRecord::Base.connection.disconnect!
|
674
|
+
# end
|
675
|
+
#
|
676
|
+
# after_fork do |server, worker|
|
677
|
+
# # Here we are establishing the connection after forking worker
|
678
|
+
# # processes
|
679
|
+
# defined?(ActiveRecord::Base) and
|
680
|
+
# ActiveRecord::Base.establish_connection
|
681
|
+
# end
|
682
|
+
TEXT
|
683
|
+
end
|
684
|
+
|
685
|
+
remove_file 'config/unicorn.god'
|
686
|
+
create_file 'config/unicorn.god' do <<-TEXT
|
687
|
+
# http://unicorn.bogomips.org/SIGNALS.html
|
688
|
+
|
689
|
+
rails_env = ENV['RAILS_ENV'] || 'production'
|
690
|
+
rails_root = ENV['RAILS_ROOT'] || File.dirname(File.dirname(__FILE__))
|
691
|
+
|
692
|
+
God.watch do |w|
|
693
|
+
w.name = "unicorn_qiwi_middleware"
|
694
|
+
w.interval = 30.seconds # default
|
695
|
+
|
696
|
+
# unicorn needs to be run from the rails root
|
697
|
+
w.start = "cd \#{rails_root} && unicorn -c \#{rails_root}/config/unicorn.rb -E \#{rails_env} -D"
|
698
|
+
|
699
|
+
# QUIT gracefully shuts down workers
|
700
|
+
w.stop = "kill -KILL `cat \#{rails_root}/tmp/pids/unicorn.pid`"
|
701
|
+
|
702
|
+
# USR2 causes the master to re-create itself and spawn a new worker pool
|
703
|
+
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"
|
704
|
+
|
705
|
+
w.start_grace = 10.seconds
|
706
|
+
w.restart_grace = 10.seconds
|
707
|
+
w.pid_file = "\#{rails_root}/tmp/pids/unicorn.pid"
|
708
|
+
|
709
|
+
w.uid = 'ack'
|
710
|
+
w.gid = 'ack'
|
711
|
+
|
712
|
+
w.behavior(:clean_pid_file)
|
713
|
+
|
714
|
+
w.start_if do |start|
|
715
|
+
start.condition(:process_running) do |c|
|
716
|
+
c.interval = 5.seconds
|
717
|
+
c.running = false
|
718
|
+
end
|
719
|
+
end
|
720
|
+
|
721
|
+
w.restart_if do |restart|
|
722
|
+
restart.condition(:memory_usage) do |c|
|
723
|
+
c.above = 150.megabytes
|
724
|
+
c.times = [3, 5] # 3 out of 5 intervals
|
725
|
+
end
|
726
|
+
|
727
|
+
restart.condition(:cpu_usage) do |c|
|
728
|
+
c.above = 50.percent
|
729
|
+
c.times = 5
|
730
|
+
end
|
731
|
+
end
|
732
|
+
|
733
|
+
# lifecycle
|
734
|
+
w.lifecycle do |on|
|
735
|
+
on.condition(:flapping) do |c|
|
736
|
+
c.to_state = [:start, :restart]
|
737
|
+
c.times = 5
|
738
|
+
c.within = 5.minute
|
739
|
+
c.transition = :unmonitored
|
740
|
+
c.retry_in = 10.minutes
|
741
|
+
c.retry_times = 5
|
742
|
+
c.retry_within = 2.hours
|
743
|
+
end
|
744
|
+
end
|
745
|
+
end
|
746
|
+
TEXT
|
747
|
+
end
|
748
|
+
|
749
|
+
|
750
|
+
|
751
|
+
#scripts
|
752
|
+
remove_file 'scripts/assets_precompile.sh'
|
753
|
+
create_file 'scripts/assets_precompile.sh' do <<-TEXT
|
754
|
+
#!/bin/sh
|
755
|
+
|
756
|
+
RAILS_ENV=production rake assets:precompile
|
757
|
+
TEXT
|
758
|
+
end
|
759
|
+
|
760
|
+
remove_file 'scripts/bundle_production.sh'
|
761
|
+
create_file 'scripts/bundle_production.sh' do <<-TEXT
|
762
|
+
#!/bin/sh
|
763
|
+
|
764
|
+
rm Gemfile.lock
|
765
|
+
bundle install --without development test
|
766
|
+
TEXT
|
767
|
+
end
|
768
|
+
|
769
|
+
remove_file 'scripts/full_assets_precompile.sh'
|
770
|
+
create_file 'scripts/full_assets_precompile.sh' do <<-TEXT
|
771
|
+
#!/bin/sh
|
772
|
+
|
773
|
+
RAILS_ENV=production rake assets:precompile
|
774
|
+
TEXT
|
775
|
+
end
|
776
|
+
|
777
|
+
remove_file 'scripts/restart_thru_kill.sh'
|
778
|
+
create_file 'scripts/restart_thru_kill.sh' do <<-TEXT
|
779
|
+
#!/bin/sh
|
780
|
+
|
781
|
+
kill $(cat ./tmp/pids/unicorn.pid)
|
782
|
+
TEXT
|
783
|
+
end
|
784
|
+
|
785
|
+
remove_file 'scripts/send_usr2.sh'
|
786
|
+
create_file 'scripts/send_usr2.sh' do <<-TEXT
|
787
|
+
#!/bin/sh
|
788
|
+
|
789
|
+
kill -USR2 $(cat ./tmp/pids/unicorn.pid)
|
790
|
+
TEXT
|
791
|
+
end
|
792
|
+
|
793
|
+
remove_file 'scripts/send_hup.sh'
|
794
|
+
create_file 'scripts/send_hup.sh' do <<-TEXT
|
795
|
+
#!/bin/sh
|
796
|
+
|
797
|
+
kill -HUP $(cat ./tmp/pids/unicorn.pid)
|
798
|
+
TEXT
|
799
|
+
end
|
800
|
+
|
801
|
+
inject_into_file 'config/initializers/assets.rb', before: /\z/ do <<-TEXT
|
802
|
+
Rails.application.config.assets.precompile += %w( ckeditor/* )
|
803
|
+
TEXT
|
804
|
+
end
|
805
|
+
|
806
|
+
|
807
|
+
|
808
|
+
if mongoid
|
809
|
+
FileUtils.cp(Pathname.new(destination_root).join('config', 'mongoid.yml').to_s, Pathname.new(destination_root).join('config', 'mongoid.yml.example').to_s)
|
810
|
+
else
|
811
|
+
FileUtils.cp(Pathname.new(destination_root).join('config', 'database.yml').to_s, Pathname.new(destination_root).join('config', 'database.yml.example').to_s)
|
812
|
+
end
|
813
|
+
|
814
|
+
FileUtils.cp(Pathname.new(destination_root).join('config', 'secrets.yml').to_s, Pathname.new(destination_root).join('config', 'secrets.yml.example').to_s)
|
815
|
+
|
816
|
+
unless mongoid
|
817
|
+
generate "paper_trail:install"
|
818
|
+
generate "friendly_id"
|
819
|
+
rake "db:migrate"
|
820
|
+
end
|
821
|
+
|
822
|
+
git :init
|
823
|
+
git add: "."
|
824
|
+
git commit: %Q{ -m 'Initial commit' }
|