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.
Files changed (172) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/.rspec +1 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/Gemfile +5 -0
  7. data/Gemfile.lock +249 -0
  8. data/LICENSE.txt +22 -0
  9. data/README.md +137 -0
  10. data/Rakefile +1 -0
  11. data/app/assets/javascripts/enjoy_cms.coffee +6 -0
  12. data/app/assets/javascripts/enjoy_cms/flash.js.coffee +3 -0
  13. data/app/assets/javascripts/enjoy_cms/map.js.coffee +22 -0
  14. data/app/assets/javascripts/head.load.js +707 -0
  15. data/app/assets/javascripts/jquery.placeholder.js +157 -0
  16. data/app/assets/stylesheets/enjoy_cms.sass +5 -0
  17. data/app/assets/stylesheets/enjoy_cms/flash.sass +63 -0
  18. data/app/assets/stylesheets/enjoy_cms/normalize.scss +406 -0
  19. data/app/assets/stylesheets/enjoy_cms/powered.sass +18 -0
  20. data/app/controllers/concerns/enjoy/errors.rb +93 -0
  21. data/app/controllers/concerns/enjoy/fancybox.rb +14 -0
  22. data/app/controllers/concerns/enjoy/localizeable.rb +33 -0
  23. data/app/controllers/concerns/enjoy/nav_menu.rb +64 -0
  24. data/app/controllers/concerns/enjoy/no_cache.rb +12 -0
  25. data/app/controllers/concerns/enjoy/seo_pages.rb +83 -0
  26. data/app/controllers/enjoy/contacts_controller.rb +5 -0
  27. data/app/controllers/enjoy/home_controller.rb +6 -0
  28. data/app/controllers/enjoy/news_controller.rb +5 -0
  29. data/app/controllers/enjoy/pages_controller.rb +5 -0
  30. data/app/controllers/enjoy/search_controller.rb +6 -0
  31. data/app/helpers/enjoy/gzip_helper.rb +27 -0
  32. data/app/helpers/enjoy/powered_helper.rb +12 -0
  33. data/app/mailers/enjoy/contact_mailer.rb +17 -0
  34. data/app/models/concerns/enjoy/boolean_field.rb +17 -0
  35. data/app/models/concerns/enjoy/enableable.rb +8 -0
  36. data/app/models/concerns/enjoy/geocodeable.rb +4 -0
  37. data/app/models/concerns/enjoy/mappable.rb +95 -0
  38. data/app/models/concerns/enjoy/mongoid_paperclip.rb +37 -0
  39. data/app/models/concerns/enjoy/seoable.rb +36 -0
  40. data/app/models/concerns/enjoy/sitemap_data.rb +23 -0
  41. data/app/models/concerns/enjoy/sort_field.rb +20 -0
  42. data/app/models/concerns/enjoy/sortable.rb +8 -0
  43. data/app/models/enjoy/contact_message.rb +12 -0
  44. data/app/models/enjoy/embedded_element.rb +15 -0
  45. data/app/models/enjoy/embedded_gallery_image.rb +15 -0
  46. data/app/models/enjoy/gallery.rb +10 -0
  47. data/app/models/enjoy/gallery_image.rb +10 -0
  48. data/app/models/enjoy/menu.rb +12 -0
  49. data/app/models/enjoy/news.rb +12 -0
  50. data/app/models/enjoy/page.rb +12 -0
  51. data/app/models/enjoy/seo.rb +13 -0
  52. data/app/views/blocks/_favicon.html.slim +21 -0
  53. data/app/views/blocks/_footer.html.slim +1 -0
  54. data/app/views/blocks/_seo_block.html.slim +18 -0
  55. data/app/views/blocks/_seo_block_with_obj.html.slim +27 -0
  56. data/app/views/devise/registrations/edit.html.slim +21 -0
  57. data/app/views/devise/registrations/new.html.slim +21 -0
  58. data/app/views/devise/sessions/new.html.slim +22 -0
  59. data/app/views/devise/shared/_links.html.slim +11 -0
  60. data/app/views/enjoy/contact_mailer/new_message_email.html.slim +15 -0
  61. data/app/views/enjoy/contacts/index.html.slim +10 -0
  62. data/app/views/enjoy/contacts/new.html.slim +10 -0
  63. data/app/views/enjoy/contacts/sent.html.slim +4 -0
  64. data/app/views/enjoy/home/index.html.slim +1 -0
  65. data/app/views/enjoy/news/index.html.slim +9 -0
  66. data/app/views/enjoy/news/show.html.slim +8 -0
  67. data/app/views/enjoy/pages/show.html.slim +1 -0
  68. data/app/views/enjoy/search/index.html.slim +19 -0
  69. data/app/views/errors/_base.html.slim +3 -0
  70. data/app/views/errors/error_403.html.slim +1 -0
  71. data/app/views/errors/error_404.html.slim +1 -0
  72. data/app/views/errors/error_500.html.slim +1 -0
  73. data/app/views/layouts/application.html.slim +25 -0
  74. data/app/views/rails_admin/main/_check_boxes.html.slim +27 -0
  75. data/app/views/rails_admin/main/_enum_check_boxes.html.slim +5 -0
  76. data/app/views/rails_admin/main/_enum_radio_buttons.html.slim +5 -0
  77. data/app/views/rails_admin/main/_form_raw.html.slim +1 -0
  78. data/app/views/shared/_admin_link.html.slim +3 -0
  79. data/app/views/shared/_messages.html.slim +7 -0
  80. data/app/views/shared/_meta.html.slim +19 -0
  81. data/app/views/shared/_obj.html.slim +21 -0
  82. data/app/views/shared/_og.html.slim +4 -0
  83. data/app/views/simple_captcha/_simple_captcha.html.slim +12 -0
  84. data/config/initializers/simple_captcha.rb +29 -0
  85. data/config/locales/en.enjoy.yml +29 -0
  86. data/config/locales/en.enjoy_admin.yml +6 -0
  87. data/config/locales/ru.cancan.yml +4 -0
  88. data/config/locales/ru.devise.yml +65 -0
  89. data/config/locales/ru.enjoy.yml +39 -0
  90. data/config/locales/ru.enjoy_admin.yml +6 -0
  91. data/config/locales/ru.kaminari.yml +17 -0
  92. data/config/locales/ru.models.yml +103 -0
  93. data/config/locales/ru.mongoid.yml +450 -0
  94. data/config/locales/ru.rails_admin.yml +148 -0
  95. data/config/locales/ru.simple_captcha.yml +3 -0
  96. data/config/locales/ru.simple_form.yml +9 -0
  97. data/config/routes.rb +14 -0
  98. data/enjoy_cms.gemspec +53 -0
  99. data/lib/enjoy/admin.rb +350 -0
  100. data/lib/enjoy/admin/contact_message.rb +36 -0
  101. data/lib/enjoy/admin/embedded_element.rb +11 -0
  102. data/lib/enjoy/admin/embedded_gallery_image.rb +15 -0
  103. data/lib/enjoy/admin/gallery.rb +20 -0
  104. data/lib/enjoy/admin/gallery_image.rb +18 -0
  105. data/lib/enjoy/admin/menu.rb +27 -0
  106. data/lib/enjoy/admin/news.rb +57 -0
  107. data/lib/enjoy/admin/page.rb +81 -0
  108. data/lib/enjoy/admin/seo.rb +17 -0
  109. data/lib/enjoy/configuration.rb +73 -0
  110. data/lib/enjoy/controller.rb +31 -0
  111. data/lib/enjoy/controllers/contacts.rb +70 -0
  112. data/lib/enjoy/controllers/news.rb +36 -0
  113. data/lib/enjoy/controllers/pages.rb +22 -0
  114. data/lib/enjoy/controllers/search.rb +62 -0
  115. data/lib/enjoy/elastic_search.rb +31 -0
  116. data/lib/enjoy/engine.rb +46 -0
  117. data/lib/enjoy/migration.rb +34 -0
  118. data/lib/enjoy/model.rb +22 -0
  119. data/lib/enjoy/models/active_record/contact_message.rb +14 -0
  120. data/lib/enjoy/models/active_record/menu.rb +17 -0
  121. data/lib/enjoy/models/active_record/news.rb +26 -0
  122. data/lib/enjoy/models/active_record/page.rb +20 -0
  123. data/lib/enjoy/models/active_record/seo.rb +17 -0
  124. data/lib/enjoy/models/contact_message.rb +37 -0
  125. data/lib/enjoy/models/embedded_element.rb +12 -0
  126. data/lib/enjoy/models/embedded_gallery_image.rb +16 -0
  127. data/lib/enjoy/models/gallery.rb +29 -0
  128. data/lib/enjoy/models/gallery_image.rb +23 -0
  129. data/lib/enjoy/models/menu.rb +28 -0
  130. data/lib/enjoy/models/mongoid/contact_message.rb +20 -0
  131. data/lib/enjoy/models/mongoid/embedded_element.rb +13 -0
  132. data/lib/enjoy/models/mongoid/embedded_gallery_image.rb +19 -0
  133. data/lib/enjoy/models/mongoid/gallery.rb +23 -0
  134. data/lib/enjoy/models/mongoid/gallery_image.rb +21 -0
  135. data/lib/enjoy/models/mongoid/menu.rb +15 -0
  136. data/lib/enjoy/models/mongoid/news.rb +29 -0
  137. data/lib/enjoy/models/mongoid/page.rb +25 -0
  138. data/lib/enjoy/models/mongoid/seo.rb +28 -0
  139. data/lib/enjoy/models/news.rb +58 -0
  140. data/lib/enjoy/models/page.rb +90 -0
  141. data/lib/enjoy/models/seo.rb +22 -0
  142. data/lib/enjoy/patch.rb +58 -0
  143. data/lib/enjoy/rails_admin_menu.rb +145 -0
  144. data/lib/enjoy/simple_form_patch.rb +12 -0
  145. data/lib/enjoy/tasks.rb +13 -0
  146. data/lib/enjoy/version.rb +3 -0
  147. data/lib/enjoy_cms.rb +109 -0
  148. data/lib/filename_to_slug.rb +34 -0
  149. data/lib/generators/enjoy/ability_generator.rb +14 -0
  150. data/lib/generators/enjoy/admin_generator.rb +21 -0
  151. data/lib/generators/enjoy/capify_generator.rb +39 -0
  152. data/lib/generators/enjoy/layout_generator.rb +14 -0
  153. data/lib/generators/enjoy/migration_generator.rb +18 -0
  154. data/lib/generators/enjoy/templates/Capfile +17 -0
  155. data/lib/generators/enjoy/templates/ability.erb +26 -0
  156. data/lib/generators/enjoy/templates/admin.erb +89 -0
  157. data/lib/generators/enjoy/templates/deploy.erb +47 -0
  158. data/lib/generators/enjoy/templates/dl.erb +30 -0
  159. data/lib/generators/enjoy/templates/migration_contact_messages.rb +15 -0
  160. data/lib/generators/enjoy/templates/migration_news.rb +26 -0
  161. data/lib/generators/enjoy/templates/migration_pages.rb +45 -0
  162. data/lib/generators/enjoy/templates/migration_seos.rb +14 -0
  163. data/lib/generators/enjoy/templates/production.erb +8 -0
  164. data/lib/generators/enjoy/templates/unicorn.erb +66 -0
  165. data/lib/generators/enjoy/utils.rb +21 -0
  166. data/lib/manual_slug.rb +10 -0
  167. data/lib/manual_slug/active_record.rb +32 -0
  168. data/lib/manual_slug/mongoid.rb +36 -0
  169. data/lib/rails_admin/custom_show_in_app.rb +43 -0
  170. data/release.sh +13 -0
  171. data/template.rb +824 -0
  172. metadata +579 -0
