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.
Files changed (187) hide show
  1. checksums.yaml +5 -5
  2. data/app/assets/javascripts/caboose/admin.js +1 -1
  3. data/app/assets/javascripts/caboose/admin/application.js +20 -0
  4. data/app/assets/javascripts/caboose/admin_main.js +13 -3
  5. data/app/assets/javascripts/caboose/admin_media_index.js +158 -161
  6. data/app/assets/javascripts/caboose/application.js +7 -8
  7. data/app/assets/javascripts/caboose/block_content_controller_dragdrop.js +4 -60
  8. data/app/assets/javascripts/caboose/block_modal_controllers/block_dd_modal_controller.js +2 -3
  9. data/app/assets/javascripts/caboose/block_modal_controllers/media_modal_controller.js +6 -17
  10. data/app/assets/javascripts/caboose/model/all.js +1 -5
  11. data/app/assets/stylesheets/caboose/admin/_config.scss +102 -0
  12. data/app/assets/stylesheets/caboose/admin/application.css +11 -0
  13. data/app/assets/stylesheets/caboose/admin/component.css +183 -0
  14. data/app/assets/stylesheets/caboose/admin/froala.min.css +91 -0
  15. data/app/assets/stylesheets/caboose/admin/ie.scss +67 -0
  16. data/app/assets/stylesheets/caboose/admin/integrations/main.scss +6 -0
  17. data/app/assets/stylesheets/caboose/admin/integrations/shopify.scss +128 -0
  18. data/app/assets/stylesheets/caboose/admin/jquery-ui-subnav-theme.min.css +5 -0
  19. data/app/assets/stylesheets/caboose/admin/layout.scss +150 -0
  20. data/app/assets/stylesheets/caboose/admin/main.scss +34 -0
  21. data/app/assets/stylesheets/caboose/admin/modules/body.scss +176 -0
  22. data/app/assets/stylesheets/caboose/admin/modules/buttons.scss +120 -0
  23. data/app/assets/stylesheets/caboose/admin/modules/countdown.css +21 -0
  24. data/app/assets/stylesheets/caboose/admin/modules/crumbtrail.scss +80 -0
  25. data/app/assets/stylesheets/caboose/admin/modules/data_table.scss +92 -0
  26. data/app/assets/stylesheets/caboose/admin/modules/footer.scss +62 -0
  27. data/app/assets/stylesheets/caboose/admin/modules/forms.scss +72 -0
  28. data/app/assets/stylesheets/caboose/admin/modules/functions.scss +31 -0
  29. data/app/assets/stylesheets/caboose/admin/modules/grid.scss +108 -0
  30. data/app/assets/stylesheets/caboose/admin/modules/header.scss +77 -0
  31. data/app/assets/stylesheets/caboose/admin/modules/headings.scss +38 -0
  32. data/app/assets/stylesheets/caboose/admin/modules/main_nav.scss +73 -0
  33. data/app/assets/stylesheets/caboose/admin/modules/message_boxes.scss +55 -0
  34. data/app/assets/stylesheets/caboose/admin/modules/model_binder.scss +189 -0
  35. data/app/assets/stylesheets/caboose/admin/modules/navigation.scss +261 -0
  36. data/app/assets/stylesheets/caboose/admin/modules/order_bumps.scss +57 -0
  37. data/app/assets/stylesheets/caboose/admin/modules/pager.scss +34 -0
  38. data/app/assets/stylesheets/caboose/admin/modules/product_images.scss +21 -0
  39. data/app/assets/stylesheets/caboose/admin/modules/products.css +86 -0
  40. data/app/assets/stylesheets/caboose/admin/modules/search.scss +49 -0
  41. data/app/assets/stylesheets/caboose/admin/modules/selects.scss +12 -0
  42. data/app/assets/stylesheets/caboose/admin/modules/subnav_tabs.scss +34 -0
  43. data/app/assets/stylesheets/caboose/admin/modules/tabs.scss +140 -0
  44. data/app/assets/stylesheets/caboose/admin/page_edit/block_anchors.scss +48 -0
  45. data/app/assets/stylesheets/caboose/admin/page_edit/block_overlays.scss +182 -0
  46. data/app/assets/stylesheets/caboose/admin/page_edit/device_selector.scss +65 -0
  47. data/app/assets/stylesheets/caboose/admin/page_edit/froala.scss +81 -0
  48. data/app/assets/stylesheets/caboose/admin/page_edit/group_overlay.scss +115 -0
  49. data/app/assets/stylesheets/caboose/admin/page_edit/layout.scss +128 -0
  50. data/app/assets/stylesheets/caboose/admin/page_edit/main.scss +18 -0
  51. data/app/assets/stylesheets/caboose/admin/page_edit/modal.scss +11 -0
  52. data/app/assets/stylesheets/caboose/admin/page_edit/preview.scss +25 -0
  53. data/app/assets/stylesheets/caboose/admin/page_edit/publish.scss +25 -0
  54. data/app/assets/stylesheets/caboose/admin/page_edit/revisions.scss +58 -0
  55. data/app/assets/stylesheets/caboose/admin/page_edit/subnav.scss +273 -0
  56. data/app/assets/stylesheets/caboose/admin/page_edit/top_nav.scss +109 -0
  57. data/app/assets/stylesheets/caboose/admin/pages/assets_index.css +48 -0
  58. data/app/assets/stylesheets/caboose/admin/pages/block_edit_image.css.scss +386 -0
  59. data/app/assets/stylesheets/caboose/admin/pages/media_index.css.scss +300 -0
  60. data/app/assets/stylesheets/caboose/admin/pages/new_block.css +9 -0
  61. data/app/assets/stylesheets/caboose/admin/pages/page_edit.scss +960 -0
  62. data/app/assets/stylesheets/caboose/admin/pages/page_edit_content.scss +103 -0
  63. data/app/assets/stylesheets/caboose/admin/pages/pages_index.scss +79 -0
  64. data/app/assets/stylesheets/caboose/admin/pages/post_edit_content.css +46 -0
  65. data/app/assets/stylesheets/caboose/admin/print.css +3 -0
  66. data/app/assets/stylesheets/caboose/admin/slack.scss +51 -0
  67. data/app/assets/stylesheets/caboose/admin_block_edit_image.css.scss +1 -2
  68. data/app/assets/stylesheets/caboose/admin_edit_page_content_dragdrop.scss +15 -71
  69. data/app/assets/stylesheets/caboose/admin_main.css.scss +29 -25
  70. data/app/assets/stylesheets/caboose/admin_media_index.css.scss +5 -26
  71. data/app/assets/stylesheets/caboose/application.css +5 -11
  72. data/app/assets/stylesheets/caboose/login.scss +0 -1
  73. data/app/assets/stylesheets/caboose/modal_main.css +19 -21
  74. data/app/assets/stylesheets/caboose/model_binder.css +4 -13
  75. data/app/assets/stylesheets/caboose/page_bar_generator.css +1 -2
  76. data/app/controllers/caboose/admin_controller.rb +4 -3
  77. data/app/controllers/caboose/application_controller.rb +19 -16
  78. data/app/controllers/caboose/assets_controller.rb +65 -0
  79. data/app/controllers/caboose/block_types_controller.rb +6 -8
  80. data/app/controllers/caboose/cart_controller.rb +2 -2
  81. data/app/controllers/caboose/fonts_controller.rb +2 -139
  82. data/app/controllers/caboose/invoices_controller.rb +4 -5
  83. data/app/controllers/caboose/login_logs_controller.rb +7 -5
  84. data/app/controllers/caboose/media_categories_controller.rb +2 -16
  85. data/app/controllers/caboose/media_controller.rb +11 -14
  86. data/app/controllers/caboose/pages_controller.rb +42 -104
  87. data/app/controllers/caboose/posts_controller.rb +7 -53
  88. data/app/controllers/caboose/products_controller.rb +1 -1
  89. data/app/controllers/caboose/sites_controller.rb +6 -25
  90. data/app/controllers/caboose/sns_controller.rb +3 -3
  91. data/app/controllers/caboose/themes_controller.rb +0 -30
  92. data/app/controllers/caboose/users_controller.rb +10 -17
  93. data/app/controllers/caboose/variants_controller.rb +9 -9
  94. data/app/models/caboose/ab_variant.rb +1 -1
  95. data/app/models/caboose/asset.rb +23 -0
  96. data/app/models/caboose/asset_manager.rb +92 -0
  97. data/app/models/caboose/asset_manifest.rb +91 -0
  98. data/app/models/caboose/block.rb +24 -100
  99. data/app/models/caboose/block_cache.rb +105 -0
  100. data/app/models/caboose/block_cache_file.rb +22 -0
  101. data/app/models/caboose/block_cache_image.rb +53 -0
  102. data/app/models/caboose/block_type.rb +3 -4
  103. data/app/models/caboose/block_type_category.rb +2 -2
  104. data/app/models/caboose/block_type_parser.rb +1 -1
  105. data/app/models/caboose/block_type_source.rb +2 -2
  106. data/app/models/caboose/calendar_event_group.rb +2 -2
  107. data/app/models/caboose/category.rb +2 -2
  108. data/app/models/caboose/comment_routes.rb +8 -7
  109. data/app/models/caboose/core_plugin.rb +3 -4
  110. data/app/models/caboose/export.rb +1 -1
  111. data/app/models/caboose/font.rb +2 -7
  112. data/app/models/caboose/font_variant.rb +0 -12
  113. data/app/models/caboose/invoice.rb +14 -14
  114. data/app/models/caboose/line_item.rb +4 -4
  115. data/app/models/caboose/media.rb +4 -15
  116. data/app/models/caboose/media_category.rb +7 -5
  117. data/app/models/caboose/modification.rb +2 -2
  118. data/app/models/caboose/page.rb +54 -325
  119. data/app/models/caboose/page_bar_generator.rb +10 -20
  120. data/app/models/caboose/page_cache.rb +12 -0
  121. data/app/models/caboose/page_cacher.rb +137 -0
  122. data/app/models/caboose/post.rb +8 -108
  123. data/app/models/caboose/product.rb +5 -5
  124. data/app/models/caboose/product_image.rb +1 -1
  125. data/app/models/caboose/role.rb +2 -2
  126. data/app/models/caboose/schema.rb +72 -73
  127. data/app/models/caboose/site.rb +1 -203
  128. data/app/models/caboose/theme.rb +5 -70
  129. data/app/views/caboose/admin/_content.html.erb +44 -0
  130. data/app/views/caboose/admin/_fonts.html.erb +47 -0
  131. data/app/views/caboose/admin/_footer.html.erb +1 -0
  132. data/app/views/caboose/admin/_header.html.erb +12 -0
  133. data/app/views/caboose/admin/_icons.html.erb +6 -0
  134. data/app/views/caboose/admin/_mobile_navigation.html.erb +22 -0
  135. data/app/views/caboose/admin/_post.html.erb +74 -0
  136. data/app/views/caboose/admin/index.html.erb +33 -36
  137. data/app/views/caboose/block_types/admin_edit.html.erb +8 -6
  138. data/app/views/caboose/blocks/_file.html.erb +2 -2
  139. data/app/views/caboose/blocks/_ga.html.erb +2 -1
  140. data/app/views/caboose/blocks/_image.html.erb +0 -4
  141. data/app/views/caboose/blocks/_render_function.html.erb +4 -9
  142. data/app/views/caboose/fonts/admin_index.html.erb +10 -55
  143. data/app/views/caboose/invoices_mailer/customer_status_updated.html.erb +14 -5
  144. data/app/views/caboose/login_logs/admin_index_for_user.html.erb +1 -1
  145. data/app/views/caboose/media/admin_index.html.erb +24 -14
  146. data/app/views/caboose/my_account/index.html.erb +0 -1
  147. data/app/views/caboose/pages/_admin_header.html.erb +0 -5
  148. data/app/views/caboose/pages/admin_edit_content.html.erb +2 -6
  149. data/app/views/caboose/pages/admin_edit_general.html.erb +4 -32
  150. data/app/views/caboose/pages/admin_new_old.html.erb +46 -0
  151. data/app/views/caboose/pages/test.html.erb +64 -0
  152. data/app/views/caboose/posts/_admin_header.html.erb +0 -5
  153. data/app/views/caboose/posts/admin_delete_form.html.erb +1 -1
  154. data/app/views/caboose/posts/admin_edit_content.html.erb +2 -6
  155. data/app/views/caboose/products/admin_group_variants.html.erb +1 -1
  156. data/app/views/caboose/products/admin_sort.html copy.erb +1 -1
  157. data/app/views/caboose/sites/admin_edit.html.erb +0 -21
  158. data/app/views/caboose/themes/admin_edit.html.erb +3 -7
  159. data/app/views/caboose/users/_admin_header.html.erb +0 -4
  160. data/app/views/caboose/users/admin_edit_roles.html.erb +0 -1
  161. data/app/views/caboose/variants/admin_group.html.erb +1 -1
  162. data/app/views/layouts/caboose/admin.html.erb +2 -9
  163. data/app/views/layouts/caboose/application.html.erb +92 -62
  164. data/config/routes.rb +1 -4
  165. data/lib/caboose/version.rb +1 -1
  166. data/lib/tasks/caboose.rake +14 -3
  167. metadata +238 -57
  168. data/app/controllers/caboose/change_logs_controller.rb +0 -13
  169. data/app/models/caboose/change_log.rb +0 -97
  170. data/app/views/caboose/blocks/_cached_block.html.erb +0 -28
  171. data/app/views/caboose/change_logs/admin_index.html.erb +0 -65
  172. data/app/views/caboose/fonts/admin_family_edit.html.erb +0 -63
  173. data/app/views/caboose/fonts/admin_family_index.html.erb +0 -42
  174. data/app/views/caboose/fonts/admin_variant_edit.html.erb +0 -84
  175. data/app/views/caboose/pages/admin_change_logs.html.erb +0 -56
  176. data/app/views/caboose/pages/compiled_asset.css.erb +0 -0
  177. data/app/views/caboose/pages/compiled_asset.js.erb +0 -0
  178. data/app/views/caboose/posts/admin_change_logs.html.erb +0 -56
  179. data/app/views/caboose/sites/compiled_asset.css.erb +0 -0
  180. data/app/views/caboose/sites/compiled_asset.js.erb +0 -0
  181. data/app/views/caboose/themes/admin_error_log.html.erb +0 -9
  182. data/app/views/caboose/themes/admin_js.html.erb +0 -131
  183. data/app/views/caboose/users/admin_change_logs.html.erb +0 -63
  184. data/app/views/layouts/caboose/css.css.erb +0 -44
  185. data/app/views/layouts/caboose/footer_css.css.erb +0 -41
  186. data/app/views/layouts/caboose/footer_js.js.erb +0 -31
  187. data/app/views/layouts/caboose/js.js.erb +0 -34
