caboose-cms 0.9.228 → 0.9.229

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/caboose/admin.js +1 -1
  3. data/app/assets/javascripts/caboose/admin_main.js +1 -13
  4. data/app/assets/javascripts/caboose/admin_media_index.js +161 -158
  5. data/app/assets/javascripts/caboose/application.js +8 -7
  6. data/app/assets/javascripts/caboose/block_content_controller_dragdrop.js +60 -4
  7. data/app/assets/javascripts/caboose/block_modal_controllers/block_dd_modal_controller.js +3 -2
  8. data/app/assets/javascripts/caboose/block_modal_controllers/media_modal_controller.js +17 -6
  9. data/app/assets/javascripts/caboose/model/all.js +5 -1
  10. data/app/assets/stylesheets/caboose/admin_block_edit_image.css.scss +2 -1
  11. data/app/assets/stylesheets/caboose/admin_edit_page_content_dragdrop.scss +71 -15
  12. data/app/assets/stylesheets/caboose/admin_main.css.scss +25 -29
  13. data/app/assets/stylesheets/caboose/admin_media_index.css.scss +26 -5
  14. data/app/assets/stylesheets/caboose/application.css +11 -5
  15. data/app/assets/stylesheets/caboose/login.scss +1 -0
  16. data/app/assets/stylesheets/caboose/model_binder.css +13 -4
  17. data/app/assets/stylesheets/caboose/page_bar_generator.css +2 -1
  18. data/app/controllers/caboose/admin_controller.rb +3 -4
  19. data/app/controllers/caboose/application_controller.rb +16 -19
  20. data/app/controllers/caboose/block_types_controller.rb +8 -6
  21. data/app/controllers/caboose/cart_controller.rb +2 -2
  22. data/app/controllers/caboose/change_logs_controller.rb +13 -0
  23. data/app/controllers/caboose/fonts_controller.rb +139 -2
  24. data/app/controllers/caboose/invoices_controller.rb +5 -4
  25. data/app/controllers/caboose/login_logs_controller.rb +5 -7
  26. data/app/controllers/caboose/media_categories_controller.rb +16 -2
  27. data/app/controllers/caboose/media_controller.rb +14 -11
  28. data/app/controllers/caboose/pages_controller.rb +104 -42
  29. data/app/controllers/caboose/posts_controller.rb +53 -7
  30. data/app/controllers/caboose/products_controller.rb +1 -1
  31. data/app/controllers/caboose/sites_controller.rb +25 -6
  32. data/app/controllers/caboose/sns_controller.rb +3 -3
  33. data/app/controllers/caboose/themes_controller.rb +30 -0
  34. data/app/controllers/caboose/users_controller.rb +17 -10
  35. data/app/controllers/caboose/variants_controller.rb +9 -9
  36. data/app/models/caboose/block.rb +98 -22
  37. data/app/models/caboose/block_type.rb +2 -1
  38. data/app/models/caboose/block_type_parser.rb +1 -1
  39. data/app/models/caboose/calendar_event_group.rb +2 -2
  40. data/app/models/caboose/change_log.rb +97 -0
  41. data/app/models/caboose/core_plugin.rb +4 -3
  42. data/app/models/caboose/font.rb +7 -2
  43. data/app/models/caboose/font_variant.rb +12 -0
  44. data/app/models/caboose/media.rb +15 -4
  45. data/app/models/caboose/media_category.rb +2 -4
  46. data/app/models/caboose/page.rb +316 -45
  47. data/app/models/caboose/page_bar_generator.rb +20 -10
  48. data/app/models/caboose/post.rb +108 -8
  49. data/app/models/caboose/product.rb +1 -1
  50. data/app/models/caboose/role.rb +2 -2
  51. data/app/models/caboose/schema.rb +73 -72
  52. data/app/models/caboose/site.rb +203 -1
  53. data/app/models/caboose/theme.rb +70 -5
  54. data/app/views/caboose/block_types/admin_edit.html.erb +6 -8
  55. data/app/views/caboose/blocks/_cached_block.html.erb +28 -0
  56. data/app/views/caboose/blocks/_file.html.erb +2 -2
  57. data/app/views/caboose/blocks/_ga.html.erb +1 -2
  58. data/app/views/caboose/blocks/_image.html.erb +4 -0
  59. data/app/views/caboose/blocks/_render_function.html.erb +9 -4
  60. data/app/views/caboose/change_logs/admin_index.html.erb +65 -0
  61. data/app/views/caboose/fonts/admin_family_edit.html.erb +63 -0
  62. data/app/views/caboose/fonts/admin_family_index.html.erb +42 -0
  63. data/app/views/caboose/fonts/admin_index.html.erb +55 -10
  64. data/app/views/caboose/fonts/admin_variant_edit.html.erb +84 -0
  65. data/app/views/caboose/invoices_mailer/customer_status_updated.html.erb +5 -14
  66. data/app/views/caboose/login_logs/admin_index_for_user.html.erb +1 -1
  67. data/app/views/caboose/media/admin_index.html.erb +14 -24
  68. data/app/views/caboose/my_account/index.html.erb +1 -0
  69. data/app/views/caboose/pages/_admin_header.html.erb +5 -0
  70. data/app/views/caboose/pages/admin_change_logs.html.erb +56 -0
  71. data/app/views/caboose/pages/admin_edit_content.html.erb +6 -2
  72. data/app/views/caboose/pages/admin_edit_general.html.erb +32 -4
  73. data/app/views/caboose/pages/compiled_asset.css.erb +0 -0
  74. data/app/views/caboose/pages/compiled_asset.js.erb +0 -0
  75. data/app/views/caboose/posts/_admin_header.html.erb +5 -0
  76. data/app/views/caboose/posts/admin_change_logs.html.erb +56 -0
  77. data/app/views/caboose/posts/admin_delete_form.html.erb +1 -1
  78. data/app/views/caboose/posts/admin_edit_content.html.erb +6 -2
  79. data/app/views/caboose/products/admin_group_variants.html.erb +1 -1
  80. data/app/views/caboose/products/admin_sort.html copy.erb +1 -1
  81. data/app/views/caboose/sites/admin_edit.html.erb +21 -0
  82. data/app/views/caboose/sites/compiled_asset.css.erb +0 -0
  83. data/app/views/caboose/sites/compiled_asset.js.erb +0 -0
  84. data/app/views/caboose/themes/admin_edit.html.erb +7 -3
  85. data/app/views/caboose/themes/admin_error_log.html.erb +9 -0
  86. data/app/views/caboose/themes/admin_js.html.erb +131 -0
  87. data/app/views/caboose/users/_admin_header.html.erb +4 -0
  88. data/app/views/caboose/users/admin_change_logs.html.erb +63 -0
  89. data/app/views/caboose/users/admin_edit_roles.html.erb +1 -0
  90. data/app/views/caboose/variants/admin_group.html.erb +1 -1
  91. data/app/views/layouts/caboose/admin.html.erb +9 -2
  92. data/app/views/layouts/caboose/application.html.erb +62 -92
  93. data/app/views/layouts/caboose/css.css.erb +44 -0
  94. data/app/views/layouts/caboose/footer_css.css.erb +41 -0
  95. data/app/views/layouts/caboose/footer_js.js.erb +31 -0
  96. data/app/views/layouts/caboose/js.js.erb +34 -0
  97. data/lib/caboose/version.rb +1 -1
  98. data/lib/tasks/caboose.rake +3 -14
  99. metadata +23 -27
  100. data/app/controllers/caboose/assets_controller.rb +0 -65
  101. data/app/models/caboose/asset.rb +0 -23
  102. data/app/models/caboose/asset_manifest.rb +0 -91
  103. data/app/models/caboose/block_cache.rb +0 -105
  104. data/app/models/caboose/block_cache_file.rb +0 -22
  105. data/app/models/caboose/block_cache_image.rb +0 -53
  106. data/app/models/caboose/page_cache.rb +0 -12
  107. data/app/models/caboose/page_cacher.rb +0 -137
  108. data/app/views/caboose/pages/admin_new_old.html.erb +0 -46
  109. data/app/views/caboose/pages/test.html.erb +0 -64
