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.
Files changed (213) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.ruby-version +1 -1
  4. data/Gemfile.lock +62 -111
  5. data/app/assets/javascripts/{enjoy_cms → enjoy/cms}/flash.coffee +0 -0
  6. data/app/assets/javascripts/enjoy/cms/init.coffee +1 -0
  7. data/app/assets/javascripts/{enjoy_cms → enjoy/cms}/map.coffee +0 -0
  8. data/app/assets/javascripts/enjoy/cms.coffee +11 -0
  9. data/app/assets/javascripts/enjoy/rails_admin/cms.ui.coffee +26 -0
  10. data/app/assets/javascripts/{enjoy_cms → enjoy}/rails_admin/custom/ui.coffee +0 -0
  11. data/app/assets/javascripts/rails_admin/custom/ui.coffee +2 -2
  12. data/app/assets/stylesheets/{enjoy_cms → enjoy/cms}/flash.sass +0 -0
  13. data/app/assets/stylesheets/{enjoy_cms → enjoy/cms}/normalize.scss +0 -0
  14. data/app/assets/stylesheets/{enjoy_cms → enjoy/cms}/powered.sass +0 -0
  15. data/app/assets/stylesheets/{enjoy_cms.sass → enjoy/cms.sass} +3 -1
  16. data/app/assets/stylesheets/enjoy/rails_admin/cms.ui.sass +117 -0
  17. data/{lib/enjoy/controllers/sitemap_data.rb → app/assets/stylesheets/enjoy/rails_admin/custom/ui.sass} +0 -0
  18. data/app/assets/stylesheets/rails_admin/custom/theming.sass +2 -0
  19. data/app/controllers/concerns/enjoy/errors.rb +1 -1
  20. data/app/controllers/enjoy/registrations_controller.rb +20 -0
  21. data/app/controllers/enjoy/sessions_controller.rb +19 -0
  22. data/app/helpers/enjoy/home_helper.rb +2 -0
  23. data/app/helpers/enjoy/powered_helper.rb +1 -1
  24. data/app/models/concerns/enjoy/html_field.rb +3 -0
  25. data/app/views/blocks/_favicon.html.slim +60 -21
  26. data/app/views/devise/registrations/edit.html.slim +2 -2
  27. data/app/views/devise/registrations/new.html.slim +9 -3
  28. data/app/views/devise/sessions/new.html.slim +8 -2
  29. data/app/views/devise/shared/_links.html.slim +4 -4
  30. data/app/views/{errors → enjoy/errors}/_base.html.slim +0 -0
  31. data/app/views/{errors → enjoy/errors}/error_403.html.slim +0 -0
  32. data/app/views/{errors → enjoy/errors}/error_404.html.slim +0 -0
  33. data/app/views/{errors → enjoy/errors}/error_500.html.slim +0 -0
  34. data/app/views/{simple_captcha → enjoy/simple_captcha}/_simple_captcha.html.slim +0 -0
  35. data/app/views/layouts/application.html.slim +8 -4
  36. data/app/views/layouts/enjoy/devise/confirmations.html.slim +27 -0
  37. data/app/views/layouts/enjoy/devise/passwords.html.slim +27 -0
  38. data/app/views/layouts/enjoy/devise/registrations.html.slim +27 -0
  39. data/app/views/layouts/enjoy/devise/sessions.html.slim +27 -0
  40. data/app/views/layouts/enjoy/devise/unlocks.html.slim +27 -0
  41. data/app/views/rails_admin/main/_setting_value.html.haml +104 -0
  42. data/app/views/shared/_messages.html.slim +1 -1
  43. data/config/initializers/simple_captcha.rb +29 -20
  44. data/config/locales/en.enjoy.yml +1 -1
  45. data/config/locales/ru.enjoy.yml +0 -7
  46. data/config/locales/ru.models.yml +2 -39
  47. data/enjoy_cms.gemspec +7 -20
  48. data/lib/enjoy/configuration.rb +24 -40
  49. data/lib/enjoy/controller.rb +5 -3
  50. data/lib/enjoy/engine.rb +28 -28
  51. data/lib/enjoy/migration.rb +0 -19
  52. data/lib/enjoy/model.rb +5 -2
  53. data/lib/enjoy/rails_admin_ext/config.rb +112 -0
  54. data/lib/enjoy/rails_admin_ext/enjoy_hash.rb +0 -2
  55. data/lib/enjoy/rails_admin_ext/enjoy_slugs.rb +31 -0
  56. data/lib/enjoy/rails_admin_ext/group_patch.rb +2 -1
  57. data/lib/enjoy/rails_admin_settings_patch.rb +7 -0
  58. data/lib/enjoy/routes.rb +1 -26
  59. data/lib/enjoy/version.rb +1 -1
  60. data/lib/enjoy_cms.rb +25 -71
  61. data/lib/filename_to_slug.rb +20 -22
  62. data/lib/generators/enjoy/{ability_generator.rb → cms/ability_generator.rb} +3 -3
  63. data/lib/generators/enjoy/{admin_generator.rb → cms/admin_generator.rb} +2 -2
  64. data/lib/generators/enjoy/cms/application_generator.rb +14 -0
  65. data/lib/generators/enjoy/cms/assets_generator.rb +35 -0
  66. data/lib/generators/enjoy/{config/install_generator.rb → cms/config_generator.rb} +3 -3
  67. data/lib/generators/enjoy/cms/gemfile_generator.rb +13 -0
  68. data/lib/generators/enjoy/{layout_generator.rb → cms/layout_generator.rb} +2 -2
  69. data/lib/generators/enjoy/cms/paperclip_optimizer_generator.rb +13 -0
  70. data/lib/generators/enjoy/cms/rack_generator.rb +12 -0
  71. data/lib/generators/enjoy/cms/robots_generator.rb +12 -0
  72. data/lib/generators/enjoy/cms/scripts_generator.rb +25 -0
  73. data/lib/generators/enjoy/cms/templates/Gemfile.erb +69 -0
  74. data/lib/generators/enjoy/cms/templates/ability.erb +45 -0
  75. data/lib/generators/enjoy/{templates → cms/templates}/admin.erb +5 -26
  76. data/lib/generators/enjoy/cms/templates/application.erb +42 -0
  77. data/lib/generators/enjoy/cms/templates/assets/javascripts/application.coffee.erb +1 -0
  78. data/lib/generators/enjoy/cms/templates/assets/stylesheets/application.sass.erb +15 -0
  79. data/lib/generators/enjoy/cms/templates/assets/stylesheets/enjoy/rails_admin/custom/ui.sass.erb +106 -0
  80. data/lib/generators/enjoy/cms/templates/enjoy_cms.erb +28 -0
  81. data/lib/generators/enjoy/cms/templates/paperclip_optimizer.erb +80 -0
  82. data/lib/generators/enjoy/cms/templates/rack.erb +15 -0
  83. data/lib/generators/enjoy/cms/templates/robots.txt.erb +4 -0
  84. data/lib/generators/enjoy/cms/templates/scripts/assets_precompile.sh +3 -0
  85. data/lib/generators/enjoy/cms/templates/scripts/bundle_production.sh +4 -0
  86. data/lib/generators/enjoy/cms/templates/scripts/db_dump.sh.erb +3 -0
  87. data/lib/generators/enjoy/cms/templates/scripts/db_restore.sh +3 -0
  88. data/lib/generators/enjoy/cms/templates/scripts/full_assets_precompile.sh +4 -0
  89. data/lib/generators/enjoy/cms/templates/scripts/restart_thru_kill.sh +3 -0
  90. data/lib/generators/enjoy/cms/templates/scripts/send_hup.sh +3 -0
  91. data/lib/generators/enjoy/cms/templates/scripts/send_usr2.sh +3 -0
  92. data/lib/generators/enjoy/cms/templates/unicorn.erb +57 -0
  93. data/lib/generators/enjoy/cms/templates/unicorn.god.erb +59 -0
  94. data/lib/generators/enjoy/cms/unicorn_god_generator.rb +15 -0
  95. data/lib/generators/enjoy/{utils.rb → cms/utils.rb} +1 -1
  96. data/lib/rails_admin/custom_show_in_app.rb +13 -13
  97. data/template.rb +197 -543
  98. metadata +73 -325
  99. data/app/assets/javascripts/enjoy_cms/contacts.coffee +0 -11
  100. data/app/assets/javascripts/enjoy_cms/rails_admin/cms.ui.coffee +0 -6
  101. data/app/assets/javascripts/enjoy_cms.coffee +0 -7
  102. data/app/controllers/concerns/enjoy/blocksetable.rb +0 -37
  103. data/app/controllers/concerns/enjoy/decorators/contacts.rb +0 -5
  104. data/app/controllers/concerns/enjoy/decorators/news.rb +0 -5
  105. data/app/controllers/concerns/enjoy/decorators/pages.rb +0 -5
  106. data/app/controllers/concerns/enjoy/decorators/search.rb +0 -5
  107. data/app/controllers/concerns/enjoy/nav_menu.rb +0 -91
  108. data/app/controllers/concerns/enjoy/seo_pages.rb +0 -90
  109. data/app/controllers/enjoy/contacts_controller.rb +0 -7
  110. data/app/controllers/enjoy/news_controller.rb +0 -7
  111. data/app/controllers/enjoy/pages_controller.rb +0 -7
  112. data/app/controllers/enjoy/search_controller.rb +0 -8
  113. data/app/mailers/enjoy/contact_mailer.rb +0 -17
  114. data/app/models/concerns/enjoy/connectable.rb +0 -36
  115. data/app/models/concerns/enjoy/decorators/contact_message.rb +0 -5
  116. data/app/models/concerns/enjoy/decorators/embedded_gallery_image.rb +0 -5
  117. data/app/models/concerns/enjoy/decorators/gallery.rb +0 -5
  118. data/app/models/concerns/enjoy/decorators/gallery_image.rb +0 -5
  119. data/app/models/concerns/enjoy/decorators/menu.rb +0 -5
  120. data/app/models/concerns/enjoy/decorators/news.rb +0 -5
  121. data/app/models/concerns/enjoy/decorators/page.rb +0 -5
  122. data/app/models/concerns/enjoy/decorators/page_block.rb +0 -5
  123. data/app/models/concerns/enjoy/decorators/page_blockset.rb +0 -5
  124. data/app/models/concerns/enjoy/decorators/seo.rb +0 -5
  125. data/app/models/concerns/enjoy/decorators/sitemap_data.rb +0 -5
  126. data/app/models/concerns/enjoy/mongoid_paperclip.rb +0 -51
  127. data/app/models/concerns/enjoy/seoable.rb +0 -36
  128. data/app/models/concerns/enjoy/sitemap_data_field.rb +0 -17
  129. data/app/models/enjoy/contact_message.rb +0 -16
  130. data/app/models/enjoy/embedded_gallery_image.rb +0 -16
  131. data/app/models/enjoy/gallery.rb +0 -13
  132. data/app/models/enjoy/gallery_image.rb +0 -13
  133. data/app/models/enjoy/menu.rb +0 -16
  134. data/app/models/enjoy/news.rb +0 -16
  135. data/app/models/enjoy/page.rb +0 -16
  136. data/app/models/enjoy/page_block.rb +0 -13
  137. data/app/models/enjoy/page_blockset.rb +0 -13
  138. data/app/models/enjoy/seo.rb +0 -16
  139. data/app/models/enjoy/sitemap_data.rb +0 -16
  140. data/app/views/enjoy/contact_mailer/new_message_email.html.slim +0 -15
  141. data/app/views/enjoy/contacts/_form.html.slim +0 -7
  142. data/app/views/enjoy/contacts/_form_with_wrapper.html.slim +0 -2
  143. data/app/views/enjoy/contacts/_success.html.slim +0 -3
  144. data/app/views/enjoy/contacts/index.html.slim +0 -4
  145. data/app/views/enjoy/contacts/new.html.slim +0 -4
  146. data/app/views/enjoy/contacts/sent.html.slim +0 -3
  147. data/app/views/enjoy/news/index.html.slim +0 -9
  148. data/app/views/enjoy/news/show.html.slim +0 -8
  149. data/app/views/enjoy/pages/show.html.slim +0 -1
  150. data/app/views/enjoy/search/index.html.slim +0 -19
  151. data/app/views/rails_admin/main/_enjoy_connectable.html.slim +0 -56
  152. data/config/locales/ru.kaminari.yml +0 -17
  153. data/config/locales/ru.simple_captcha.yml +0 -3
  154. data/config/locales/ru.simple_form.yml +0 -9
  155. data/lib/enjoy/admin/contact_message.rb +0 -42
  156. data/lib/enjoy/admin/embedded_gallery_image.rb +0 -38
  157. data/lib/enjoy/admin/gallery.rb +0 -44
  158. data/lib/enjoy/admin/gallery_image.rb +0 -31
  159. data/lib/enjoy/admin/menu.rb +0 -27
  160. data/lib/enjoy/admin/news.rb +0 -89
  161. data/lib/enjoy/admin/page.rb +0 -96
  162. data/lib/enjoy/admin/page_block.rb +0 -49
  163. data/lib/enjoy/admin/page_blockset.rb +0 -50
  164. data/lib/enjoy/admin/seo.rb +0 -41
  165. data/lib/enjoy/admin/sitemap_data.rb +0 -29
  166. data/lib/enjoy/controllers/contacts.rb +0 -86
  167. data/lib/enjoy/controllers/news.rb +0 -36
  168. data/lib/enjoy/controllers/pages.rb +0 -22
  169. data/lib/enjoy/controllers/search.rb +0 -62
  170. data/lib/enjoy/elastic_search.rb +0 -31
  171. data/lib/enjoy/models/active_record/contact_message.rb +0 -14
  172. data/lib/enjoy/models/active_record/menu.rb +0 -17
  173. data/lib/enjoy/models/active_record/news.rb +0 -26
  174. data/lib/enjoy/models/active_record/page.rb +0 -20
  175. data/lib/enjoy/models/active_record/seo.rb +0 -17
  176. data/lib/enjoy/models/active_record/sitemap_data.rb +0 -11
  177. data/lib/enjoy/models/contact_message.rb +0 -41
  178. data/lib/enjoy/models/embedded_gallery_image.rb +0 -13
  179. data/lib/enjoy/models/gallery.rb +0 -21
  180. data/lib/enjoy/models/gallery_image.rb +0 -19
  181. data/lib/enjoy/models/menu.rb +0 -23
  182. data/lib/enjoy/models/mongoid/contact_message.rb +0 -23
  183. data/lib/enjoy/models/mongoid/embedded_gallery_image.rb +0 -24
  184. data/lib/enjoy/models/mongoid/gallery.rb +0 -32
  185. data/lib/enjoy/models/mongoid/gallery_image.rb +0 -29
  186. data/lib/enjoy/models/mongoid/menu.rb +0 -20
  187. data/lib/enjoy/models/mongoid/news.rb +0 -37
  188. data/lib/enjoy/models/mongoid/page.rb +0 -49
  189. data/lib/enjoy/models/mongoid/page_block.rb +0 -56
  190. data/lib/enjoy/models/mongoid/page_blockset.rb +0 -20
  191. data/lib/enjoy/models/mongoid/seo.rb +0 -35
  192. data/lib/enjoy/models/mongoid/sitemap_data.rb +0 -25
  193. data/lib/enjoy/models/news.rb +0 -58
  194. data/lib/enjoy/models/page.rb +0 -92
  195. data/lib/enjoy/models/page_block.rb +0 -22
  196. data/lib/enjoy/models/page_blockset.rb +0 -24
  197. data/lib/enjoy/models/seo.rb +0 -17
  198. data/lib/enjoy/models/sitemap_data.rb +0 -17
  199. data/lib/enjoy/rails_admin_ext/enjoy_connectable.rb +0 -33
  200. data/lib/enjoy/rails_admin_ext/menu.rb +0 -147
  201. data/lib/generators/enjoy/capify_generator.rb +0 -39
  202. data/lib/generators/enjoy/config/templates/enjoy_cms.erb +0 -27
  203. data/lib/generators/enjoy/migration_generator.rb +0 -18
  204. data/lib/generators/enjoy/templates/Capfile +0 -17
  205. data/lib/generators/enjoy/templates/ability.erb +0 -48
  206. data/lib/generators/enjoy/templates/deploy.erb +0 -47
  207. data/lib/generators/enjoy/templates/dl.erb +0 -30
  208. data/lib/generators/enjoy/templates/migration_contact_messages.rb +0 -15
  209. data/lib/generators/enjoy/templates/migration_news.rb +0 -26
  210. data/lib/generators/enjoy/templates/migration_pages.rb +0 -45
  211. data/lib/generators/enjoy/templates/migration_seos.rb +0 -14
  212. data/lib/generators/enjoy/templates/production.erb +0 -8
  213. data/lib/generators/enjoy/templates/unicorn.erb +0 -66