@@ -176,7 +176,7 @@ module Caboose
176
176
  :invoice_action => InvoiceLog::ACTION_LINE_ITEM_CREATED
177
177
  )
178
178
  end
179
- GA.delay(:queue => 'general', :priority => 20).event(@site.id, 'cart', 'add', "Product #{v.product.id}, Variant #{v.id}")
179
+ GA.delay(:queue => 'caboose_store').event(@site.id, 'cart', 'add', "Product #{v.product.id}, Variant #{v.id}")
180
180
 
181
181
  resp.success = true
182
182
  resp.item_count = @invoice.item_count
@@ -320,7 +320,7 @@ module Caboose
320
320
 
321
321
  resp.success = true
322
322
  resp.invoice_total = @invoice.total
323
- GA.delay(:queue => 'general', :priority => 20).event(@site.id, 'giftcard', 'add', "Giftcard #{gc.id}")
323
+ GA.delay(:queue => 'caboose_store').event(@site.id, 'giftcard', 'add', "Giftcard #{gc.id}")
324
324
  end
325
325
  render :json => resp
326
326
  end
@@ -16,12 +16,6 @@ module Caboose
16
16
  if !@bfbi then @bfbi = Font.create(:site_id => @site.id, :name => "body-font-bold-italic", :family => "Open Sans", :variant => "600italic", :url => "http://fonts.gstatic.com/s/opensans/v13/PRmiXeptR36kaC0GEAetxpZ7xm-Bj30Bj2KNdXDzSZg.ttf") end
