hancock_cms 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (182) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +23 -0
  3. data/.rspec +1 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +113 -0
  9. data/Rakefile +1 -0
  10. data/app/assets/images/devices/login-bg.jpg +0 -0
  11. data/app/assets/images/rails-admin/hancock_logo.svg +5 -0
  12. data/app/assets/javascripts/hancock/app/back_to_top.coffee +24 -0
  13. data/app/assets/javascripts/hancock/cms.coffee +11 -0
  14. data/app/assets/javascripts/hancock/cms/flash.coffee +3 -0
  15. data/app/assets/javascripts/hancock/cms/init.coffee +1 -0
  16. data/app/assets/javascripts/hancock/cms/map.coffee +22 -0
  17. data/app/assets/javascripts/hancock/rails_admin/cms.ui.coffee +43 -0
  18. data/app/assets/javascripts/hancock/rails_admin/custom/ui.coffee +0 -0
  19. data/app/assets/javascripts/head.load.js +707 -0
  20. data/app/assets/javascripts/jquery.placeholder.js +157 -0
  21. data/app/assets/javascripts/rails_admin/custom/ui.coffee +2 -0
  22. data/app/assets/stylesheets/hancock/cms.sass +9 -0
  23. data/app/assets/stylesheets/hancock/cms/devise.sass +157 -0
  24. data/app/assets/stylesheets/hancock/cms/flash.sass +69 -0
  25. data/app/assets/stylesheets/hancock/cms/mixins.sass +98 -0
  26. data/app/assets/stylesheets/hancock/cms/normalize.scss +407 -0
  27. data/app/assets/stylesheets/hancock/cms/powered.sass +18 -0
  28. data/app/assets/stylesheets/hancock/rails_admin/cms.theming.sass +703 -0
  29. data/app/assets/stylesheets/hancock/rails_admin/custom/theming.sass +1 -0
  30. data/app/assets/stylesheets/hancock/toplink/toplink.sass +24 -0
  31. data/app/assets/stylesheets/rails_admin/custom/theming.sass +4 -0
  32. data/app/controllers/concerns/hancock/current_user.rb +12 -0
  33. data/app/controllers/concerns/hancock/decorators/home.rb +12 -0
  34. data/app/controllers/concerns/hancock/decorators/registrations.rb +5 -0
  35. data/app/controllers/concerns/hancock/decorators/sessions.rb +5 -0
  36. data/app/controllers/concerns/hancock/errors.rb +94 -0
  37. data/app/controllers/concerns/hancock/fancybox.rb +14 -0
  38. data/app/controllers/concerns/hancock/no_cache.rb +12 -0
  39. data/app/controllers/hancock/home_controller.rb +10 -0
  40. data/app/controllers/hancock/registrations_controller.rb +23 -0
  41. data/app/controllers/hancock/sessions_controller.rb +24 -0
  42. data/app/helpers/hancock/gzip_helper.rb +27 -0
  43. data/app/helpers/hancock/home_helper.rb +2 -0
  44. data/app/helpers/hancock/powered_helper.rb +42 -0
  45. data/app/models/concerns/hancock/boolean_field.rb +21 -0
  46. data/app/models/concerns/hancock/cacheable.rb +33 -0
  47. data/app/models/concerns/hancock/decorators/embedded_element.rb +28 -0
  48. data/app/models/concerns/hancock/enableable.rb +8 -0
  49. data/app/models/concerns/hancock/geocodeable.rb +4 -0
  50. data/app/models/concerns/hancock/hash_field.rb +113 -0
  51. data/app/models/concerns/hancock/html_field.rb +33 -0
  52. data/app/models/concerns/hancock/mappable.rb +91 -0
  53. data/app/models/concerns/hancock/model_localizeable.rb +33 -0
  54. data/app/models/concerns/hancock/rails_admin_patch.rb +86 -0
  55. data/app/models/concerns/hancock/sort_field.rb +20 -0
  56. data/app/models/concerns/hancock/sortable.rb +8 -0
  57. data/app/models/hancock/embedded_element.rb +17 -0
  58. data/app/views/blocks/_favicon.html.slim +60 -0
  59. data/app/views/blocks/_footer.html.slim +1 -0
  60. data/app/views/blocks/_header.html.slim +3 -0
  61. data/app/views/devise/passwords/edit.html.slim +29 -0
  62. data/app/views/devise/passwords/new.html.slim +19 -0
  63. data/app/views/devise/registrations/edit.html.slim +31 -0
  64. data/app/views/devise/registrations/new.html.slim +39 -0
  65. data/app/views/devise/sessions/new.html.slim +39 -0
  66. data/app/views/devise/shared/_links.html.slim +11 -0
  67. data/app/views/hancock/errors/_base.html.slim +3 -0
  68. data/app/views/hancock/errors/error_403.html.slim +1 -0
  69. data/app/views/hancock/errors/error_404.html.slim +1 -0
  70. data/app/views/hancock/errors/error_500.html.slim +1 -0
  71. data/app/views/hancock/home/index.html.slim +1 -0
  72. data/app/views/hancock/simple_captcha/_simple_captcha.html.slim +13 -0
  73. data/app/views/hancock/toplink/_toplink.html.slim +2 -0
  74. data/app/views/layouts/application.html.slim +35 -0
  75. data/app/views/layouts/hancock/devise/confirmations.html.slim +22 -0
  76. data/app/views/layouts/hancock/devise/passwords.html.slim +22 -0
  77. data/app/views/layouts/hancock/devise/registrations.html.slim +22 -0
  78. data/app/views/layouts/hancock/devise/sessions.html.slim +22 -0
  79. data/app/views/layouts/hancock/devise/unlocks.html.slim +22 -0
  80. data/app/views/layouts/rails_admin/_footer.html.slim +2 -0
  81. data/app/views/layouts/rails_admin/_footer_navigation.html.slim +20 -0
  82. data/app/views/layouts/rails_admin/_navigation.html.slim +73 -0
  83. data/app/views/layouts/rails_admin/_secondary_navigation.html.slim +32 -0
  84. data/app/views/layouts/rails_admin/application.html.haml +68 -0
  85. data/app/views/layouts/rails_admin/pjax.html.haml +17 -0
  86. data/app/views/rails_admin/main/_check_boxes.html.slim +27 -0
  87. data/app/views/rails_admin/main/_enum_check_boxes.html.slim +5 -0
  88. data/app/views/rails_admin/main/_enum_radio_buttons.html.slim +5 -0
  89. data/app/views/rails_admin/main/_form_hancock_multiselect.html.slim +48 -0
  90. data/app/views/rails_admin/main/_form_raw.html.slim +1 -0
  91. data/app/views/rails_admin/main/_hancock_hash.html.slim +9 -0
  92. data/app/views/rails_admin/main/_hancock_hash_ml.html.slim +10 -0
  93. data/app/views/rails_admin/main/_hancock_html.html.slim +16 -0
  94. data/app/views/rails_admin/main/_hancock_html_ml.html.slim +53 -0
  95. data/app/views/shared/_admin_link.html.slim +3 -0
  96. data/app/views/shared/_messages.html.slim +7 -0
  97. data/config/initializers/embedded_findable.rb +57 -0
  98. data/config/initializers/hancock_cms.rb +11 -0
  99. data/config/initializers/simple_captcha.rb +70 -0
  100. data/config/locales/en.hancock.yml +29 -0
  101. data/config/locales/en.hancock_admin.yml +6 -0
  102. data/config/locales/ru.cancan.yml +4 -0
  103. data/config/locales/ru.devise.yml +65 -0
  104. data/config/locales/ru.hancock.yml +36 -0
  105. data/config/locales/ru.hancock_admin.yml +6 -0
  106. data/config/locales/ru.models.yml +82 -0
  107. data/config/locales/ru.mongoid.yml +450 -0
  108. data/config/locales/ru.rails_admin.yml +168 -0
  109. data/hancock_cms.gemspec +46 -0
  110. data/lib/filename_to_slug.rb +32 -0
  111. data/lib/generators/hancock/cms/ability_generator.rb +14 -0
  112. data/lib/generators/hancock/cms/admin_generator.rb +21 -0
  113. data/lib/generators/hancock/cms/application_generator.rb +14 -0
  114. data/lib/generators/hancock/cms/assets_generator.rb +35 -0
  115. data/lib/generators/hancock/cms/config_generator.rb +13 -0
  116. data/lib/generators/hancock/cms/controllers/decorators_generator.rb +27 -0
  117. data/lib/generators/hancock/cms/gemfile_generator.rb +13 -0
  118. data/lib/generators/hancock/cms/layout_generator.rb +14 -0
  119. data/lib/generators/hancock/cms/model_generator.rb +39 -0
  120. data/lib/generators/hancock/cms/models/embedded_element_generator.rb +56 -0
  121. data/lib/generators/hancock/cms/models/templates/embedded_element.erb +47 -0
  122. data/lib/generators/hancock/cms/paperclip_optimizer_generator.rb +13 -0
  123. data/lib/generators/hancock/cms/rack_generator.rb +12 -0
  124. data/lib/generators/hancock/cms/robots_generator.rb +14 -0
  125. data/lib/generators/hancock/cms/scripts_generator.rb +31 -0
  126. data/lib/generators/hancock/cms/templates/Gemfile.erb +69 -0
  127. data/lib/generators/hancock/cms/templates/ability.erb +49 -0
  128. data/lib/generators/hancock/cms/templates/admin.erb +74 -0
  129. data/lib/generators/hancock/cms/templates/application.erb +42 -0
  130. data/lib/generators/hancock/cms/templates/assets/javascripts/application.coffee.erb +5 -0
  131. data/lib/generators/hancock/cms/templates/assets/stylesheets/application.sass.erb +88 -0
  132. data/lib/generators/hancock/cms/templates/hancock_cms.erb +30 -0
  133. data/lib/generators/hancock/cms/templates/model.erb +42 -0
  134. data/lib/generators/hancock/cms/templates/paperclip_optimizer.erb +80 -0
  135. data/lib/generators/hancock/cms/templates/rack.erb +15 -0
  136. data/lib/generators/hancock/cms/templates/robots.txt.erb +5 -0
  137. data/lib/generators/hancock/cms/templates/scripts/assets_precompile.sh +3 -0
  138. data/lib/generators/hancock/cms/templates/scripts/bundle_production.sh +4 -0
  139. data/lib/generators/hancock/cms/templates/scripts/db_dump.sh.erb +3 -0
  140. data/lib/generators/hancock/cms/templates/scripts/db_restore.sh +3 -0
  141. data/lib/generators/hancock/cms/templates/scripts/full_assets_precompile.sh +4 -0
  142. data/lib/generators/hancock/cms/templates/scripts/restart_thru_kill.sh +3 -0
  143. data/lib/generators/hancock/cms/templates/scripts/send_hup.sh +3 -0
  144. data/lib/generators/hancock/cms/templates/scripts/send_usr2.sh +3 -0
  145. data/lib/generators/hancock/cms/templates/scripts/server.sh +5 -0
  146. data/lib/generators/hancock/cms/templates/scripts/server_alt.sh +5 -0
  147. data/lib/generators/hancock/cms/templates/unicorn.erb +57 -0
  148. data/lib/generators/hancock/cms/templates/unicorn.god.erb +59 -0
  149. data/lib/generators/hancock/cms/unicorn_god_generator.rb +15 -0
  150. data/lib/generators/hancock/cms/utils.rb +21 -0
  151. data/lib/hancock/admin.rb +60 -0
  152. data/lib/hancock/admin/embedded_element.rb +26 -0
  153. data/lib/hancock/configuration.rb +48 -0
  154. data/lib/hancock/controller.rb +30 -0
  155. data/lib/hancock/engine.rb +48 -0
  156. data/lib/hancock/migration.rb +15 -0
  157. data/lib/hancock/model.rb +53 -0
  158. data/lib/hancock/models/embedded_element.rb +12 -0
  159. data/lib/hancock/models/mongoid/embedded_element.rb +14 -0
  160. data/lib/hancock/plugin.rb +25 -0
  161. data/lib/hancock/plugin_configuration.rb +30 -0
  162. data/lib/hancock/rails_admin_ext/config.rb +129 -0
  163. data/lib/hancock/rails_admin_ext/hancock_hash.rb +84 -0
  164. data/lib/hancock/rails_admin_ext/hancock_html.rb +79 -0
  165. data/lib/hancock/rails_admin_ext/hancock_multiselect.rb +44 -0
  166. data/lib/hancock/rails_admin_ext/hancock_slugs.rb +35 -0
  167. data/lib/hancock/rails_admin_ext/patches/field_patch.rb +14 -0
  168. data/lib/hancock/rails_admin_ext/patches/group_patch.rb +41 -0
  169. data/lib/hancock/rails_admin_ext/patches/hancock_cms_group.rb +61 -0
  170. data/lib/hancock/rails_admin_ext/patches/new_controller_patch.rb +54 -0
  171. data/lib/hancock/routes.rb +20 -0
  172. data/lib/hancock/simple_form_patch.rb +12 -0
  173. data/lib/hancock/tasks.rb +13 -0
  174. data/lib/hancock/version.rb +3 -0
  175. data/lib/hancock_cms.rb +130 -0
  176. data/lib/manual_slug.rb +10 -0
  177. data/lib/manual_slug/active_record.rb +32 -0
  178. data/lib/manual_slug/mongoid.rb +40 -0
  179. data/lib/rails_admin/custom_show_in_app.rb +43 -0
  180. data/release.sh +12 -0
  181. data/template.rb +564 -0
  182. metadata +455 -0