@@ -1,29 +0,0 @@
1
- module Enjoy
2
- module Admin
3
- module SitemapData
4
- def self.config(is_active = false, fields = {})
5
- Proc.new {
6
- navigation_label 'SEO'
7
- label I18n.t('enjoy.sitemap_data')
8
- field :sitemap_data_field do
9
- read_only true
10
- end
11
- field :sitemap_show, :toggle
12
- field :sitemap_lastmod
13
- field :sitemap_changefreq, :enum do
14
- enum do
15
- Enjoy::SitemapData::SITEMAP_CHANGEFREQ_ARRAY
16
- end
17
- end
18
- field :sitemap_priority
19
-
20
- Enjoy::RailsAdminGroupPatch::enjoy_cms_group(self, fields)
21
-
22
- if block_given?
23
- yield self
24
- end
25
- }
26
- end
27
- end
28
- end
29
- end
@@ -1,86 +0,0 @@
1
- module Enjoy
2
- module Controllers
3
- module Contacts
4
- extend ActiveSupport::Concern
5
- def index
6
- @contact_message = model.new
7
- after_initialize
8
- xhr_checker
9
- end
10
-
11
- def new
12
- @contact_message = model.new
13
- after_initialize
14
- xhr_checker
15
- end
16
-
17
- def create
18
- @contact_message = model.new(message_params)
19
- after_initialize
20
- if Enjoy.config.contacts_captcha
21
- meth = :save_with_captcha
22
- else
23
- meth = :save
24
- end
25
- if @contact_message.send(meth)
26
- after_create
27
- if request.xhr? && process_ajax
28
- ajax_success
29
- else
30
- redirect_after_done
31
- end
32
- else
33
- render_contacts_error
34
- end
35
- end
36
-
37
- def sent
38
- end
39
-
40
- private
41
- def render_contacts_error
42
- if request.xhr? && process_ajax
43
- render partial: form_partial
44
- # render json: {errors: @contact_message.errors}, status: 422
45
- else
46
- flash.now[:alert] = @contact_message.errors.full_messages.join("\n")
47
- render action: Enjoy.configuration.recreate_contact_message_action, status: 422
48
- end
49
- end
50
- def process_ajax
51
- true
52
- end
53
- def ajax_success
54
- render partial: success_partial
55
- # render json: {ok: true}
56
- end
57
- def redirect_after_done
58
- redirect_to :contacts_sent
59
- end
60
- def xhr_checker
61
- if request.xhr?
62
- render layout: false
63
- end
64
- end
65
- def after_initialize
66
- end
67
- def after_create
68
- # overrideable hook for updating message
69
- end
70
- def form_partial
71
- "enjoy/contacts/form"
72
- end
73
- def success_partial
74
- "enjoy/contacts/success"
75
- end
76
- def model
77
- Enjoy::ContactMessage
78
- end
79
- def message_params
80
- params.require(model.to_param.gsub("::", "").underscore).permit(
81
- Enjoy.config.contacts_fields.keys + [:name, :email, :phone, :content, :captcha, :captcha_key]
82
- )
83
- end
84
- end
85
- end
86
- end
@@ -1,36 +0,0 @@
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
@@ -1,22 +0,0 @@
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
@@ -1,62 +0,0 @@
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
@@ -1,31 +0,0 @@
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
@@ -1,14 +0,0 @@
1
- module Enjoy
2
- module Models
3
- module ActiveRecord
4
- module ContactMessage
5
- extend ActiveSupport::Concern
6
- included do
7
- has_paper_trail
8
- validates_lengths_from_database
9
- end
10
- end
11
- end
12
- end
13
- end
14
-
@@ -1,17 +0,0 @@
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
-
@@ -1,26 +0,0 @@
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
-
@@ -1,20 +0,0 @@
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
-
@@ -1,17 +0,0 @@
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
-
@@ -1,11 +0,0 @@
1
- module Enjoy
2
- module Models
3
- module ActiveRecord
4
- module SitemapData
5
- extend ActiveSupport::Concern
6
- included do
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,41 +0,0 @@
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('enjoy.no_contact_info'))
20
- end
21
- end
22
-
23
- after_create do
24
- mailer_class.send(mailer_method, self).deliver if send_emails?
25
- end
26
- end
27
-
28
- def send_emails?
29
- true
30
- end
31
-
32
- def mailer_class
33
- ContactMailer
34
- end
35
-
36
- def mailer_method
37
- :new_message_email
38
- end
39
- end
40
- end
41
- end
@@ -1,13 +0,0 @@
1
- module Enjoy
2
- module Models
3
- module EmbeddedGalleryImage
4
- extend ActiveSupport::Concern
5
-
6
- include Enjoy.orm_specific('EmbeddedGalleryImage')
7
-
8
- included do
9
- validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/, if: :image?
10
- end
11
- end
12
- end
13
- end
@@ -1,21 +0,0 @@
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::SitemapDataField
9
-
10
- include Enjoy.orm_specific('Gallery')
11
-
12
- included do
13
-
14
- has_many :gallery_images, class_name: "Enjoy::GalleryImage"
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
- end
20
- end
21
- end
@@ -1,19 +0,0 @@
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: "Enjoy::Gallery"
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
- end
18
- end
19
- end
@@ -1,23 +0,0 @@
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
-
11
- included do
12
- manual_slug :name
13
-
14
- after_save do
15
- Rails.cache.delete 'menus'
16
- end
17
- after_destroy do
18
- Rails.cache.delete 'menus'
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,23 +0,0 @@
1
- module Enjoy
2
- module Models
3
- module Mongoid
4
- module ContactMessage
5
- extend ActiveSupport::Concern
6
- included do
7
- if defined?(RailsAdminComments)
8
- include RailsAdminComments::Commentable
9
- end
10
-
11
- field :name, type: String
12
- field :email, type: String
13
- field :phone, type: String
14
- field :content, type: String
15
- Enjoy.config.contacts_fields.each_pair do |fn, ft|
16
- next if ft.nil?
17
- field fn, type: ft
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,24 +0,0 @@
1
- module Enjoy
2
- module Models
3
- module Mongoid
4
- module EmbeddedGalleryImage
5
- extend ActiveSupport::Concern
6
- include Enjoy::MongoidPaperclip
7
-
8
- included do
9
-
10
- enjoy_cms_mongoid_attached_file(:image,
11
- styles: lambda { |attachment| attachment.instance.image_styles },
12
- content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] }
13
- )
14
- end
15
-
16
-
17
- def image_styles
18
- {}
19
- end
20
-
21
- end
22
- end
23
- end
24
- end
@@ -1,32 +0,0 @@
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
- if defined?(RailsAdminComments)
10
- include RailsAdminComments::Commentable
11
- end
12
-
13
-
14
- manual_slug :name
15
-
16
- acts_as_nested_set
17
- scope :sorted, -> { order_by([:lft, :asc]) }
18
-
19
- enjoy_cms_mongoid_attached_file(:image,
20
- styles: lambda { |attachment| attachment.instance.image_styles },
21
- content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] }
22
- )
23
- end
24
-
25
- def image_styles
26
- {}
27
- end
28
-
29
- end
30
- end
31
- end
32
- end
@@ -1,29 +0,0 @@
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
- if defined?(RailsAdminComments)
10
- include RailsAdminComments::Commentable
11
- end
12
-
13
-
14
- acts_as_nested_set
15
- scope :sorted, -> { order_by([:lft, :asc]) }
16
-
17
- enjoy_cms_mongoid_attached_file(:image,
18
- styles: lambda { |attachment| attachment.instance.image_styles },
19
- content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] }
20
- )
21
- end
22
-
23
- def image_styles
24
- {}
25
- end
26
- end
27
- end
28
- end
29
- end
@@ -1,20 +0,0 @@
1
- module Enjoy
2
- module Models
3
- module Mongoid
4
- module Menu
5
- extend ActiveSupport::Concern
6
-
7
- included do
8
- if defined?(RailsAdminComments)
9
- include RailsAdminComments::Commentable
10
- end
11
-
12
- has_and_belongs_to_many :pages, inverse_of: :menus, class_name: "Enjoy::Page"
13
- alias_method :items, :pages
14
-
15
- field :name, type: String, default: ""
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,37 +0,0 @@
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
-
10
- include Enjoy::HtmlField
11
-
12
- included do
13
- if defined?(RailsAdminComments)
14
- include RailsAdminComments::Commentable
15
- end
16
-
17
- field :name, type: String, localize: Enjoy.config.localize, default: ""
18
-
19
- field :time, type: Time
20
- index({enabled: 1, time: 1})
21
- unless Enjoy.config.news_image_styles.nil?
22
- enjoy_cms_mongoid_attached_file(:image,
23
- styles: Enjoy.configuration.news_image_styles,
24
- content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] }
25
- )
26
- end
27
-
28
- enjoy_cms_html_field :excerpt, type: String, localize: Enjoy.configuration.localize, default: ""
29
- enjoy_cms_html_field :content, type: String, localize: Enjoy.configuration.localize, default: ""
30
-
31
- scope :after_now, -> { where(:time.lt => Time.now) }
32
- scope :by_date, -> { desc(:time) }
33
- end
34
- end
35
- end
36
- end
37
- end