17
17
  @btn = Font.where(:site_id => @site.id, :name => "button-font").last
18
18
  if !@btn then @btn = Font.create(:site_id => @site.id, :name => "button-font", :family => "Open Sans", :variant => "regular", :url => "http://fonts.gstatic.com/s/opensans/v13/IgZJs4-7SA1XX_edsoXWog.ttf") end
19
- @custom1 = Font.where(:site_id => @site.id, :name => "custom1-font").last
20
- if !@custom1 then @custom1 = Font.create(:site_id => @site.id, :name => "custom1-font", :family => "Open Sans", :variant => "regular", :url => "http://fonts.gstatic.com/s/opensans/v13/IgZJs4-7SA1XX_edsoXWog.ttf") end
21
- @custom2 = Font.where(:site_id => @site.id, :name => "custom2-font").last
22
- if !@custom2 then @custom2 = Font.create(:site_id => @site.id, :name => "custom2-font", :family => "Open Sans", :variant => "regular", :url => "http://fonts.gstatic.com/s/opensans/v13/IgZJs4-7SA1XX_edsoXWog.ttf") end
23
- @custom3 = Font.where(:site_id => @site.id, :name => "custom3-font").last
24
- if !@custom3 then @custom3 = Font.create(:site_id => @site.id, :name => "custom3-font", :family => "Open Sans", :variant => "regular", :url => "http://fonts.gstatic.com/s/opensans/v13/IgZJs4-7SA1XX_edsoXWog.ttf") end
25
19
  end