@@ -0,0 +1,18 @@
1
+ .powered
2
+ width: 33%
3
+ position: relative
4
+ display: block
5
+ float: left
6
+ height: 50px
7
+ line-height: 50px
8
+ text-align: right
9
+ a
10
+ text-decoration: none
11
+ color: #efefef
12
+ cursor: pointer
13
+ +transition(color, 0.5s)
14
+ &:hover
15
+ color: #536e7b
16
+
17
+ .powered_by
18
+ cursor: pointer
@@ -0,0 +1,93 @@
1
+ module Enjoy::Errors
2
+ extend ActiveSupport::Concern
3
+ included do
4
+ if Rails.env.production? || Rails.env.staging?
5
+ rescue_from Exception, with: :render_500
6
+ rescue_from ActionController::RoutingError, with: :render_404
7
+ rescue_from ActionController::UnknownController, with: :render_404
8
+ rescue_from ActionController::MissingFile, with: :render_404
9
+ rescue_from AbstractController::ActionNotFound, with: :render_404
10
+ if Enjoy.mongoid?
11
+ rescue_from Mongoid::Errors::DocumentNotFound, with: :render_404
12
+ rescue_from Mongoid::Errors::InvalidFind, with: :render_404
13
+ end
14
+ if Enjoy.active_record?
15
+ rescue_from ActiveRecord::RecordNotFound, with: :render_404
16
+ end
17
+ end
18
+
19
+ if defined?(CanCan)
20
+ rescue_from CanCan::AccessDenied do |exception|
21
+ Rails.logger.error "__________________________"
22
+ Rails.logger.error "Error 403"
23
+ Rails.logger.error (params ? params.inspect : "no params data")
24
+ Rails.logger.error (current_user ? current_user.inspect : "no current_user")
25
+ unless exception.nil?
26
+ Rails.logger.error exception.message
27
+ Rails.logger.error exception.backtrace.join("\n")
28
+ capture_exception(exception) if defined?(Raven)
29
+ end
30
+ Rails.logger.error "__________________________"
31
+ if !user_signed_in?
32
+ #scope = rails_admin? ? main_app : self
33
+ #redirect_to scope.new_user_session_path, alert: "Необходимо авторизоваться"
34
+ authenticate_user!
35
+ else
36
+ redirect_to '/', alert: t('rs.errors.access_denied')
37
+ end
38
+ end
39
+ end
40
+
41
+ rescue_from ActionController::InvalidAuthenticityToken do |exception|
42
+ redirect_to '/', alert: t('rs.errors.form_expired')
43
+ end
44
+ end
45
+
46
+ private
47
+ def render_404(exception = nil)
48
+ Rails.logger.error "__________________________"
49
+ Rails.logger.error "Error 404"
50
+ Rails.logger.error (params ? params.inspect : "no params data")
51
+ Rails.logger.error (current_user ? current_user.inspect : "no current_user")
52
+ unless exception.nil?
53
+ Rails.logger.error exception.message
54
+ Rails.logger.error exception.backtrace.join("\n")
55
+ capture_exception(exception) if defined?(Raven)
56
+ end
57
+ Rails.logger.error "__________________________"
58
+ render_error(404)
59
+ end
60
+
61
+ def render_500(exception = nil)
62
+ Rails.logger.error "__________________________"
63
+ Rails.logger.error "Error 500"
64
+ Rails.logger.error (params ? params.inspect : "no params data")
65
+ Rails.logger.error (current_user ? current_user.inspect : "no current_user")
66
+ unless exception.nil?
67
+ Rails.logger.error exception.message
68
+ Rails.logger.error exception.backtrace.join("\n")
69
+ capture_exception(exception) if defined?(Raven)
70
+ end
71
+ Rails.logger.error "__________________________"
72
+ begin
73
+ if rails_admin?
74
+ render text: t('rs.errors.internal_error_full', klass: exception.class.name, message: exception.message), status: 500
75
+ return
76
+ end
77
+ rescue Exception => e
78
+ puts "error while rendering rails admin exception"
79
+ puts e.class.name
80
+ puts e.message
81
+ puts e.backtrace.join("\n")
82
+ end
83
+ render_error(500)
84
+ end
85
+
86
+ def render_error(code = 500)
87
+ render template: "errors/error_#{code}", formats: [:html], handlers: [:slim], layout: Enjoy.config.error_layout, status: code
88
+ end
89
+
90
+ def rails_admin?
91
+ self.is_a?(RailsAdmin::ApplicationController) || self.is_a?(RailsAdmin::MainController)
92
+ end
93
+ end
@@ -0,0 +1,14 @@
1
+ module Enjoy::Fancybox
2
+ extend ActiveSupport::Concern
3
+ included do
4
+ helper_method :request_for_fancybox?
5
+ end
6
+
7
+ def render_for_fancybox
8
+ render layout: false if request_for_fancybox?
9
+ end
10
+
11
+ def request_for_fancybox?
12
+ request.xhr? and params[:load_by_fancybox] == "true"
13
+ end
14
+ end
@@ -0,0 +1,33 @@
1
+ module Enjoy::Localizeable
2
+ extend ActiveSupport::Concern
3
+ included do
4
+ before_filter do
5
+ I18n.locale = params[:locale] || I18n.default_locale
6
+ Settings.ns_default = "main_#{I18n.locale}"
7
+ Settings.ns_fallback = "main"
8
+ end
9
+ end
10
+ private
11
+ def default_url_options(options={})
12
+ {locale: params[:locale]}
13
+ end
14
+ def nav_get_menu_items(type)
15
+ pages = Enjoy::Menu.find(type.to_s).pages.enabled
16
+ if Enjoy.mongoid?
17
+ pages = pages.where(:"name.#{I18n.locale}".exists => true)
18
+ elsif Enjoy.active_record?
19
+ pages = pages.where(["EXIST(name_translations, ?) = TRUE AND name_translations -> ? != ''", I18n.locale, I18n.locale])
20
+ end
21
+ pages.sorted.to_a
22
+ end
23
+ def nav_get_url(item)
24
+ (params[:locale].blank? ? "" : "/#{params[:locale]}") + (item.redirect.blank? ? item.fullpath : item.redirect)
25
+ end
26
+ def find_seo_extra(path)
27
+ page_class.enabled.where(fullpath: path.gsub(/(\/ru|\/en)/, "")).first
28
+ end
29
+
30
+ def page_class
31
+ Enjoy::Page
32
+ end
33
+ end
@@ -0,0 +1,64 @@
1
+ module Enjoy::NavMenu
2
+ extend ActiveSupport::Concern
3
+ included do
4
+ helper_method :navigation
5
+ end
6
+
7
+ private
8
+ def render_with_subs(items, primary, item)
9
+ subs = items.select { |i| i.parent_id == item.id && !i.name.blank? && i.enabled }
10
+ if subs.empty?
11
+ block = nil
12
+ else
13
+ block = Proc.new do |sub_nav|
14
+ subs.each { |sub| render_with_subs(items, sub_nav, sub) }
15
+ end
16
+ end
17
+ cr = item.clean_regexp
18
+ navigation_item(primary, item, block)
19
+ end
20
+
21
+ def navigation_item(primary, item, block=nil)
22
+ url = nav_get_url(item)
23
+ if block.nil?
24
+ primary.item(item.slug, item.name, url, item.nav_options)
25
+ else
26
+ primary.item(item.slug, item.name, url, item.nav_options, &block)
27
+ end
28
+ end
29
+
30
+ def navigation(type)
31
+ Proc.new do |primary|
32
+ SimpleNavigation.config.autogenerate_item_ids = false
33
+ begin
34
+ nav_extra_data_before(type, primary)
35
+ all_items = nav_get_menu_items(type)
36
+ items = all_items.select { |i| i.parent_id.nil? && !i.name.blank? && i.enabled }
37
+ items.each do |item|
38
+ render_with_subs(all_items, primary, item)
39
+ end
40
+ nav_extra_data_after(type, primary)
41
+ rescue Exception => exception
42
+ Rails.logger.error exception.message
43
+ Rails.logger.error exception.backtrace.join("\n")
44
+ puts exception.message
45
+ puts exception.backtrace.join("\n")
46
+ capture_exception(exception) if respond_to?(:capture_exception)
47
+ items || []
48
+ end
49
+ end
50
+ end
51
+
52
+ def nav_get_url(item)
53
+ item.redirect.blank? ? item.fullpath : item.redirect
54
+ end
55
+ def nav_get_menu_items(type)
56
+ Enjoy::Menu.find(type.to_s).pages.enabled.sorted.to_a
57
+ end
58
+ def nav_extra_data_before(type, primary)
59
+ # override for additional config or items
60
+ end
61
+ def nav_extra_data_after(type, primary)
62
+ # override for additional config or items
63
+ end
64
+ end
@@ -0,0 +1,12 @@
1
+ module Enjoy::Cache
2
+ extend ActiveSupport::Concern
3
+ included do
4
+ before_filter :set_cache_buster
5
+ end
6
+
7
+ protected
8
+ def set_cache_buster
9
+ expires_now()
10
+ response.headers["Pragma"] = "no-cache"
11
+ end
12
+ end
@@ -0,0 +1,83 @@
1
+ module Enjoy::SeoPages
2
+ extend ActiveSupport::Concern
3
+ included do
4
+ before_filter :find_page
5
+ end
6
+
7
+ private
8
+ def find_page
9
+ return if rails_admin?
10
+ @seo_page = find_seo_page request.path
11
+ if !@seo_page.nil? && !@seo_page.redirect.blank?
12
+ redirect_to @seo_page.redirect, status: :moved_permanently
13
+ end
14
+ end
15
+
16
+ def find_seo_page(path)
17
+ do_redirect = false
18
+ if path[0] != '/'
19
+ path = '/' + path
20
+ end
21
+ if path.length > 1 && path[-1] == '/'
22
+ path = path[0..-2]
23
+ do_redirect = true
24
+ end
25
+ page = Enjoy::Page.enabled.where(fullpath: path).first
26
+
27
+ if page.nil? && !params[:slug].blank?
28
+ page = Enjoy::Page.enabled.where(fullpath: "/" + params[:slug]).first
29
+ end
30
+
31
+ if page.nil?
32
+ page = find_seo_extra(path)
33
+ end
34
+
35
+ if page.nil?
36
+ do_redirect = true
37
+ spath = path.chomp(File.extname(path))
38
+ if spath != path
39
+ page = Enjoy::Page.enabled.where(fullpath: spath).first
40
+ end
41
+ end
42
+
43
+ if !page.nil? && do_redirect
44
+ redirect_to path, status: :moved_permanently
45
+ end
46
+
47
+ page
48
+ end
49
+
50
+ def find_seo_page_with_redirect(path)
51
+ do_redirect = false
52
+ if path[0] != '/'
53
+ path = '/' + path
54
+ end
55
+ if path.length > 1 && path[-1] == '/'
56
+ path = path[0..-2]
57
+ do_redirect = true
58
+ end
59
+
60
+ page = Page.enabled.any_of({fullpath: path}, {redirect: path}).first
61
+ if page.nil?
62
+ do_redirect = true
63
+ spath = path.chomp(File.extname(path))
64
+ if spath != path
65
+ page = Enjoy::Page.enabled.any_of({fullpath: spath}, {redirect: spath}).first
66
+ end
67
+ end
68
+ if !page.nil? && do_redirect
69
+ redirect_to path, status: :moved_permanently
70
+ end
71
+
72
+ page
73
+
74
+ end
75
+
76
+ def find_seo_extra(path)
77
+ nil
78
+ end
79
+
80
+ def rails_admin?
81
+ self.is_a?(RailsAdmin::ApplicationController) || self.is_a?(RailsAdmin::MainController)
82
+ end
83
+ end
@@ -0,0 +1,5 @@
1
+ module Enjoy
2
+ class ContactsController < ApplicationController
3
+ include Enjoy::Controllers::Contacts
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ module Enjoy
2
+ class HomeController < ApplicationController
3
+ def index
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Enjoy
2
+ class NewsController < ApplicationController
3
+ include Enjoy::Controllers::News
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Enjoy
2
+ class PagesController < ApplicationController
3
+ include Enjoy::Controllers::Pages
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ #todo multimodelsearch
2
+ module Enjoy
3
+ class SearchController < ApplicationController
4
+ include Enjoy::Controllers::Search
5
+ end
6
+ end
@@ -0,0 +1,27 @@
1
+ module Enjoy::GzipHelper
2
+ def gzip_javascript_include_tag(*sources)
3
+ # Grab the asset html include tag
4
+ tag = javascript_include_tag *sources
5
+
6
+ # If we are in production and the requesting client accepts gzip encoding, swap for the gzip asset
7
+ if Rails.env.production? && request.accept_encoding =~ /gzip/i
8
+ tag = tag.gsub(/\.js/i, ".js.gz")
9
+ end
10
+
11
+ # Return the asset whether or not it was modified
12
+ tag.html_safe
13
+ end
14
+
15
+ def gzip_stylesheet_link_tag(*sources)
16
+ # Grab the asset html include tag
17
+ tag = stylesheet_link_tag *sources
18
+
19
+ # If we are in production and the requesting client accepts gzip encoding, swap for the gzip asset
20
+ if Rails.env.production? && request.accept_encoding =~ /gzip/i
21
+ tag = tag.gsub(/\.css/i, ".css.gz")
22
+ end
23
+
24
+ # Return the asset whether or not it was modified
25
+ tag.html_safe
26
+ end
27
+ end
@@ -0,0 +1,12 @@
1
+ module Enjoy::PoweredHelper
2
+ def render_powered_block
3
+ content_tag :div, class: 'powered' do
4
+ ret = []
5
+ ret << content_tag(:span, class: 'powered') do
6
+ "Сайт разработан"
7
+ end
8
+ ret << link_to("Enjoy Creative studio", "http://enjoycreate.ru", class: "powered_by", target: "_blank", title: "Enjoy Creative studio")
9
+ ret.join.html_safe
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,17 @@
1
+ module Enjoy
2
+ class ContactMailer < ActionMailer::Base
3
+ def new_message_email(message)
4
+ @message = message
5
+
6
+ #if message.attachment?
7
+ # attachments[message.attachment.identifier] = File.read(message.attachment.current_path)
8
+ #end
9
+
10
+ mail(
11
+ from: Settings.default_email_from(default: 'noreply@enjoycreate.ru'),
12
+ to: Settings.form_email(default: 'admin@enjoycreate.ru'),
13
+ subject: "[#{Settings.email_topic(default: 'с сайта')}] #{message.name} #{message.email}"
14
+ )
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module Enjoy::BooleanField
2
+ extend ActiveSupport::Concern
3
+ module ClassMethods
4
+ def boolean_field(name, default = true)
5
+ if Enjoy.mongoid?
6
+ field name, type: Mongoid::Boolean, default: default
7
+ end
8
+ scope name, -> { where(name => true) }
9
+
10
+ if name == 'active'
11
+ scope :inactive, -> { where(active: false) }
12
+ elsif name == 'enabled'
13
+ scope :disabled, -> { where(enabled: false) }
14
+ end
15
+ end
16
+ end
17
+ end