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,23 @@
|
|
|
1
|
+
module Enjoy
|
|
2
|
+
module Models
|
|
3
|
+
module GalleryImage
|
|
4
|
+
extend ActiveSupport::Concern
|
|
5
|
+
include Enjoy::Model
|
|
6
|
+
include Enjoy::Enableable
|
|
7
|
+
|
|
8
|
+
include Enjoy.orm_specific('GalleryImage')
|
|
9
|
+
|
|
10
|
+
included do
|
|
11
|
+
|
|
12
|
+
belongs_to :gallery, class_name: gallery_class_name
|
|
13
|
+
field :name, type: String, localize: Enjoy.configuration.localize
|
|
14
|
+
|
|
15
|
+
validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/, if: :image?
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def gallery_class_name
|
|
19
|
+
"Enjoy::Gallery"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module Enjoy
|
|
2
|
+
module Models
|
|
3
|
+
module Menu
|
|
4
|
+
extend ActiveSupport::Concern
|
|
5
|
+
include Enjoy::Model
|
|
6
|
+
include ManualSlug
|
|
7
|
+
include Enjoy::Enableable
|
|
8
|
+
|
|
9
|
+
include Enjoy.orm_specific('Menu')
|
|
10
|
+
included do
|
|
11
|
+
|
|
12
|
+
field :name, type: String
|
|
13
|
+
manual_slug :name
|
|
14
|
+
|
|
15
|
+
after_save do
|
|
16
|
+
Rails.cache.delete 'menus'
|
|
17
|
+
end
|
|
18
|
+
after_destroy do
|
|
19
|
+
Rails.cache.delete 'menus'
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def page_class_name
|
|
24
|
+
"Enjoy::Page"
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Enjoy
|
|
2
|
+
module Models
|
|
3
|
+
module Mongoid
|
|
4
|
+
module ContactMessage
|
|
5
|
+
extend ActiveSupport::Concern
|
|
6
|
+
included do
|
|
7
|
+
|
|
8
|
+
field :name, type: String
|
|
9
|
+
field :email, type: String
|
|
10
|
+
field :phone, type: String
|
|
11
|
+
field :content, type: String
|
|
12
|
+
Enjoy.config.contacts_fields.each_pair do |fn, ft|
|
|
13
|
+
next if ft.nil?
|
|
14
|
+
field fn, type: ft
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Enjoy
|
|
2
|
+
module Models
|
|
3
|
+
module Mongoid
|
|
4
|
+
module EmbeddedGalleryImage
|
|
5
|
+
extend ActiveSupport::Concern
|
|
6
|
+
include Enjoy::MongoidPaperclip
|
|
7
|
+
include Enjoy::EmbeddedElement
|
|
8
|
+
|
|
9
|
+
included do
|
|
10
|
+
|
|
11
|
+
enjoy_mongoid_attached_file(:image,
|
|
12
|
+
styles: image_styles,
|
|
13
|
+
content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] }
|
|
14
|
+
)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Enjoy
|
|
2
|
+
module Models
|
|
3
|
+
module Mongoid
|
|
4
|
+
module Gallery
|
|
5
|
+
extend ActiveSupport::Concern
|
|
6
|
+
include Enjoy::MongoidPaperclip
|
|
7
|
+
|
|
8
|
+
included do
|
|
9
|
+
|
|
10
|
+
manual_slug :name
|
|
11
|
+
|
|
12
|
+
acts_as_nested_set
|
|
13
|
+
scope :sorted, -> { order_by([:lft, :asc]) }
|
|
14
|
+
|
|
15
|
+
enjoy_mongoid_attached_file(:image,
|
|
16
|
+
styles: image_styles,
|
|
17
|
+
content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] }
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Enjoy
|
|
2
|
+
module Models
|
|
3
|
+
module Mongoid
|
|
4
|
+
module GalleryImage
|
|
5
|
+
extend ActiveSupport::Concern
|
|
6
|
+
include Enjoy::MongoidPaperclip
|
|
7
|
+
|
|
8
|
+
included do
|
|
9
|
+
|
|
10
|
+
acts_as_nested_set
|
|
11
|
+
scope :sorted, -> { order_by([:lft, :asc]) }
|
|
12
|
+
|
|
13
|
+
enjoy_mongoid_attached_file(:image,
|
|
14
|
+
styles: image_styles,
|
|
15
|
+
content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] }
|
|
16
|
+
)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Enjoy
|
|
2
|
+
module Models
|
|
3
|
+
module Mongoid
|
|
4
|
+
module Menu
|
|
5
|
+
extend ActiveSupport::Concern
|
|
6
|
+
included do
|
|
7
|
+
has_and_belongs_to_many :pages, inverse_of: :menus, class_name: page_class_name
|
|
8
|
+
alias_method :items, :pages
|
|
9
|
+
|
|
10
|
+
field :name, type: String, default: ""
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Enjoy
|
|
2
|
+
module Models
|
|
3
|
+
module Mongoid
|
|
4
|
+
module News
|
|
5
|
+
extend ActiveSupport::Concern
|
|
6
|
+
unless Enjoy.config.news_image_styles.nil?
|
|
7
|
+
include Enjoy::MongoidPaperclip
|
|
8
|
+
end
|
|
9
|
+
included do
|
|
10
|
+
|
|
11
|
+
field :time, type: Time
|
|
12
|
+
index({enabled: 1, time: 1})
|
|
13
|
+
unless Enjoy.config.news_image_styles.nil?
|
|
14
|
+
enjoy_mongoid_attached_file(:image,
|
|
15
|
+
styles: Enjoy.configuration.news_image_styles,
|
|
16
|
+
content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] }
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
field :excerpt, type: String, localize: Enjoy.configuration.localize, default: ""
|
|
21
|
+
field :content, type: String, localize: Enjoy.configuration.localize, default: ""
|
|
22
|
+
|
|
23
|
+
scope :after_now, -> { where(:time.lt => Time.now) }
|
|
24
|
+
scope :by_date, -> { desc(:time) }
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Enjoy
|
|
2
|
+
module Models
|
|
3
|
+
module Mongoid
|
|
4
|
+
module Page
|
|
5
|
+
extend ActiveSupport::Concern
|
|
6
|
+
included do
|
|
7
|
+
|
|
8
|
+
field :regexp, type: String, default: ""
|
|
9
|
+
field :redirect, type: String, default: ""
|
|
10
|
+
field :excerpt, type: String, localize: Enjoy.config.localize, default: ""
|
|
11
|
+
field :content, type: String, localize: Enjoy.config.localize, default: ""
|
|
12
|
+
field :fullpath, type: String, default: ""
|
|
13
|
+
|
|
14
|
+
has_and_belongs_to_many :menus, inverse_of: :pages, class_name: menu_class_name
|
|
15
|
+
acts_as_nested_set
|
|
16
|
+
|
|
17
|
+
manual_slug :name
|
|
18
|
+
|
|
19
|
+
scope :sorted, -> { order_by([:lft, :asc]) }
|
|
20
|
+
scope :menu, ->(menu_id) { enabled.sorted.where(menu_ids: menu_id) }
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module Enjoy
|
|
2
|
+
module Models
|
|
3
|
+
module Mongoid
|
|
4
|
+
module Seo
|
|
5
|
+
extend ActiveSupport::Concern
|
|
6
|
+
include ::Mongoid::Paperclip
|
|
7
|
+
included do
|
|
8
|
+
|
|
9
|
+
field :name, type: String, localize: Enjoy.config.localize
|
|
10
|
+
field :h1, type: String, localize: Enjoy.config.localize
|
|
11
|
+
|
|
12
|
+
field :title, type: String, localize: Enjoy.config.localize
|
|
13
|
+
field :keywords, type: String, localize: Enjoy.config.localize
|
|
14
|
+
field :description, type: String, localize: Enjoy.config.localize
|
|
15
|
+
field :robots, type: String, localize: Enjoy.config.localize
|
|
16
|
+
|
|
17
|
+
field :og_title, type: String, localize: Enjoy.config.localize
|
|
18
|
+
unless Enjoy.config.news_image_styles.nil?
|
|
19
|
+
enjoy_mongoid_attached_file(:image,
|
|
20
|
+
styles: og_image_styles,
|
|
21
|
+
content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] }
|
|
22
|
+
)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
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::SitemapData
|
|
10
|
+
|
|
11
|
+
include Enjoy.orm_specific('News')
|
|
12
|
+
|
|
13
|
+
# if Enjoy.config.search_enabled
|
|
14
|
+
# include Enjoy::ElasticSearch
|
|
15
|
+
# end
|
|
16
|
+
|
|
17
|
+
included do
|
|
18
|
+
|
|
19
|
+
unless Enjoy.config.news_image_styles.nil?
|
|
20
|
+
validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/, if: :image?
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
validates_presence_of :name
|
|
24
|
+
if Enjoy.config.news_content_required
|
|
25
|
+
validates_presence_of :content
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
before_validation do
|
|
29
|
+
self.time = Time.now if self.time.blank?
|
|
30
|
+
end
|
|
31
|
+
scope :recent, ->(count = 5) { enabled.after_now.by_date.limit(count) }
|
|
32
|
+
unless Enjoy.config.news_per_page.nil?
|
|
33
|
+
paginates_per Enjoy.config.news_per_page
|
|
34
|
+
end
|
|
35
|
+
smart_excerpt :excerpt, :content, Enjoy.config.news_excerpt
|
|
36
|
+
manual_slug :report_slug
|
|
37
|
+
|
|
38
|
+
Enjoy.apply_patches self
|
|
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
|
|
@@ -0,0 +1,90 @@
|
|
|
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::SitemapData
|
|
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
|
+
end
|
|
25
|
+
|
|
26
|
+
def page_h1
|
|
27
|
+
_ret = h1
|
|
28
|
+
_ret = name if _ret.blank?
|
|
29
|
+
_ret = title if _ret.blank?
|
|
30
|
+
_ret
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def menu_class_name
|
|
34
|
+
"Enjoy::Menu"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def get_fullpath
|
|
38
|
+
redirect.blank? ? fullpath : redirect
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def has_content?
|
|
42
|
+
@content_used.nil? && !content.blank?
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def page_content
|
|
46
|
+
if @content_used.nil?
|
|
47
|
+
@content_used = true
|
|
48
|
+
if content.nil?
|
|
49
|
+
''
|
|
50
|
+
else
|
|
51
|
+
content.gsub(/\{\{(.*?)\}\}/) do
|
|
52
|
+
Settings ? Settings.get($1).val : "" #temp
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
else
|
|
56
|
+
''
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def is_current?(url)
|
|
61
|
+
if fullpath == '/'
|
|
62
|
+
url == '/'
|
|
63
|
+
else
|
|
64
|
+
url.match(clean_regexp)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def regexp_prefix
|
|
69
|
+
""
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def clean_regexp
|
|
73
|
+
if regexp.blank?
|
|
74
|
+
/^#{regexp_prefix}#{Regexp.escape(fullpath)}$/
|
|
75
|
+
else
|
|
76
|
+
begin
|
|
77
|
+
/#{regexp}/
|
|
78
|
+
rescue
|
|
79
|
+
# not a valid regexp - treat as literal search string
|
|
80
|
+
/#{Regexp.escape(regexp)}/
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def nav_options
|
|
86
|
+
{highlights_on: clean_regexp}
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Enjoy
|
|
2
|
+
module Models
|
|
3
|
+
module Seo
|
|
4
|
+
extend ActiveSupport::Concern
|
|
5
|
+
include Enjoy::Model
|
|
6
|
+
include Enjoy::Enableable
|
|
7
|
+
include Enjoy::Seoable
|
|
8
|
+
|
|
9
|
+
include Enjoy.orm_specific('Seo')
|
|
10
|
+
|
|
11
|
+
included do
|
|
12
|
+
|
|
13
|
+
Enjoy.apply_patches self
|
|
14
|
+
validates_attachment_content_type :og_image, content_type: /\Aimage\/.*\Z/, if: :og_image?
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def og_image_styles
|
|
18
|
+
{thumb: "800x600>"}
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
data/lib/enjoy/patch.rb
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
module Enjoy
|
|
2
|
+
class PatchDSL
|
|
3
|
+
def self.call(&blk)
|
|
4
|
+
instance = new
|
|
5
|
+
instance.instance_eval(&blk)
|
|
6
|
+
instance.instance_variables.inject({}) { |result_hash, instance_variable|
|
|
7
|
+
result_hash[instance_variable[1..-1].to_sym] = instance.instance_variable_get(instance_variable)
|
|
8
|
+
result_hash
|
|
9
|
+
}
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def initialize
|
|
13
|
+
@model = Proc.new {}
|
|
14
|
+
@admin = Proc.new {}
|
|
15
|
+
@list = Proc.new {}
|
|
16
|
+
@show = Proc.new {}
|
|
17
|
+
@edit = Proc.new {}
|
|
18
|
+
@export = Proc.new {}
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def model(&blk); @model = blk; end
|
|
22
|
+
def admin(&blk); @admin = blk; end
|
|
23
|
+
def list(&blk); @list = blk; end
|
|
24
|
+
def show(&blk); @show = blk; end
|
|
25
|
+
def edit(&blk); @edit = blk; end
|
|
26
|
+
def export(&blk); @export = blk; end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
@@patches = {}
|
|
30
|
+
|
|
31
|
+
def self.only_patches(s, sections)
|
|
32
|
+
s.instance_eval do
|
|
33
|
+
sections.each do |section|
|
|
34
|
+
send section do
|
|
35
|
+
Enjoy.apply_patches self
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def self.apply_patches(s)
|
|
42
|
+
if s.class.name.index('RailsAdmin::Config::Sections::').nil?
|
|
43
|
+
if s.class.name == 'RailsAdmin::Config::Model'
|
|
44
|
+
s.instance_eval(&@@patches[s.abstract_model.model_name][:admin]) unless @@patches[s.abstract_model.model_name].nil?
|
|
45
|
+
else
|
|
46
|
+
s.instance_eval(&@@patches[s.name][:model]) unless @@patches[s.name].nil?
|
|
47
|
+
end
|
|
48
|
+
else
|
|
49
|
+
model = s.abstract_model.model_name
|
|
50
|
+
action = s.class.name.split('::')[-1].downcase.to_sym
|
|
51
|
+
s.instance_eval(&@@patches[model][action]) unless @@patches[model].nil?
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def self.patch(model, &blk)
|
|
56
|
+
@@patches[model] = PatchDSL.call(&blk)
|
|
57
|
+
end
|
|
58
|
+
end
|