26
20
 
27
21
  # @route PUT /admin/fonts
@@ -31,15 +25,13 @@ module Caboose
31
25
  name = params[:name]
32
26
  url = params[:url]
33
27
  variant = params[:variant]
28
+
34
29
  if !family.blank? && !name.blank? && !url.blank? && !variant.blank?
35
30
  font = Font.where(:site_id => @site.id, :name => name).last
36
31
  if font
37
- fam = FontFamily.where(:name => family).first
38
- var = fam ? FontVariant.where(:font_family_id => fam.id).where("CONCAT(style,weight) = ?", variant).first : nil
39
32
  font.family = family
40
33
  font.url = url
41
34
  font.variant = variant
42
- font.variant_id = var.id if var
43
35
  font.save
44
36
  resp.success = "Font saved!"
45
37
  else
@@ -49,137 +41,8 @@ module Caboose
49
41
  resp.error = "Error saving font"
50
42
  end
51
43
  render :json => resp
52
- end
53
-
54
-
55
- # Font Families
56
-
57
- # @route GET /admin/font-families
58
- def admin_family_index
59
- return if !user_is_allowed('fonts', 'view')
60
- end
61
-
62
- # @route GET /admin/font-families/json
63
- def admin_family_json
64
- return if !user_is_allowed('fonts', 'view')
65
- pager = PageBarGenerator.new(params, {
66
- 'name_like' => ''
67
- },{
68
- 'model' => 'Caboose::FontFamily',
69
- 'sort' => 'name',
70
- 'desc' => false,
71
- 'base_url' => '/admin/font-families',
72
- 'items_per_page' => 50
73
- })
74
- render :json => {
75
- :pager => pager,
76
- :models => pager.items.as_json
77
- }
78
- end
79
-
80
- # @route GET /admin/font-families/:id/json
81
- def admin_family_json_single
82
- return if !user_is_allowed('fonts', 'view')
83
- ff = FontFamily.find(params[:id])
84
- render :json => ff.as_json
85
- end
86
-
87
- # @route POST /admin/font-families
88
- def admin_family_add
89
- return if !user_is_allowed('fonts', 'add')
90
- resp = StdClass.new
91
- if params[:name].blank?
92
- resp.error = "Name is required."
93
- render :json => resp and return
94
- end
95
- ff = FontFamily.new
96
- ff.name = params[:name]
97
- ff.save
98
- resp.redirect = "/admin/font-families/#{ff.id}"
99
- render :json => resp
100
- end
101
-
102
-
103
- # @route GET /admin/font-families/:id
104
- def admin_family_edit
105
- return if !user_is_allowed('fonts', 'add')
106
- @ff = FontFamily.find(params[:id])
107
- end
108
-
109
- # @route GET /admin/font-variants/:id
110
- def admin_variant_edit
111
- return if !user_is_allowed('fonts', 'edit')
112
- @variant = FontVariant.find(params[:id])
113
- end
114
-
115
- # @route POST /admin/font-variants
116
- def admin_variant_add
117
- return if !user_is_allowed('fonts', 'add')
118
- resp = StdClass.new
119
- if params[:variant].blank?
120
- resp.error = "Variant Name is required."
121
- render :json => resp and return
122
- end
123
- ff = FontVariant.new
124
- ff.font_family_id = params[:family_id]
125
- ff.weight = 'regular'
126
- ff.variant = params[:variant]
127
- ff.sort_order = 10
128
- ff.save
129
- resp.redirect = "/admin/font-variants/#{ff.id}"
130
- render :json => resp
131
- end
132
-
133
- # @route PUT /admin/font-variants/:id
134
- def admin_variant_update
135
- return unless user_is_allowed_to 'edit', 'fonts'
136
- resp = Caboose::StdClass.new
137
- variant = FontVariant.find(params[:id])
138
- params.each do |k,v|
139
- case k
140
- when "variant" then variant.variant = v
141
- when "ttf_url" then (variant.ttf_url = v if (v.blank? || (v.include?('.ttf') && v.include?('http'))))
142
- when "weight" then variant.weight = v
143
- when "style" then variant.style = v
144
- when "sort_order" then variant.sort_order = v
145
- end
146
- end
147
- resp.success = variant.save
148
- render :json => resp
149
- end
150
-
151
- # @route POST /admin/font-variants/:id/ttf-file
152
- def admin_variant_update_ttf_file
153
- return unless user_is_allowed_to 'edit', 'fonts'
154
- resp = Caboose::StdClass.new
155
- var = FontVariant.find(params[:id])
156
- var.ttf_file = params[:ttf_file]
157
- var.save
158
- resp.success = true
159
- resp.attributes = { 'ttf_file' => { 'value' => var.ttf_file.url }}
160
- render :json => resp
161
- end
162
44
 
