caboose-cms 0.9.229 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/app/assets/javascripts/caboose/admin.js +1 -1
- data/app/assets/javascripts/caboose/admin/application.js +20 -0
- data/app/assets/javascripts/caboose/admin_main.js +13 -3
- data/app/assets/javascripts/caboose/admin_media_index.js +158 -161
- data/app/assets/javascripts/caboose/application.js +7 -8
- data/app/assets/javascripts/caboose/block_content_controller_dragdrop.js +4 -60
- data/app/assets/javascripts/caboose/block_modal_controllers/block_dd_modal_controller.js +2 -3
- data/app/assets/javascripts/caboose/block_modal_controllers/media_modal_controller.js +6 -17
- data/app/assets/javascripts/caboose/model/all.js +1 -5
- data/app/assets/stylesheets/caboose/admin/_config.scss +102 -0
- data/app/assets/stylesheets/caboose/admin/application.css +11 -0
- data/app/assets/stylesheets/caboose/admin/component.css +183 -0
- data/app/assets/stylesheets/caboose/admin/froala.min.css +91 -0
- data/app/assets/stylesheets/caboose/admin/ie.scss +67 -0
- data/app/assets/stylesheets/caboose/admin/integrations/main.scss +6 -0
- data/app/assets/stylesheets/caboose/admin/integrations/shopify.scss +128 -0
- data/app/assets/stylesheets/caboose/admin/jquery-ui-subnav-theme.min.css +5 -0
- data/app/assets/stylesheets/caboose/admin/layout.scss +150 -0
- data/app/assets/stylesheets/caboose/admin/main.scss +34 -0
- data/app/assets/stylesheets/caboose/admin/modules/body.scss +176 -0
- data/app/assets/stylesheets/caboose/admin/modules/buttons.scss +120 -0
- data/app/assets/stylesheets/caboose/admin/modules/countdown.css +21 -0
- data/app/assets/stylesheets/caboose/admin/modules/crumbtrail.scss +80 -0
- data/app/assets/stylesheets/caboose/admin/modules/data_table.scss +92 -0
- data/app/assets/stylesheets/caboose/admin/modules/footer.scss +62 -0
- data/app/assets/stylesheets/caboose/admin/modules/forms.scss +72 -0
- data/app/assets/stylesheets/caboose/admin/modules/functions.scss +31 -0
- data/app/assets/stylesheets/caboose/admin/modules/grid.scss +108 -0
- data/app/assets/stylesheets/caboose/admin/modules/header.scss +77 -0
- data/app/assets/stylesheets/caboose/admin/modules/headings.scss +38 -0
- data/app/assets/stylesheets/caboose/admin/modules/main_nav.scss +73 -0
- data/app/assets/stylesheets/caboose/admin/modules/message_boxes.scss +55 -0
- data/app/assets/stylesheets/caboose/admin/modules/model_binder.scss +189 -0
- data/app/assets/stylesheets/caboose/admin/modules/navigation.scss +261 -0
- data/app/assets/stylesheets/caboose/admin/modules/order_bumps.scss +57 -0
- data/app/assets/stylesheets/caboose/admin/modules/pager.scss +34 -0
- data/app/assets/stylesheets/caboose/admin/modules/product_images.scss +21 -0
- data/app/assets/stylesheets/caboose/admin/modules/products.css +86 -0
- data/app/assets/stylesheets/caboose/admin/modules/search.scss +49 -0
- data/app/assets/stylesheets/caboose/admin/modules/selects.scss +12 -0
- data/app/assets/stylesheets/caboose/admin/modules/subnav_tabs.scss +34 -0
- data/app/assets/stylesheets/caboose/admin/modules/tabs.scss +140 -0
- data/app/assets/stylesheets/caboose/admin/page_edit/block_anchors.scss +48 -0
- data/app/assets/stylesheets/caboose/admin/page_edit/block_overlays.scss +182 -0
- data/app/assets/stylesheets/caboose/admin/page_edit/device_selector.scss +65 -0
- data/app/assets/stylesheets/caboose/admin/page_edit/froala.scss +81 -0
- data/app/assets/stylesheets/caboose/admin/page_edit/group_overlay.scss +115 -0
- data/app/assets/stylesheets/caboose/admin/page_edit/layout.scss +128 -0
- data/app/assets/stylesheets/caboose/admin/page_edit/main.scss +18 -0
- data/app/assets/stylesheets/caboose/admin/page_edit/modal.scss +11 -0
- data/app/assets/stylesheets/caboose/admin/page_edit/preview.scss +25 -0
- data/app/assets/stylesheets/caboose/admin/page_edit/publish.scss +25 -0
- data/app/assets/stylesheets/caboose/admin/page_edit/revisions.scss +58 -0
- data/app/assets/stylesheets/caboose/admin/page_edit/subnav.scss +273 -0
- data/app/assets/stylesheets/caboose/admin/page_edit/top_nav.scss +109 -0
- data/app/assets/stylesheets/caboose/admin/pages/assets_index.css +48 -0
- data/app/assets/stylesheets/caboose/admin/pages/block_edit_image.css.scss +386 -0
- data/app/assets/stylesheets/caboose/admin/pages/media_index.css.scss +300 -0
- data/app/assets/stylesheets/caboose/admin/pages/new_block.css +9 -0
- data/app/assets/stylesheets/caboose/admin/pages/page_edit.scss +960 -0
- data/app/assets/stylesheets/caboose/admin/pages/page_edit_content.scss +103 -0
- data/app/assets/stylesheets/caboose/admin/pages/pages_index.scss +79 -0
- data/app/assets/stylesheets/caboose/admin/pages/post_edit_content.css +46 -0
- data/app/assets/stylesheets/caboose/admin/print.css +3 -0
- data/app/assets/stylesheets/caboose/admin/slack.scss +51 -0
- data/app/assets/stylesheets/caboose/admin_block_edit_image.css.scss +1 -2
- data/app/assets/stylesheets/caboose/admin_edit_page_content_dragdrop.scss +15 -71
- data/app/assets/stylesheets/caboose/admin_main.css.scss +29 -25
- data/app/assets/stylesheets/caboose/admin_media_index.css.scss +5 -26
- data/app/assets/stylesheets/caboose/application.css +5 -11
- data/app/assets/stylesheets/caboose/login.scss +0 -1
- data/app/assets/stylesheets/caboose/modal_main.css +19 -21
- data/app/assets/stylesheets/caboose/model_binder.css +4 -13
- data/app/assets/stylesheets/caboose/page_bar_generator.css +1 -2
- data/app/controllers/caboose/admin_controller.rb +4 -3
- data/app/controllers/caboose/application_controller.rb +19 -16
- data/app/controllers/caboose/assets_controller.rb +65 -0
- data/app/controllers/caboose/block_types_controller.rb +6 -8
- data/app/controllers/caboose/cart_controller.rb +2 -2
- data/app/controllers/caboose/fonts_controller.rb +2 -139
- data/app/controllers/caboose/invoices_controller.rb +4 -5
- data/app/controllers/caboose/login_logs_controller.rb +7 -5
- data/app/controllers/caboose/media_categories_controller.rb +2 -16
- data/app/controllers/caboose/media_controller.rb +11 -14
- data/app/controllers/caboose/pages_controller.rb +42 -104
- data/app/controllers/caboose/posts_controller.rb +7 -53
- data/app/controllers/caboose/products_controller.rb +1 -1
- data/app/controllers/caboose/sites_controller.rb +6 -25
- data/app/controllers/caboose/sns_controller.rb +3 -3
- data/app/controllers/caboose/themes_controller.rb +0 -30
- data/app/controllers/caboose/users_controller.rb +10 -17
- data/app/controllers/caboose/variants_controller.rb +9 -9
- data/app/models/caboose/ab_variant.rb +1 -1
- data/app/models/caboose/asset.rb +23 -0
- data/app/models/caboose/asset_manager.rb +92 -0
- data/app/models/caboose/asset_manifest.rb +91 -0
- data/app/models/caboose/block.rb +24 -100
- data/app/models/caboose/block_cache.rb +105 -0
- data/app/models/caboose/block_cache_file.rb +22 -0
- data/app/models/caboose/block_cache_image.rb +53 -0
- data/app/models/caboose/block_type.rb +3 -4
- data/app/models/caboose/block_type_category.rb +2 -2
- data/app/models/caboose/block_type_parser.rb +1 -1
- data/app/models/caboose/block_type_source.rb +2 -2
- data/app/models/caboose/calendar_event_group.rb +2 -2
- data/app/models/caboose/category.rb +2 -2
- data/app/models/caboose/comment_routes.rb +8 -7
- data/app/models/caboose/core_plugin.rb +3 -4
- data/app/models/caboose/export.rb +1 -1
- data/app/models/caboose/font.rb +2 -7
- data/app/models/caboose/font_variant.rb +0 -12
- data/app/models/caboose/invoice.rb +14 -14
- data/app/models/caboose/line_item.rb +4 -4
- data/app/models/caboose/media.rb +4 -15
- data/app/models/caboose/media_category.rb +7 -5
- data/app/models/caboose/modification.rb +2 -2
- data/app/models/caboose/page.rb +54 -325
- data/app/models/caboose/page_bar_generator.rb +10 -20
- data/app/models/caboose/page_cache.rb +12 -0
- data/app/models/caboose/page_cacher.rb +137 -0
- data/app/models/caboose/post.rb +8 -108
- data/app/models/caboose/product.rb +5 -5
- data/app/models/caboose/product_image.rb +1 -1
- data/app/models/caboose/role.rb +2 -2
- data/app/models/caboose/schema.rb +72 -73
- data/app/models/caboose/site.rb +1 -203
- data/app/models/caboose/theme.rb +5 -70
- data/app/views/caboose/admin/_content.html.erb +44 -0
- data/app/views/caboose/admin/_fonts.html.erb +47 -0
- data/app/views/caboose/admin/_footer.html.erb +1 -0
- data/app/views/caboose/admin/_header.html.erb +12 -0
- data/app/views/caboose/admin/_icons.html.erb +6 -0
- data/app/views/caboose/admin/_mobile_navigation.html.erb +22 -0
- data/app/views/caboose/admin/_post.html.erb +74 -0
- data/app/views/caboose/admin/index.html.erb +33 -36
- data/app/views/caboose/block_types/admin_edit.html.erb +8 -6
- data/app/views/caboose/blocks/_file.html.erb +2 -2
- data/app/views/caboose/blocks/_ga.html.erb +2 -1
- data/app/views/caboose/blocks/_image.html.erb +0 -4
- data/app/views/caboose/blocks/_render_function.html.erb +4 -9
- data/app/views/caboose/fonts/admin_index.html.erb +10 -55
- data/app/views/caboose/invoices_mailer/customer_status_updated.html.erb +14 -5
- data/app/views/caboose/login_logs/admin_index_for_user.html.erb +1 -1
- data/app/views/caboose/media/admin_index.html.erb +24 -14
- data/app/views/caboose/my_account/index.html.erb +0 -1
- data/app/views/caboose/pages/_admin_header.html.erb +0 -5
- data/app/views/caboose/pages/admin_edit_content.html.erb +2 -6
- data/app/views/caboose/pages/admin_edit_general.html.erb +4 -32
- data/app/views/caboose/pages/admin_new_old.html.erb +46 -0
- data/app/views/caboose/pages/test.html.erb +64 -0
- data/app/views/caboose/posts/_admin_header.html.erb +0 -5
- data/app/views/caboose/posts/admin_delete_form.html.erb +1 -1
- data/app/views/caboose/posts/admin_edit_content.html.erb +2 -6
- data/app/views/caboose/products/admin_group_variants.html.erb +1 -1
- data/app/views/caboose/products/admin_sort.html copy.erb +1 -1
- data/app/views/caboose/sites/admin_edit.html.erb +0 -21
- data/app/views/caboose/themes/admin_edit.html.erb +3 -7
- data/app/views/caboose/users/_admin_header.html.erb +0 -4
- data/app/views/caboose/users/admin_edit_roles.html.erb +0 -1
- data/app/views/caboose/variants/admin_group.html.erb +1 -1
- data/app/views/layouts/caboose/admin.html.erb +2 -9
- data/app/views/layouts/caboose/application.html.erb +92 -62
- data/config/routes.rb +1 -4
- data/lib/caboose/version.rb +1 -1
- data/lib/tasks/caboose.rake +14 -3
- metadata +238 -57
- data/app/controllers/caboose/change_logs_controller.rb +0 -13
- data/app/models/caboose/change_log.rb +0 -97
- data/app/views/caboose/blocks/_cached_block.html.erb +0 -28
- data/app/views/caboose/change_logs/admin_index.html.erb +0 -65
- data/app/views/caboose/fonts/admin_family_edit.html.erb +0 -63
- data/app/views/caboose/fonts/admin_family_index.html.erb +0 -42
- data/app/views/caboose/fonts/admin_variant_edit.html.erb +0 -84
- data/app/views/caboose/pages/admin_change_logs.html.erb +0 -56
- data/app/views/caboose/pages/compiled_asset.css.erb +0 -0
- data/app/views/caboose/pages/compiled_asset.js.erb +0 -0
- data/app/views/caboose/posts/admin_change_logs.html.erb +0 -56
- data/app/views/caboose/sites/compiled_asset.css.erb +0 -0
- data/app/views/caboose/sites/compiled_asset.js.erb +0 -0
- data/app/views/caboose/themes/admin_error_log.html.erb +0 -9
- data/app/views/caboose/themes/admin_js.html.erb +0 -131
- data/app/views/caboose/users/admin_change_logs.html.erb +0 -63
- data/app/views/layouts/caboose/css.css.erb +0 -44
- data/app/views/layouts/caboose/footer_css.css.erb +0 -41
- data/app/views/layouts/caboose/footer_js.js.erb +0 -31
- data/app/views/layouts/caboose/js.js.erb +0 -34
@@ -0,0 +1,91 @@
|
|
1
|
+
module Caboose
|
2
|
+
class AssetManifest
|
3
|
+
|
4
|
+
#@@bucket = nil
|
5
|
+
#
|
6
|
+
#def AssetManifest.bucket
|
7
|
+
# if @@bucket.nil?
|
8
|
+
# config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
|
9
|
+
# AWS.config({ :access_key_id => config['access_key_id'], :secret_access_key => config['secret_access_key'] })
|
10
|
+
# @@bucket = AWS::S3::Bucket.new(config['bucket'])
|
11
|
+
# end
|
12
|
+
# return @@bucket
|
13
|
+
#end
|
14
|
+
#
|
15
|
+
#def AssetManifest.save_asset(path, str, reset = true)
|
16
|
+
#
|
17
|
+
# file = self.bucket.objects[path]
|
18
|
+
# return { :error => "Can't find file." } if file.nil?
|
19
|
+
#
|
20
|
+
# # Save the contents into the source file
|
21
|
+
# return { :error => "Can't write to file." } if !file.write(str)
|
22
|
+
#
|
23
|
+
# # Compile the file
|
24
|
+
# str_compiled = ''
|
25
|
+
# begin
|
26
|
+
# str_compiled = Uglifier.compile(str)
|
27
|
+
# rescue Exception => e
|
28
|
+
# return { :error => e.message }
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# # Compute the digest for the compiled file
|
32
|
+
# # Note: digest must be generated with environment set to 'production' (sprockets changes digests per environment)
|
33
|
+
# digest = Rails.application.assets.file_digest('/Users/william/Sites/caboosecms.com/sites/benttree/images/icons/loading.gif')
|
34
|
+
# digest = Rails.application.assets.digest.hexdigest(str_compiled)
|
35
|
+
# digest = Digest::SHA2.hexdigest(str_compiled)
|
36
|
+
#
|
37
|
+
# # See if the digest file for the compiled file exists
|
38
|
+
# digest_path = self.path_with_digest(path, digest)
|
39
|
+
# if self.bucket.objects[digest_path].exists?
|
40
|
+
# digest_file = bucket.objects[digest_path]
|
41
|
+
# digest_file.write(str_compiled)
|
42
|
+
# end
|
43
|
+
#
|
44
|
+
# # See if the digest is in the manifest
|
45
|
+
# manifest = self.bucket.objects['assets/manifest.yml']
|
46
|
+
# exists = false
|
47
|
+
# changed = false
|
48
|
+
# new_lines = []
|
49
|
+
# manifest.read.split("\n").each do|line|
|
50
|
+
# if line.starts_with?("#{path}: ")
|
51
|
+
# exists = true
|
52
|
+
# changed = true if line != "#{path}: #{digest_path}"
|
53
|
+
# new_lines << "#{path}: #{digest_path}"
|
54
|
+
# else
|
55
|
+
# new_lines << line
|
56
|
+
# end
|
57
|
+
# end
|
58
|
+
# if !exists
|
59
|
+
# new_lines << "#{path}: #{digest_path}"
|
60
|
+
# changed = true
|
61
|
+
# end
|
62
|
+
#
|
63
|
+
# # If the digest has changed, update the manifest and set the app asset digests
|
64
|
+
# if changed
|
65
|
+
# manifest.write(new_lines.join("\n"))
|
66
|
+
# self.reset_asset_digests(new_lines) if reset
|
67
|
+
# end
|
68
|
+
#
|
69
|
+
# return { :sucess => true }
|
70
|
+
#end
|
71
|
+
#
|
72
|
+
#def AssetManifest.reset_asset_digests(lines = nil)
|
73
|
+
# lines = self.bucket.objects['assets/manifest.yml'].read.split("\n") if lines.nil?
|
74
|
+
# lines.each do|line|
|
75
|
+
# arr = line.split(": ")
|
76
|
+
# Rails.application.config.assets.digests[arr[0]] = arr[1]
|
77
|
+
# end
|
78
|
+
#end
|
79
|
+
#
|
80
|
+
#def AssetManifest.path_with_digest(path, digest)
|
81
|
+
# arr = path.split('/')
|
82
|
+
# filename = arr.pop
|
83
|
+
# filename = filename.split('.')
|
84
|
+
# ext = filename.pop
|
85
|
+
# filename = "#{filename.join('.')}-#{digest}.#{ext}"
|
86
|
+
# return filename if arr.count == 0
|
87
|
+
# return "#{arr.join('/')}/#{filename}"
|
88
|
+
#end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
data/app/models/caboose/block.rb
CHANGED
@@ -9,8 +9,8 @@ class Caboose::Block < ActiveRecord::Base
|
|
9
9
|
belongs_to :page
|
10
10
|
belongs_to :media
|
11
11
|
belongs_to :block_type
|
12
|
-
belongs_to :parent, :foreign_key => 'parent_id', :class_name => 'Caboose::Block'
|
13
|
-
has_many :children, :foreign_key => 'parent_id', :class_name => 'Caboose::Block', :
|
12
|
+
belongs_to :parent, :foreign_key => 'parent_id', :class_name => 'Caboose::Block'
|
13
|
+
has_many :children, -> { order(:sort_order) }, :foreign_key => 'parent_id', :class_name => 'Caboose::Block', :dependent => :delete_all
|
14
14
|
has_attached_file :file, :path => ':caboose_prefixuploads/:block_file_upload_name.:extension'
|
15
15
|
do_not_validate_attachment_file_type :file
|
16
16
|
has_attached_file :image,
|
@@ -39,11 +39,7 @@ class Caboose::Block < ActiveRecord::Base
|
|
39
39
|
:new_parent_id,
|
40
40
|
:new_sort_order,
|
41
41
|
:new_value,
|
42
|
-
:new_media_id
|
43
|
-
:cached_value,
|
44
|
-
:cached_css,
|
45
|
-
:cached_js,
|
46
|
-
:use_cache
|
42
|
+
:new_media_id
|
47
43
|
|
48
44
|
after_initialize :caste_value
|
49
45
|
before_save :caste_value
|
@@ -62,82 +58,6 @@ class Caboose::Block < ActiveRecord::Base
|
|
62
58
|
return self.name if parent_id.nil?
|
63
59
|
return "#{parent.full_name}_#{self.name}"
|
64
60
|
end
|
65
|
-
|
66
|
-
def cached_ancestor
|
67
|
-
begin
|
68
|
-
page_or_post = self.page ? self.page : self.post
|
69
|
-
content = page_or_post.block.child('content')
|
70
|
-
index_page = Caboose::Page.index_page(page_or_post.site_id)
|
71
|
-
footer = index_page.block.child('footer')
|
72
|
-
return Caboose::Block.cached_ancestor_helper(self, content.id, footer.id)
|
73
|
-
rescue
|
74
|
-
return nil
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def self.cached_ancestor_helper(b, content_id, footer_id)
|
79
|
-
if b.block_type && b.name.nil? && !b.block_type.is_dynamic && (b.parent_id == content_id || b.parent_id == footer_id)
|
80
|
-
return b.id
|
81
|
-
elsif b.parent
|
82
|
-
return cached_ancestor_helper(b.parent, content_id, footer_id)
|
83
|
-
else
|
84
|
-
return nil
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def has_dynamic_descendant
|
89
|
-
return Caboose::Block.descendant_helper(self)
|
90
|
-
end
|
91
|
-
|
92
|
-
def self.descendant_helper(block)
|
93
|
-
return true if block.block_type.nil? || block.block_type.is_dynamic
|
94
|
-
is_dynamic = false
|
95
|
-
block.children.where("name is null OR name ILIKE ?","%_column").each do |b|
|
96
|
-
is_dynamic = Caboose::Block.descendant_helper(b)
|
97
|
-
return true if is_dynamic == true
|
98
|
-
end
|
99
|
-
return is_dynamic
|
100
|
-
end
|
101
|
-
|
102
|
-
def update_cache
|
103
|
-
par = self.parent
|
104
|
-
hdd = self.has_dynamic_descendant
|
105
|
-
if par && self.block_type && self.name.blank? && !self.block_type.is_dynamic && !hdd
|
106
|
-
opts = {
|
107
|
-
:view => nil,
|
108
|
-
:controller_view_content => nil,
|
109
|
-
:modal => false,
|
110
|
-
:empty_text => '',
|
111
|
-
:editing => false,
|
112
|
-
:css => nil,
|
113
|
-
:js => nil,
|
114
|
-
:csrf_meta_tags => nil,
|
115
|
-
:csrf_meta_tags2 => nil,
|
116
|
-
:logged_in_user => nil,
|
117
|
-
:page => self.page,
|
118
|
-
:post => self.post,
|
119
|
-
:site => self.page ? self.page.site : self.post.site,
|
120
|
-
:is_cache => true,
|
121
|
-
:protocol => "https://"
|
122
|
-
}
|
123
|
-
str = par.render(self, opts)
|
124
|
-
host = Rails.env.production? ? "https://#{ActionController::Base.asset_host}" : ""
|
125
|
-
self.cached_value = str.blank? ? '' : str.gsub('"/assets/',"\"#{host}/assets/")
|
126
|
-
self.use_cache = true
|
127
|
-
elsif self.block_type && !self.block_type.is_dynamic && self.children && self.children.count > 0 && hdd # Try caching the children
|
128
|
-
self.cached_value = nil
|
129
|
-
self.cached_css = nil
|
130
|
-
self.cached_js = nil
|
131
|
-
self.children.where(:name => nil).each do |child|
|
132
|
-
child.delay(:queue => 'caching', :priority => 6).update_cache
|
133
|
-
end
|
134
|
-
elsif hdd
|
135
|
-
self.cached_value = nil
|
136
|
-
self.cached_css = nil
|
137
|
-
self.cached_js = nil
|
138
|
-
end
|
139
|
-
self.save
|
140
|
-
end
|
141
61
|
|
142
62
|
def child_value(name)
|
143
63
|
b = self.child(name)
|
@@ -150,6 +70,8 @@ class Caboose::Block < ActiveRecord::Base
|
|
150
70
|
return b.media.file if b.media
|
151
71
|
return b.file
|
152
72
|
end
|
73
|
+
#return b.image if b.block_type.field_type == 'image'
|
74
|
+
#return b.file if b.block_type.field_type == 'file'
|
153
75
|
return b.value
|
154
76
|
end
|
155
77
|
|
@@ -231,8 +153,11 @@ class Caboose::Block < ActiveRecord::Base
|
|
231
153
|
end
|
232
154
|
end
|
233
155
|
|
234
|
-
def render(block, options)
|
156
|
+
def render(block, options)
|
157
|
+
#Caboose.log("block.full_name = #{block.full_name}")
|
158
|
+
#Caboose.log("block.render\nself.id = #{self.id}\nblock = #{block}\nblock.full_name = #{block.full_name}\noptions.class = #{options.class}\noptions = #{options}")
|
235
159
|
if block && block.is_a?(String)
|
160
|
+
#Caboose.log("Block #{block} is a string, finding block object... self.id = #{self.id}")
|
236
161
|
b = self.child(block)
|
237
162
|
if b.nil?
|
238
163
|
self.create_children
|
@@ -256,14 +181,14 @@ class Caboose::Block < ActiveRecord::Base
|
|
256
181
|
:js => nil,
|
257
182
|
:csrf_meta_tags => nil,
|
258
183
|
:csrf_meta_tags2 => nil,
|
259
|
-
:logged_in_user => nil
|
260
|
-
:is_cache => false
|
184
|
+
:logged_in_user => nil
|
261
185
|
}
|
262
|
-
|
186
|
+
#defaults = { :modal => false, :empty_text => '', :editing => false, :css => nil, :js => nil, :block => block }
|
263
187
|
options2 = nil
|
264
188
|
if options.is_a?(Hash)
|
265
189
|
options2 = defaults.merge(options)
|
266
190
|
else
|
191
|
+
#options2 = { :modal => options.modal, :empty_text => options.empty_text, :editing => options.editing, :css => options.css, :js => options.js }
|
267
192
|
options2 = {
|
268
193
|
:view => options.view ? options.view : nil,
|
269
194
|
:controller_view_content => options.controller_view_content ? options.controller_view_content : nil,
|
@@ -274,15 +199,11 @@ class Caboose::Block < ActiveRecord::Base
|
|
274
199
|
:js => options.js ? options.js : nil,
|
275
200
|
:csrf_meta_tags => options.csrf_meta_tags ? options.csrf_meta_tags : nil,
|
276
201
|
:csrf_meta_tags2 => options.csrf_meta_tags2 ? options.csrf_meta_tags2 : nil,
|
277
|
-
:logged_in_user => options.logged_in_user ? options.logged_in_user : nil
|
278
|
-
:is_cache => options.is_cache ? options.is_cache : nil
|
202
|
+
:logged_in_user => options.logged_in_user ? options.logged_in_user : nil
|
279
203
|
}
|
280
204
|
end
|
281
205
|
options2[:block] = block
|
282
206
|
|
283
|
-
pop = block.page ? block.page : block.post
|
284
|
-
return block.cached_value if block && pop && pop.site && pop.site.use_caching && block.use_cache && !block.cached_value.blank? && block.block_type && !block.block_type.is_dynamic && !options2[:is_cache] && (options2[:editing] == false || (pop && pop.is_published))
|
285
|
-
|
286
207
|
view = options2[:view]
|
287
208
|
view = ActionView::Base.new(ActionController::Base.view_paths) if view.nil?
|
288
209
|
|
@@ -306,7 +227,7 @@ class Caboose::Block < ActiveRecord::Base
|
|
306
227
|
block.block_type.latest_error = "#{msg}#{ex.message}\n#{ex.backtrace.join("\n")}"
|
307
228
|
block.block_type.save
|
308
229
|
end
|
309
|
-
end
|
230
|
+
end
|
310
231
|
else
|
311
232
|
|
312
233
|
full_name = block.block_type.full_name
|
@@ -356,9 +277,12 @@ class Caboose::Block < ActiveRecord::Base
|
|
356
277
|
return "<p class='note error'>Could not find block view anywhere.</p>" if i > arr.count
|
357
278
|
begin
|
358
279
|
str = view.render(:partial => arr[i], :locals => options)
|
359
|
-
|
280
|
+
# Caboose.log("Level #{i+1} for #{full_name}: Found partial #{arr[i]}")
|
281
|
+
rescue ActionView::MissingTemplate => ex
|
282
|
+
# Caboose.log("Level #{i+1} for #{full_name}: #{ex.message}")
|
360
283
|
str = render_helper(view, options, block, full_name, arr, i+1)
|
361
|
-
rescue Exception => ex
|
284
|
+
rescue Exception => ex
|
285
|
+
# Caboose.log("Level #{i+1} for #{full_name}: #{ex.message}")
|
362
286
|
str = "<p class='note error'>#{self.block_message(block, ex)}</p>"
|
363
287
|
end
|
364
288
|
return str
|
@@ -375,7 +299,8 @@ class Caboose::Block < ActiveRecord::Base
|
|
375
299
|
end
|
376
300
|
|
377
301
|
def render_from_function(options)
|
378
|
-
self.create_children
|
302
|
+
self.create_children
|
303
|
+
#locals = OpenStruct.new(:block => self, :empty_text => empty_text, :editing => editing)
|
379
304
|
locals = OpenStruct.new(options)
|
380
305
|
erb = ERB.new(block_type.render_function)
|
381
306
|
return erb.result(locals.instance_eval { binding })
|
@@ -392,13 +317,13 @@ class Caboose::Block < ActiveRecord::Base
|
|
392
317
|
:js => nil,
|
393
318
|
:csrf_meta_tags => nil,
|
394
319
|
:csrf_meta_tags2 => nil,
|
395
|
-
:logged_in_user => nil
|
396
|
-
:is_cache => false
|
320
|
+
:logged_in_user => nil
|
397
321
|
}
|
398
322
|
options2 = nil
|
399
323
|
if options.is_a?(Hash)
|
400
324
|
options2 = defaults.merge(options)
|
401
325
|
else
|
326
|
+
#options2 = { :modal => options.modal, :empty_text => options.empty_text, :editing => options.editing, :css => options.css, :js => options.js }
|
402
327
|
options2 = {
|
403
328
|
:view => options.view ? options.view : nil,
|
404
329
|
:controller_view_content => options.controller_view_content ? options.controller_view_content : nil,
|
@@ -409,8 +334,7 @@ class Caboose::Block < ActiveRecord::Base
|
|
409
334
|
:js => options.js ? options.js : nil,
|
410
335
|
:csrf_meta_tags => options.csrf_meta_tags ? options.csrf_meta_tags : nil,
|
411
336
|
:csrf_meta_tags2 => options.csrf_meta_tags2 ? options.csrf_meta_tags2 : nil,
|
412
|
-
:logged_in_user => options.logged_in_user ? options.logged_in_user : nil
|
413
|
-
:is_cache => options.is_cache ? options.is_cache : nil
|
337
|
+
:logged_in_user => options.logged_in_user ? options.logged_in_user : nil
|
414
338
|
}
|
415
339
|
end
|
416
340
|
options2[:block] = self
|
@@ -0,0 +1,105 @@
|
|
1
|
+
module Caboose
|
2
|
+
class BlockCache
|
3
|
+
|
4
|
+
attr_accessor :id,
|
5
|
+
:page_id,
|
6
|
+
:parent_id,
|
7
|
+
:block_type_id,
|
8
|
+
:block_type_field_type,
|
9
|
+
:sort_order,
|
10
|
+
:name,
|
11
|
+
:value,
|
12
|
+
:file,
|
13
|
+
:image,
|
14
|
+
:children
|
15
|
+
|
16
|
+
def child_value(name)
|
17
|
+
b = self.child(name)
|
18
|
+
return nil if b.nil?
|
19
|
+
return b.image if b.block_type_field_type == 'image'
|
20
|
+
return b.file if b.block_type_field_type == 'file'
|
21
|
+
return b.value
|
22
|
+
end
|
23
|
+
|
24
|
+
def child(name)
|
25
|
+
self.children.each do |kid|
|
26
|
+
return kid if kid.name == name
|
27
|
+
end
|
28
|
+
return nil
|
29
|
+
end
|
30
|
+
|
31
|
+
def children_where(h)
|
32
|
+
arr = []
|
33
|
+
self.children.each do |b|
|
34
|
+
matches = true
|
35
|
+
h.each do |k,v|
|
36
|
+
if b.send(k) != v
|
37
|
+
matches = false
|
38
|
+
break
|
39
|
+
end
|
40
|
+
end
|
41
|
+
arr << b if matches
|
42
|
+
end
|
43
|
+
return nil if arr.count == 0
|
44
|
+
return arr
|
45
|
+
end
|
46
|
+
|
47
|
+
#def render(block, options = nil)
|
48
|
+
# block = self.child(block) if block && block.is_a?(String)
|
49
|
+
# eval("CabooseBlockRendering::render_block_type_#{block.block_type_id}(block)")
|
50
|
+
#end
|
51
|
+
|
52
|
+
def initialize(b)
|
53
|
+
self.id = b.id
|
54
|
+
self.page_id = b.page_id
|
55
|
+
self.parent_id = b.parent_id
|
56
|
+
self.block_type_id = b.block_type_id
|
57
|
+
self.block_type_field_type = b.block_type ? b.block_type.field_type : nil
|
58
|
+
self.sort_order = b.sort_order
|
59
|
+
self.name = b.name
|
60
|
+
self.value = b.value
|
61
|
+
self.file = BlockCacheFile.new(b.file)
|
62
|
+
self.image = BlockCacheImage.new(b.image)
|
63
|
+
self.children = b.children.collect{ |b2| BlockCache.new(b2) }
|
64
|
+
end
|
65
|
+
|
66
|
+
def page
|
67
|
+
return $page
|
68
|
+
end
|
69
|
+
|
70
|
+
def marshal_dump
|
71
|
+
[
|
72
|
+
self.id,
|
73
|
+
self.page_id,
|
74
|
+
self.parent_id,
|
75
|
+
self.block_type_id,
|
76
|
+
self.block_type_field_type,
|
77
|
+
self.sort_order,
|
78
|
+
self.name,
|
79
|
+
self.value,
|
80
|
+
Marshal.dump(self.file),
|
81
|
+
Marshal.dump(self.image),
|
82
|
+
self.children.collect{ |b| Marshal.dump(b) }
|
83
|
+
]
|
84
|
+
end
|
85
|
+
|
86
|
+
def marshal_load array
|
87
|
+
self.id,
|
88
|
+
self.page_id,
|
89
|
+
self.parent_id,
|
90
|
+
self.block_type_id,
|
91
|
+
self.block_type_field_type,
|
92
|
+
self.sort_order,
|
93
|
+
self.name,
|
94
|
+
self.value,
|
95
|
+
self.file,
|
96
|
+
self.image,
|
97
|
+
self.children = array
|
98
|
+
|
99
|
+
self.file = Marshal.load(self.file)
|
100
|
+
self.image = Marshal.load(self.image)
|
101
|
+
self.children = self.children.collect{ |kid| Marshal.load(kid) }
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
module Caboose
|
3
|
+
class BlockCacheFile
|
4
|
+
|
5
|
+
def initialize(file)
|
6
|
+
@_url = file.url
|
7
|
+
end
|
8
|
+
|
9
|
+
def url(style = nil)
|
10
|
+
return @_url
|
11
|
+
end
|
12
|
+
|
13
|
+
def marshal_dump
|
14
|
+
[@_url]
|
15
|
+
end
|
16
|
+
|
17
|
+
def marshal_load array
|
18
|
+
@url = array.first
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
|
2
|
+
module Caboose
|
3
|
+
class BlockCacheImage
|
4
|
+
|
5
|
+
def initialize(image)
|
6
|
+
@urls = {}
|
7
|
+
image.styles.each do |style|
|
8
|
+
@urls[style[0].to_s] = image.url(style[0])
|
9
|
+
end
|
10
|
+
#puts "--------------------------------------------"
|
11
|
+
#puts "Caboose::BlockCacheImage.initialize"
|
12
|
+
#puts "urls = #{@urls.inspect}"
|
13
|
+
#puts "--------------------------------------------"
|
14
|
+
end
|
15
|
+
|
16
|
+
def url(style = nil)
|
17
|
+
#puts "--------------------------------------------"
|
18
|
+
#puts "Caboose::BlockCacheImage.url"
|
19
|
+
#puts "urls = #{@urls.inspect}"
|
20
|
+
#puts "--------------------------------------------"
|
21
|
+
|
22
|
+
return @urls['thumb'] if style.nil?
|
23
|
+
return @urls[style.to_s]
|
24
|
+
end
|
25
|
+
|
26
|
+
def marshal_dump
|
27
|
+
arr = []
|
28
|
+
if @urls && @urls.count > 0
|
29
|
+
@urls.each do |k,v|
|
30
|
+
arr << k
|
31
|
+
arr << v
|
32
|
+
end
|
33
|
+
end
|
34
|
+
return arr
|
35
|
+
end
|
36
|
+
|
37
|
+
def marshal_load arr
|
38
|
+
@urls = {}
|
39
|
+
i = 0
|
40
|
+
count = arr.count
|
41
|
+
while i<count
|
42
|
+
k = arr[i]
|
43
|
+
@urls[k] = arr[i+1]
|
44
|
+
i = i + 2
|
45
|
+
end
|
46
|
+
#puts "--------------------------------------------"
|
47
|
+
#puts "Caboose::BlockCacheImage.marshal_load"
|
48
|
+
#puts "urls = #{@urls.inspect}"
|
49
|
+
#puts "--------------------------------------------"
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|