@@ -42,6 +42,7 @@ class Caboose::Site < ActiveRecord::Base
42
42
  :analytics_id ,
43
43
  :use_retargeting ,
44
44
  :use_dragdrop ,
45
+ :use_change_logs ,
45
46
  :date_js_updated ,
46
47
  :date_css_updated ,
47
48
  :default_layout_id ,
@@ -65,7 +66,13 @@ class Caboose::Site < ActiveRecord::Base
65
66
  :head_code,
66
67
  :body_open_code,
67
68
  :body_close_code,
68
- :recaptcha_threshold
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
69
76
 
70
77
  before_save :validate_presence_of_store_config
71
78
 
@@ -151,6 +158,16 @@ class Caboose::Site < ActiveRecord::Base
151
158
  def self.sanitize_name(name)
152
159
  self.name = self.name.downcase.gsub(' ', '_')
153
160
  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
154
171
 
155
172
  def primary_domain
156
173
  Caboose::Domain.where(:site_id => self.id, :primary => true).first
@@ -235,5 +252,190 @@ class Caboose::Site < ActiveRecord::Base
235
252
  rm = Caboose::RoleMembership.create(:role_id => eli_role.id, :user_id => eli_user.id) if rm.nil?
236
253
 
237
254
  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
+
238
440
 