163
- # @route POST /admin/font-variants/:id/woff-file
164
- def admin_variant_update_woff_file
165
- return unless user_is_allowed_to 'edit', 'fonts'
166
- resp = Caboose::StdClass.new
167
- var = FontVariant.find(params[:id])
168
- var.woff_file = params[:woff_file]
169
- var.save
170
- resp.success = true
171
- resp.attributes = { 'woff_file' => { 'value' => var.woff_file.url }}
172
- render :json => resp
173
45
  end
174
-
175
- # @route DELETE /admin/font-variants/:id
176
- # def admin_variant_delete
177
- # return unless user_is_allowed_to 'delete', 'fonts'
178
- # var = FontVariant.find(params[:id])
179
- # resp = Caboose::StdClass.new('redirect' => "/admin/font-variants/#{var.font_family_id}")
180
- # var.destroy
181
- # render :json => resp
182
- # end
183
-
46
+
184
47
  end
185
48
  end
@@ -13,7 +13,7 @@ module Caboose
13
13
  end
14
14
 
15
15
  status = request.fullpath == '/admin/invoices' ? Caboose::Invoice::STATUS_PENDING : ''
16
- #Caboose.log(params)
16
+
17
17
  @pager = Caboose::PageBarGenerator.new(params, {
18
18
  'site_id' => @site.id,
19
19
  'customer_id' => params[:user_id] ? params[:user_id] : '',
@@ -24,8 +24,7 @@ module Caboose
24
24
  'invoice_number' => '',
25
25
  'total_lte' => '',
26
26
  'total_gte' => ''
27
- },
28
- {
27
+ }, {
29
28
  'model' => 'Caboose::Invoice',
30
29
  'sort' => 'id',
31
30
  'desc' => 1,
@@ -337,7 +336,7 @@ module Caboose
337
336
  def admin_send_for_authorization
338
337
  return if !user_is_allowed('invoices', 'edit')
339
338
  invoice = Invoice.find(params[:id])
340
- invoice.delay(:queue => 'general', :priority => 12).send_payment_authorization_email
339
+ invoice.delay(:queue => 'caboose_store').send_payment_authorization_email
341
340
  # invoice.send_payment_authorization_email
342
341
  render :json => { :success => true }
343
342
  end
@@ -346,7 +345,7 @@ module Caboose
346
345
  def admin_send_receipt
347
346
  return if !user_is_allowed('invoices', 'edit')
348
347
  invoice = Invoice.find(params[:id])
349
- invoice.delay(:queue => 'general', :priority => 12).send_receipt_email
348
+ invoice.delay(:queue => 'caboose_store').send_receipt_email
350
349
  # invoice.send_receipt_email
351
350
  render :json => { :success => true }
352
351
  end
@@ -1,3 +1,4 @@
1
+
1
2
  module Caboose
2
3
  class LoginLogsController < ApplicationController
3
4
  layout 'caboose/admin'
@@ -8,7 +9,7 @@ module Caboose
8
9
 
9
10
  # @route GET /admin/login-logs/user/:userid
10
11
  def admin_index_for_user
11
- return if !user_is_allowed_to 'view', 'login_logs'
12
+ return if !user_is_allowed_to 'view', 'loginlogs'
12
13
  @pager = self.login_logs_pager
13
14
  @edituser = Caboose::User.find(params[:userid]) if !params[:userid].blank?
14
15
  render :layout => 'caboose/admin'
@@ -16,14 +17,14 @@ module Caboose
16
17
 
17
18
  # @route GET /admin/login-logs
18
19
  def admin_index
19
- return if !user_is_allowed_to 'view', 'login_logs'
20
+ return if !user_is_allowed_to 'view', 'loginlogs'
20
21
  @pager = self.login_logs_pager
21
22
  render :layout => 'caboose/admin'
22
23
  end
23
24
 
24
25
  # @route GET /admin/login-logs/json
25
26
  def admin_json
26
- return if !user_is_allowed_to 'view', 'login_logs'
27
+ return if !user_is_allowed_to 'view', 'loginlogs'
27
28
  pager = self.login_logs_pager
28
29
  render :json => {
29
30
  :pager => pager,
@@ -52,17 +53,18 @@ module Caboose
52
53
 
53
54
  # @route GET /admin/login-logs/:id/json
54
55
  def admin_json_single
55
- return if !user_is_allowed_to 'view', 'login_logs'
56
+ return if !user_is_allowed_to 'view', 'loginlogs'
56
57
  login_log = LoginLog.find(params[:id])
57
58
  render :json => login_log
58
59
  end
59
60
 
60
61
  # @route GET /admin/login-logs/:id
61
62
  def admin_edit
62
- return if !user_is_allowed_to 'edit', 'login_logs'
63
+ return if !user_is_allowed_to 'edit', 'loginlogs'
63
64
  @login_log = LoginLog.find(params[:id])
64
65
  render :layout => 'caboose/admin'
65
66
  end
66
67
 
67
68
  end
68
69
  end
70
+
@@ -61,7 +61,6 @@ 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
65
64
  resp.new_id = cat.id
66
65
  resp.refresh = true
67
66
  end
@@ -99,14 +98,8 @@ module Caboose
99
98
  def admin_delete
100
99
  return unless user_is_allowed('mediacategories', 'delete')
101
100
  cat = MediaCategory.find(params[:id])
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
101
+ Media.where(:media_category_id => cat.id).destroy_all
102
+ cat.destroy
110
103
  render :json => { :success => true }
111
104
  end
112
105
 
@@ -120,13 +113,6 @@ module Caboose
120
113
  ids.each do |id|
121
114
  m = Media.where(:id => id).first
122
115
  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
130
116
  m.update_attribute(:media_category_id, media_category_id)
131
117
  p = Product.where(:media_category_id => media_category_id).last
132
118
  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? || params[:media_category_id].blank?
76
- arr = Media.where(:media_category_id => params[:media_category_id], :deleted => false).reorder(:sort_order).all
75
+ render :json => false and return if @site.nil?
76
+ arr = Media.where(:media_category_id => params[:media_category_id]).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 => 'general', :priority => 2).download_image_from_url(value)
134
+ m.delay(:queue => 'caboose_media', :priority => 2).download_image_from_url(value)
135
135
  end
136
136
  end
137
137
 
@@ -163,14 +163,12 @@ module Caboose
163
163
  # @route DELETE /admin/media/:id
164
164
  def admin_delete
165
165
  return unless user_is_allowed('media', 'delete')
166
+
166
167
  model_ids = params[:id] == 'bulk' ? params[:ids] : [params[:id]]
167
168
  model_ids.each do |media_id|
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
169
+ ProductImage.where(:media_id => media_id).destroy_all
170
+ Media.where(:id => media_id).destroy_all
171
+ end
174
172
  render :json => { :success => true }
175
173
  end
176
174
 
@@ -187,12 +185,11 @@ module Caboose
187
185
  else
188
186
  file_content_type = file_type
189
187
  end
190
- #m = Media.where(:media_category_id => media_category_id, :original_name => original_name, :name => name, :deleted => false).first
191
- #if m.nil?
188
+ m = Media.where(:media_category_id => media_category_id, :original_name => original_name, :name => name).first
189
+ if m.nil?
192
190
  max = Media.where(:media_category_id => media_category_id).maximum(:sort_order)
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
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
+ end
196
193
  p = Product.where(:media_category_id => media_category_id).last
197
194
  if p
198
195
  pi = ProductImage.create(:product_id => p.id, :media_id => m.id)
@@ -5,8 +5,7 @@ module Caboose
5
5
  helper :application
6
6
 
7
7
  def before_action
8
- # removing temporarily - looks like not needed:
9
- #@page = Page.page_with_uri(request.host_with_port, '/admin')
8
+ @page = Page.page_with_uri(request.host_with_port, '/admin')
10
9
  end
11
10
 
12
11
  # @route GET /pages/:id/redirect
@@ -138,48 +137,25 @@ module Caboose
138
137
  #header("Content-Disposition: inline filename=\"$asset->filename\"")
139
138
 
140
139
  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
147
140
 
148
141
  #===========================================================================
149
142
  # Admin actions
150
143
  #===========================================================================
151
144
 
152
- # @route PUT /admin/pages/:id/publish
145
+ # @route GET /admin/pages/:id/publish
153
146
  def admin_publish
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
147
+ return unless user_is_allowed('pages', 'edit')
148
+ page = Page.find(params[:id])
149
+ page.publish
150
+ redirect_to "/admin/pages/#{page.id}/content"
173
151
  end
174
152
 
175
153
  # @route GET /admin/pages/:id/revert
176
154
  def admin_revert
177
155
  return unless user_is_allowed('pages', 'edit')
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"
156
+ page = Page.find(params[:id])
157
+ page.revert
158
+ redirect_to "/admin/pages/#{page.id}/content"
183
159
  end
184
160
 
185
161
  # @route GET /admin/pages
@@ -379,35 +355,6 @@ module Caboose
379
355
  render :layout => 'caboose/admin'
380
356
  end
381
357
  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
411
358
 
412
359
  # @route GET /admin/pages/:id/js
413
360
  def admin_edit_js
@@ -485,7 +432,7 @@ module Caboose
485
432
  elsif site_id.nil? then resp.error = "Invalid site"
486
433
  elsif parent_id.nil? then resp.error = "Invalid parent"
487
434
  else
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)
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)
489
436
  resp.success = true
