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
@@ -1,49 +0,0 @@
|
|
1
|
-
module Enjoy
|
2
|
-
module Models
|
3
|
-
module Mongoid
|
4
|
-
module Page
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
|
7
|
-
include Enjoy::HtmlField
|
8
|
-
|
9
|
-
included do
|
10
|
-
if defined?(RailsAdminComments)
|
11
|
-
include RailsAdminComments::Commentable
|
12
|
-
end
|
13
|
-
|
14
|
-
belongs_to :connectable, polymorphic: true
|
15
|
-
scope :connected, -> {
|
16
|
-
where(:connectable_id.ne => nil)
|
17
|
-
}
|
18
|
-
scope :unconnected, -> (except_this = nil) {
|
19
|
-
if except_this
|
20
|
-
where({"$or" =>[
|
21
|
-
{:connectable_id => nil},
|
22
|
-
{"$and" => [
|
23
|
-
{connectable_type: except_this.class.to_param},
|
24
|
-
{connectable_id: except_this._id}
|
25
|
-
]}
|
26
|
-
]})
|
27
|
-
else
|
28
|
-
where(:connectable_id => nil)
|
29
|
-
end
|
30
|
-
}
|
31
|
-
|
32
|
-
field :name, type: String, localize: Enjoy.config.localize, default: ""
|
33
|
-
|
34
|
-
field :regexp, type: String, default: ""
|
35
|
-
field :redirect, type: String, default: ""
|
36
|
-
enjoy_cms_html_field :excerpt, type: String, localize: Enjoy.config.localize, default: ""
|
37
|
-
enjoy_cms_html_field :content, type: String, localize: Enjoy.config.localize, default: ""
|
38
|
-
field :fullpath, type: String, default: ""
|
39
|
-
|
40
|
-
has_and_belongs_to_many :menus, inverse_of: :pages, class_name: "Enjoy::Menu"
|
41
|
-
acts_as_nested_set
|
42
|
-
|
43
|
-
scope :sorted, -> { order_by([:lft, :asc]) }
|
44
|
-
scope :menu, ->(menu_id) { enabled.sorted.where(menu_ids: menu_id) }
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
module Enjoy
|
2
|
-
module Models
|
3
|
-
module Mongoid
|
4
|
-
module PageBlock
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
|
7
|
-
include Enjoy::HtmlField
|
8
|
-
|
9
|
-
included do
|
10
|
-
field :file_path, type: String, localize: Enjoy.config.localize, default: ""
|
11
|
-
field :partial, type: Boolean, default: true
|
12
|
-
embedded_in :blockset, inverse_of: :blocks, class_name: "Enjoy::PageBlockset"
|
13
|
-
|
14
|
-
enjoy_cms_html_field :content, type: String, localize: Enjoy.config.localize, default: ""
|
15
|
-
end
|
16
|
-
|
17
|
-
def file_pathname_as_partial
|
18
|
-
self.file_pathname.dirname.join("_#{self.file_pathname.basename}")
|
19
|
-
end
|
20
|
-
|
21
|
-
def file_pathname_for_fs
|
22
|
-
self.partial ? self.file_path_as_partial : self.file_pathname
|
23
|
-
end
|
24
|
-
|
25
|
-
def render_or_content_html(view, opts = {})
|
26
|
-
unless self.file_path.blank?
|
27
|
-
opts.merge!(partial: self.file_path)
|
28
|
-
view.render(opts) rescue self.content_html.html_safe
|
29
|
-
else
|
30
|
-
self.content_html.html_safe
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def render_or_content(view, opts = {})
|
35
|
-
unless self.file_path.blank?
|
36
|
-
opts.merge!(partial: self.file_path)
|
37
|
-
view.render(opts) rescue self.content
|
38
|
-
else
|
39
|
-
self.content
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def file_fullpath(with_ext = false, ext = ".html.slim")
|
44
|
-
ret = nil
|
45
|
-
unless self.file_path.blank?
|
46
|
-
res_filename = self.file_pathname_for_fs.to_s
|
47
|
-
res_filename += ext if with_ext
|
48
|
-
ret = Rails.root.join("views", res_filename)
|
49
|
-
end
|
50
|
-
return ret
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Enjoy
|
2
|
-
module Models
|
3
|
-
module Mongoid
|
4
|
-
module PageBlockset
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
|
7
|
-
included do
|
8
|
-
if defined?(RailsAdminComments)
|
9
|
-
include RailsAdminComments::Commentable
|
10
|
-
end
|
11
|
-
|
12
|
-
field :name, type: String, default: ""
|
13
|
-
|
14
|
-
embeds_many :blocks, inverse_of: :blockset, class_name: "Enjoy::PageBlock"
|
15
|
-
accepts_nested_attributes_for :blocks
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module Enjoy
|
2
|
-
module Models
|
3
|
-
module Mongoid
|
4
|
-
module Seo
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
include Enjoy::MongoidPaperclip
|
7
|
-
included do
|
8
|
-
|
9
|
-
if defined?(RailsAdminComments)
|
10
|
-
include RailsAdminComments::Commentable
|
11
|
-
end
|
12
|
-
|
13
|
-
field :name, type: String, localize: Enjoy.config.localize
|
14
|
-
field :h1, type: String, localize: Enjoy.config.localize
|
15
|
-
|
16
|
-
field :title, type: String, localize: Enjoy.config.localize
|
17
|
-
field :keywords, type: String, localize: Enjoy.config.localize
|
18
|
-
field :description, type: String, localize: Enjoy.config.localize
|
19
|
-
field :robots, type: String, localize: Enjoy.config.localize
|
20
|
-
|
21
|
-
field :og_title, type: String, localize: Enjoy.config.localize
|
22
|
-
enjoy_cms_mongoid_attached_file(:og_image,
|
23
|
-
styles: lambda { |attachment| attachment.instance.og_image_styles },
|
24
|
-
content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] }
|
25
|
-
)
|
26
|
-
end
|
27
|
-
|
28
|
-
def og_image_styles
|
29
|
-
{thumb: "800x600>"}
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Enjoy
|
2
|
-
module Models
|
3
|
-
module Mongoid
|
4
|
-
module SitemapData
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
|
7
|
-
included do
|
8
|
-
|
9
|
-
if defined?(RailsAdminComments)
|
10
|
-
include RailsAdminComments::Commentable
|
11
|
-
end
|
12
|
-
|
13
|
-
field :sitemap_show, type: Boolean, default: true
|
14
|
-
field :sitemap_lastmod, type: DateTime
|
15
|
-
field :sitemap_changefreq, type: String, default: 'daily'
|
16
|
-
field :sitemap_priority, type: Float
|
17
|
-
|
18
|
-
scope :sitemap_show, -> { where(sitemap_show: true) }
|
19
|
-
scope :for_sitemap, -> { sitemap_show }
|
20
|
-
scope :show_in_sitemap, -> { sitemap_show }
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/lib/enjoy/models/news.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
module Enjoy
|
2
|
-
module Models
|
3
|
-
module News
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
include Enjoy::Model
|
6
|
-
include ManualSlug
|
7
|
-
include Enjoy::Seoable
|
8
|
-
include Enjoy::Enableable
|
9
|
-
include Enjoy::SitemapDataField
|
10
|
-
include Enjoy::Connectable
|
11
|
-
|
12
|
-
include Enjoy.orm_specific('News')
|
13
|
-
|
14
|
-
# if Enjoy.config.search_enabled
|
15
|
-
# include Enjoy::ElasticSearch
|
16
|
-
# end
|
17
|
-
|
18
|
-
included do
|
19
|
-
enjoy_connectable_field :connected_pages
|
20
|
-
|
21
|
-
unless Enjoy.config.news_image_styles.nil?
|
22
|
-
validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/, if: :image?
|
23
|
-
end
|
24
|
-
|
25
|
-
validates_presence_of :name
|
26
|
-
if Enjoy.config.news_content_required
|
27
|
-
validates_presence_of :content_html
|
28
|
-
end
|
29
|
-
|
30
|
-
before_validation do
|
31
|
-
self.time = Time.now if self.time.blank?
|
32
|
-
end
|
33
|
-
scope :recent, ->(count = 5) { enabled.after_now.by_date.limit(count) }
|
34
|
-
unless Enjoy.config.news_per_page.nil?
|
35
|
-
paginates_per Enjoy.config.news_per_page
|
36
|
-
end
|
37
|
-
smart_excerpt :excerpt, :content, Enjoy.config.news_excerpt
|
38
|
-
manual_slug :report_slug
|
39
|
-
end
|
40
|
-
|
41
|
-
def report_slug
|
42
|
-
if time.blank?
|
43
|
-
name
|
44
|
-
elsif name.blank?
|
45
|
-
time.strftime('%Y-%m-%d')
|
46
|
-
else
|
47
|
-
time.strftime('%Y-%m-%d') + '-' + name[0..20]
|
48
|
-
end
|
49
|
-
end
|
50
|
-
def html5_date
|
51
|
-
time.strftime('%Y-%m-%d')
|
52
|
-
end
|
53
|
-
def format_date
|
54
|
-
time.strftime(I18n.t('Enjoy.format_time'))
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
data/lib/enjoy/models/page.rb
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
module Enjoy
|
2
|
-
module Models
|
3
|
-
module Page
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
include Enjoy::Model
|
6
|
-
include ManualSlug
|
7
|
-
include Enjoy::Enableable
|
8
|
-
include Enjoy::Seoable
|
9
|
-
include Enjoy::SitemapDataField
|
10
|
-
|
11
|
-
include Enjoy.orm_specific('Page')
|
12
|
-
|
13
|
-
# if Enjoy.config.search_enabled
|
14
|
-
# include Enjoy::ElasticSearch
|
15
|
-
# end
|
16
|
-
|
17
|
-
included do
|
18
|
-
validates_uniqueness_of :fullpath
|
19
|
-
validates_presence_of :name
|
20
|
-
manual_slug :name
|
21
|
-
before_validation do
|
22
|
-
self.fullpath = "/pages/#{slug}" if self.fullpath.blank?
|
23
|
-
end
|
24
|
-
|
25
|
-
before_save do
|
26
|
-
self.connectable_id = nil if self.connectable_type.nil?
|
27
|
-
self.connectable_type = nil if self.connectable_id.nil?
|
28
|
-
self
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def page_h1
|
33
|
-
_ret = seo ? seo.h1 : nil
|
34
|
-
_ret = name if _ret.blank?
|
35
|
-
_ret = title if _ret.blank?
|
36
|
-
_ret
|
37
|
-
end
|
38
|
-
|
39
|
-
def get_fullpath
|
40
|
-
redirect.blank? ? fullpath : redirect
|
41
|
-
end
|
42
|
-
|
43
|
-
def has_content?
|
44
|
-
@content_used.nil? && !content.blank?
|
45
|
-
end
|
46
|
-
|
47
|
-
def page_content
|
48
|
-
if @content_used.nil?
|
49
|
-
@content_used = true
|
50
|
-
if content.nil?
|
51
|
-
''
|
52
|
-
else
|
53
|
-
content.gsub(/\{\{(.*?)\}\}/) do
|
54
|
-
Settings ? Settings.get($1).val : "" #temp
|
55
|
-
end
|
56
|
-
end
|
57
|
-
else
|
58
|
-
''
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def is_current?(url)
|
63
|
-
if fullpath == '/'
|
64
|
-
url == '/'
|
65
|
-
else
|
66
|
-
url.match(clean_regexp)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def regexp_prefix
|
71
|
-
Enjoy.config.localize ? "(?:#{I18n.available_locales.map { |l| "\\/#{l}"}.join("|")})?" : ""
|
72
|
-
end
|
73
|
-
|
74
|
-
def clean_regexp
|
75
|
-
if regexp.blank?
|
76
|
-
/^#{regexp_prefix}#{Regexp.escape(fullpath)}$/
|
77
|
-
else
|
78
|
-
begin
|
79
|
-
/#{regexp}/
|
80
|
-
rescue
|
81
|
-
# not a valid regexp - treat as literal search string
|
82
|
-
/#{Regexp.escape(regexp)}/
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def nav_options
|
88
|
-
{highlights_on: clean_regexp}
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Enjoy
|
2
|
-
module Models
|
3
|
-
module PageBlock
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
include Enjoy.orm_specific('PageBlock')
|
7
|
-
|
8
|
-
included do
|
9
|
-
validates :file_path, format: {
|
10
|
-
# with: /\A(?!layouts\/).*\Z/,
|
11
|
-
without: /\Alayouts\/.*\Z/,
|
12
|
-
message: "Недопустимый путь к файлу"
|
13
|
-
}
|
14
|
-
|
15
|
-
attr_accessor :file_pathname
|
16
|
-
after_initialize do
|
17
|
-
self.file_pathname = Pathname.new(file_path) unless file_path.nil?
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module Enjoy
|
2
|
-
module Models
|
3
|
-
module PageBlockset
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
include Enjoy::Model
|
6
|
-
include Enjoy::Enableable
|
7
|
-
include ManualSlug
|
8
|
-
|
9
|
-
include Enjoy.orm_specific('PageBlockset')
|
10
|
-
|
11
|
-
included do
|
12
|
-
manual_slug :name
|
13
|
-
|
14
|
-
# after_save do
|
15
|
-
# Rails.cache.delete 'blocksets'
|
16
|
-
# end
|
17
|
-
# after_destroy do
|
18
|
-
# Rails.cache.delete 'blocksets'
|
19
|
-
# end
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
data/lib/enjoy/models/seo.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
module Enjoy
|
2
|
-
module Models
|
3
|
-
module Seo
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
include Enjoy::Model
|
6
|
-
include Enjoy::Enableable
|
7
|
-
|
8
|
-
include Enjoy.orm_specific('Seo')
|
9
|
-
|
10
|
-
included do
|
11
|
-
belongs_to :seoable, polymorphic: true
|
12
|
-
|
13
|
-
validates_attachment_content_type :og_image, content_type: /\Aimage\/.*\Z/, if: :og_image?
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Enjoy
|
2
|
-
module Models
|
3
|
-
module SitemapData
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
include Enjoy::Model
|
6
|
-
include Enjoy::Enableable
|
7
|
-
|
8
|
-
include Enjoy.orm_specific('SitemapData')
|
9
|
-
|
10
|
-
SITEMAP_CHANGEFREQ_ARRAY = %w(always hourly daily weekly monthly yearly never)
|
11
|
-
|
12
|
-
included do
|
13
|
-
belongs_to :sitemap_data_field, polymorphic: true
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'rails_admin/config/fields/types/has_many_association'
|
2
|
-
|
3
|
-
module RailsAdmin
|
4
|
-
module Config
|
5
|
-
module Fields
|
6
|
-
module Types
|
7
|
-
class EnjoyConnectable < RailsAdmin::Config::Fields::Types::HasManyAssociation
|
8
|
-
RailsAdmin::Config::Fields::Types::register(self)
|
9
|
-
include RailsAdmin::Engine.routes.url_helpers
|
10
|
-
|
11
|
-
register_instance_option :partial do
|
12
|
-
:enjoy_connectable
|
13
|
-
end
|
14
|
-
|
15
|
-
register_instance_option :autocreate_page_attr do
|
16
|
-
:enjoy_connectable_autocreate_page
|
17
|
-
end
|
18
|
-
|
19
|
-
register_instance_option :allowed_methods do
|
20
|
-
[method_name, autocreate_page_attr]
|
21
|
-
end
|
22
|
-
|
23
|
-
register_instance_option :associated_collection_scope do
|
24
|
-
me = bindings[:object]
|
25
|
-
Proc.new do |scope|
|
26
|
-
scope.unconnected(me).enabled.sorted
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,147 +0,0 @@
|
|
1
|
-
require 'rails_admin/config/fields/base'
|
2
|
-
|
3
|
-
module RailsAdmin
|
4
|
-
module Config
|
5
|
-
module Fields
|
6
|
-
module Types
|
7
|
-
class Menu < RailsAdmin::Config::Fields::Base
|
8
|
-
# Register field type for the type loader
|
9
|
-
RailsAdmin::Config::Fields::Types::register(self)
|
10
|
-
include RailsAdmin::Engine.routes.url_helpers
|
11
|
-
|
12
|
-
register_instance_option :pretty_value do
|
13
|
-
obj = bindings[:object]
|
14
|
-
ret = []
|
15
|
-
menus = Rails.cache.fetch 'menus', expires_in: 10.minutes do
|
16
|
-
if Enjoy.mongoid?
|
17
|
-
::Enjoy::Menu.all.map { |m| {id: m.id.to_s, name: m.name } }
|
18
|
-
else
|
19
|
-
::Enjoy::Menu.all.map { |m| {id: m.id, name: m.name } }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
menus.each do |m|
|
23
|
-
if Enjoy.mongoid?
|
24
|
-
on = obj.menu_ids.include?(BSON::ObjectId.from_string(m[:id]))
|
25
|
-
else
|
26
|
-
on = obj.menu_ids.include?(m[:id].to_i)
|
27
|
-
end
|
28
|
-
ret << bindings[:view].link_to(
|
29
|
-
m[:name],
|
30
|
-
bindings[:view].toggle_menu_path(model_name: @abstract_model, id: obj.id, menu: m[:id], on: !on),
|
31
|
-
#method: :post,
|
32
|
-
title: m[:name],
|
33
|
-
class: "btn btn-mini #{on ? "btn-success" : "btn-danger"}",
|
34
|
-
style: 'margin-bottom: 5px;',
|
35
|
-
onclick: 'var $t = $(this); $.ajax({type: "POST", url: $t.attr("href"), data: {ajax:true}, success: function(r) { $t.attr("href", r.href); $t.attr("class", r.class); }, error: function(e) { alert(e.responseText); }}); return false;'
|
36
|
-
)
|
37
|
-
end
|
38
|
-
('<div style="white-space: normal;">' + ret.join(' ') + '</div>').html_safe
|
39
|
-
end
|
40
|
-
|
41
|
-
register_instance_option :formatted_value do
|
42
|
-
pretty_value
|
43
|
-
end
|
44
|
-
|
45
|
-
register_instance_option :export_value do
|
46
|
-
nil
|
47
|
-
end
|
48
|
-
|
49
|
-
register_instance_option :partial do
|
50
|
-
:form_raw
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
module RailsAdmin
|
59
|
-
module Config
|
60
|
-
module Actions
|
61
|
-
class ToggleMenu < Base
|
62
|
-
RailsAdmin::Config::Actions.register(self)
|
63
|
-
|
64
|
-
# Is the action acting on the root level (Example: /admin/contact)
|
65
|
-
register_instance_option :root? do
|
66
|
-
false
|
67
|
-
end
|
68
|
-
|
69
|
-
register_instance_option :collection? do
|
70
|
-
false
|
71
|
-
end
|
72
|
-
|
73
|
-
# Is the action on an object scope (Example: /admin/team/1/edit)
|
74
|
-
register_instance_option :member? do
|
75
|
-
true
|
76
|
-
end
|
77
|
-
|
78
|
-
register_instance_option :controller do
|
79
|
-
proc do
|
80
|
-
ajax_link = Proc.new do |am, obj, menu, on|
|
81
|
-
render json: {
|
82
|
-
href: toggle_menu_path(model_name: am, id: obj.id, menu: menu.id, on: !on),
|
83
|
-
class: "btn btn-mini #{on ? "btn-success" : "btn-danger"}",
|
84
|
-
}
|
85
|
-
end
|
86
|
-
if params['id'].present?
|
87
|
-
begin
|
88
|
-
@object = @abstract_model.model.find(params['id'])
|
89
|
-
@menu = ::Enjoy::Menu.find(params[:menu])
|
90
|
-
if params[:on] == 'true'
|
91
|
-
@object.menus << @menu
|
92
|
-
else
|
93
|
-
@object.menus.delete(@menu)
|
94
|
-
end
|
95
|
-
|
96
|
-
if @object.save
|
97
|
-
if params['ajax'].present?
|
98
|
-
if params[:on] == 'true'
|
99
|
-
ajax_link.call(@abstract_model, @object, @menu, true)
|
100
|
-
else
|
101
|
-
ajax_link.call(@abstract_model, @object, @menu, false)
|
102
|
-
end
|
103
|
-
else
|
104
|
-
if params[:on] == 'true'
|
105
|
-
flash[:success] = I18n.t('rs.m.enabled', menu: @menu.name)
|
106
|
-
else
|
107
|
-
flash[:success] = I18n.t('rs.m.disabled', menu: @menu.name)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
else
|
111
|
-
if params['ajax'].present?
|
112
|
-
render text: @object.errors.full_messages.join(', '), layout: false, status: 422
|
113
|
-
else
|
114
|
-
flash[:error] = @object.errors.full_messages.join(', ')
|
115
|
-
end
|
116
|
-
end
|
117
|
-
rescue Exception => e
|
118
|
-
if params['ajax'].present?
|
119
|
-
render text: I18n.t('rs.m.error', err: e.to_s), status: 422
|
120
|
-
else
|
121
|
-
flash[:error] = I18n.t('rs.m.error', err: e.to_s)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
else
|
125
|
-
if params['ajax'].present?
|
126
|
-
render text: I18n.t('rs.m.no_id'), status: 422
|
127
|
-
else
|
128
|
-
flash[:error] = I18n.t('rs.m.no_id')
|
129
|
-
end
|
130
|
-
|
131
|
-
end
|
132
|
-
|
133
|
-
redirect_to :back unless params['ajax'].present?
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
register_instance_option :link_icon do
|
138
|
-
'icon-move'
|
139
|
-
end
|
140
|
-
|
141
|
-
register_instance_option :http_methods do
|
142
|
-
[:post]
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'rails/generators'
|
2
|
-
|
3
|
-
module Enjoy
|
4
|
-
class CapifyGenerator < Rails::Generators::Base
|
5
|
-
argument :kind, type: :string
|
6
|
-
argument :port, type: :string
|
7
|
-
argument :domain, type: :string
|
8
|
-
|
9
|
-
source_root File.expand_path('../templates', __FILE__)
|
10
|
-
|
11
|
-
def app_name
|
12
|
-
Rails.application.class.name.split("::")[0]
|
13
|
-
end
|
14
|
-
|
15
|
-
def deploy_to
|
16
|
-
if kind == 'data'
|
17
|
-
"/data/#{app_name.downcase}/app"
|
18
|
-
else
|
19
|
-
"/home/#{app_name.downcase}/www/#{app_name.downcase}"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
def tmp_path
|
23
|
-
if kind == 'data'
|
24
|
-
"/data/#{app_name.downcase}/tmp_dump"
|
25
|
-
else
|
26
|
-
"/home/#{app_name.downcase}/www/#{app_name.downcase}/tmp_dump"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
desc 'Enjoy capistrano setup generator'
|
31
|
-
def install
|
32
|
-
copy_file "Capfile", "Capfile"
|
33
|
-
template "unicorn.erb", "config/unicorn/production.rb"
|
34
|
-
template "deploy.erb", "config/deploy.rb"
|
35
|
-
template "production.erb", "config/deploy/production.rb"
|
36
|
-
template "dl.erb", "lib/tasks/dl.thor"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
Enjoy.configure do |config|
|
2
|
-
##### defaults #####
|
3
|
-
# config.news_image_styles = {
|
4
|
-
# main: '400x200>',
|
5
|
-
# thumb: '200x100>'
|
6
|
-
# }
|
7
|
-
# config.news_per_page = 10
|
8
|
-
# config.news_excerpt = 12
|
9
|
-
# config.news_content_required = true
|
10
|
-
#
|
11
|
-
# config.main_index_layout = 'application'
|
12
|
-
# config.error_layout = 'application'
|
13
|
-
# config.menu_max_depth = 2
|
14
|
-
#
|
15
|
-
# config.search_enabled = false
|
16
|
-
# config.search_per_page = 10
|
17
|
-
# config.search_models = []
|
18
|
-
#
|
19
|
-
# config.contacts_captcha = false
|
20
|
-
# config.contacts_fields = {}
|
21
|
-
# config.contacts_message_required = true
|
22
|
-
#
|
23
|
-
# config.contacts_captcha_error_message = "Код проверки введен неверно"
|
24
|
-
# config.recreate_contact_message_action = "new"
|
25
|
-
#
|
26
|
-
# config.localize = false
|
27
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'rails/generators'
|
2
|
-
require 'rails/generators/active_record'
|
3
|
-
|
4
|
-
module Enjoy
|
5
|
-
class MigrationGenerator < Rails::Generators::Base
|
6
|
-
include ActiveRecord::Generators::Migration
|
7
|
-
source_root File.expand_path('../templates', __FILE__)
|
8
|
-
|
9
|
-
desc 'Enjoy migration generator'
|
10
|
-
def install
|
11
|
-
if Enjoy.active_record?
|
12
|
-
# %w(contact_messages news pages seos).each do |table_name|
|
13
|
-
# migration_template "migration_#{table_name}.rb", "db/migrate/enjoy_create_#{table_name}.rb"
|
14
|
-
# end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|