239
441
  end
@@ -102,7 +102,13 @@ class Caboose::Theme < ActiveRecord::Base
102
102
 
103
103
  :digest,
104
104
  :custom_sass,
105
- :cl_banner_version
105
+ :cl_banner_version,
106
+ :sass_error,
107
+ :main_js,
108
+ :js_digest,
109
+
110
+ :default_page_padding,
111
+ :default_page_constrain
106
112
 
107
113
  def compile(for_site_id = 0)
108
114
  theme = self
@@ -111,6 +117,7 @@ class Caboose::Theme < ActiveRecord::Base
111
117
  body = ERB.new(File.read(File.join(path))).result(theme.get_binding(for_site_id))
112
118
  tmp_themes_path = File.join(Rails.root, 'tmp', 'themes')
113
119
  tmp_asset_name = "theme_#{self.id}_site_#{for_site_id}"
120
+ old_digest = self.digest
114
121
  FileUtils.mkdir_p(tmp_themes_path) unless File.directory?(tmp_themes_path)
115
122
  File.open(File.join(tmp_themes_path, "#{tmp_asset_name}.scss"), 'w') { |f| f.write(body) }
116
123
  begin
@@ -131,17 +138,28 @@ class Caboose::Theme < ActiveRecord::Base
131
138
  config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
132
139
  AWS.config(:access_key_id => config['access_key_id'], :secret_access_key => config['secret_access_key'])
133
140
  bucket = AWS::S3.new.buckets[config['bucket']]
134
- bucket.objects[theme.asset_path(asset.digest, for_site_id)].write(str, :acl => 'public-read', :content_type => 'text/css')
141
+ bucket.objects[theme.asset_path(asset.digest, for_site_id)].write(str, :acl => 'public-read', :content_type => 'text/css', :cache_control => 'public, max-age=86400')
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
135
147
  else
136
148
  theme_path = File.join(Rails.root, 'public', 'assets', 'themes')
137
149
  FileUtils.mkdir_p(theme_path) unless File.directory?(theme_path)
138
150
  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
139
155
  end
140
156
  self.update_digest(asset.digest)
141
157
  rescue Sass::SyntaxError => error
142
158
  if Rails.env.development?
143
159
  raise error
144
160
  end
161
+ theme.sass_error = error
162
+ theme.save
145
163
  theme.revert
146
164
  end
147
165
  end
@@ -179,9 +197,56 @@ class Caboose::Theme < ActiveRecord::Base
179
197
  end
180
198
  end
181
199
 
182
- def js_url
183
- # TODO - figure out how to do this
184
- "https://cabooseit.s3.amazonaws.com/assets/natureseyenri/js/application.js"
200
+ def js_path(site_id = 0, digest = self.js_digest)
201
+ "assets/themes/theme_#{self.id}_site_#{site_id}_#{digest}.js"
202
+ end
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
185
250
  end
