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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/caboose/admin.js +1 -1
- data/app/assets/javascripts/caboose/admin_main.js +1 -13
- data/app/assets/javascripts/caboose/admin_media_index.js +161 -158
- data/app/assets/javascripts/caboose/application.js +8 -7
- data/app/assets/javascripts/caboose/block_content_controller_dragdrop.js +60 -4
- data/app/assets/javascripts/caboose/block_modal_controllers/block_dd_modal_controller.js +3 -2
- data/app/assets/javascripts/caboose/block_modal_controllers/media_modal_controller.js +17 -6
- data/app/assets/javascripts/caboose/model/all.js +5 -1
- data/app/assets/stylesheets/caboose/admin_block_edit_image.css.scss +2 -1
- data/app/assets/stylesheets/caboose/admin_edit_page_content_dragdrop.scss +71 -15
- data/app/assets/stylesheets/caboose/admin_main.css.scss +25 -29
- data/app/assets/stylesheets/caboose/admin_media_index.css.scss +26 -5
- data/app/assets/stylesheets/caboose/application.css +11 -5
- data/app/assets/stylesheets/caboose/login.scss +1 -0
- data/app/assets/stylesheets/caboose/model_binder.css +13 -4
- data/app/assets/stylesheets/caboose/page_bar_generator.css +2 -1
- data/app/controllers/caboose/admin_controller.rb +3 -4
- data/app/controllers/caboose/application_controller.rb +16 -19
- data/app/controllers/caboose/block_types_controller.rb +8 -6
- data/app/controllers/caboose/cart_controller.rb +2 -2
- data/app/controllers/caboose/change_logs_controller.rb +13 -0
- data/app/controllers/caboose/fonts_controller.rb +139 -2
- data/app/controllers/caboose/invoices_controller.rb +5 -4
- data/app/controllers/caboose/login_logs_controller.rb +5 -7
- data/app/controllers/caboose/media_categories_controller.rb +16 -2
- data/app/controllers/caboose/media_controller.rb +14 -11
- data/app/controllers/caboose/pages_controller.rb +104 -42
- data/app/controllers/caboose/posts_controller.rb +53 -7
- data/app/controllers/caboose/products_controller.rb +1 -1
- data/app/controllers/caboose/sites_controller.rb +25 -6
- data/app/controllers/caboose/sns_controller.rb +3 -3
- data/app/controllers/caboose/themes_controller.rb +30 -0
- data/app/controllers/caboose/users_controller.rb +17 -10
- data/app/controllers/caboose/variants_controller.rb +9 -9
- data/app/models/caboose/block.rb +98 -22
- data/app/models/caboose/block_type.rb +2 -1
- data/app/models/caboose/block_type_parser.rb +1 -1
- data/app/models/caboose/calendar_event_group.rb +2 -2
- data/app/models/caboose/change_log.rb +97 -0
- data/app/models/caboose/core_plugin.rb +4 -3
- data/app/models/caboose/font.rb +7 -2
- data/app/models/caboose/font_variant.rb +12 -0
- data/app/models/caboose/media.rb +15 -4
- data/app/models/caboose/media_category.rb +2 -4
- data/app/models/caboose/page.rb +316 -45
- data/app/models/caboose/page_bar_generator.rb +20 -10
- data/app/models/caboose/post.rb +108 -8
- data/app/models/caboose/product.rb +1 -1
- data/app/models/caboose/role.rb +2 -2
- data/app/models/caboose/schema.rb +73 -72
- data/app/models/caboose/site.rb +203 -1
- data/app/models/caboose/theme.rb +70 -5
- data/app/views/caboose/block_types/admin_edit.html.erb +6 -8
- data/app/views/caboose/blocks/_cached_block.html.erb +28 -0
- data/app/views/caboose/blocks/_file.html.erb +2 -2
- data/app/views/caboose/blocks/_ga.html.erb +1 -2
- data/app/views/caboose/blocks/_image.html.erb +4 -0
- data/app/views/caboose/blocks/_render_function.html.erb +9 -4
- data/app/views/caboose/change_logs/admin_index.html.erb +65 -0
- data/app/views/caboose/fonts/admin_family_edit.html.erb +63 -0
- data/app/views/caboose/fonts/admin_family_index.html.erb +42 -0
- data/app/views/caboose/fonts/admin_index.html.erb +55 -10
- data/app/views/caboose/fonts/admin_variant_edit.html.erb +84 -0
- data/app/views/caboose/invoices_mailer/customer_status_updated.html.erb +5 -14
- data/app/views/caboose/login_logs/admin_index_for_user.html.erb +1 -1
- data/app/views/caboose/media/admin_index.html.erb +14 -24
- data/app/views/caboose/my_account/index.html.erb +1 -0
- data/app/views/caboose/pages/_admin_header.html.erb +5 -0
- data/app/views/caboose/pages/admin_change_logs.html.erb +56 -0
- data/app/views/caboose/pages/admin_edit_content.html.erb +6 -2
- data/app/views/caboose/pages/admin_edit_general.html.erb +32 -4
- 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_header.html.erb +5 -0
- data/app/views/caboose/posts/admin_change_logs.html.erb +56 -0
- data/app/views/caboose/posts/admin_delete_form.html.erb +1 -1
- data/app/views/caboose/posts/admin_edit_content.html.erb +6 -2
- 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 +21 -0
- 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_edit.html.erb +7 -3
- data/app/views/caboose/themes/admin_error_log.html.erb +9 -0
- data/app/views/caboose/themes/admin_js.html.erb +131 -0
- data/app/views/caboose/users/_admin_header.html.erb +4 -0
- data/app/views/caboose/users/admin_change_logs.html.erb +63 -0
- data/app/views/caboose/users/admin_edit_roles.html.erb +1 -0
- data/app/views/caboose/variants/admin_group.html.erb +1 -1
- data/app/views/layouts/caboose/admin.html.erb +9 -2
- data/app/views/layouts/caboose/application.html.erb +62 -92
- data/app/views/layouts/caboose/css.css.erb +44 -0
- data/app/views/layouts/caboose/footer_css.css.erb +41 -0
- data/app/views/layouts/caboose/footer_js.js.erb +31 -0
- data/app/views/layouts/caboose/js.js.erb +34 -0
- data/lib/caboose/version.rb +1 -1
- data/lib/tasks/caboose.rake +3 -14
- metadata +23 -27
- data/app/controllers/caboose/assets_controller.rb +0 -65
- data/app/models/caboose/asset.rb +0 -23
- data/app/models/caboose/asset_manifest.rb +0 -91
- data/app/models/caboose/block_cache.rb +0 -105
- data/app/models/caboose/block_cache_file.rb +0 -22
- data/app/models/caboose/block_cache_image.rb +0 -53
- data/app/models/caboose/page_cache.rb +0 -12
- data/app/models/caboose/page_cacher.rb +0 -137
- data/app/views/caboose/pages/admin_new_old.html.erb +0 -46
- data/app/views/caboose/pages/test.html.erb +0 -64
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
module Caboose
|
3
2
|
class LoginLogsController < ApplicationController
|
4
3
|
layout 'caboose/admin'
|
@@ -9,7 +8,7 @@ module Caboose
|
|
9
8
|
|
10
9
|
# @route GET /admin/login-logs/user/:userid
|
11
10
|
def admin_index_for_user
|
12
|
-
return if !user_is_allowed_to 'view', '
|
11
|
+
return if !user_is_allowed_to 'view', 'login_logs'
|
13
12
|
@pager = self.login_logs_pager
|
14
13
|
@edituser = Caboose::User.find(params[:userid]) if !params[:userid].blank?
|
15
14
|
render :layout => 'caboose/admin'
|
@@ -17,14 +16,14 @@ module Caboose
|
|
17
16
|
|
18
17
|
# @route GET /admin/login-logs
|
19
18
|
def admin_index
|
20
|
-
return if !user_is_allowed_to 'view', '
|
19
|
+
return if !user_is_allowed_to 'view', 'login_logs'
|
21
20
|
@pager = self.login_logs_pager
|
22
21
|
render :layout => 'caboose/admin'
|
23
22
|
end
|
24
23
|
|
25
24
|
# @route GET /admin/login-logs/json
|
26
25
|
def admin_json
|
27
|
-
return if !user_is_allowed_to 'view', '
|
26
|
+
return if !user_is_allowed_to 'view', 'login_logs'
|
28
27
|
pager = self.login_logs_pager
|
29
28
|
render :json => {
|
30
29
|
:pager => pager,
|
@@ -53,18 +52,17 @@ module Caboose
|
|
53
52
|
|
54
53
|
# @route GET /admin/login-logs/:id/json
|
55
54
|
def admin_json_single
|
56
|
-
return if !user_is_allowed_to 'view', '
|
55
|
+
return if !user_is_allowed_to 'view', 'login_logs'
|
57
56
|
login_log = LoginLog.find(params[:id])
|
58
57
|
render :json => login_log
|
59
58
|
end
|
60
59
|
|
61
60
|
# @route GET /admin/login-logs/:id
|
62
61
|
def admin_edit
|
63
|
-
return if !user_is_allowed_to 'edit', '
|
62
|
+
return if !user_is_allowed_to 'edit', 'login_logs'
|
64
63
|
@login_log = LoginLog.find(params[:id])
|
65
64
|
render :layout => 'caboose/admin'
|
66
65
|
end
|
67
66
|
|
68
67
|
end
|
69
68
|
end
|
70
|
-
|
@@ -61,6 +61,7 @@ module Caboose
|
|
61
61
|
if !cat.save
|
62
62
|
resp.error = cat.errors.first[1]
|
63
63
|
else
|
64
|
+
Caboose::ChangeLog.create(:site_id => @site.id, :description => "Media Category: #{cat.name}", :is_field => true, :user_id => logged_in_user.id, :media_id => cat.id, :timestamp => DateTime.now, :action => 'created') if @site.use_change_logs
|
64
65
|
resp.new_id = cat.id
|
65
66
|
resp.refresh = true
|
66
67
|
end
|
@@ -98,8 +99,14 @@ module Caboose
|
|
98
99
|
def admin_delete
|
99
100
|
return unless user_is_allowed('mediacategories', 'delete')
|
100
101
|
cat = MediaCategory.find(params[:id])
|
101
|
-
|
102
|
-
|
102
|
+
if MediaCategory.top_category(@site.id).id != cat.id
|
103
|
+
Media.where(:media_category_id => cat.id).update_all(:deleted => true)
|
104
|
+
cat.parent_id = 0
|
105
|
+
cat.save
|
106
|
+
if @site.use_change_logs
|
107
|
+
Caboose::ChangeLog.create(:site_id => @site.id, :description => "Media Category: #{cat.name}", :is_field => true, :user_id => logged_in_user.id, :media_id => cat.id, :timestamp => DateTime.now, :action => 'deleted') if @site.use_change_logs
|
108
|
+
end
|
109
|
+
end
|
103
110
|
render :json => { :success => true }
|
104
111
|
end
|
105
112
|
|
@@ -113,6 +120,13 @@ module Caboose
|
|
113
120
|
ids.each do |id|
|
114
121
|
m = Media.where(:id => id).first
|
115
122
|
next if m.nil?
|
123
|
+
if @site.use_change_logs
|
124
|
+
mc1 = Caboose::MediaCategory.where(:id => m.media_category_id).first
|
125
|
+
mc2 = Caboose::MediaCategory.where(:id => media_category_id).first
|
126
|
+
ov = mc1 ? mc1.name : "N/A"
|
127
|
+
nv = mc2 ? mc2.name : "N/A"
|
128
|
+
Caboose::ChangeLog.create(:site_id => @site.id, :description => "Category", :user_id => logged_in_user.id, :media_id => m.id, :timestamp => DateTime.now, :action => 'edited', :old_value => ov, :new_value => nv)
|
129
|
+
end
|
116
130
|
m.update_attribute(:media_category_id, media_category_id)
|
117
131
|
p = Product.where(:media_category_id => media_category_id).last
|
118
132
|
if p
|
@@ -72,8 +72,8 @@ module Caboose
|
|
72
72
|
# @route GET /admin/media/json
|
73
73
|
def admin_json
|
74
74
|
return if !user_is_allowed('media', 'view')
|
75
|
-
render :json => false and return if @site.nil?
|
76
|
-
arr = Media.where(:media_category_id => params[:media_category_id]).reorder(:sort_order).all
|
75
|
+
render :json => false and return if @site.nil? || params[:media_category_id].blank?
|
76
|
+
arr = Media.where(:media_category_id => params[:media_category_id], :deleted => false).reorder(:sort_order).all
|
77
77
|
render :json => arr.collect{ |m| m.api_hash }
|
78
78
|
end
|
79
79
|
|
@@ -131,7 +131,7 @@ module Caboose
|
|
131
131
|
when 'sort_order' then m.sort_order = value
|
132
132
|
when 'image_url' then
|
133
133
|
m.processed = false
|
134
|
-
m.delay(:queue => '
|
134
|
+
m.delay(:queue => 'general', :priority => 2).download_image_from_url(value)
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
@@ -163,12 +163,14 @@ module Caboose
|
|
163
163
|
# @route DELETE /admin/media/:id
|
164
164
|
def admin_delete
|
165
165
|
return unless user_is_allowed('media', 'delete')
|
166
|
-
|
167
166
|
model_ids = params[:id] == 'bulk' ? params[:ids] : [params[:id]]
|
168
167
|
model_ids.each do |media_id|
|
169
|
-
|
170
|
-
|
171
|
-
|
168
|
+
if @site.use_change_logs
|
169
|
+
on = Media.title_for_id(media_id)
|
170
|
+
Caboose::ChangeLog.create(:site_id => @site.id, :description => on, :user_id => logged_in_user.id, :media_id => media_id, :timestamp => DateTime.now, :action => 'deleted')
|
171
|
+
end
|
172
|
+
Media.where(:id => media_id).update_all(:deleted => true)
|
173
|
+
end
|
172
174
|
render :json => { :success => true }
|
173
175
|
end
|
174
176
|
|
@@ -185,11 +187,12 @@ module Caboose
|
|
185
187
|
else
|
186
188
|
file_content_type = file_type
|
187
189
|
end
|
188
|
-
m = Media.where(:media_category_id => media_category_id, :original_name => original_name, :name => name).first
|
189
|
-
if m.nil?
|
190
|
+
#m = Media.where(:media_category_id => media_category_id, :original_name => original_name, :name => name, :deleted => false).first
|
191
|
+
#if m.nil?
|
190
192
|
max = Media.where(:media_category_id => media_category_id).maximum(:sort_order)
|
191
|
-
m = Media.create(:media_category_id => media_category_id, :description => desc, :sort_order => (max ? (max + 1) : 0), :original_name => original_name, :name => name, :image_content_type => image_content_type, :file_content_type => file_content_type, :processed => false)
|
192
|
-
|
193
|
+
m = Media.create(:media_category_id => media_category_id, :description => desc, :sort_order => (max ? (max + 1) : 0), :original_name => original_name, :name => name, :image_content_type => image_content_type, :file_content_type => file_content_type, :processed => false, :deleted => false)
|
194
|
+
Caboose::ChangeLog.create(:site_id => @site.id, :description => original_name, :user_id => logged_in_user.id, :media_id => m.id, :timestamp => DateTime.now, :action => 'uploaded') if @site.use_change_logs
|
195
|
+
#end
|
193
196
|
p = Product.where(:media_category_id => media_category_id).last
|
194
197
|
if p
|
195
198
|
pi = ProductImage.create(:product_id => p.id, :media_id => m.id)
|
@@ -5,7 +5,8 @@ module Caboose
|
|
5
5
|
helper :application
|
6
6
|
|
7
7
|
def before_action
|
8
|
-
|
8
|
+
# removing temporarily - looks like not needed:
|
9
|
+
#@page = Page.page_with_uri(request.host_with_port, '/admin')
|
9
10
|
end
|
10
11
|
|
11
12
|
# @route GET /pages/:id/redirect
|
@@ -137,25 +138,48 @@ module Caboose
|
|
137
138
|
#header("Content-Disposition: inline filename=\"$asset->filename\"")
|
138
139
|
|
139
140
|
end
|
141
|
+
|
142
|
+
# @route GET /api/sitemap
|
143
|
+
def api_sitemap
|
144
|
+
siteid = params[:site_id].blank? ? @site.id : params[:site_id]
|
145
|
+
render :json => Caboose::Page.select([:id, :title, :menu_title, :parent_id, :redirect_url, :uri, :sort_order]).where(:site_id => siteid, :hide => false).order(:id).all
|
146
|
+
end
|
140
147
|
|
141
148
|
#===========================================================================
|
142
149
|
# Admin actions
|
143
150
|
#===========================================================================
|
144
151
|
|
145
|
-
# @route
|
152
|
+
# @route PUT /admin/pages/:id/publish
|
146
153
|
def admin_publish
|
147
|
-
|
148
|
-
|
149
|
-
page.
|
150
|
-
|
154
|
+
resp = Caboose::StdClass.new
|
155
|
+
resp.success = false
|
156
|
+
@page = Page.find(params[:id])
|
157
|
+
condition = @page && @logged_in_user && (@logged_in_user.is_super_admin? || (@logged_in_user.site_id == @page.site_id && ( @logged_in_user.is_allowed('all','all') || @logged_in_user.is_allowed('pages','edit') && Page.permissible_actions(@logged_in_user, @page.id).include?('edit'))))
|
158
|
+
render :json => resp and return unless condition
|
159
|
+
resp.success = true
|
160
|
+
@page.delay(:queue => 'caching', :priority => 2).publish(logged_in_user.id)
|
161
|
+
render :json => resp
|
162
|
+
end
|
163
|
+
|
164
|
+
# @route GET /admin/pages/:id/status
|
165
|
+
def admin_status
|
166
|
+
resp = Caboose::StdClass.new
|
167
|
+
resp.status = 'pending'
|
168
|
+
@page = Page.find(params[:id])
|
169
|
+
if @page && @page.is_published
|
170
|
+
resp.status = 'published'
|
171
|
+
end
|
172
|
+
render :json => resp
|
151
173
|
end
|
152
174
|
|
153
175
|
# @route GET /admin/pages/:id/revert
|
154
176
|
def admin_revert
|
155
177
|
return unless user_is_allowed('pages', 'edit')
|
156
|
-
page = Page.find(params[:id])
|
157
|
-
page.
|
158
|
-
redirect_to
|
178
|
+
@page = Page.find(params[:id])
|
179
|
+
condition = @page && @logged_in_user && (@logged_in_user.is_super_admin? || (@logged_in_user.site_id == @page.site_id && ( @logged_in_user.is_allowed('all','all') || @logged_in_user.is_allowed('pages','edit') && Page.permissible_actions(@logged_in_user, @page.id).include?('edit'))))
|
180
|
+
redirect_to '/admin/pages' and return unless condition
|
181
|
+
@page.revert
|
182
|
+
redirect_to "/admin/pages/#{@page.id}/content"
|
159
183
|
end
|
160
184
|
|
161
185
|
# @route GET /admin/pages
|
@@ -355,6 +379,35 @@ module Caboose
|
|
355
379
|
render :layout => 'caboose/admin'
|
356
380
|
end
|
357
381
|
end
|
382
|
+
|
383
|
+
# @route GET /api/page_:id
|
384
|
+
def compiled_asset
|
385
|
+
@page = Page.find(params[:id])
|
386
|
+
respond_to do |format|
|
387
|
+
format.css { render :layout => 'caboose/css', :content_type => "text/css" }
|
388
|
+
format.js { render :layout => 'caboose/js', :content_type => "text/javascript" }
|
389
|
+
end
|
390
|
+
end
|
391
|
+
|
392
|
+
# @route GET /api/pages/:id/refresh-cache
|
393
|
+
def refresh_cached_blocks
|
394
|
+
render :json => false and return unless (user_is_allowed('pages', 'edit') && @site.use_caching)
|
395
|
+
resp = Caboose::StdClass.new
|
396
|
+
@page = Page.find(params[:id])
|
397
|
+
content = @page.block.child('content')
|
398
|
+
home_page = Caboose::Page.index_page(@site.id)
|
399
|
+
footer = home_page.block.child('footer')
|
400
|
+
block_ids = Caboose::Block.where("parent_id = ? OR parent_id = ?", content.id, footer.id).pluck(:id)
|
401
|
+
@page.update_cached_blocks(block_ids)
|
402
|
+
@page.delay(:queue => 'caching', :priority => 8).update_css_file
|
403
|
+
@page.delay(:queue => 'caching', :priority => 8).update_js_file
|
404
|
+
if home_page && @page.id == home_page.id
|
405
|
+
@site.delay(:queue => 'caching', :priority => 8).update_footer_css_file
|
406
|
+
@site.delay(:queue => 'caching', :priority => 8).update_footer_js_file
|
407
|
+
end
|
408
|
+
resp.success = true
|
409
|
+
render :json => resp
|
410
|
+
end
|
358
411
|
|
359
412
|
# @route GET /admin/pages/:id/js
|
360
413
|
def admin_edit_js
|
@@ -432,7 +485,7 @@ module Caboose
|
|
432
485
|
elsif site_id.nil? then resp.error = "Invalid site"
|
433
486
|
elsif parent_id.nil? then resp.error = "Invalid parent"
|
434
487
|
else
|
435
|
-
resp.new_id = Rails.env.production? ? p.delay(:priority => 20).duplicate(site_id, parent_id, duplicate_children, block_type_id, child_block_type_id) : p.duplicate(site_id, parent_id, duplicate_children, block_type_id, child_block_type_id)
|
488
|
+
resp.new_id = Rails.env.production? ? p.delay(:queue => 'general', :priority => 20).duplicate(site_id, parent_id, duplicate_children, block_type_id, child_block_type_id, logged_in_user.id) : p.duplicate(site_id, parent_id, duplicate_children, block_type_id, child_block_type_id, logged_in_user.id)
|
436
489
|
resp.success = true
|
437
490
|
end
|
438
491
|
|
@@ -468,12 +521,24 @@ module Caboose
|
|
468
521
|
end
|
469
522
|
end
|
470
523
|
|
524
|
+
# @route GET /admin/pages/:id/logs
|
525
|
+
def admin_change_logs
|
526
|
+
return unless user_is_allowed('logs', 'view')
|
527
|
+
@page = Page.find(params[:id])
|
528
|
+
if @page.site_id != @logged_in_user.site_id && !@logged_in_user.is_super_admin?
|
529
|
+
redirect_to '/admin/pages'
|
530
|
+
else
|
531
|
+
@logs = ChangeLog.where(:page_id => @page.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)
|
532
|
+
render :layout => 'caboose/admin'
|
533
|
+
end
|
534
|
+
end
|
535
|
+
|
471
536
|
# @route GET /admin/pages/:id
|
472
537
|
def admin_edit_general
|
473
538
|
return if !user_is_allowed('pages', 'edit')
|
474
539
|
#return if !Page.is_allowed(logged_in_user, params[:id], 'edit')
|
475
540
|
@page = Page.find(params[:id])
|
476
|
-
@can_edit_home =
|
541
|
+
@can_edit_home = logged_in_user.is_allowed(Caboose::Page.index_page(@site.id), 'edit')
|
477
542
|
if @page.site_id != @logged_in_user.site_id && !@logged_in_user.is_super_admin?
|
478
543
|
redirect_to '/admin/pages'
|
479
544
|
else
|
@@ -496,11 +561,12 @@ module Caboose
|
|
496
561
|
|
497
562
|
parent = Caboose::Page.find(parent_id)
|
498
563
|
|
564
|
+
allowed_to_edit = Page.page_ids_with_permission(logged_in_user, 'edit')
|
565
|
+
allowed_to_edit = allowed_to_edit.count > 0 ? allowed_to_edit.include?(parent.id) : false
|
566
|
+
|
499
567
|
if title.blank?
|
500
568
|
resp.error = "Page Title is required."
|
501
|
-
elsif (!logged_in_user.is_allowed('all', 'all') &&
|
502
|
-
!Page.page_ids_with_permission(logged_in_user, 'edit' ).include?(parent_id) &&
|
503
|
-
!Page.page_ids_with_permission(logged_in_user, 'approve').include?(parent_id))
|
569
|
+
elsif (!logged_in_user.is_allowed('all', 'all') && !allowed_to_edit)
|
504
570
|
resp.error = "You don't have permission to add a page there."
|
505
571
|
end
|
506
572
|
if (!resp.error.nil?)
|
@@ -520,7 +586,6 @@ module Caboose
|
|
520
586
|
page.title = title
|
521
587
|
page.parent_id = parent_id
|
522
588
|
page.hide = true
|
523
|
-
page.content_format = Caboose::Page::CONTENT_FORMAT_HTML
|
524
589
|
page.save
|
525
590
|
i = 0
|
526
591
|
begin
|
@@ -538,13 +603,14 @@ module Caboose
|
|
538
603
|
Caboose::Page.update_authorized_for_action(page.id, 'view', viewers)
|
539
604
|
Caboose::Page.update_authorized_for_action(page.id, 'edit', editors)
|
540
605
|
resp.redirect = "/admin/pages/#{page.id}/content"
|
606
|
+
Caboose::ChangeLog.create(:site_id => @site.id, :description => page.title, :user_id => logged_in_user.id, :page_id => page.id, :timestamp => DateTime.now, :action => 'created') if @site.use_change_logs
|
541
607
|
|
542
608
|
# Copy from an existing page
|
543
609
|
elsif !params[:copy_from_id].blank? && params[:use_copy] == 'yes'
|
544
610
|
source = Caboose::Page.find(params[:copy_from_id])
|
545
611
|
if source
|
546
612
|
Caboose.log("copying from source page: #{source.id}")
|
547
|
-
new_page = source.duplicate(@site.id, parent_id, false, layout_id, nil)
|
613
|
+
new_page = source.duplicate(@site.id, parent_id, false, layout_id, nil, logged_in_user.id)
|
548
614
|
new_page.title = params[:title]
|
549
615
|
new_page.hide = true
|
550
616
|
i = 0
|
@@ -560,6 +626,7 @@ module Caboose
|
|
560
626
|
Caboose::Page.update_authorized_for_action(new_page.id, 'view', viewers)
|
561
627
|
Caboose::Page.update_authorized_for_action(new_page.id, 'edit', editors)
|
562
628
|
resp.redirect = "/admin/pages/#{new_page.id}/content"
|
629
|
+
Caboose::ChangeLog.create(:site_id => @site.id, :description => new_page.title, :user_id => logged_in_user.id, :page_id => new_page.id, :timestamp => DateTime.now, :action => 'created') if @site.use_change_logs
|
563
630
|
else
|
564
631
|
resp.redirect = "/admin/pages/new"
|
565
632
|
end
|
@@ -568,7 +635,7 @@ module Caboose
|
|
568
635
|
elsif !params[:template_id].blank? && params[:use_template] == 'yes'
|
569
636
|
template = Caboose::PageTemplate.find(params[:template_id])
|
570
637
|
if template && template.page
|
571
|
-
new_page = template.page.duplicate(@site.id, parent_id, false, layout_id, nil)
|
638
|
+
new_page = template.page.duplicate(@site.id, parent_id, false, layout_id, nil, logged_in_user.id)
|
572
639
|
new_page.title = params[:title]
|
573
640
|
new_page.hide = true
|
574
641
|
i = 0
|
@@ -584,6 +651,7 @@ module Caboose
|
|
584
651
|
Caboose::Page.update_authorized_for_action(new_page.id, 'view', viewers)
|
585
652
|
Caboose::Page.update_authorized_for_action(new_page.id, 'edit', editors)
|
586
653
|
resp.redirect = "/admin/pages/#{new_page.id}/content"
|
654
|
+
Caboose::ChangeLog.create(:site_id => @site.id, :description => new_page.title, :user_id => logged_in_user.id, :page_id => new_page.id, :timestamp => DateTime.now, :action => 'created') if @site.use_change_logs
|
587
655
|
else
|
588
656
|
resp.redirect = "/admin/pages/new"
|
589
657
|
end
|
@@ -602,6 +670,7 @@ module Caboose
|
|
602
670
|
save = true
|
603
671
|
user = logged_in_user
|
604
672
|
params.each do |name, value|
|
673
|
+
old_value = page[name]
|
605
674
|
case name
|
606
675
|
when 'parent_id'
|
607
676
|
value = value.to_i
|
@@ -627,30 +696,10 @@ module Caboose
|
|
627
696
|
when 'custom_css', 'custom_css_files', 'custom_js', 'custom_js_files'
|
628
697
|
value.strip!
|
629
698
|
page[name.to_sym] = value
|
630
|
-
|
631
|
-
when 'title', 'menu_title', 'hide', '
|
699
|
+
|
700
|
+
when 'title', 'menu_title', 'hide', 'redirect_url',
|
632
701
|
'seo_title', 'meta_keywords', 'meta_description', 'fb_description', 'gp_description', 'canonical_url'
|
633
702
|
page[name.to_sym] = value
|
634
|
-
|
635
|
-
when 'linked_resources'
|
636
|
-
result = []
|
637
|
-
value.each_line do |line|
|
638
|
-
line.chomp!
|
639
|
-
line.strip!
|
640
|
-
next if line.empty?
|
641
|
-
|
642
|
-
if !(line.ends_with('.js') || line.ends_with('.css'))
|
643
|
-
resp.error = "Resource '#{line}' has an unsupported file type ('#{comps.last}')."
|
644
|
-
save = false
|
645
|
-
end
|
646
|
-
|
647
|
-
result << line
|
648
|
-
end
|
649
|
-
page.linked_resources = result.join("\n")
|
650
|
-
|
651
|
-
when 'content_format'
|
652
|
-
page.content_format = value
|
653
|
-
resp.attributes['content_format'] = { 'text' => value }
|
654
703
|
|
655
704
|
when 'meta_robots'
|
656
705
|
arr = value.split(',').collect { |v| v.strip }
|
@@ -695,8 +744,8 @@ module Caboose
|
|
695
744
|
Page.update_authorized_for_action(page.id, 'view', value)
|
696
745
|
when 'editors'
|
697
746
|
Page.update_authorized_for_action(page.id, 'edit', value)
|
698
|
-
when 'approvers'
|
699
|
-
|
747
|
+
# when 'approvers'
|
748
|
+
# Page.update_authorized_for_action(page.id, 'approve', value)
|
700
749
|
when 'tags'
|
701
750
|
current_tags = page.page_tags.collect{ |t| t.tag }
|
702
751
|
new_tags = value.split(',').collect{ |v| v.strip.downcase }.reject{ |t| t.nil? || t.strip.length == 0 }
|
@@ -707,10 +756,22 @@ module Caboose
|
|
707
756
|
# Add any new tags not in current_tags
|
708
757
|
new_tags.each{ |t| PageTag.create(:page_id => page.id, :tag => t) if !current_tags.include?(t) }
|
709
758
|
end
|
710
|
-
|
759
|
+
|
760
|
+
if @site.use_change_logs && !['id','action','controller'].include?(name)
|
761
|
+
ov = name == 'parent_id' ? Caboose::Page.title_for_id(old_value) : old_value
|
762
|
+
nv = name == 'parent_id' ? Caboose::Page.title_for_id(value) : value
|
763
|
+
ov = ['hide','custom_sort_children'].include?(name) ? (ov ? 'yes' : 'no') : ov
|
764
|
+
nv = ['hide','custom_sort_children'].include?(name) ? ( ['1',1,true,'true'].include?(nv) ? 'yes' : 'no') : nv
|
765
|
+
cl = Caboose::ChangeLog.create(:site_id => @site.id, :description => "Page #{name.titleize}", :user_id => user.id, :page_id => page.id, :timestamp => DateTime.now, :action => 'edited', :old_value => ov, :new_value => nv)
|
766
|
+
end
|
767
|
+
|
711
768
|
end
|
712
769
|
|
713
770
|
resp.success = save && page.save
|
771
|
+
|
772
|
+
page.delay(:queue => 'caching', :priority => 8).update_css_file if params[:custom_css] && @site.use_caching
|
773
|
+
page.delay(:queue => 'caching', :priority => 8).update_js_file if params[:custom_js] && @site.use_caching
|
774
|
+
|
714
775
|
render json: resp
|
715
776
|
end
|
716
777
|
|
@@ -718,6 +779,7 @@ module Caboose
|
|
718
779
|
def admin_delete
|
719
780
|
return unless user_is_allowed('pages', 'delete')
|
720
781
|
p = Page.find(params[:id])
|
782
|
+
Caboose::ChangeLog.create(:site_id => @site.id, :description => p.title, :user_id => logged_in_user.id, :page_id => p.id, :timestamp => DateTime.now, :action => 'deleted') if @site.use_change_logs
|
721
783
|
p.destroy
|
722
784
|
resp = StdClass.new({
|
723
785
|
'redirect' => '/admin/pages'
|
@@ -73,12 +73,38 @@ module Caboose
|
|
73
73
|
render :layout => 'caboose/admin'
|
74
74
|
end
|
75
75
|
|
76
|
-
# @route GET /admin/posts/:id/
|
76
|
+
# @route GET /admin/posts/:id/logs
|
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
|
77
89
|
def admin_publish
|
78
|
-
|
90
|
+
resp = Caboose::StdClass.new
|
91
|
+
resp.success = false
|
92
|
+
render :json => resp and return unless user_is_allowed('posts', 'edit')
|
79
93
|
post = get_edit_post(params[:id], @site.id)
|
80
|
-
|
81
|
-
|
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'
|
103
|
+
post = get_edit_post(params[:id], @site.id)
|
104
|
+
if post && post.is_published
|
105
|
+
resp.status = 'published'
|
106
|
+
end
|
107
|
+
render :json => resp
|
82
108
|
end
|
83
109
|
|
84
110
|
# @route GET /admin/posts/:id/revert
|
@@ -170,7 +196,9 @@ module Caboose
|
|
170
196
|
resp = Caboose::StdClass.new({'attributes' => {}})
|
171
197
|
post = get_edit_post(params[:id], @site.id)
|
172
198
|
save = true
|
173
|
-
|
199
|
+
user = logged_in_user
|
200
|
+
params.each do |name, value|
|
201
|
+
old_value = post[name]
|
174
202
|
case name
|
175
203
|
when 'site_id' then post.site_id = value.to_i
|
176
204
|
when 'slug' then post.set_slug_and_uri(value)
|
@@ -185,6 +213,13 @@ module Caboose
|
|
185
213
|
when 'created_at' then post.created_at = DateTime.strptime(value,'%m/%d/%Y')
|
186
214
|
when 'updated_at' then post.updated_at = DateTime.parse(value)
|
187
215
|
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
|
188
223
|
end
|
189
224
|
resp.success = save && post.save
|
190
225
|
render :json => resp
|
@@ -192,20 +227,25 @@ module Caboose
|
|
192
227
|
|
193
228
|
# @route POST /admin/posts/:id/image
|
194
229
|
def admin_update_image
|
195
|
-
return if !user_is_allowed('posts', 'edit')
|
230
|
+
return if !user_is_allowed('posts', 'edit')
|
231
|
+
user = logged_in_user
|
196
232
|
resp = Caboose::StdClass.new
|
197
233
|
post = get_edit_post(params[:id], @site.id)
|
234
|
+
ov = post.image_file_name
|
198
235
|
post.image = params[:image]
|
199
236
|
resp.success = post.save
|
200
237
|
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
|
201
239
|
render :text => resp.to_json
|
202
240
|
end
|
203
241
|
|
204
242
|
# @route POST /admin/posts/:id/remove-image
|
205
243
|
def admin_remove_image
|
206
244
|
return unless user_is_allowed("posts", 'edit')
|
207
|
-
resp = Caboose::StdClass.new
|
245
|
+
resp = Caboose::StdClass.new
|
246
|
+
user = logged_in_user
|
208
247
|
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
|
209
249
|
b.image_file_name = nil
|
210
250
|
b.image_file_size = nil
|
211
251
|
b.image_content_type = nil
|
@@ -241,6 +281,7 @@ module Caboose
|
|
241
281
|
bt = BlockType.where(:id => @site.default_layout_id).first
|
242
282
|
Block.create(:post_id => post.id, :block_type_id => bt.id, :name => bt.name) if post && bt
|
243
283
|
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
|
244
285
|
end
|
245
286
|
render :json => resp
|
246
287
|
end
|
@@ -250,8 +291,10 @@ module Caboose
|
|
250
291
|
return if !user_is_allowed('posts', 'edit')
|
251
292
|
post = get_edit_post(params[:id], @site.id)
|
252
293
|
cat_id = params[:post_category_id]
|
294
|
+
cat = PostCategory.where(:id => cat_id).first
|
253
295
|
if post && !PostCategoryMembership.exists?(:post_id => post.id, :post_category_id => cat_id)
|
254
296
|
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
|
255
298
|
end
|
256
299
|
render :json => true
|
257
300
|
end
|
@@ -261,8 +304,10 @@ module Caboose
|
|
261
304
|
return if !user_is_allowed('posts', 'edit')
|
262
305
|
post = get_edit_post(params[:id], @site.id)
|
263
306
|
cat_id = params[:post_category_id]
|
307
|
+
cat = PostCategory.where(:id => cat_id).first
|
264
308
|
if post && PostCategoryMembership.exists?(:post_id => post.id, :post_category_id => cat_id)
|
265
309
|
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
|
266
311
|
end
|
267
312
|
render :json => true
|
268
313
|
end
|
@@ -272,6 +317,7 @@ module Caboose
|
|
272
317
|
return if !user_is_allowed('posts', 'edit')
|
273
318
|
post = get_edit_post(params[:id], @site.id)
|
274
319
|
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
|
275
321
|
Post.where(:id => post.id).destroy_all if post
|
276
322
|
render :json => { 'redirect' => '/admin/posts' }
|
277
323
|
end
|