490
437
  end
491
438
 
@@ -521,24 +468,12 @@ module Caboose
521
468
  end
522
469
  end
523
470
 
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
-
536
471
  # @route GET /admin/pages/:id
537
472
  def admin_edit_general
538
473
  return if !user_is_allowed('pages', 'edit')
539
474
  #return if !Page.is_allowed(logged_in_user, params[:id], 'edit')
540
475
  @page = Page.find(params[:id])
541
- @can_edit_home = logged_in_user.is_allowed(Caboose::Page.index_page(@site.id), 'edit')
476
+ @can_edit_home = user_is_allowed_to('edit', Caboose::Page.index_page(@site.id))
542
477
  if @page.site_id != @logged_in_user.site_id && !@logged_in_user.is_super_admin?
543
478
  redirect_to '/admin/pages'
544
479
  else
@@ -561,12 +496,11 @@ module Caboose
561
496
 
562
497
  parent = Caboose::Page.find(parent_id)
563
498
 
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
-
567
499
  if title.blank?
568
500
  resp.error = "Page Title is required."
569
- elsif (!logged_in_user.is_allowed('all', 'all') && !allowed_to_edit)
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))
570
504
  resp.error = "You don't have permission to add a page there."
571
505
  end
572
506
  if (!resp.error.nil?)