186
251
 
187
252
  def update_digest(digest)
@@ -16,8 +16,6 @@ bt = @block_type
16
16
 
17
17
  <h2>Children</h2>
18
18
  <div id='block_types'></div>
19
-
20
-
21
19
 
22
20
  <h2>Advanced</h2>
23
21
  <p><div id='blocktype_<%= bt.id %>_block_type_category_id' ></div></p>
@@ -30,17 +28,16 @@ bt = @block_type
30
28
  <p><div id='blocktype_<%= bt.id %>_options' ></div></p>
31
29
  <!-- <p><div id='blocktype_<%= bt.id %>_is_global' ></div></p> -->
32
30
  <p><div id='blocktype_<%= bt.id %>_use_render_function' ></div></p>
33
- <p><div id='blocktype_<%= bt.id %>_use_render_function_for_layout' ></div></p>
31
+ <!-- <p><div id='blocktype_<%= bt.id %>_use_render_function_for_layout' ></div></p> -->
34
32
  <p><div id='blocktype_<%= bt.id %>_use_js_for_modal' ></div></p>
35
33
  <p><div id='blocktype_<%= bt.id %>_allow_child_blocks' ></div></p>
34
+ <p><div id='blocktype_<%= bt.id %>_is_dynamic' ></div></p>
36
35
  <p><div id='blocktype_<%= bt.id %>_default_child_block_type_id' ></div></p>
37
36
  <!-- <p><div id='blocktype_<%= bt.id %>_default_constrain' ></div></p>
38
37
  <p><div id='blocktype_<%= bt.id %>_default_full_width' ></div></p> -->
39
38
  <p><div id='blocktype_<%= bt.id %>_default_included' ></div></p>
40
- <p>
41
39
 
42
- </p>
43
- <p><div id='blocktype_<%= bt.id %>_options_function' ></div></p>
40
+ <!-- <p><div id='blocktype_<%= bt.id %>_options_function' ></div></p> -->
44
41
 
45
42
  <div id='message'></div>
46
43
 
