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
@@ -73,38 +73,12 @@ module Caboose
|
|
73
73
|
render :layout => 'caboose/admin'
|
74
74
|
end
|
75
75
|
|
76
|
-
# @route GET /admin/posts/:id/
|
77
|
-
def admin_change_logs
|
78
|
-
return unless user_is_allowed('logs', 'view')
|
79
|
-
@post = Post.find(params[:id])
|
80
|
-
if @post.site_id != @logged_in_user.site_id && !@logged_in_user.is_super_admin?
|
81
|
-
redirect_to '/admin/posts'
|
82
|
-
else
|
83
|
-
@logs = ChangeLog.where(:post_id => @post.id).where('(is_field is false and (action = ? OR action = ?)) OR (action != ? and action != ?)','added','deleted','added','deleted').order('timestamp desc, id desc').limit(500)
|
84
|
-
render :layout => 'caboose/admin'
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
# @route PUT /admin/posts/:id/publish
|
76
|
+
# @route GET /admin/posts/:id/publish
|
89
77
|
def admin_publish
|
90
|
-
|
91
|
-
resp.success = false
|
92
|
-
render :json => resp and return unless user_is_allowed('posts', 'edit')
|
93
|
-
post = get_edit_post(params[:id], @site.id)
|
94
|
-
resp.success = true
|
95
|
-
post.delay(:queue => 'caching', :priority => 5).publish(logged_in_user.id)
|
96
|
-
render :json => resp
|
97
|
-
end
|
98
|
-
|
99
|
-
# @route GET /admin/posts/:id/status
|
100
|
-
def admin_status
|
101
|
-
resp = Caboose::StdClass.new
|
102
|
-
resp.status = 'pending'
|
78
|
+
return unless user_is_allowed('posts', 'edit')
|
103
79
|
post = get_edit_post(params[:id], @site.id)
|
104
|
-
|
105
|
-
|
106
|
-
end
|
107
|
-
render :json => resp
|
80
|
+
post.publish
|
81
|
+
redirect_to "/admin/posts/#{post.id}/content"
|
108
82
|
end
|
109
83
|
|
110
84
|
# @route GET /admin/posts/:id/revert
|
@@ -196,9 +170,7 @@ module Caboose
|
|
196
170
|
resp = Caboose::StdClass.new({'attributes' => {}})
|
197
171
|
post = get_edit_post(params[:id], @site.id)
|
198
172
|
save = true
|
199
|
-
|
200
|
-
params.each do |name, value|
|
201
|
-
old_value = post[name]
|
173
|
+
params.each do |name, value|
|
202
174
|
case name
|
203
175
|
when 'site_id' then post.site_id = value.to_i
|
204
176
|
when 'slug' then post.set_slug_and_uri(value)
|
@@ -213,13 +185,6 @@ module Caboose
|
|
213
185
|
when 'created_at' then post.created_at = DateTime.strptime(value,'%m/%d/%Y')
|
214
186
|
when 'updated_at' then post.updated_at = DateTime.parse(value)
|
215
187
|
end
|
216
|
-
if @site.use_change_logs && !['id','action','controller'].include?(name)
|
217
|
-
ov = old_value
|
218
|
-
nv = value
|
219
|
-
ov = ['published'].include?(name) ? (ov ? 'yes' : 'no') : ov
|
220
|
-
nv = ['published'].include?(name) ? ( ['1',1,true,'true'].include?(nv) ? 'yes' : 'no') : nv
|
221
|
-
cl = Caboose::ChangeLog.create(:site_id => @site.id, :description => "Post #{name.titleize}", :user_id => user.id, :post_id => post.id, :timestamp => DateTime.now, :action => 'edited', :old_value => ov, :new_value => nv)
|
222
|
-
end
|
223
188
|
end
|
224
189
|
resp.success = save && post.save
|
225
190
|
render :json => resp
|
@@ -227,25 +192,20 @@ module Caboose
|
|
227
192
|
|
228
193
|
# @route POST /admin/posts/:id/image
|
229
194
|
def admin_update_image
|
230
|
-
return if !user_is_allowed('posts', 'edit')
|
231
|
-
user = logged_in_user
|
195
|
+
return if !user_is_allowed('posts', 'edit')
|
232
196
|
resp = Caboose::StdClass.new
|
233
197
|
post = get_edit_post(params[:id], @site.id)
|
234
|
-
ov = post.image_file_name
|
235
198
|
post.image = params[:image]
|
236
199
|
resp.success = post.save
|
237
200
|
resp.attributes = { 'image' => { 'value' => post.image.url(:thumb) }}
|
238
|
-
Caboose::ChangeLog.create(:site_id => @site.id, :description => "Post Image", :user_id => user.id, :post_id => post.id, :timestamp => DateTime.now, :action => 'edited', :old_value => ov, :new_value => post.image_file_name) if @site.use_change_logs
|
239
201
|
render :text => resp.to_json
|
240
202
|
end
|
241
203
|
|
242
204
|
# @route POST /admin/posts/:id/remove-image
|
243
205
|
def admin_remove_image
|
244
206
|
return unless user_is_allowed("posts", 'edit')
|
245
|
-
resp = Caboose::StdClass.new
|
246
|
-
user = logged_in_user
|
207
|
+
resp = Caboose::StdClass.new
|
247
208
|
b = Post.find(params[:id])
|
248
|
-
Caboose::ChangeLog.create(:site_id => @site.id, :description => "Post Image", :user_id => user.id, :post_id => b.id, :timestamp => DateTime.now, :action => 'edited', :old_value => b.image_file_name, :new_value => 'None') if @site.use_change_logs
|
249
209
|
b.image_file_name = nil
|
250
210
|
b.image_file_size = nil
|
251
211
|
b.image_content_type = nil
|
@@ -281,7 +241,6 @@ module Caboose
|
|
281
241
|
bt = BlockType.where(:id => @site.default_layout_id).first
|
282
242
|
Block.create(:post_id => post.id, :block_type_id => bt.id, :name => bt.name) if post && bt
|
283
243
|
resp.redirect = "/admin/posts/#{post.id}"
|
284
|
-
Caboose::ChangeLog.create(:site_id => @site.id, :description => post.title, :user_id => logged_in_user.id, :post_id => post.id, :timestamp => DateTime.now, :action => 'created') if @site.use_change_logs
|
285
244
|
end
|
286
245
|
render :json => resp
|
287
246
|
end
|
@@ -291,10 +250,8 @@ module Caboose
|
|
291
250
|
return if !user_is_allowed('posts', 'edit')
|
292
251
|
post = get_edit_post(params[:id], @site.id)
|
293
252
|
cat_id = params[:post_category_id]
|
294
|
-
cat = PostCategory.where(:id => cat_id).first
|
295
253
|
if post && !PostCategoryMembership.exists?(:post_id => post.id, :post_category_id => cat_id)
|
296
254
|
PostCategoryMembership.create(:post_id => post.id, :post_category_id => cat_id)
|
297
|
-
Caboose::ChangeLog.create(:site_id => @site.id, :description => "Post Category", :user_id => logged_in_user.id, :post_id => post.id, :timestamp => DateTime.now, :action => "added", :new_value => (cat ? cat.name : nil)) if @site.use_change_logs
|
298
255
|
end
|
299
256
|
render :json => true
|
300
257
|
end
|
@@ -304,10 +261,8 @@ module Caboose
|
|
304
261
|
return if !user_is_allowed('posts', 'edit')
|
305
262
|
post = get_edit_post(params[:id], @site.id)
|
306
263
|
cat_id = params[:post_category_id]
|
307
|
-
cat = PostCategory.where(:id => cat_id).first
|
308
264
|
if post && PostCategoryMembership.exists?(:post_id => post.id, :post_category_id => cat_id)
|
309
265
|
PostCategoryMembership.where(:post_id => post.id, :post_category_id => cat_id).destroy_all
|
310
|
-
Caboose::ChangeLog.create(:site_id => @site.id, :description => "Post Category", :user_id => logged_in_user.id, :post_id => post.id, :timestamp => DateTime.now, :action => "deleted", :old_value => (cat ? cat.name : nil)) if @site.use_change_logs
|
311
266
|
end
|
312
267
|
render :json => true
|
313
268
|
end
|
@@ -317,7 +272,6 @@ module Caboose
|
|
317
272
|
return if !user_is_allowed('posts', 'edit')
|
318
273
|
post = get_edit_post(params[:id], @site.id)
|
319
274
|
PostCategoryMembership.where(:post_id => post.id).destroy_all if post
|
320
|
-
Caboose::ChangeLog.create(:site_id => @site.id, :description => post.title, :user_id => logged_in_user.id, :post_id => post.id, :timestamp => DateTime.now, :action => 'deleted') if post && @site.use_change_logs
|
321
275
|
Post.where(:id => post.id).destroy_all if post
|
322
276
|
render :json => { 'redirect' => '/admin/posts' }
|
323
277
|
end
|
@@ -323,7 +323,7 @@ module Caboose
|
|
323
323
|
:params => params.to_json,
|
324
324
|
:status => 'pending'
|
325
325
|
)
|
326
|
-
e.delay(:queue => '
|
326
|
+
e.delay(:queue => 'caboose_general', :priority => 8).product_process if Rails.env.production?
|
327
327
|
e.product_process if Rails.env.development?
|
328
328
|
resp.new_id = e.id
|
329
329
|
resp.success = true
|
@@ -89,8 +89,8 @@ module Caboose
|
|
89
89
|
|
90
90
|
# @route GET /admin/sites/:id/block-types
|
91
91
|
def admin_edit_block_types
|
92
|
-
return
|
93
|
-
if (
|
92
|
+
return if !user_is_allowed('sites', 'edit')
|
93
|
+
if (!logged_in_user.is_super_admin?)
|
94
94
|
@error = "You are not allowed to edit this site."
|
95
95
|
render :file => 'caboose/extras/error' and return
|
96
96
|
end
|
@@ -139,8 +139,8 @@ module Caboose
|
|
139
139
|
|
140
140
|
# @route GET /admin/sites/:id
|
141
141
|
def admin_edit
|
142
|
-
return
|
143
|
-
if (
|
142
|
+
return if !user_is_allowed('sites', 'edit')
|
143
|
+
if (!logged_in_user.is_super_admin?)
|
144
144
|
@error = "You are not allowed to edit this site."
|
145
145
|
render :file => 'caboose/extras/error' and return
|
146
146
|
end
|
@@ -168,7 +168,6 @@ module Caboose
|
|
168
168
|
site.description = site_name
|
169
169
|
site.use_fonts = true
|
170
170
|
site.use_dragdrop = true
|
171
|
-
site.use_caching = true
|
172
171
|
site.theme_color = '#141414'
|
173
172
|
site.allow_self_registration = false
|
174
173
|
site.use_store = false
|
@@ -215,11 +214,8 @@ module Caboose
|
|
215
214
|
when 'state' then site.state = value
|
216
215
|
when 'zip' then site.zip = value
|
217
216
|
when 'fax' then site.fax = value
|
218
|
-
when 'use_change_logs' then site.use_change_logs = value
|
219
|
-
when 'google_api_key' then site.google_api_key = value
|
220
217
|
when 'contact_email' then site.contact_email = value
|
221
218
|
when 'recaptcha_threshold' then site.recaptcha_threshold = value
|
222
|
-
when 'use_caching' then site.use_caching = value
|
223
219
|
when 'head_code' then site.head_code = (value.blank? ? nil : value.gsub('<end/script>','</script>'))
|
224
220
|
when 'body_open_code' then site.body_open_code = (value.blank? ? nil : value.gsub('<end/script>','</script>'))
|
225
221
|
when 'body_close_code' then site.body_close_code = (value.blank? ? nil : value.gsub('<end/script>','</script>'))
|
@@ -303,8 +299,8 @@ module Caboose
|
|
303
299
|
# @route GET /admin/sites/:field-options
|
304
300
|
# @route GET /admin/sites/:id/:field-options
|
305
301
|
def options
|
306
|
-
return if !user_is_allowed('sites', '
|
307
|
-
render :json => { :error => "You are not allowed to manage sites." } and return if
|
302
|
+
return if !user_is_allowed('sites', 'view')
|
303
|
+
render :json => { :error => "You are not allowed to manage sites." } and return if !@site.is_master
|
308
304
|
case params[:field]
|
309
305
|
when nil
|
310
306
|
options = logged_in_user.is_super_admin? ? Site.reorder('name').all.collect { |s| { 'value' => s.id, 'text' => s.name }} : []
|
@@ -319,21 +315,6 @@ module Caboose
|
|
319
315
|
end
|
320
316
|
|
321
317
|
|
322
|
-
# @route PUT /admin/sites/:id/refresh-cache
|
323
|
-
def admin_refresh_cache
|
324
|
-
return if !user_is_allowed('sites', 'edit')
|
325
|
-
@site.delay(:queue => 'caching', :priority => 5).refresh_all_page_caches
|
326
|
-
render :json => true
|
327
|
-
end
|
328
|
-
|
329
|
-
# @route GET /api/generate-asset/site_:id
|
330
|
-
def compiled_asset
|
331
|
-
respond_to do |format|
|
332
|
-
format.css { render :layout => 'caboose/footer_css', :content_type => "text/css" }
|
333
|
-
format.js { render :layout => 'caboose/footer_js', :content_type => "text/javascript" }
|
334
|
-
end
|
335
|
-
end
|
336
|
-
|
337
318
|
private
|
338
319
|
|
339
320
|
def get_edit_site(s_id, site_id)
|
@@ -22,9 +22,9 @@ module Caboose
|
|
22
22
|
media_category_id = arr.shift
|
23
23
|
original_name = arr.join('_')
|
24
24
|
name = Caboose::Media.upload_name(original_name)
|
25
|
-
m = Media.where(:media_category_id => media_category_id, :original_name => original_name, :name => name
|
26
|
-
m = Media.create(:media_category_id => media_category_id, :original_name => original_name, :name => name, :processed => false
|
27
|
-
m.delay(:queue => '
|
25
|
+
m = Media.where(:media_category_id => media_category_id, :original_name => original_name, :name => name).first
|
26
|
+
m = Media.create(:media_category_id => media_category_id, :original_name => original_name, :name => name, :processed => false) if m.nil?
|
27
|
+
m.delay(:queue => 'caboose_media', :priority => 3).process
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -134,18 +134,6 @@ module Caboose
|
|
134
134
|
@theme = @site.theme
|
135
135
|
end
|
136
136
|
|
137
|
-
# @route GET /admin/theme/js
|
138
|
-
def admin_js
|
139
|
-
return if !user_is_allowed('theme', 'edit')
|
140
|
-
@theme = @site.theme
|
141
|
-
end
|
142
|
-
|
143
|
-
# @route GET /admin/theme/errors
|
144
|
-
def admin_error_log
|
145
|
-
return if !user_is_allowed('theme', 'edit')
|
146
|
-
@theme = @site.theme
|
147
|
-
end
|
148
|
-
|
149
137
|
# @route PUT /admin/theme/sass
|
150
138
|
def admin_update_sass
|
151
139
|
return if !user_is_allowed('theme', 'edit')
|
@@ -158,19 +146,6 @@ module Caboose
|
|
158
146
|
render :json => resp
|
159
147
|
end
|
160
148
|
|
161
|
-
# @route PUT /admin/theme/js
|
162
|
-
def admin_update_js
|
163
|
-
return if !user_is_allowed('theme', 'edit')
|
164
|
-
resp = StdClass.new
|
165
|
-
@theme = @site.theme
|
166
|
-
@theme.main_js = params['code']
|
167
|
-
@theme.save
|
168
|
-
@theme.upload_js(@site.id)
|
169
|
-
resp.success = true
|
170
|
-
resp.message = "Code has been saved!"
|
171
|
-
render :json => resp
|
172
|
-
end
|
173
|
-
|
174
149
|
# @route POST /admin/themes/:id/default-banner-image
|
175
150
|
def admin_update_default_banner_image
|
176
151
|
return if !user_is_allowed('theme', 'edit')
|
@@ -191,7 +166,6 @@ module Caboose
|
|
191
166
|
resp = Caboose::StdClass.new
|
192
167
|
checked = params[:checked]
|
193
168
|
theme_id = params[:id]
|
194
|
-
theme = Caboose::Theme.find(theme_id)
|
195
169
|
file_id = params[:file_id]
|
196
170
|
if checked && checked != false && checked != 'false'
|
197
171
|
am = Caboose::ThemeFileMembership.where(:theme_id => theme_id, :theme_file_id => file_id).first
|
@@ -202,10 +176,6 @@ module Caboose
|
|
202
176
|
else
|
203
177
|
Caboose::ThemeFileMembership.delete_all(:theme_id => theme_id, :theme_file_id => file_id)
|
204
178
|
end
|
205
|
-
file = Caboose::ThemeFile.find(file_id)
|
206
|
-
if file && file.filename.include?('.js')
|
207
|
-
Rails.env.production? ? theme.delay(:queue => 'general', :priority => 12).upload_js(@site.id) : theme.upload_js(@site.id)
|
208
|
-
end
|
209
179
|
resp.success = "Success"
|
210
180
|
render :json => resp
|
211
181
|
end
|
@@ -26,7 +26,6 @@ module Caboose
|
|
26
26
|
# @route GET /admin/users/json
|
27
27
|
def admin_json
|
28
28
|
return if !user_is_allowed('users', 'view')
|
29
|
-
where2 = @logged_in_user && @logged_in_user.is_allowed('all', 'all') ? "id is not null" : "username is null or (username != 'admin' and username != 'eli' and username != 'elo')"
|
30
29
|
pager = PageBarGenerator.new(params, {
|
31
30
|
'site_id' => @site.id,
|
32
31
|
'first_name_like' => '',
|
@@ -39,7 +38,7 @@ module Caboose
|
|
39
38
|
'desc' => false,
|
40
39
|
'base_url' => '/admin/users',
|
41
40
|
'use_url_params' => false,
|
42
|
-
'additional_where' => [ "(site_id = #{@site.id})
|
41
|
+
'additional_where' => [ "(site_id = #{@site.id})" ]
|
43
42
|
})
|
44
43
|
render :json => {
|
45
44
|
:pager => pager,
|
@@ -115,7 +114,7 @@ module Caboose
|
|
115
114
|
:params => params.to_json,
|
116
115
|
:status => 'pending'
|
117
116
|
)
|
118
|
-
e.delay(:queue => '
|
117
|
+
e.delay(:queue => 'caboose_general', :priority => 8).user_process if Rails.env.production?
|
119
118
|
e.user_process if Rails.env.development?
|
120
119
|
resp.new_id = e.id
|
121
120
|
resp.success = true
|
@@ -127,14 +126,6 @@ module Caboose
|
|
127
126
|
return if !user_is_allowed('users', 'edit')
|
128
127
|
@edituser = get_edit_user(params[:id], @site.id)
|
129
128
|
end
|
130
|
-
|
131
|
-
# @route GET /admin/users/:id/logs
|
132
|
-
def admin_change_logs
|
133
|
-
return unless user_is_allowed('logs', 'view')
|
134
|
-
@edituser = get_edit_user(params[:id], @site.id)
|
135
|
-
mc = "Media Category"
|
136
|
-
@logs = ChangeLog.where(:user_id => @edituser.id, :site_id => @site.id).where('(is_field = false and (action = ? OR action = ?)) OR (action != ? and action != ?) OR (is_field = true AND description ILIKE (?))','added','deleted','added','deleted',"%#{mc}%").order('timestamp desc, id desc').limit(500)
|
137
|
-
end
|
138
129
|
|
139
130
|
# @route GET /admin/users/:id/password
|
140
131
|
def admin_edit_password
|
@@ -221,11 +212,13 @@ module Caboose
|
|
221
212
|
|
222
213
|
# @route POST /admin/users
|
223
214
|
def admin_add
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
215
|
+
return if !user_is_allowed('users', 'add')
|
216
|
+
|
217
|
+
resp = StdClass.new({
|
218
|
+
'error' => nil,
|
219
|
+
'redirect' => nil
|
220
|
+
})
|
221
|
+
|
229
222
|
user = User.new()
|
230
223
|
user.email = params[:email] ? params[:email].strip.downcase : nil
|
231
224
|
user.site_id = @site.id
|
@@ -403,7 +396,7 @@ module Caboose
|
|
403
396
|
token = params[:token]
|
404
397
|
if user.token == params[:token]
|
405
398
|
if logged_in? || logged_in_user.id == User::LOGGED_OUT_USER_ID
|
406
|
-
|
399
|
+
Caboose.log(logged_in_user.id)
|
407
400
|
redirect_to "/logout?return_url=/admin/users/#{params[:id]}/su/#{user.token}"
|
408
401
|
return
|
409
402
|
end
|
@@ -316,38 +316,38 @@ module Caboose
|
|
316
316
|
when 'sale_price'
|
317
317
|
variants.each_with_index do |v, i|
|
318
318
|
v.sale_price = value
|
319
|
-
v.product.delay(:run_at => 3.seconds.from_now, :queue => '
|
319
|
+
v.product.delay(:run_at => 3.seconds.from_now, :queue => 'caboose_store').update_on_sale if i == 0
|
320
320
|
end
|
321
321
|
when 'date_sale_starts'
|
322
322
|
variants.each_with_index do |v, i|
|
323
323
|
v.date_sale_starts = ModelBinder.update_date(v.date_sale_starts, value, @logged_in_user.timezone)
|
324
324
|
if i == 0
|
325
|
-
v.product.delay(:run_at => v.date_sale_starts, :queue => '
|
326
|
-
v.product.delay(:run_at => 3.seconds.from_now, :queue => '
|
325
|
+
v.product.delay(:run_at => v.date_sale_starts, :queue => 'caboose_store').update_on_sale
|
326
|
+
v.product.delay(:run_at => 3.seconds.from_now, :queue => 'caboose_store').update_on_sale
|
327
327
|
end
|
328
328
|
end
|
329
329
|
when 'time_sale_starts'
|
330
330
|
variants.each_with_index do |v, i|
|
331
331
|
v.date_sale_starts = ModelBinder.update_time(v.date_sale_starts, value, @logged_in_user.timezone)
|
332
332
|
if i == 0
|
333
|
-
v.product.delay(:run_at => v.date_sale_starts, :queue => '
|
334
|
-
v.product.delay(:run_at => 3.seconds.from_now, :queue => '
|
333
|
+
v.product.delay(:run_at => v.date_sale_starts, :queue => 'caboose_store').update_on_sale
|
334
|
+
v.product.delay(:run_at => 3.seconds.from_now, :queue => 'caboose_store').update_on_sale
|
335
335
|
end
|
336
336
|
end
|
337
337
|
when 'date_sale_ends'
|
338
338
|
variants.each_with_index do |v, i|
|
339
339
|
v.date_sale_ends = ModelBinder.update_date(v.date_sale_ends, value, @logged_in_user.timezone)
|
340
340
|
if i == 0
|
341
|
-
v.product.delay(:run_at => v.date_sale_ends , :queue => '
|
342
|
-
v.product.delay(:run_at => 3.seconds.from_now, :queue => '
|
341
|
+
v.product.delay(:run_at => v.date_sale_ends , :queue => 'caboose_store').update_on_sale
|
342
|
+
v.product.delay(:run_at => 3.seconds.from_now, :queue => 'caboose_store').update_on_sale
|
343
343
|
end
|
344
344
|
end
|
345
345
|
when 'time_sale_ends'
|
346
346
|
variants.each_with_index do |v, i|
|
347
347
|
v.date_sale_ends = ModelBinder.update_time(v.date_sale_ends, value, @logged_in_user.timezone)
|
348
348
|
if i == 0
|
349
|
-
v.product.delay(:run_at => v.date_sale_ends , :queue => '
|
350
|
-
v.product.delay(:run_at => 3.seconds.from_now, :queue => '
|
349
|
+
v.product.delay(:run_at => v.date_sale_ends , :queue => 'caboose_store').update_on_sale
|
350
|
+
v.product.delay(:run_at => 3.seconds.from_now, :queue => 'caboose_store').update_on_sale
|
351
351
|
end
|
352
352
|
end
|
353
353
|
|
@@ -5,7 +5,7 @@
|
|
5
5
|
class Caboose::AbVariant < ActiveRecord::Base
|
6
6
|
self.table_name = "ab_variants"
|
7
7
|
|
8
|
-
has_many :ab_options,
|
8
|
+
has_many :ab_options, -> { order(:id) }, :dependent => :destroy
|
9
9
|
has_many :ab_values, :dependent => :destroy
|
10
10
|
attr_accessible :name, :analytics_name
|
11
11
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
class Caboose::Asset < ActiveRecord::Base
|
3
|
+
self.table_name = "assets"
|
4
|
+
belongs_to :page
|
5
|
+
attr_accessible :page_id, :uploaded_by_id, :date_uploaded, :name, :filename, :description, :extension
|
6
|
+
|
7
|
+
def sanitize_name(str)
|
8
|
+
return str.gsub(' ', '_').downcase
|
9
|
+
end
|
10
|
+
|
11
|
+
def assets_with_uri(host_with_port, uri)
|
12
|
+
uri[0] = '' if uri.start_with? '/'
|
13
|
+
|
14
|
+
page = Page.page_with_uri(host_with_port, File.dirname(uri), false)
|
15
|
+
return false if page.nil?
|
16
|
+
|
17
|
+
asset = Asset.where(:page_id => page.id,:filename => File.basename(uri)).first
|
18
|
+
return false if asset.nil?
|
19
|
+
|
20
|
+
return asset
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module Caboose
|
2
|
+
class AssetManager
|
3
|
+
def AssetManager.referenced_assets_in_views
|
4
|
+
|
5
|
+
files = []
|
6
|
+
|
7
|
+
# Stylesheets
|
8
|
+
str = `grep -Rh stylesheet_link_tag #{Rails.root}/app/views`
|
9
|
+
str << `grep -Rh stylesheet_link_tag #{Rails.root}/sites/*/views`
|
10
|
+
str.strip.split("\n").each do |line|
|
11
|
+
file = self.replace_css_line(line)
|
12
|
+
files << (file.ends_with?('.css') ? "#{file}" : "#{file}.css") if file
|
13
|
+
end
|
14
|
+
|
15
|
+
# Javascript
|
16
|
+
str = `grep -Rh javascript_include_tag #{Rails.root}/app/views`
|
17
|
+
str << `grep -Rh javascript_include_tag #{Rails.root}/sites/*/views`
|
18
|
+
str.strip.split("\n").each do |line|
|
19
|
+
file = self.replace_js_line(line)
|
20
|
+
files << (file.ends_with?('.js') ? "#{file}" : "#{file}.js") if file
|
21
|
+
end
|
22
|
+
|
23
|
+
return files.uniq
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def AssetManager.referenced_assets_in_caboose_views
|
28
|
+
|
29
|
+
# Get anything that was referenced in the views
|
30
|
+
spec = Gem::Specification.find_by_name('caboose-cms')
|
31
|
+
files = []
|
32
|
+
|
33
|
+
# Stylesheets
|
34
|
+
str = `grep -Rh stylesheet_link_tag #{spec.gem_dir}/app/views`
|
35
|
+
str.strip.split("\n").each do |line|
|
36
|
+
file = self.replace_css_line(line)
|
37
|
+
files << (file.ends_with?('.css') ? "#{file}" : "#{file}.css") if file
|
38
|
+
end
|
39
|
+
|
40
|
+
# Javascript
|
41
|
+
str = `grep -Rh javascript_include_tag #{spec.gem_dir}/app/views`
|
42
|
+
str.strip.split("\n").each do |line|
|
43
|
+
file = self.replace_js_line(line)
|
44
|
+
files << (file.ends_with?('.js') ? "#{file}" : "#{file}.js") if file
|
45
|
+
end
|
46
|
+
|
47
|
+
#puts "--------------------------------------------------------------------"
|
48
|
+
#puts files.uniq
|
49
|
+
#puts "--------------------------------------------------------------------"
|
50
|
+
#return files.uniq
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
def AssetManager.replace_css_line(str)
|
55
|
+
return nil if str.include?('#{') || str.include?('@') || str.include?(".each do")
|
56
|
+
str = str
|
57
|
+
.gsub('<%=','')
|
58
|
+
.gsub('%>','')
|
59
|
+
.gsub('gzip_stylesheet_link_tag','')
|
60
|
+
.gsub('stylesheet_link_tag','')
|
61
|
+
.gsub('(','')
|
62
|
+
.gsub(')','')
|
63
|
+
.gsub('"','')
|
64
|
+
.gsub("'",'')
|
65
|
+
.gsub(',','')
|
66
|
+
.gsub(':media => "all"','')
|
67
|
+
.strip.split(' ').first.strip
|
68
|
+
return nil if str.length == 0 || str.starts_with?('#') || str.starts_with?('http') || str.starts_with?('//')
|
69
|
+
return str
|
70
|
+
end
|
71
|
+
|
72
|
+
def AssetManager.replace_js_line(str)
|
73
|
+
return nil if str.include?('#{') || str.include?('@') || str.include?(".each do")
|
74
|
+
str = str
|
75
|
+
.gsub('<%=','')
|
76
|
+
.gsub('<%','')
|
77
|
+
.gsub('%>','')
|
78
|
+
.gsub('gzip_javascript_include_tag','')
|
79
|
+
.gsub('javascript_include_tag','')
|
80
|
+
.gsub('(','')
|
81
|
+
.gsub(')','')
|
82
|
+
.gsub('"','')
|
83
|
+
.gsub("'",'')
|
84
|
+
.gsub(",",'')
|
85
|
+
.strip.split(' ').first.strip
|
86
|
+
return nil if str.length == 0 || str.starts_with?('#') || str.starts_with?('http') || str.starts_with?('//')
|
87
|
+
return str
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|