@@ -586,6 +520,7 @@ module Caboose
586
520
  page.title = title
587
521
  page.parent_id = parent_id
588
522
  page.hide = true
523
+ page.content_format = Caboose::Page::CONTENT_FORMAT_HTML
589
524
  page.save
590
525
  i = 0
591
526
  begin
@@ -603,14 +538,13 @@ module Caboose
603
538
  Caboose::Page.update_authorized_for_action(page.id, 'view', viewers)
604
539
  Caboose::Page.update_authorized_for_action(page.id, 'edit', editors)
605
540
  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
607
541
 
608
542
  # Copy from an existing page
609
543
  elsif !params[:copy_from_id].blank? && params[:use_copy] == 'yes'
610
544
  source = Caboose::Page.find(params[:copy_from_id])
611
545
  if source
612
546
  Caboose.log("copying from source page: #{source.id}")
613
- new_page = source.duplicate(@site.id, parent_id, false, layout_id, nil, logged_in_user.id)
547
+ new_page = source.duplicate(@site.id, parent_id, false, layout_id, nil)
614
548
  new_page.title = params[:title]
615
549
  new_page.hide = true
616
550
  i = 0
@@ -626,7 +560,6 @@ module Caboose
626
560
  Caboose::Page.update_authorized_for_action(new_page.id, 'view', viewers)