@@ -102,7 +99,7 @@ $(document).ready(function() {
102
99
  { name: 'block_type_category_id' , sort: 'block_type_category_id' , show: false , bulk_edit: false, nice_name: 'Category' , type: 'select' , value: function(bt) { return bt.block_type_category_id; }, width: 400, options_url: '/admin/block-type-categories/tree-options' },
103
100
  // { name: 'is_global' , sort: 'is_global' , show: false , bulk_edit: false, nice_name: 'Global' , type: 'checkbox' , value: function(bt) { return bt.is_global; }, text: function(bt) { return bt.is_global ? 'Yes' : 'No' }, width: 400 },
104
101
  { name: 'use_render_function' , sort: 'use_render_function' , show: true , bulk_edit: false, nice_name: 'Use Render Function' , type: 'checkbox' , value: function(bt) { return bt.use_render_function; }, text: function(bt) { return bt.use_render_function ? 'Yes' : 'No' }, width: 400 },
105
- { name: 'use_render_function_for_layout' , sort: 'use_render_function_for_layout' , show: true , bulk_edit: false, nice_name: 'Use Render Function for Modal' , type: 'checkbox' , value: function(bt) { return bt.use_render_function_for_layout; }, text: function(bt) { return bt.use_render_function_for_layout ? 'Yes' : 'No' }, width: 400 },
102
+ // { name: 'use_render_function_for_layout' , sort: 'use_render_function_for_layout' , show: true , bulk_edit: false, nice_name: 'Use Render Function for Modal' , type: 'checkbox' , value: function(bt) { return bt.use_render_function_for_layout; }, text: function(bt) { return bt.use_render_function_for_layout ? 'Yes' : 'No' }, width: 400 },
106
103
  { name: 'use_js_for_modal' , sort: 'use_js_for_modal' , show: true , bulk_edit: false, nice_name: 'Use JS for Modal' , type: 'checkbox' , value: function(bt) { return bt.use_js_for_modal; }, text: function(bt) { return bt.use_js_for_modal ? 'Yes' : 'No' }, width: 400 },
107
104
  { name: 'allow_child_blocks' , sort: 'allow_child_blocks' , show: true , bulk_edit: false, nice_name: 'Allow Child Blocks' , type: 'checkbox' , value: function(bt) { return bt.allow_child_blocks; }, text: function(bt) { return bt.allow_child_blocks ? 'Yes' : 'No' }, width: 400 },
108
105
  { name: 'default_child_block_type_id' , sort: 'default_child_block_type_id' , show: false , bulk_edit: false, nice_name: 'Default Child Block Type ID' , type: 'text' , value: function(bt) { return bt.default_child_block_type_id; }, width: 400 },
@@ -137,6 +134,7 @@ $(document).ready(function() {
137
134
  { name: 'use_render_function_for_layout' , nice_name: 'Use Render Function for Modal' , type: 'checkbox' , value: <%= bt.use_render_function_for_layout ? 'true' : 'false' %>, width: 400 },
138
135
  { name: 'use_js_for_modal' , nice_name: 'Use JS for Modal' , type: 'checkbox' , value: <%= bt.use_js_for_modal ? 'true' : 'false' %>, width: 400 },
139
136
  { name: 'allow_child_blocks' , nice_name: 'Allow Child Blocks' , type: 'checkbox' , value: <%= bt.allow_child_blocks ? 'true' : 'false' %>, width: 400 },
137
+ { name: 'is_dynamic' , nice_name: 'Dynamic Block' , type: 'checkbox' , value: <%= bt.is_dynamic ? 'true' : 'false' %>, width: 400 },
140
138
  { name: 'default_child_block_type_id' , nice_name: 'Default Child Block Type ID' , type: 'text' , value: <%= raw Caboose.json(bt.default_child_block_type_id) %>, width: 400 },
141
139
  { name: 'field_type' , nice_name: 'Field type' , type: 'select' , value: <%= raw Caboose.json(bt.field_type) %>, text: <%= raw Caboose.json(bt.field_type) %>, width: 400, options_url: '/admin/block-types/field-type-options' },
142
140
  { name: 'default' , nice_name: 'Default value' , type: 'text' , value: <%= raw Caboose.json(bt.default) %>, width: 400 },
@@ -144,7 +142,7 @@ $(document).ready(function() {
144
142
  { name: 'height' , nice_name: 'Height' , type: 'text' , value: <%= raw Caboose.json(bt.height) %>, width: 400 },
145
143
  { name: 'fixed_placeholder' , nice_name: 'Fixed placeholder' , type: 'checkbox' , value: <%= raw Caboose.json(bt.fixed_placeholder) %>, width: 400 },
146
144
  { name: 'options_url' , nice_name: 'Options URL' , type: 'text' , value: <%= raw Caboose.json(bt.options_url) %>, width: 400 },
147
- { name: 'options_function' , nice_name: 'Options Function' , type: 'textarea' , value: <%= raw Caboose.json(bt.options_function) %>, width: 400, height: 100 },
145
+ // { name: 'options_function' , nice_name: 'Options Function' , type: 'textarea' , value: <%= raw Caboose.json(bt.options_function) %>, width: 400, height: 100 },
148
146
  { name: 'options' , nice_name: 'Options' , type: 'textarea' , value: <%= raw Caboose.json(bt.options) %>, width: 400, height: 100 },
149
147
  { name: 'default_included' , sort: 'default_included' , nice_name: 'Include on New Sites' , type: 'checkbox' , value: <%= bt.default_included ? 'true' : 'false' %> , width: 400 }
150
148
  ]
@@ -0,0 +1,28 @@
1
+ <%== ERB.new(render_function).result(self.instance_eval { binding }) %>
2
+
3
+ <% if caboose_js && caboose_js.length > 1 %>
4
+ <% caboose_js.to_a.each_with_index do |js, ind| %>
5
+ <% next if ind == 0 %>
6
+ <% content_for :js do %>
7
+ <% begin %>
8
+ <% block.cached_js = ERB.new(js).result(self.instance_eval { binding }) %>
9
+ <% block.save %>
10
+ <% rescue %>
11
+ <% Caboose.log("JS ERROR for block #{block.id}") %>
12
+ <% end %>
13
+ <% end %>
14
+ <% end %>
15
+ <% end %>
16
+ <% if caboose_css && caboose_css.length > 1 %>
17
+ <% caboose_css.to_a.each_with_index do |css, ind| %>
18
+ <% next if ind == 0 %>
19
+ <% content_for :css do %>
20
+ <% begin %>
21
+ <% block.cached_css = ERB.new(css).result(self.instance_eval { binding }) %>
22
+ <% block.save %>
23
+ <% rescue %>
24
+ <% Caboose.log("CSS ERROR for block #{block.id}") %>
25
+ <% end %>
26
+ <% end %>
27
+ <% end %>
28
+ <% end %>
@@ -12,9 +12,9 @@ end
12
12
 
13
13
  if editing
14
14
  if url.nil? || url.starts_with?('http://placehold.it') || url.include?('missing')
15
- %><div id='block_<%= block.id %>'><p>Click to select a file.</p></div><%
15
+ %><div id='block_<%= block.id %>' class='file-select'><p>Click to select file for <%= block.block_type.description %>.</p></div><%
16
16
  else
17
- %><div id='block_<%= block.id %>'><p><span><%= name %></span></p></div><%
17
+ %><div id='block_<%= block.id %>' class='file-select'><p><%= block.block_type.description %> file:<br /><span><%= name %></span></p></div><%
18
18
  end
19
19
  elsif url
20
20
  %><div id='block_<%= block.id %>'><p><a href="<%= raw file.url %>">Download File</a></p></div><%
@@ -1,6 +1,5 @@
1
1
  <% sc = site.social_config %>
2
-
3
- <% if sc.auto_ga_js && !sc.google_analytics_id.blank? %>
2
+ <% if sc.auto_ga_js && !sc.google_analytics_id.blank? && !editing && Rails.env.production? %>
4
3
  <script async src="https://www.googletagmanager.com/gtag/js?id=<%== sc.google_analytics_id %>"></script>
5
4
  <script>
6
5
  window.dataLayer = window.dataLayer || [];
@@ -1,12 +1,15 @@
1
1
  <%
2
2
  url = nil
3
+ mc = "Media"
3
4
  if block.media
4
5
  url = block.media.image.url(:tiny)
6
+ mc = block.media.media_category ? block.media.media_category.name : mc
5
7
  elsif block.image
6
8
  url = block.image.url(:tiny)
7
9
  end
8
10
  if editing && url.include?('placehold') %>
9
11
  <div class="img-wrap" style="position:relative;display:inline-block;">
12
+ <% if block.media %><span>Media > <%= mc %> > <%= block.media.original_name %></span><% end %>
10
13
  <div class="img-holder" style="background-image:url(https://cabooseit.s3.amazonaws.com/assets/caboose/grid.png);background-size:15px;display:inline-block;position:relative;" id='block_<%= block.id %>'>
11
14
  <img src='https://cabooseit.s3.amazonaws.com/assets/select_image.png' width="150" style="max-width:100%;display:block;" />
12
15
  <span style="opacity:0;" class="select">Select an Image</span>
@@ -14,6 +17,7 @@ if editing && url.include?('placehold') %>
14
17
  </div>
15
18
  <% elsif editing %>
16
19
  <div class="img-wrap" style="position:relative;display:inline-block;">
20
+ <% if block.media %><span>Media > <%= mc %> > <%= block.media.original_name %></span><% end %>
17
21
  <div class="img-holder" style="background-image:url(https://cabooseit.s3.amazonaws.com/assets/caboose/grid.png);background-size:15px;display:inline-block;position:relative;" id='block_<%= block.id %>'>
18
22
  <img src='<%== url %>' width="200" style="max-width:100%;display:block;" />
19
23
  <span style="opacity:0;" class="select">Select an Image</span>