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 Enjoy
|
2
|
+
module Controllers
|
3
|
+
module News
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
def index
|
7
|
+
@news = model.enabled.after_now.by_date
|
8
|
+
|
9
|
+
unless Enjoy.config.news_per_page.nil?
|
10
|
+
@news = @news.page(params[:page])
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def show
|
15
|
+
@news = model.after_now.find(params[:id])
|
16
|
+
|
17
|
+
if @news and @news.text_slug != params[:id]
|
18
|
+
redirect_to @news, status_code: 301
|
19
|
+
return true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def model
|
25
|
+
Enjoy::News
|
26
|
+
end
|
27
|
+
def page_title
|
28
|
+
if @news.class.name == model.name
|
29
|
+
@news.page_title
|
30
|
+
else
|
31
|
+
super
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Enjoy
|
2
|
+
module Controllers
|
3
|
+
module Pages
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
def show
|
6
|
+
if @seo_page.nil? || !@seo_page.persisted?
|
7
|
+
if !params[:id].blank? or !params[:slug].blank?
|
8
|
+
@seo_page = model.enabled.find(params[:id] || params[:slug])
|
9
|
+
end
|
10
|
+
end
|
11
|
+
if @seo_page.nil?
|
12
|
+
render_404
|
13
|
+
return true
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def model
|
18
|
+
Enjoy::Page
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Enjoy
|
2
|
+
module Controllers
|
3
|
+
module Search
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
# def index
|
6
|
+
# if params[:query].blank?
|
7
|
+
# @results = []
|
8
|
+
# else
|
9
|
+
# @results = Mongoid::Elasticsearch.search({
|
10
|
+
# body: {
|
11
|
+
# query: {
|
12
|
+
# query_string: {
|
13
|
+
# query: Mongoid::Elasticsearch::Utils.clean(params[:query])
|
14
|
+
# }
|
15
|
+
# },
|
16
|
+
# highlight: {
|
17
|
+
# fields: {
|
18
|
+
# name: {},
|
19
|
+
# content: {}
|
20
|
+
# }
|
21
|
+
# }
|
22
|
+
# }},
|
23
|
+
# page: params[:page],
|
24
|
+
# per_page: Enjoy.configuration.search_per_page,
|
25
|
+
# )
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
|
29
|
+
def index
|
30
|
+
if params[:q].blank?
|
31
|
+
@results = []
|
32
|
+
else
|
33
|
+
query = params[:q].to_s.gsub(/\P{Word}+/, ' ').gsub(/ +/, ' ').strip
|
34
|
+
@results = Enjoy::Page.search(query,
|
35
|
+
per_page: 10,
|
36
|
+
highlight: true,
|
37
|
+
suggest: true,
|
38
|
+
page: params[:page],
|
39
|
+
per_page: Enjoy.configuration.search_per_page
|
40
|
+
)
|
41
|
+
# @results = Mongoid::Elasticsearch.search({
|
42
|
+
# body: {
|
43
|
+
# query: {
|
44
|
+
# query_string: {
|
45
|
+
# query: Mongoid::Elasticsearch::Utils.clean(params[:query])
|
46
|
+
# }
|
47
|
+
# },
|
48
|
+
# highlight: {
|
49
|
+
# fields: {
|
50
|
+
# name: {},
|
51
|
+
# content: {}
|
52
|
+
# }
|
53
|
+
# }
|
54
|
+
# }},
|
55
|
+
# page: params[:page],
|
56
|
+
# per_page: Enjoy.config.search_per_page,
|
57
|
+
# )
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Enjoy::ElasticSearch
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
included do
|
4
|
+
searchkick(
|
5
|
+
language: "Russian",
|
6
|
+
suggest: ["name"],
|
7
|
+
settings: {
|
8
|
+
analysis: {
|
9
|
+
analyzer: {
|
10
|
+
default_index: {
|
11
|
+
type: "custom",
|
12
|
+
tokenizer: "standard",
|
13
|
+
filter: ["standard", "lowercase", "asciifolding", "searchkick_index_shingle", "searchkick_stemmer", "snowball"]
|
14
|
+
|
15
|
+
# https://github.com/imotov/elasticsearch-analysis-morphology
|
16
|
+
# filter: ["standard", "lowercase", "asciifolding", "searchkick_index_shingle", "searchkick_stemmer", "snowball", "russian_morphology", "english_morphology"]
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
)
|
22
|
+
|
23
|
+
def search_data
|
24
|
+
{
|
25
|
+
_id: _id,
|
26
|
+
name: name,
|
27
|
+
content: SmartExcerpt.strip_tags(content),
|
28
|
+
}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/enjoy/engine.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
module Enjoy
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace Enjoy
|
4
|
+
|
5
|
+
rake_tasks do
|
6
|
+
require File.expand_path('../tasks', __FILE__)
|
7
|
+
end
|
8
|
+
|
9
|
+
initializer "enjoy_cms.email_defaults" do
|
10
|
+
# Write default email settings to DB so they can be changed.
|
11
|
+
|
12
|
+
#temp
|
13
|
+
begin
|
14
|
+
if Settings.table_exists?
|
15
|
+
Settings.default_email_from(default: 'noreply@site.domain')
|
16
|
+
Settings.form_email(default: 'admin@site.domain')
|
17
|
+
Settings.email_topic(default: 'с сайта')
|
18
|
+
end
|
19
|
+
rescue
|
20
|
+
end
|
21
|
+
end
|
22
|
+
initializer 'enjoy_cms.paperclip' do
|
23
|
+
require 'paperclip/style'
|
24
|
+
module ::Paperclip
|
25
|
+
class Style
|
26
|
+
alias_method :processor_options_without_auto_orient, :processor_options
|
27
|
+
def processor_options
|
28
|
+
processor_options_without_auto_orient.merge(auto_orient: false)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
config.after_initialize do
|
35
|
+
# trigger autoload so models are registered in Mongoid::Elasticearch
|
36
|
+
Enjoy.config.search_models.map(&:constantize)
|
37
|
+
|
38
|
+
# Write default email settings to DB so they can be changed.
|
39
|
+
if Settings.table_exists?
|
40
|
+
Settings.default_email_from(default: 'noreply@site.domain')
|
41
|
+
Settings.form_email(default: 'admin@site.domain')
|
42
|
+
Settings.email_topic(default: 'с сайта')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Enjoy
|
2
|
+
module Migration
|
3
|
+
extend self
|
4
|
+
|
5
|
+
def seo_fields(t)
|
6
|
+
if Enjoy.config.localize
|
7
|
+
t.column :h1_translations, 'hstore', default: {}
|
8
|
+
t.column :title_translations, 'hstore', default: {}
|
9
|
+
t.column :keywords_translations, 'hstore', default: {}
|
10
|
+
t.column :description_translations, 'hstore', default: {}
|
11
|
+
t.column :og_title_translations, 'hstore', default: {}
|
12
|
+
else
|
13
|
+
t.string :h1
|
14
|
+
t.string :title
|
15
|
+
t.text :keywords
|
16
|
+
t.text :description
|
17
|
+
t.string :og_title
|
18
|
+
end
|
19
|
+
t.string :robots
|
20
|
+
t.attachment :og_image
|
21
|
+
end
|
22
|
+
|
23
|
+
def map_fields(t)
|
24
|
+
t.text :address
|
25
|
+
t.text :map_address
|
26
|
+
t.text :map_hint
|
27
|
+
t.float :latitude
|
28
|
+
t.float :longitude
|
29
|
+
t.float :lat
|
30
|
+
t.float :lon
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
data/lib/enjoy/model.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Enjoy
|
2
|
+
module Model
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
included do
|
5
|
+
if Enjoy.mongoid?
|
6
|
+
include Mongoid::Document
|
7
|
+
include Mongoid::Timestamps::Short
|
8
|
+
end
|
9
|
+
|
10
|
+
include ActiveModel::ForbiddenAttributesProtection
|
11
|
+
include Enjoy::BooleanField
|
12
|
+
include Enjoy::SortField
|
13
|
+
|
14
|
+
include SmartExcerpt
|
15
|
+
include SimpleCaptcha::ModelHelpers
|
16
|
+
|
17
|
+
if Enjoy.mongoid? && defined?(Trackable)
|
18
|
+
include Trackable
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Enjoy
|
2
|
+
module Models
|
3
|
+
module ActiveRecord
|
4
|
+
module Menu
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
included do
|
7
|
+
has_paper_trail
|
8
|
+
validates_lengths_from_database
|
9
|
+
if Enjoy.config.localize
|
10
|
+
translates :name
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Enjoy
|
2
|
+
module Models
|
3
|
+
module ActiveRecord
|
4
|
+
module News
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
included do
|
7
|
+
unless Enjoy.config.news_image_styles.nil?
|
8
|
+
has_attached_file :image, styles: Enjoy.config.news_image_styles
|
9
|
+
end
|
10
|
+
|
11
|
+
has_paper_trail
|
12
|
+
|
13
|
+
validates_lengths_from_database only: [:name, :title, :content, :excerpt, :h1, :keywords, :robots, :og_title]
|
14
|
+
|
15
|
+
scope :after_now, -> { where("time < ?", Time.now) }
|
16
|
+
scope :by_date, -> { order(time: :desc) }
|
17
|
+
|
18
|
+
if Enjoy.config.localize
|
19
|
+
translates :name, :excerpt, :content
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Enjoy
|
2
|
+
module Models
|
3
|
+
module ActiveRecord
|
4
|
+
module Page
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
acts_as_nested_set
|
9
|
+
has_paper_trail
|
10
|
+
validates_lengths_from_database only: [:name, :title, :content, :excerpt, :h1, :keywords, :robots, :og_title, :regexp, :redirect, :fullpath]
|
11
|
+
scope :sorted, -> { order(lft: :asc) }
|
12
|
+
if Enjoy.config.localize
|
13
|
+
translates :name, :content
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Enjoy
|
2
|
+
module Models
|
3
|
+
module ActiveRecord
|
4
|
+
module Seo
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
included do
|
7
|
+
has_attached_file :og_image, styles: {thumb: "800x600>"}
|
8
|
+
if Enjoy.config.localize
|
9
|
+
translates :h1, :title, :keywords, :description, :og_title
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Enjoy
|
2
|
+
module Models
|
3
|
+
module ContactMessage
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
include Enjoy::Model
|
6
|
+
|
7
|
+
include Enjoy.orm_specific('ContactMessage')
|
8
|
+
|
9
|
+
included do
|
10
|
+
|
11
|
+
apply_simple_captcha message: Enjoy.configuration.contacts_captcha_error_message
|
12
|
+
|
13
|
+
validates_email_format_of :email, unless: 'email.blank?'
|
14
|
+
if Enjoy.config.contacts_message_required
|
15
|
+
validates_presence_of :content
|
16
|
+
end
|
17
|
+
validate do
|
18
|
+
if email.blank? && phone.blank?
|
19
|
+
errors.add(:email, I18n.t('rs.no_contact_info'))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
after_create do
|
24
|
+
mailer_class.send(mailer_method, self).deliver
|
25
|
+
end
|
26
|
+
|
27
|
+
def mailer_class
|
28
|
+
ContactMailer
|
29
|
+
end
|
30
|
+
|
31
|
+
def mailer_method
|
32
|
+
:new_message_email
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Enjoy
|
2
|
+
module Models
|
3
|
+
module EmbeddedGalleryImage
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
include Enjoy::Model
|
6
|
+
include Enjoy::Enableable
|
7
|
+
include Enjoy::Sortable
|
8
|
+
|
9
|
+
include Enjoy.orm_specific('EmbeddedGalleryImage')
|
10
|
+
|
11
|
+
included do
|
12
|
+
validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/, if: :image?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Enjoy
|
2
|
+
module Models
|
3
|
+
module Gallery
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
include Enjoy::Model
|
6
|
+
include ManualSlug
|
7
|
+
include Enjoy::Enableable
|
8
|
+
include Enjoy::SitemapData
|
9
|
+
|
10
|
+
include Enjoy.orm_specific('Gallery')
|
11
|
+
|
12
|
+
included do
|
13
|
+
|
14
|
+
has_many :gallery_images, class_name: gallery_image_class_name
|
15
|
+
field :name, type: String, localize: Enjoy.configuration.localize
|
16
|
+
|
17
|
+
validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/, if: :image?
|
18
|
+
end
|
19
|
+
|
20
|
+
def gallery_image_class_name
|
21
|
+
"Enjoy::GalleryImage"
|
22
|
+
end
|
23
|
+
|
24
|
+
def image_styles
|
25
|
+
{}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|