@@ -0,0 +1,24 @@
1
+ .toplink
2
+ display: block
3
+ position: fixed
4
+ bottom: 15px
5
+ right: 15px
6
+ text-align: center
7
+ font-size: 30px
8
+ line-height: 48px
9
+ height: 50px
10
+ width: 50px
11
+ border-radius: 3px
12
+ -webkit-border-radius: 3px
13
+ -moz-border-radius: 3px
14
+ z-index: 100
15
+ outline: none !important
16
+ background: rgba(0,0,0,0.3)
17
+ color: #fff !important
18
+ transform: translate3d(0,70px,0)
19
+ @include transition(all 0.3s ease-in-out)
20
+ &:hover
21
+ background: #ff2b58
22
+
23
+ .toplink.active
24
+ transform: translate3d(0,0,0)
@@ -0,0 +1,4 @@
1
+ @import hancock/cms/mixins
2
+
3
+ @import hancock/rails_admin/cms.theming
4
+ @import hancock/rails_admin/custom/theming
@@ -0,0 +1,12 @@
1
+ module Hancock::Errors
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ before_action :set_current_user
6
+
7
+ def set_current_user
8
+ User.current_user = current_user
9
+ end
10
+ end
11
+
12
+ end
@@ -0,0 +1,12 @@
1
+ module Hancock::Decorators
2
+ module Home
3
+ extend ActiveSupport::Concern
4
+
5
+ # included
6
+ # def index
7
+ # render layout: Hancock.config.main_index_layout
8
+ # end
9
+ # end
10
+
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ module Hancock::Decorators
2
+ module Registrations
3
+ extend ActiveSupport::Concern
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Hancock::Decorators
2
+ module Sessions
3
+ extend ActiveSupport::Concern
4
+ end
5
+ end
@@ -0,0 +1,94 @@
1
+ module Hancock::Errors
2
+ extend ActiveSupport::Concern
3
+ included do
4
+ if Rails.env.production? || Rails.env.staging? || (respond_to?(:hancock_check_errors) and hancock_check_errors)
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 Hancock.mongoid?
11
+ rescue_from Mongoid::Errors::DocumentNotFound, with: :render_404
12
+ rescue_from Mongoid::Errors::InvalidFind, with: :render_404
13
+ end
14
+ if Hancock.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 "__________________________".freeze
22
+ Rails.logger.error "Error 403".freeze
23
+ Rails.logger.error (params ? params.inspect : "no params data".freeze)
24
+ Rails.logger.error (current_user ? current_user.inspect : "no current_user".freeze)
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
+ if rails_admin? and can?(:access, :rails_admin)
37
+ redirect_to dashboard_path
38
+ else
39
+ redirect_to main_app.root_path, alert: t('hancock.errors.access_denied')
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+ rescue_from ActionController::InvalidAuthenticityToken do |exception|
46
+ redirect_to :back, alert: t('hancock.errors.form_expired')
47
+ end
48
+ end
49
+
50
+ private
51
+ def render_404(exception = nil)
52
+ Rails.logger.error "__________________________".freeze
53
+ Rails.logger.error "Error 404".freeze
54
+ Rails.logger.error (params ? params.inspect : "no params data".freeze)
55
+ Rails.logger.error (current_user ? current_user.inspect : "no current_user".freeze)
56
+ unless exception.nil?
57
+ Rails.logger.error exception.message
58
+ Rails.logger.error exception.backtrace.join("\n")
59
+ capture_exception(exception) if defined?(Raven)
60
+ end
61
+ Rails.logger.error "__________________________".freeze
62
+ render_error(404)
63
+ end
64
+
65
+ def render_500(exception = nil)
66
+ Rails.logger.error "__________________________".freeze
67
+ Rails.logger.error "Error 500".freeze
68
+ Rails.logger.error (params ? params.inspect : "no params data".freeze)
69
+ Rails.logger.error (current_user ? current_user.inspect : "no current_user".freeze)
70
+ unless exception.nil?
71
+ Rails.logger.error exception.message
72
+ Rails.logger.error exception.backtrace.join("\n")
73
+ capture_exception(exception) if defined?(Raven)
74
+ end
75
+ Rails.logger.error "__________________________".freeze
76
+ begin
77
+ if rails_admin?
78
+ render text: t('hancock.errors.internal_error_full', klass: exception.class.name, message: exception.message), status: 500
79
+ return
80
+ end
81
+ rescue Exception => e
82
+ puts "error while rendering rails admin exception".freeze
83
+ puts e.class.name
84
+ puts e.message
85
+ puts e.backtrace.join("\n")
86
+ end
87
+ render_error(500)
88
+ end
89
+
90
+ def render_error(code = 500)
91
+ render template: "hancock/errors/error_#{code}", formats: [:html], handlers: [:slim], layout: Hancock.config.error_layout, status: code
92
+ end
93
+
94
+ end
@@ -0,0 +1,14 @@
1
+ module Hancock::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,12 @@
1
+ module Hancock::NoCache
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,10 @@
1
+ module Hancock
2
+ class HomeController < ApplicationController
3
+
4
+ def index
5
+ render layout: Hancock.config.main_index_layout
6
+ end
7
+
8
+ include Hancock::Decorators::Home
9
+ end
10
+ end
@@ -0,0 +1,23 @@
1
+ class Hancock::RegistrationsController < Devise::RegistrationsController
2
+ prepend_before_action :check_recaptcha, only: [:create]
3
+
4
+ private
5
+ def check_recaptcha
6
+ if Hancock.config.recaptcha_support and (!Rails.env.development? or Hancock.config.captcha_on_development)
7
+ if verify_recaptcha
8
+ true
9
+ else
10
+ self.resource = resource_class.new sign_up_params
11
+ self.resource.valid?
12
+ @recaptcha_error = "Вы робот?".freeze
13
+ respond_with_navigational(resource) { render :new }
14
+ end
15
+
16
+ else
17
+ true
18
+ end
19
+ end
20
+
21
+ include Hancock::Decorators::Registrations
22
+
23
+ end
@@ -0,0 +1,24 @@
1
+ class Hancock::SessionsController < Devise::SessionsController
2
+ prepend_before_action :check_recaptcha, only: [:create]
3
+
4
+ private
5
+ def check_recaptcha
6
+ if Hancock.config.recaptcha_support and (!Rails.env.development? or Hancock.config.captcha_on_development)
7
+ if verify_recaptcha
8
+ true
9
+ else
10
+ self.resource = resource_class.new sign_in_params
11
+ resource.errors.add(:email, "Неверный e-mail или пароль".freeze)
12
+ resource.errors.add(:password, "Неверный e-mail или пароль".freeze)
13
+ @recaptcha_error = "Вы робот?".freeze
14
+ respond_with_navigational(resource) { render :new }
15
+ end
16
+
17
+ else
18
+ true
19
+ end
20
+ end
21
+
22
+ include Hancock::Decorators::Sessions
23
+
24
+ end
@@ -0,0 +1,27 @@
1
+ module Hancock::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,2 @@
1
+ module Hancock::HomeHelper
2
+ end
@@ -0,0 +1,42 @@
1
+ module Hancock::PoweredHelper
2
+
3
+ # TODO CMS site block
4
+ # def render_hancock_powered_on_block
5
+ # content_tag :div, class: 'hancock-powered-on' do
6
+ # ret = []
7
+ # ret << content_tag(:span, class: 'powered-on') do
8
+ # "Сайт работает на "
9
+ # end
10
+ # _attrs = {
11
+ # class: "powered_on",
12
+ # target: "_blank",
13
+ # title: "Hancock CMS",
14
+ # data: {
15
+ # "hancock-goto-disabled": true
16
+ # }
17
+ # }
18
+ # ret << link_to("Hancock CMS", "http://hancock.redrocks.pro/", _attrs)
19
+ # ret.join.html_safe
20
+ # end
21
+ # end
22
+
23
+ def render_hancock_created_by_block
24
+ content_tag :div, class: 'hancock-created-by' do
25
+ ret = []
26
+ ret << content_tag(:span, class: 'created-by') do
27
+ "Сайт разработан".freeze
28
+ end
29
+ _attrs = {
30
+ class: "created_by",
31
+ target: "_blank",
32
+ title: "Hancock Creative studio",
33
+ data: {
34
+ "hancock-goto-disabled": true
35
+ }
36
+ }.freeze
37
+ ret << link_to("Redrocks studio".freeze, "http://redrocks.pro/".freeze, _attrs)
38
+ ret.join.html_safe
39
+ end
40
+ end
41
+
42
+ end
@@ -0,0 +1,21 @@
1
+ module Hancock::BooleanField
2
+ extend ActiveSupport::Concern
3
+ module ClassMethods
4
+ def boolean_field(name, default = true)
5
+ if default.is_a?(Hash)
6
+ default = default[:default]
7
+ end
8
+
9
+ if Hancock.mongoid?
10
+ field name, type: Mongoid::Boolean, default: default
11
+ end
12
+ scope name, -> { where(name => true) }
13
+
14
+ if name == 'active'
15
+ scope :inactive, -> { where(active: false) }
16
+ elsif name == 'enabled'
17
+ scope :disabled, -> { where(enabled: false) }
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,33 @@
1
+ if Hancock.mongoid?
2
+
3
+ module Hancock::Cacheable
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ field :cache_keys_str, type: String, default: -> { default_cache_keys.join("\n") }
8
+ def self.default_cache_keys
9
+ []
10
+ end
11
+ def default_cache_keys
12
+ self.class.default_cache_keys
13
+ end
14
+
15
+ def cache_keys
16
+ cache_keys_str.split(/\s+/).map { |k| k.strip }.reject { |k| k.blank? }
17
+ end
18
+ field :perform_caching, type: Boolean, default: true
19
+
20
+ after_save :clear_cache
21
+ after_destroy :clear_cache
22
+ def clear_cache
23
+ if perform_caching
24
+ cache_keys.each do |k|
25
+ Rails.cache.delete(k)
26
+ end
27
+ end
28
+ end
29
+
30
+ end
31
+ end
32
+
33
+ end
@@ -0,0 +1,28 @@
1
+ module Hancock::Decorators
2
+ module EmbeddedElement
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+
7
+ # def image_styles
8
+ # super
9
+ # end
10
+ #
11
+ # def image_jcrop_options
12
+ # super
13
+ # end
14
+ #
15
+ # ############# rails_admin ##############
16
+ # def self.rails_admin_add_fields
17
+ # [] #super
18
+ # end
19
+ #
20
+ # def self.rails_admin_add_config(config)
21
+ # #super(config)
22
+ # end
23
+
24
+ end
25
+
26
+
27
+ end
28
+ end
@@ -0,0 +1,8 @@
1
+ module Hancock::Enableable
2
+ extend ActiveSupport::Concern
3
+ include Hancock::BooleanField
4
+
5
+ included do
6
+ boolean_field(:enabled)
7
+ end
8
+ end
@@ -0,0 +1,4 @@
1
+ module Hancock::Geocodeable
2
+ extend ActiveSupport::Concern
3
+ include Hancock::Mappable
4
+ end