627
561
  Caboose::Page.update_authorized_for_action(new_page.id, 'edit', editors)
628
562
  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
630
563
  else
631
564
  resp.redirect = "/admin/pages/new"
632
565
  end
@@ -635,7 +568,7 @@ module Caboose
635
568
  elsif !params[:template_id].blank? && params[:use_template] == 'yes'
636
569
  template = Caboose::PageTemplate.find(params[:template_id])
637
570
  if template && template.page
638
- new_page = template.page.duplicate(@site.id, parent_id, false, layout_id, nil, logged_in_user.id)
571
+ new_page = template.page.duplicate(@site.id, parent_id, false, layout_id, nil)
639
572
  new_page.title = params[:title]
640
573
  new_page.hide = true
641
574
  i = 0
@@ -651,7 +584,6 @@ module Caboose
651
584
  Caboose::Page.update_authorized_for_action(new_page.id, 'view', viewers)
652
585
  Caboose::Page.update_authorized_for_action(new_page.id, 'edit', editors)
653
586
  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
655
587
  else
656
588
  resp.redirect = "/admin/pages/new"
657
589
  end
@@ -670,7 +602,6 @@ module Caboose
670
602
  save = true
671
603
  user = logged_in_user
672
604
  params.each do |name, value|
673
- old_value = page[name]
674
605
  case name
675
606
  when 'parent_id'
676
607
  value = value.to_i
@@ -696,10 +627,30 @@ module Caboose
696
627
  when 'custom_css', 'custom_css_files', 'custom_js', 'custom_js_files'
697
628
  value.strip!
698
629
  page[name.to_sym] = value
699
-
700
- when 'title', 'menu_title', 'hide', 'redirect_url',
630
+
631
+ when 'title', 'menu_title', 'hide', 'layout', 'redirect_url',
701
632
  'seo_title', 'meta_keywords', 'meta_description', 'fb_description', 'gp_description', 'canonical_url'
702
633
  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 }
703
654
 
704
655
  when 'meta_robots'
705
656
  arr = value.split(',').collect { |v| v.strip }
@@ -744,8 +695,8 @@ module Caboose
744
695
  Page.update_authorized_for_action(page.id, 'view', value)
745
696
  when 'editors'
746
697
  Page.update_authorized_for_action(page.id, 'edit', value)
747
- # when 'approvers'
748
- # Page.update_authorized_for_action(page.id, 'approve', value)
698
+ when 'approvers'
699
+ Page.update_authorized_for_action(page.id, 'approve', value)
749
700
  when 'tags'
750
701
  current_tags = page.page_tags.collect{ |t| t.tag }
751
702
  new_tags = value.split(',').collect{ |v| v.strip.downcase }.reject{ |t| t.nil? || t.strip.length == 0 }
@@ -756,22 +707,10 @@ module Caboose
756
707
  # Add any new tags not in current_tags
757
708
  new_tags.each{ |t| PageTag.create(:page_id => page.id, :tag => t) if !current_tags.include?(t) }
758
709
  end
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
-
710
+
768
711
  end
769
712
 
770
713
  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
-
775
714
  render json: resp
776
715
  end
777
716
 
@@ -779,7 +718,6 @@ module Caboose
779
718
  def admin_delete
780
719
  return unless user_is_allowed('pages', 'delete')
781
720
  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
783
721
  p.destroy
784
722
  resp = StdClass.new({
785
723
  'redirect' => '/admin/pages'