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
data/app/models/caboose/site.rb
CHANGED
@@ -42,7 +42,6 @@ class Caboose::Site < ActiveRecord::Base
|
|
42
42
|
:analytics_id ,
|
43
43
|
:use_retargeting ,
|
44
44
|
:use_dragdrop ,
|
45
|
-
:use_change_logs ,
|
46
45
|
:date_js_updated ,
|
47
46
|
:date_css_updated ,
|
48
47
|
:default_layout_id ,
|
@@ -66,13 +65,7 @@ class Caboose::Site < ActiveRecord::Base
|
|
66
65
|
:head_code,
|
67
66
|
:body_open_code,
|
68
67
|
:body_close_code,
|
69
|
-
:recaptcha_threshold
|
70
|
-
:google_api_key,
|
71
|
-
:use_caching,
|
72
|
-
:footer_css_digest,
|
73
|
-
:footer_js_digest,
|
74
|
-
:custom_css_files,
|
75
|
-
:custom_js_files
|
68
|
+
:recaptcha_threshold
|
76
69
|
|
77
70
|
before_save :validate_presence_of_store_config
|
78
71
|
|
@@ -158,16 +151,6 @@ class Caboose::Site < ActiveRecord::Base
|
|
158
151
|
def self.sanitize_name(name)
|
159
152
|
self.name = self.name.downcase.gsub(' ', '_')
|
160
153
|
end
|
161
|
-
|
162
|
-
def dev_domain
|
163
|
-
Caboose::Domain.where(:site_id => self.id).where("domain LIKE ?","dev.%").first
|
164
|
-
end
|
165
|
-
|
166
|
-
def public_domain
|
167
|
-
ms = Caboose::Site.where(:is_master => true).first
|
168
|
-
md = Caboose::Domain.where(:site_id => ms.id, :primary => true).first if ms
|
169
|
-
return md ? "#{self.name}.#{md.domain}" : "caboosecms.com"
|
170
|
-
end
|
171
154
|
|
172
155
|
def primary_domain
|
173
156
|
Caboose::Domain.where(:site_id => self.id, :primary => true).first
|
@@ -252,190 +235,5 @@ class Caboose::Site < ActiveRecord::Base
|
|
252
235
|
rm = Caboose::RoleMembership.create(:role_id => eli_role.id, :user_id => eli_user.id) if rm.nil?
|
253
236
|
|
254
237
|
end
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
# Caching
|
259
|
-
|
260
|
-
def cached_footer_css
|
261
|
-
str = ''
|
262
|
-
return str if !self.use_caching
|
263
|
-
index_page = Caboose::Page.index_page(self.id)
|
264
|
-
footer_ids = Caboose::Page.home_page_footer_block_ids(index_page)
|
265
|
-
blocks = Caboose::Block.includes(:block_type).where("blocks.parent_id in (?)",footer_ids).where("blocks.cached_css IS NOT NULL").where("block_types.is_dynamic = false").order("blocks.id").all
|
266
|
-
blocks.each do |b|
|
267
|
-
str << b.cached_css
|
268
|
-
end
|
269
|
-
return str.blank? ? '' : str.gsub(/<\/style>(\s*)<style>/,'')
|
270
|
-
end
|
271
|
-
|
272
|
-
def cached_footer_js
|
273
|
-
str = ''
|
274
|
-
return str if !self.use_caching
|
275
|
-
index_page = Caboose::Page.index_page(self.id)
|
276
|
-
footer_ids = Caboose::Page.home_page_footer_block_ids(index_page)
|
277
|
-
blocks = Caboose::Block.includes(:block_type).where("blocks.parent_id in (?)",footer_ids).where("blocks.cached_js IS NOT NULL").where("block_types.is_dynamic = false").order("blocks.id").all
|
278
|
-
blocks.each do |b|
|
279
|
-
str << b.cached_js
|
280
|
-
end
|
281
|
-
host = Rails.env.production? ? "https://#{ActionController::Base.asset_host}" : ""
|
282
|
-
return str.blank? ? '' : str.gsub('"/assets/',"\"#{host}/assets/")
|
283
|
-
end
|
284
|
-
|
285
|
-
def refresh_footer_css
|
286
|
-
begin
|
287
|
-
rad = rand(999)
|
288
|
-
dom = Rails.env.production? ? self.public_domain : self.dev_domain.domain
|
289
|
-
uri = URI("http://#{dom}/api/generate-asset/site_#{self.id}.css?#{rad}")
|
290
|
-
css = Net::HTTP.get(uri)
|
291
|
-
rescue
|
292
|
-
Caboose.log("Couldn't generate site CSS")
|
293
|
-
end
|
294
|
-
end
|
295
|
-
|
296
|
-
def refresh_footer_js
|
297
|
-
begin
|
298
|
-
rad = rand(999)
|
299
|
-
dom = Rails.env.production? ? self.public_domain : self.dev_domain.domain
|
300
|
-
uri = URI("http://#{dom}/api/generate-asset/site_#{self.id}.js?#{rad}")
|
301
|
-
css = Net::HTTP.get(uri)
|
302
|
-
rescue
|
303
|
-
Caboose.log("Couldn't generate site JS")
|
304
|
-
end
|
305
|
-
end
|
306
|
-
|
307
|
-
|
308
|
-
def footer_css_path(digest = self.footer_css_digest)
|
309
|
-
return "assets/sites/site_#{self.id}_footer_#{digest}.css"
|
310
|
-
end
|
311
|
-
|
312
|
-
def footer_css_url
|
313
|
-
rad = rand(999)
|
314
|
-
old = "/api/generate-asset/site_#{self.id}.css?#{rad}"
|
315
|
-
return old if self.footer_css_digest.blank?
|
316
|
-
if Rails.env.production?
|
317
|
-
return "https://#{Caboose::cdn_domain}/#{footer_css_path}"
|
318
|
-
else
|
319
|
-
path = File.join(Rails.root, 'public', "#{footer_css_path}")
|
320
|
-
if File.file?(path)
|
321
|
-
return "#{ActionController::Base.asset_host}/#{footer_css_path}"
|
322
|
-
else
|
323
|
-
return "https://#{Caboose::cdn_domain}/#{footer_css_path}"
|
324
|
-
end
|
325
|
-
end
|
326
|
-
end
|
327
|
-
|
328
|
-
def update_footer_css_file
|
329
|
-
str = ""
|
330
|
-
footer_css_digest = SecureRandom.urlsafe_base64.to_s
|
331
|
-
old_digest = self.footer_css_digest
|
332
|
-
css = self.refresh_footer_css
|
333
|
-
if css && !css.blank?
|
334
|
-
begin
|
335
|
-
if Rails.env.production?
|
336
|
-
config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
|
337
|
-
AWS.config(:access_key_id => config['access_key_id'], :secret_access_key => config['secret_access_key'])
|
338
|
-
bucket = AWS::S3.new.buckets[config['bucket']]
|
339
|
-
bucket.objects[self.footer_css_path(footer_css_digest)].write(css, :acl => 'public-read', :content_type => 'text/css', :cache_control => 'public, max-age=86400')
|
340
|
-
if !old_digest.blank? && old_digest != 'empty'
|
341
|
-
key = self.footer_css_path(old_digest)
|
342
|
-
obj = bucket.objects[key]
|
343
|
-
obj.delete
|
344
|
-
end
|
345
|
-
else
|
346
|
-
file_path = File.join(Rails.root, 'public', 'assets', 'sites')
|
347
|
-
FileUtils.mkdir_p(file_path) unless File.directory?(file_path)
|
348
|
-
File.open(File.join(Rails.root, 'public', self.footer_css_path(footer_css_digest)), 'w') { |f| f.write( css ) }
|
349
|
-
if !old_digest.blank? && old_digest != 'empty'
|
350
|
-
path = File.join(Rails.root, 'public', self.footer_css_path(old_digest))
|
351
|
-
File.delete(path) if File.file?(path)
|
352
|
-
end
|
353
|
-
end
|
354
|
-
self.update_column('footer_css_digest', footer_css_digest)
|
355
|
-
rescue
|
356
|
-
self.update_column('footer_css_digest', old_digest)
|
357
|
-
end
|
358
|
-
else
|
359
|
-
self.update_column('footer_css_digest', 'empty')
|
360
|
-
end
|
361
|
-
end
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
def footer_js_path(digest = self.footer_js_digest)
|
367
|
-
return "assets/sites/site_#{self.id}_footer_#{digest}.js"
|
368
|
-
end
|
369
|
-
|
370
|
-
def footer_js_url
|
371
|
-
rad = rand(999)
|
372
|
-
old = "/api/generate-asset/site_#{self.id}.js?#{rad}"
|
373
|
-
return old if self.footer_js_digest.blank?
|
374
|
-
if Rails.env.production?
|
375
|
-
return "https://#{Caboose::cdn_domain}/#{footer_js_path}"
|
376
|
-
else
|
377
|
-
path = File.join(Rails.root, 'public', "#{footer_js_path}")
|
378
|
-
if File.file?(path)
|
379
|
-
return "#{ActionController::Base.asset_host}/#{footer_js_path}"
|
380
|
-
else
|
381
|
-
return "https://#{Caboose::cdn_domain}/#{footer_js_path}"
|
382
|
-
end
|
383
|
-
end
|
384
|
-
end
|
385
|
-
|
386
|
-
def update_footer_js_file
|
387
|
-
str = ""
|
388
|
-
footer_js_digest = SecureRandom.urlsafe_base64.to_s
|
389
|
-
old_digest = self.footer_js_digest
|
390
|
-
js = self.refresh_footer_js
|
391
|
-
if js && !js.blank?
|
392
|
-
begin
|
393
|
-
if Rails.env.production?
|
394
|
-
config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
|
395
|
-
AWS.config(:access_key_id => config['access_key_id'], :secret_access_key => config['secret_access_key'])
|
396
|
-
bucket = AWS::S3.new.buckets[config['bucket']]
|
397
|
-
bucket.objects[self.footer_js_path(footer_js_digest)].write(js, :acl => 'public-read', :content_type => 'text/javascript', :cache_control => 'public, max-age=86400')
|
398
|
-
if !old_digest.blank? && old_digest != 'empty'
|
399
|
-
key = self.footer_js_path(old_digest)
|
400
|
-
obj = bucket.objects[key]
|
401
|
-
obj.delete
|
402
|
-
end
|
403
|
-
else
|
404
|
-
file_path = File.join(Rails.root, 'public', 'assets', 'sites')
|
405
|
-
FileUtils.mkdir_p(file_path) unless File.directory?(file_path)
|
406
|
-
File.open(File.join(Rails.root, 'public', self.footer_js_path(footer_js_digest)), 'w') { |f| f.write( js ) }
|
407
|
-
if !old_digest.blank? && old_digest != 'empty'
|
408
|
-
path = File.join(Rails.root, 'public', self.footer_js_path(old_digest))
|
409
|
-
File.delete(path) if File.file?(path)
|
410
|
-
end
|
411
|
-
end
|
412
|
-
self.update_column('footer_js_digest', footer_js_digest)
|
413
|
-
rescue
|
414
|
-
self.update_column('footer_js_digest', old_digest)
|
415
|
-
end
|
416
|
-
else
|
417
|
-
self.update_column('footer_js_digest', 'empty')
|
418
|
-
end
|
419
|
-
end
|
420
|
-
|
421
|
-
|
422
|
-
def refresh_all_page_caches
|
423
|
-
if self.use_caching
|
424
|
-
home_page = Caboose::Page.index_page(self.id)
|
425
|
-
footer = home_page.block.child('footer')
|
426
|
-
Caboose::Page.where(:site_id => self.id).order(:id).all.each do |page|
|
427
|
-
content = page.block ? page.block.child('content') : nil
|
428
|
-
block_ids = content ? Caboose::Block.where("parent_id = ?", content.id).pluck(:id) : []
|
429
|
-
page.update_cached_blocks(block_ids)
|
430
|
-
page.delay(:queue => 'caching', :priority => 8).update_css_file
|
431
|
-
page.delay(:queue => 'caching', :priority => 8).update_js_file
|
432
|
-
end
|
433
|
-
footer_ids = Caboose::Block.where("parent_id = ?", footer.id).pluck(:id)
|
434
|
-
home_page.update_cached_blocks(footer_ids)
|
435
|
-
self.delay(:queue => 'caching', :priority => 9).update_footer_css_file
|
436
|
-
self.delay(:queue => 'caching', :priority => 9).update_footer_js_file
|
437
|
-
end
|
438
|
-
end
|
439
|
-
|
440
238
|
|
441
239
|
end
|
data/app/models/caboose/theme.rb
CHANGED
@@ -102,13 +102,7 @@ class Caboose::Theme < ActiveRecord::Base
|
|
102
102
|
|
103
103
|
:digest,
|
104
104
|
:custom_sass,
|
105
|
-
:cl_banner_version
|
106
|
-
:sass_error,
|
107
|
-
:main_js,
|
108
|
-
:js_digest,
|
109
|
-
|
110
|
-
:default_page_padding,
|
111
|
-
:default_page_constrain
|
105
|
+
:cl_banner_version
|
112
106
|
|
113
107
|
def compile(for_site_id = 0)
|
114
108
|
theme = self
|
@@ -117,7 +111,6 @@ class Caboose::Theme < ActiveRecord::Base
|
|
117
111
|
body = ERB.new(File.read(File.join(path))).result(theme.get_binding(for_site_id))
|
118
112
|
tmp_themes_path = File.join(Rails.root, 'tmp', 'themes')
|
119
113
|
tmp_asset_name = "theme_#{self.id}_site_#{for_site_id}"
|
120
|
-
old_digest = self.digest
|
121
114
|
FileUtils.mkdir_p(tmp_themes_path) unless File.directory?(tmp_themes_path)
|
122
115
|
File.open(File.join(tmp_themes_path, "#{tmp_asset_name}.scss"), 'w') { |f| f.write(body) }
|
123
116
|
begin
|
@@ -138,28 +131,17 @@ class Caboose::Theme < ActiveRecord::Base
|
|
138
131
|
config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
|
139
132
|
AWS.config(:access_key_id => config['access_key_id'], :secret_access_key => config['secret_access_key'])
|
140
133
|
bucket = AWS::S3.new.buckets[config['bucket']]
|
141
|
-
bucket.objects[theme.asset_path(asset.digest, for_site_id)].write(str, :acl => 'public-read', :content_type => 'text/css'
|
142
|
-
# if !old_digest.blank?
|
143
|
-
# key = self.asset_path(old_digest, for_site_id)
|
144
|
-
# obj = bucket.objects[key]
|
145
|
-
# obj.delete
|
146
|
-
# end
|
134
|
+
bucket.objects[theme.asset_path(asset.digest, for_site_id)].write(str, :acl => 'public-read', :content_type => 'text/css')
|
147
135
|
else
|
148
136
|
theme_path = File.join(Rails.root, 'public', 'assets', 'themes')
|
149
137
|
FileUtils.mkdir_p(theme_path) unless File.directory?(theme_path)
|
150
138
|
File.open(File.join(Rails.root, 'public', theme.asset_path(asset.digest, for_site_id)), 'w') { |f| f.write(compressed_body) }
|
151
|
-
if !old_digest.blank?
|
152
|
-
path = File.join(Rails.root, 'public', self.asset_path(old_digest, for_site_id))
|
153
|
-
File.delete(path) if File.file?(path)
|
154
|
-
end
|
155
139
|
end
|
156
140
|
self.update_digest(asset.digest)
|
157
141
|
rescue Sass::SyntaxError => error
|
158
142
|
if Rails.env.development?
|
159
143
|
raise error
|
160
144
|
end
|
161
|
-
theme.sass_error = error
|
162
|
-
theme.save
|
163
145
|
theme.revert
|
164
146
|
end
|
165
147
|
end
|
@@ -197,56 +179,9 @@ class Caboose::Theme < ActiveRecord::Base
|
|
197
179
|
end
|
198
180
|
end
|
199
181
|
|
200
|
-
def
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
def upload_js(for_site_id = 0)
|
205
|
-
str = ""
|
206
|
-
js_digest = SecureRandom.urlsafe_base64.to_s
|
207
|
-
old_digest = self.js_digest
|
208
|
-
Caboose::ThemeFile.where("filename ILIKE (?)","%.js%").all.each do |jsfile|
|
209
|
-
if Caboose::ThemeFileMembership.where(:theme_id => self.id, :theme_file_id => jsfile.id).exists?
|
210
|
-
uri = URI(jsfile.filename)
|
211
|
-
str += Net::HTTP.get(uri)
|
212
|
-
end
|
213
|
-
end
|
214
|
-
str += self.main_js
|
215
|
-
if Rails.env.production?
|
216
|
-
config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
|
217
|
-
AWS.config(:access_key_id => config['access_key_id'], :secret_access_key => config['secret_access_key'])
|
218
|
-
bucket = AWS::S3.new.buckets[config['bucket']]
|
219
|
-
bucket.objects[self.js_path(for_site_id, js_digest)].write(str, :acl => 'public-read', :content_type => 'application/javascript', :cache_control => 'public, max-age=86400')
|
220
|
-
# if !old_digest.blank?
|
221
|
-
# key = self.js_path(for_site_id, old_digest)
|
222
|
-
# obj = bucket.objects[key]
|
223
|
-
# obj.delete
|
224
|
-
# end
|
225
|
-
else
|
226
|
-
theme_path = File.join(Rails.root, 'public', 'assets', 'themes')
|
227
|
-
FileUtils.mkdir_p(theme_path) unless File.directory?(theme_path)
|
228
|
-
File.open(File.join(Rails.root, 'public', self.js_path(for_site_id, js_digest)), 'w') { |f| f.write( str ) }
|
229
|
-
if !old_digest.blank?
|
230
|
-
path = File.join(Rails.root, 'public', self.js_path(for_site_id, old_digest))
|
231
|
-
File.delete(path) if File.file?(path)
|
232
|
-
end
|
233
|
-
end
|
234
|
-
self.update_column('js_digest', js_digest)
|
235
|
-
end
|
236
|
-
|
237
|
-
def js_url(site_id = 0)
|
238
|
-
old = "https://cabooseit.s3.amazonaws.com/assets/natureseyenri/js/application.js"
|
239
|
-
return old if self.main_js.blank?
|
240
|
-
if Rails.env.production?
|
241
|
-
return "https://#{ActionController::Base.asset_host}/#{js_path(site_id)}"
|
242
|
-
else
|
243
|
-
path = File.join(Rails.root, 'public', "#{js_path(site_id)}")
|
244
|
-
if File.file?(path)
|
245
|
-
return "#{ActionController::Base.asset_host}/#{js_path(site_id)}"
|
246
|
-
else
|
247
|
-
return "https://#{Caboose::cdn_domain}/#{js_path(site_id)}"
|
248
|
-
end
|
249
|
-
end
|
182
|
+
def js_url
|
183
|
+
# TODO - figure out how to do this
|
184
|
+
"https://cabooseit.s3.amazonaws.com/assets/natureseyenri/js/application.js"
|
250
185
|
end
|
251
186
|
|
252
187
|
def update_digest(digest)
|
@@ -0,0 +1,44 @@
|
|
1
|
+
<div id="admin_flex_wrapper">
|
2
|
+
<!--
|
3
|
+
<div id='admin_nav'>
|
4
|
+
<ul>
|
5
|
+
<% @nav = Caboose.plugin_hook('admin_nav', [], @logged_in_user, @page, @site) %>
|
6
|
+
<% @nav.each do |item| %>
|
7
|
+
<% href = item['href'] || '#' %>
|
8
|
+
<li id="<%= item['id'] %>" class="top-li <%= item['id'] %><% if @request.fullpath.starts_with?(href) %> selected<% end %>">
|
9
|
+
<a title="<%= item['text'] %>" href="<%= href %>">
|
10
|
+
<span class='icon'></span><span class='text'><%= item['text'] %></span>
|
11
|
+
</a>
|
12
|
+
</li>
|
13
|
+
<% end %>
|
14
|
+
</ul>
|
15
|
+
</div>
|
16
|
+
-->
|
17
|
+
<div id="admin_sub_nav">
|
18
|
+
<% @nav.each do |item| %>
|
19
|
+
<% if item['children'] && item['children'].count > 0 %>
|
20
|
+
<ul class="cbp-spmenu cbp-spmenu-vertical cbp-spmenu-left" id="cbp-spmenu-<%= item['id'] %>">
|
21
|
+
<li><a class="close" data-id="<%= item['id'] %>">×</a></li>
|
22
|
+
<% item['children'].each do |item2| %>
|
23
|
+
<% if item2['href'] != '#' %>
|
24
|
+
<li><a href='<%= item2['href'] %>'><%= item2['text'] %></a></li>
|
25
|
+
<% end %>
|
26
|
+
<% end %>
|
27
|
+
</ul>
|
28
|
+
<% end %>
|
29
|
+
<% end %>
|
30
|
+
</div>
|
31
|
+
<% subnav = yield :admin_subnav %>
|
32
|
+
<% if subnav && subnav.strip.length > 0
|
33
|
+
%><%= raw subnav %><%
|
34
|
+
subnav = true
|
35
|
+
else
|
36
|
+
subnav = false
|
37
|
+
end %>
|
38
|
+
<div id='admin_content_wrapper'<% if subnav %> class='with_subnav'<% end %>>
|
39
|
+
<div id='admin_content_body'>
|
40
|
+
<%= yield %>
|
41
|
+
</div>
|
42
|
+
</div>
|
43
|
+
</div>
|
44
|
+
</div>
|
@@ -0,0 +1,47 @@
|
|
1
|
+
<%
|
2
|
+
hf = nil #Caboose::Font.where(:site_id => @site.id, :name => "heading-font" ).last
|
3
|
+
bf = nil #Caboose::Font.where(:site_id => @site.id, :name => "body-font" ).last
|
4
|
+
bfb = nil #Caboose::Font.where(:site_id => @site.id, :name => "body-font-bold" ).last
|
5
|
+
bfi = nil #Caboose::Font.where(:site_id => @site.id, :name => "body-font-italic" ).last
|
6
|
+
bfbi = nil #Caboose::Font.where(:site_id => @site.id, :name => "body-font-bold-italic" ).last
|
7
|
+
btn = nil #Caboose::Font.where(:site_id => @site.id, :name => "button-font" ).last
|
8
|
+
default = '//fonts.gstatic.com/s/opensans/v13/MTP_ySUJH_bn48VBG8sNSi3USBnSvpkopQaUR-2r7iU.ttf'
|
9
|
+
%>
|
10
|
+
<style>
|
11
|
+
@font-face {
|
12
|
+
font-family: "heading-font";
|
13
|
+
src: url('<%= hf && !hf.blank? ? hf.url.gsub("http://","//") : default %>') format('truetype');
|
14
|
+
font-weight: normal;
|
15
|
+
font-style: normal;
|
16
|
+
}
|
17
|
+
@font-face {
|
18
|
+
font-family: "body-font";
|
19
|
+
src: url('<%= bf && !bf.blank? ? bf.url.gsub("http://","//") : default %>') format('truetype');
|
20
|
+
font-weight: normal;
|
21
|
+
font-style: normal;
|
22
|
+
}
|
23
|
+
@font-face {
|
24
|
+
font-family: "body-font";
|
25
|
+
src: url('<%= bfb && !bfb.blank? ? bfb.url.gsub("http://","//") : default %>') format('truetype');
|
26
|
+
font-weight: bold;
|
27
|
+
font-style: normal;
|
28
|
+
}
|
29
|
+
@font-face {
|
30
|
+
font-family: "body-font";
|
31
|
+
src: url('<%= bfi && !bfi.blank? ? bfi.url.gsub("http://","//") : default %>') format('truetype');
|
32
|
+
font-weight: normal;
|
33
|
+
font-style: italic;
|
34
|
+
}
|
35
|
+
@font-face {
|
36
|
+
font-family: "body-font";
|
37
|
+
src: url('<%= bfbi && !bfbi.blank? ? bfbi.url.gsub("http://","//") : default %>') format('truetype');
|
38
|
+
font-weight: bold;
|
39
|
+
font-style: italic;
|
40
|
+
}
|
41
|
+
@font-face {
|
42
|
+
font-family: "button-font";
|
43
|
+
src: url('<%= btn && !btn.blank? ? btn.url.gsub("http://","//") : default %>') format('truetype');
|
44
|
+
font-weight: normal;
|
45
|
+
font-style: normal;
|
46
|
+
}
|
47
|
+
</style>
|
@@ -0,0 +1 @@
|
|
1
|
+
<footer id='admin_footer'></footer>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<header id='admin_header'>
|
2
|
+
<div id='admin_logo_link'><a href='/' title='Admin Home'><span>Admin Home</span></a></div>
|
3
|
+
<div id='crumbtrail'></div>
|
4
|
+
<!--
|
5
|
+
<div id='admin_top_nav'>
|
6
|
+
<ul>
|
7
|
+
<li class='my_account' ><a href='/my-account'><span class='icon'></span><span class='text'>My Account</span></a></li>
|
8
|
+
<li class='help' ><a href='/admin/help'><span class='icon'></span><span class='text'>Help</span></a></li>
|
9
|
+
</ul>
|
10
|
+
</div>
|
11
|
+
-->
|
12
|
+
</header>
|