enjoy_cms 0.1.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +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,26 @@
|
|
|
1
|
+
class Ability
|
|
2
|
+
include CanCan::Ability
|
|
3
|
+
|
|
4
|
+
def initialize(user)
|
|
5
|
+
if !user.nil? and (user.admin? or user.manager?)
|
|
6
|
+
can :read, :all
|
|
7
|
+
can :access, :rails_admin # grant access to rails_admin
|
|
8
|
+
can :dashboard # grant access to the dashboard
|
|
9
|
+
if user.admin?
|
|
10
|
+
admin_ui(user)
|
|
11
|
+
elsif user.manager?
|
|
12
|
+
manager_ui(user)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def admin_ui(user)
|
|
18
|
+
can :manage, :all
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def manager_ui(user)
|
|
22
|
+
cannot :manage, Menu
|
|
23
|
+
cannot [:edit, :destroy, :new, :create], User
|
|
24
|
+
can :edit, user
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
require 'rails_admin/custom_show_in_app'
|
|
2
|
+
|
|
3
|
+
<% if Enjoy.mongoid? %>
|
|
4
|
+
RailsAdminSettings.track_history!
|
|
5
|
+
<% end %>
|
|
6
|
+
|
|
7
|
+
RailsAdmin.config do |config|
|
|
8
|
+
## == Devise ==
|
|
9
|
+
# this is required if not using cancan
|
|
10
|
+
#config.authenticate_with do
|
|
11
|
+
#warden.authenticate! scope: :user
|
|
12
|
+
#end
|
|
13
|
+
|
|
14
|
+
config.current_user_method(&:current_user)
|
|
15
|
+
|
|
16
|
+
## == Cancan ==
|
|
17
|
+
config.authorize_with :cancan
|
|
18
|
+
<% if Enjoy.mongoid? %>
|
|
19
|
+
## == MongoidAudit
|
|
20
|
+
config.audit_with :mongoid_audit, 'HistoryTracker'
|
|
21
|
+
<% elsif Enjoy.active_record? %>
|
|
22
|
+
config.audit_with :paper_trail, 'User', 'PaperTrail::Version'
|
|
23
|
+
<% end %>
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
config.actions do
|
|
27
|
+
dashboard # mandatory
|
|
28
|
+
|
|
29
|
+
# collection actions
|
|
30
|
+
index
|
|
31
|
+
new
|
|
32
|
+
export
|
|
33
|
+
bulk_delete
|
|
34
|
+
|
|
35
|
+
# member actions
|
|
36
|
+
show
|
|
37
|
+
edit
|
|
38
|
+
delete
|
|
39
|
+
|
|
40
|
+
history_index
|
|
41
|
+
history_show
|
|
42
|
+
|
|
43
|
+
nested_set do
|
|
44
|
+
visible do
|
|
45
|
+
['Page', 'Gallery', 'GalleryImage'].include? bindings[:abstract_model].model_name
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
custom_show_in_app do
|
|
50
|
+
visible do
|
|
51
|
+
#temporary
|
|
52
|
+
false #['Page', 'News'].include? bindings[:abstract_model].model_name
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
toggle
|
|
57
|
+
toggle_menu do
|
|
58
|
+
visible do
|
|
59
|
+
['Page'].include? bindings[:abstract_model].model_name
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
sitemap
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
config.main_app_name = ['<%= Rails.application.class.name.split('::')[0] %>', 'Админка']
|
|
66
|
+
|
|
67
|
+
config.excluded_models ||= []
|
|
68
|
+
config.excluded_models << [
|
|
69
|
+
'RailsAdmin::CustomShowInApp', 'HistoryTracker',
|
|
70
|
+
'Ckeditor::Asset', 'Ckeditor::AttachmentFile', 'Ckeditor::Picture',
|
|
71
|
+
'Enjoy::EmbeddedGalleryImage', 'Enjoy::EmbeddedElement'
|
|
72
|
+
]
|
|
73
|
+
config.excluded_models.flatten!
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# [required] fix for timezones to be displayed in local time instead of UTC
|
|
77
|
+
module RailsAdmin
|
|
78
|
+
module Config
|
|
79
|
+
module Fields
|
|
80
|
+
module Types
|
|
81
|
+
class Datetime
|
|
82
|
+
def value
|
|
83
|
+
bindings[:object].send(name)
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
set :user, "<%= app_name.downcase %>"
|
|
2
|
+
set :application, '<%= app_name.downcase %>'
|
|
3
|
+
set :scm, :git
|
|
4
|
+
set :repo_url, 'git@rscz.ru:rocket-science/<%= app_name.downcase %>.git'
|
|
5
|
+
|
|
6
|
+
set :branch, ENV["REVISION"] || "master"
|
|
7
|
+
|
|
8
|
+
set :deploy_to, "<%= deploy_to %>"
|
|
9
|
+
|
|
10
|
+
# require 'hipchat/capistrano'
|
|
11
|
+
# set :hipchat_token, ""
|
|
12
|
+
# set :hipchat_room_name, "<%= app_name %>"
|
|
13
|
+
# set :hipchat_announce, false
|
|
14
|
+
|
|
15
|
+
set :rvm_type, :user
|
|
16
|
+
set :rvm_ruby_version, "2.2.1@#{fetch :application}"
|
|
17
|
+
set :use_sudo, false
|
|
18
|
+
|
|
19
|
+
set :keep_releases, 20
|
|
20
|
+
|
|
21
|
+
set :linked_files, %w{config/mongoid.yml config/secrets.yml}
|
|
22
|
+
set :linked_dirs, %w{log tmp vendor/bundle public/assets public/system public/uploads public/ckeditor_assets public/sitemap}
|
|
23
|
+
|
|
24
|
+
namespace :db do
|
|
25
|
+
desc "Create the indexes defined on your mongoid models"
|
|
26
|
+
task :create_mongoid_indexes do
|
|
27
|
+
on roles(:app) do
|
|
28
|
+
execute :rake, "db:mongoid:create_indexes"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
namespace :deploy do
|
|
34
|
+
task :restart do
|
|
35
|
+
end
|
|
36
|
+
desc "Update the crontab"
|
|
37
|
+
task :update_crontab do
|
|
38
|
+
on roles(:app) do
|
|
39
|
+
execute "cd #{release_path}; #{fetch(:tmp_dir)}/#{fetch :application}/rvm-auto.sh . bundle exec whenever --update-crontab #{fetch :user} --set \'environment=#{fetch :stage}¤t_path=#{release_path}\'; true"
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
after 'deploy:publishing', 'deploy:restart'
|
|
45
|
+
after 'deploy:restart', 'unicorn:duplicate'
|
|
46
|
+
#before "deploy:update_crontab", 'rvm1:hook'
|
|
47
|
+
#after "deploy:restart", "deploy:update_crontab"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'cloner'
|
|
2
|
+
|
|
3
|
+
class Dl < Cloner::Base
|
|
4
|
+
no_commands do
|
|
5
|
+
def rails_path
|
|
6
|
+
File.expand_path("../../../config/environment", __FILE__)
|
|
7
|
+
end
|
|
8
|
+
def ssh_host
|
|
9
|
+
'<%= domain %>'
|
|
10
|
+
end
|
|
11
|
+
def ssh_user
|
|
12
|
+
'<%= app_name.downcase %>'
|
|
13
|
+
end
|
|
14
|
+
def remote_dump_path
|
|
15
|
+
'<%= tmp_path %>'
|
|
16
|
+
end
|
|
17
|
+
def remote_app_path
|
|
18
|
+
'<%= deploy_to %>/current'
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
desc "download", "clone files and DB from production"
|
|
23
|
+
def download
|
|
24
|
+
load_env
|
|
25
|
+
clone_db
|
|
26
|
+
rsync_public("ckeditor_assets")
|
|
27
|
+
rsync_public("system")
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
class EnjoyCreateContactMessages < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
create_table :contact_messages do |t|
|
|
4
|
+
t.string :name
|
|
5
|
+
t.string :email
|
|
6
|
+
t.string :phone
|
|
7
|
+
t.text :content
|
|
8
|
+
t.timestamps
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
add_index :contact_messages, :created_at
|
|
12
|
+
add_index :contact_messages, :updated_at
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
class EnjoyCreateNews < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
create_table :news do |t|
|
|
4
|
+
t.boolean :enabled, default: true, null: false
|
|
5
|
+
t.timestamp :time, null: false
|
|
6
|
+
|
|
7
|
+
if Enjoy.config.localize
|
|
8
|
+
t.column :name_translations, 'hstore', default: {}
|
|
9
|
+
t.column :excerpt_translations, 'hstore', default: {}
|
|
10
|
+
t.column :content_translations, 'hstore', default: {}
|
|
11
|
+
else
|
|
12
|
+
t.string :name, null: false
|
|
13
|
+
t.text :excerpt
|
|
14
|
+
t.text :content
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
t.string :slug, null: false
|
|
18
|
+
t.attachment :image
|
|
19
|
+
t.timestamps
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
add_index :news, :slug, unique: true
|
|
23
|
+
add_index :news, [:enabled, :time]
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
class EnjoyCreatePages < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
create_table :menus do |t|
|
|
4
|
+
|
|
5
|
+
if Enjoy.config.localize
|
|
6
|
+
t.column :name_translations, 'hstore'
|
|
7
|
+
else
|
|
8
|
+
t.string :name, null: false
|
|
9
|
+
end
|
|
10
|
+
t.string :slug, null: false
|
|
11
|
+
t.timestamps
|
|
12
|
+
end
|
|
13
|
+
add_index :menus, :slug, unique: true
|
|
14
|
+
|
|
15
|
+
create_table :pages do |t|
|
|
16
|
+
t.boolean :enabled, default: true, null: false
|
|
17
|
+
t.integer :parent_id
|
|
18
|
+
t.integer :lft
|
|
19
|
+
t.integer :rgt
|
|
20
|
+
t.integer :depth
|
|
21
|
+
|
|
22
|
+
if Enjoy.config.localize
|
|
23
|
+
t.column :name_translations, 'hstore', default: {}
|
|
24
|
+
t.column :content_translations, 'hstore', default: {}
|
|
25
|
+
else
|
|
26
|
+
t.string :name, null: false
|
|
27
|
+
t.text :content
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
t.string :slug, null: false
|
|
31
|
+
t.string :regexp
|
|
32
|
+
t.string :redirect
|
|
33
|
+
t.string :fullpath, null: false
|
|
34
|
+
t.timestamps
|
|
35
|
+
end
|
|
36
|
+
add_index :pages, :slug, unique: true
|
|
37
|
+
add_index :pages, [:enabled, :lft]
|
|
38
|
+
|
|
39
|
+
create_join_table :menus, :pages
|
|
40
|
+
|
|
41
|
+
add_foreign_key(:menus_pages, :menus, dependent: :delete)
|
|
42
|
+
add_foreign_key(:menus_pages, :pages, dependent: :delete)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class EnjoyCreateSeos < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
create_table :seos do |t|
|
|
4
|
+
t.boolean :enabled, default: true, null: false
|
|
5
|
+
t.integer :seoable_id
|
|
6
|
+
t.string :seoable_type
|
|
7
|
+
Enjoy::Migration.seo_fields(t)
|
|
8
|
+
t.timestamps
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
add_index :seos, [:seoable_id, :seoable_type], unique: true
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
rails_env = ENV['RAILS_ENV'] || 'production'
|
|
2
|
+
|
|
3
|
+
deploy_to = '<%= deploy_to %>'
|
|
4
|
+
rails_root = "#{deploy_to}/current"
|
|
5
|
+
|
|
6
|
+
tmp_dir = "#{deploy_to}/shared/tmp"
|
|
7
|
+
pid_dir = "#{tmp_dir}/pids"
|
|
8
|
+
if File.directory?(tmp_dir) && !File.directory?(pid_dir)
|
|
9
|
+
puts "creating pid dir #{pid_dir}"
|
|
10
|
+
Dir.mkdir(pid_dir)
|
|
11
|
+
end
|
|
12
|
+
pid_file = "#{pid_dir}/unicorn.pid"
|
|
13
|
+
|
|
14
|
+
log_file = "#{deploy_to}/shared/log/unicorn.log"
|
|
15
|
+
err_log_file = "#{deploy_to}/shared/log/unicorn.error.log"
|
|
16
|
+
|
|
17
|
+
old_pid_file = pid_file + '.oldbin'
|
|
18
|
+
|
|
19
|
+
worker_processes 1
|
|
20
|
+
working_directory rails_root
|
|
21
|
+
|
|
22
|
+
timeout 120
|
|
23
|
+
|
|
24
|
+
# Specify path to socket unicorn listens to,
|
|
25
|
+
# we will use this in our nginx.conf later
|
|
26
|
+
|
|
27
|
+
listen "127.0.0.1:<%= port %>"
|
|
28
|
+
|
|
29
|
+
pid pid_file
|
|
30
|
+
|
|
31
|
+
# Set log file paths
|
|
32
|
+
stderr_path err_log_file
|
|
33
|
+
stdout_path log_file
|
|
34
|
+
|
|
35
|
+
# http://tech.tulentsev.com/2012/03/deploying-with-sinatra-capistrano-unicorn/
|
|
36
|
+
# NOTE: http://unicorn.bogomips.org/SIGNALS.html
|
|
37
|
+
preload_app true
|
|
38
|
+
|
|
39
|
+
# make sure that Bundler finds the Gemfile
|
|
40
|
+
before_exec do |server|
|
|
41
|
+
ENV['BUNDLE_GEMFILE'] = File.join( rails_root, 'Gemfile' )
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
before_fork do |server, worker|
|
|
45
|
+
# при использовании preload_app = true здесь должно быть закрытие всех открытых сокетов
|
|
46
|
+
|
|
47
|
+
# Mongoid сам заботится о переконнекте
|
|
48
|
+
# http://two.mongoid.org/docs/upgrading.html
|
|
49
|
+
|
|
50
|
+
# http://stackoverflow.com/a/9498372/2041969
|
|
51
|
+
# убиваем параллельный старый-процесс просле старта нового
|
|
52
|
+
if File.exists?( old_pid_file )
|
|
53
|
+
begin
|
|
54
|
+
Process.kill( "QUIT", File.read( old_pid_file ).to_i )
|
|
55
|
+
rescue Errno::ENOENT, Errno::ESRCH
|
|
56
|
+
puts "Old master alerady dead"
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
after_fork do |server, worker|
|
|
62
|
+
# pid-ы дочерних процессов
|
|
63
|
+
child_pid_file = server.config[:pid].sub(".pid", ".#{worker.nr}.pid")
|
|
64
|
+
system("echo #{Process.pid} > #{child_pid_file}")
|
|
65
|
+
end
|
|
66
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# shamelessly stolen from https://github.com/sferik/rails_admin/blob/master/lib/generators/rails_admin/utils.rb
|
|
2
|
+
|
|
3
|
+
module Enjoy
|
|
4
|
+
module Generators
|
|
5
|
+
module Utils
|
|
6
|
+
module InstanceMethods
|
|
7
|
+
def display(output, color = :green)
|
|
8
|
+
say(" - #{output}", color)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def ask_for(wording, default_value = nil, override_if_present_value = nil)
|
|
12
|
+
if override_if_present_value.present?
|
|
13
|
+
display("Using [#{override_if_present_value}] for question '#{wording}'") && override_if_present_value
|
|
14
|
+
else
|
|
15
|
+
ask(" ? #{wording} Press <enter> for [#{default_value}] >", :yellow).presence || default_value
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
data/lib/manual_slug.rb
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module ManualSlug::ActiveRecord
|
|
2
|
+
extend ActiveSupport::Concern
|
|
3
|
+
|
|
4
|
+
included do
|
|
5
|
+
extend FriendlyId
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def text_slug
|
|
9
|
+
slug
|
|
10
|
+
end
|
|
11
|
+
def text_slug=(s)
|
|
12
|
+
self.slug = s
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
module ClassMethods
|
|
16
|
+
def manual_slug(field, options = {}, callback = true)
|
|
17
|
+
friendly_id field, use: [:slugged, :finders]
|
|
18
|
+
define_method(:should_generate_new_friendly_id?) do
|
|
19
|
+
slug.blank?
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
skip_callback :validation, :before, :set_slug
|
|
23
|
+
before_validation do
|
|
24
|
+
if self.slug.blank?
|
|
25
|
+
self.send(:set_slug)
|
|
26
|
+
end
|
|
27
|
+
true
|
|
28
|
+
end if callback
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|