caboose-cms 0.7.28 → 0.7.29

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8de6384a797dde51a30ba1e13ecc3bf391bb3789
4
- data.tar.gz: 80ceb0e6add350eafcf0a22925e95b2298f5b9c6
3
+ metadata.gz: d6a19ce084683f65c5a6cbae50ebb24dd39ae3fd
4
+ data.tar.gz: 9ca547dd829a14261d9cf4d815da60682b7e84ab
5
5
  SHA512:
6
- metadata.gz: 0b1dccb8b8fd8d2f14bacfc85ac1ab675e5b1480857ddfb20738e630a37bc3b61757d219f1ef1d80eb0f1c8dede7f01eb17b1d8563f2545f8018d0a02e151cd9
7
- data.tar.gz: fea142d2da122f86fdf31e386eb56f3ecceac08064cfcac72d9db7146ed4f3fbef636331f65ab4a2c92643bd6324163db1d764930491941943c66aaa59ec131e
6
+ metadata.gz: e1f99a0e6bcf457cf4d921625ec81d54214198148d9d3cd7c6bf5700d7b9679ad236049e123a5c15a1154571762eed176ce0adaffaa741b8a7877a8c3331ed47
7
+ data.tar.gz: b5bca74153fd3b5f8c8835ce830dfe48a58045e47e7b710961b9ea1431805121d50d65eb9d10e003c8a7736eb250fdd455293f6a0267669e5f2887ffaf3b7df5
@@ -66,7 +66,7 @@ Caboose.Store.Modules.CheckoutPayment = (function() {
66
66
  if (total_is_correct == false)
67
67
  {
68
68
  $('#message').html("<p class='note error'>It looks like the order total has changed since this page has refreshed. Please submit your order again after this page refreshes.");
69
- setTimeout(function() { window.location.reload(true); }, 3000);
69
+ setTimeout(function() { window.location.reload(true); }, 3000);
70
70
  }
71
71
  else
72
72
  {
@@ -2,14 +2,14 @@ module Caboose
2
2
  class AbOptionsController < ApplicationController
3
3
  layout 'caboose/admin'
4
4
 
5
- # GET /admin/ab_variants/:variant_id/options
5
+ # @route GET /admin/ab_variants/:variant_id/options
6
6
  def admin_index
7
7
  return unless user_is_allowed_to 'view', 'ab_variants'
8
8
  v = AbVariant.find(params[:variant_id])
9
9
  render :json => v.ab_options
10
10
  end
11
11
 
12
- # POST admin/ab-variants/:variant_id/options'
12
+ # @route POST admin/ab-variants/:variant_id/options'
13
13
  def admin_create
14
14
  return unless user_is_allowed_to 'edit','ab_variants'
15
15
 
@@ -26,7 +26,7 @@ module Caboose
26
26
  render :json => resp
27
27
  end
28
28
 
29
- # PUT /admin/ab_options/:id
29
+ # @route PUT /admin/ab_options/:id
30
30
  def admin_update
31
31
  return unless user_is_allowed_to 'edit', 'ab_variants'
32
32
 
@@ -46,7 +46,7 @@ module Caboose
46
46
  render :json => resp
47
47
  end
48
48
 
49
- # DELETE /admin/ab_options/:id
49
+ # @route DELETE /admin/ab_options/:id
50
50
  def admin_delete
51
51
  return unless user_is_allowed_to 'delete', 'ab_variants'
52
52
  AbOption.find(params[:id]).destroy
@@ -6,7 +6,7 @@ module Caboose
6
6
  @page = Page.page_with_uri(request.host_with_port, '/admin')
7
7
  end
8
8
 
9
- # GET /admin/ab_variants
9
+ # @route GET /admin/ab_variants
10
10
  def admin_index
11
11
  return unless user_is_allowed_to 'view', 'ab_variants'
12
12
 
@@ -19,19 +19,19 @@ module Caboose
19
19
  @variants = @gen.items
20
20
  end
21
21
 
22
- # GET /admin/ab_variants/new
22
+ # @route GET /admin/ab_variants/new
23
23
  def admin_new
24
24
  return unless user_is_allowed_to 'add', 'ab_variants'
25
25
  @variant = AbVariant.new
26
26
  end
27
27
 
28
- # GET /admin/ab_variants/:id
28
+ # @route GET /admin/ab_variants/:id
29
29
  def admin_edit
30
30
  return unless user_is_allowed_to 'edit', 'ab_variants'
31
31
  @variant = AbVariant.find(params[:id])
32
32
  end
33
33
 
34
- # POST /admin/ab-variants
34
+ # @route POST /admin/ab-variants
35
35
  def admin_create
36
36
  return unless user_is_allowed_to 'edit', 'ab_variants'
37
37
 
@@ -53,7 +53,7 @@ module Caboose
53
53
  render json: resp
54
54
  end
55
55
 
56
- # PUT /admin/ab_variants/:id
56
+ # @route PUT /admin/ab_variants/:id
57
57
  def admin_update
58
58
  return unless user_is_allowed_to 'edit', 'ab_variants'
59
59
 
@@ -76,7 +76,7 @@ module Caboose
76
76
  render :json => resp
77
77
  end
78
78
 
79
- # DELETE /admin/ab_variants/:id
79
+ # @route DELETE /admin/ab_variants/:id
80
80
  def admin_destroy
81
81
  return unless user_is_allowed_to 'delete', 'ab_variants'
82
82
  AbVariants.find(params[:id]).destroy
@@ -2,7 +2,7 @@
2
2
  module Caboose
3
3
  class AdminController < ApplicationController
4
4
 
5
- # GET /admin
5
+ # @route GET /admin
6
6
  def index
7
7
  return if !user_is_allowed('admin', 'view')
8
8
  #if logged_in?
@@ -12,7 +12,7 @@ module Caboose
12
12
  @return_url = params[:return_url].nil? ? '/admin/pages' : params[:return_url]
13
13
  end
14
14
 
15
- # GET /station
15
+ # @route GET /station
16
16
  def station
17
17
  @user = logged_in_user
18
18
  render :layout => 'caboose/station'
@@ -1,14 +1,14 @@
1
1
  module Caboose
2
2
  class BillingAddressesController < Caboose::ApplicationController
3
3
 
4
- # GET /admin/orders/:order_id/billing-address/json
4
+ # @route GET /admin/orders/:order_id/billing-address/json
5
5
  def admin_json
6
6
  return if !user_is_allowed('orders', 'edit')
7
7
  order = Order.find(params[:order_id])
8
8
  render :json => order.billing_address
9
9
  end
10
10
 
11
- # PUT /admin/orders/:order_id/billing-address
11
+ # @route PUT /admin/orders/:order_id/billing-address
12
12
  def admin_update
13
13
  return if !user_is_allowed('orders', 'edit')
14
14
 
@@ -48,7 +48,7 @@ module Caboose
48
48
 
49
49
  #===========================================================================
50
50
 
51
- # GET /my-account/orders/:order_id/billing-address/json
51
+ # @route GET /my-account/orders/:order_id/billing-address/json
52
52
  def my_account_json
53
53
  return if !logged_in?
54
54
  order = Order.find(params[:order_id])
@@ -59,7 +59,7 @@ module Caboose
59
59
  render :json => order.billing_address
60
60
  end
61
61
 
62
- # PUT /my-account/orders/:order_id/billing-address
62
+ # @route PUT /my-account/orders/:order_id/billing-address
63
63
  def my_account_update
64
64
  return if !logged_in?
65
65
 
@@ -2,7 +2,7 @@
2
2
  module Caboose
3
3
  class BlockTypeCategoriesController < ApplicationController
4
4
 
5
- # GET /admin/block-type-categories/tree-options
5
+ # @route GET /admin/block-type-categories/tree-options
6
6
  def admin_tree_options
7
7
  return unless user_is_allowed('pages', 'edit')
8
8
  render :json => BlockTypeCategory.tree
@@ -5,27 +5,51 @@ module Caboose
5
5
  # Admin actions
6
6
  #===========================================================================
7
7
 
8
- # GET /admin/block-type-sources
8
+ # @route GET /admin/block-type-sources
9
9
  def admin_index
10
10
  return if !user_is_allowed('blocktypesources', 'view')
11
11
  @block_type_sources = BlockTypeSource.reorder("priority, name").all
12
12
  render :layout => 'caboose/admin'
13
13
  end
14
14
 
15
- # GET /admin/block-type-sources/new
15
+ # @route GET /admin/block-type-sources/new
16
16
  def admin_new
17
17
  return unless user_is_allowed('blocktypesources', 'add')
18
18
  render :layout => 'caboose/admin'
19
19
  end
20
20
 
21
- # GET /admin/block-type-sources/:id
21
+ # @route GET /admin/block-type-sources/:id/refresh
22
+ def admin_refresh
23
+ return unless user_is_allowed('blocktypesources', 'edit')
24
+
25
+ resp = StdClass.new
26
+
27
+ bts = BlockTypeSource.find(params[:id])
28
+ if bts.refresh_summaries
29
+ resp.success = "Block types from the source have been refreshed successfully."
30
+ else
31
+ resp.error = "There was an error refreshing block types from the source."
32
+ end
33
+ render :json => resp
34
+ end
35
+
36
+ # @route GET /admin/block-type-sources/options
37
+ def admin_options
38
+ return unless user_is_allowed('blocktypesources', 'edit')
39
+ options = BlockType.reorder(:name).all.collect do |bts|
40
+ { 'value' => bts.id, 'text' => bts.name }
41
+ end
42
+ render :json => options
43
+ end
44
+
45
+ # @route GET /admin/block-type-sources/:id
22
46
  def admin_edit
23
47
  return unless user_is_allowed('blocktypesources', 'edit')
24
48
  @block_type_source = BlockTypeSource.find(params[:id])
25
49
  render :layout => 'caboose/admin'
26
50
  end
27
51
 
28
- # POST /admin/block-type-sources
52
+ # @route POST /admin/block-type-sources
29
53
  def admin_create
30
54
  return unless user_is_allowed('blocktypesources', 'add')
31
55
 
@@ -44,7 +68,7 @@ module Caboose
44
68
  render :json => resp
45
69
  end
46
70
 
47
- # PUT /admin/block-type-sources/:id
71
+ # @route PUT /admin/block-type-sources/:id
48
72
  def admin_update
49
73
  return unless user_is_allowed('blocktypesources', 'edit')
50
74
 
@@ -66,7 +90,7 @@ module Caboose
66
90
  render :json => resp
67
91
  end
68
92
 
69
- # DELETE /admin/block-type-sources/:id
93
+ # @route DELETE /admin/block-type-sources/:id
70
94
  def admin_delete
71
95
  return unless user_is_allowed('blocktypesources', 'delete')
72
96
  BlockTypeSource.find(params[:id]).destroy
@@ -75,30 +99,6 @@ module Caboose
75
99
  })
76
100
  render :json => resp
77
101
  end
78
-
79
- # GET /admin/block-type-sources/:id/refresh
80
- def admin_refresh
81
- return unless user_is_allowed('blocktypesources', 'edit')
82
-
83
- resp = StdClass.new
84
-
85
- bts = BlockTypeSource.find(params[:id])
86
- if bts.refresh_summaries
87
- resp.success = "Block types from the source have been refreshed successfully."
88
- else
89
- resp.error = "There was an error refreshing block types from the source."
90
- end
91
- render :json => resp
92
- end
93
-
94
- # GET /admin/block-type-sources/options
95
- def admin_options
96
- return unless user_is_allowed('blocktypesources', 'edit')
97
- options = BlockType.reorder(:name).all.collect do |bts|
98
- { 'value' => bts.id, 'text' => bts.name }
99
- end
100
- render :json => options
101
- end
102
102
 
103
103
  end
104
104
  end
@@ -2,7 +2,7 @@
2
2
  module Caboose
3
3
  class BlockTypeStoreController < ApplicationController
4
4
 
5
- # GET /admin/block-types/store
5
+ # @route GET /admin/block-types/store
6
6
  def admin_index
7
7
  return unless user_is_allowed('blocktypestore', 'add')
8
8
  @pager = PageBarGenerator.new(params, {
@@ -20,14 +20,7 @@ module Caboose
20
20
  render :layout => 'caboose/admin'
21
21
  end
22
22
 
23
- # GET /admin/block-types/store/:block_type_summary_id
24
- def admin_details
25
- return unless user_is_allowed('blocktypestore', 'add')
26
- @block_type_summary = BlockTypeSummary::find(params[:block_type_summary_id])
27
- render :layout => 'caboose/admin'
28
- end
29
-
30
- # GET /admin/block-types/store/:block_type_summary_id/download
23
+ # @route GET /admin/block-types/store/:block_type_summary_id/download
31
24
  def admin_download
32
25
  return unless user_is_allowed('blocktypestore', 'add')
33
26
 
@@ -37,6 +30,13 @@ module Caboose
37
30
  resp = StdClass.new('success' => 'The block type has been downloaded successfully.')
38
31
  render :json => resp
39
32
  end
40
-
33
+
34
+ # @route GET /admin/block-types/store/:block_type_summary_id
35
+ def admin_details
36
+ return unless user_is_allowed('blocktypestore', 'add')
37
+ @block_type_summary = BlockTypeSummary::find(params[:block_type_summary_id])
38
+ render :layout => 'caboose/admin'
39
+ end
40
+
41
41
  end
42
42
  end
@@ -6,14 +6,14 @@ module Caboose
6
6
  # Admin actions
7
7
  #===========================================================================
8
8
 
9
- # GET /admin/block-types
9
+ # @route GET /admin/block-types
10
10
  def admin_index
11
11
  return if !user_is_allowed('pages', 'view')
12
12
  @block_types = BlockType.where("parent_id is null or parent_id = 0").reorder(:name).all
13
13
  render :layout => 'caboose/admin'
14
14
  end
15
15
 
16
- # GET /admin/block-types/json
16
+ # @route GET /admin/block-types/json
17
17
  def admin_json
18
18
  h = {
19
19
  'name' => '',
@@ -41,15 +41,15 @@ module Caboose
41
41
  }
42
42
  end
43
43
 
44
- # GET /admin/block-types/:id/json
44
+ # @route GET /admin/block-types/:id/json
45
45
  def admin_json_single
46
46
  return if !user_is_allowed('pages', 'view')
47
47
  block_type = BlockType.find(params[:id])
48
48
  render :json => block_type.as_json(:include => :sites)
49
49
  end
50
50
 
51
- # GET /admin/block-types/new
52
- # GET /admin/block-types/:id/new
51
+ # @route GET /admin/block-types/new
52
+ # @route GET /admin/block-types/:id/new
53
53
  def admin_new
54
54
  return unless user_is_allowed('pages', 'add')
55
55
  @block_type = BlockType.new
@@ -57,21 +57,21 @@ module Caboose
57
57
  render :layout => 'caboose/admin'
58
58
  end
59
59
 
60
- # GET /admin/block-types/:id
61
- def admin_edit
60
+ # @route GET /admin/block-types/:id/icon
61
+ def admin_edit_icon
62
62
  return unless user_is_allowed('pages', 'edit')
63
63
  @block_type = BlockType.find(params[:id])
64
- render :layout => 'caboose/admin'
64
+ render :layout => 'caboose/modal'
65
65
  end
66
66
 
67
- # GET /admin/block-types/:id/icon
68
- def admin_edit_icon
67
+ # @route GET /admin/block-types/:id
68
+ def admin_edit
69
69
  return unless user_is_allowed('pages', 'edit')
70
70
  @block_type = BlockType.find(params[:id])
71
- render :layout => 'caboose/modal'
71
+ render :layout => 'caboose/admin'
72
72
  end
73
73
 
74
- # POST /admin/block-types
74
+ # @route POST /admin/block-types
75
75
  def admin_create
76
76
  return unless user_is_allowed('pages', 'add')
77
77
 
@@ -94,7 +94,7 @@ module Caboose
94
94
  render :json => resp
95
95
  end
96
96
 
97
- # PUT /admin/block-types/:id
97
+ # @route PUT /admin/block-types/:id
98
98
  def admin_update
99
99
  return unless user_is_allowed('pages', 'edit')
100
100
 
@@ -139,7 +139,7 @@ module Caboose
139
139
  render :json => resp
140
140
  end
141
141
 
142
- # DELETE /admin/block-types/:id
142
+ # @route DELETE /admin/block-types/:id
143
143
  def admin_delete
144
144
  return unless user_is_allowed('pages', 'delete')
145
145
  BlockType.find(params[:id]).destroy
@@ -148,68 +148,53 @@ module Caboose
148
148
  })
149
149
  render :json => resp
150
150
  end
151
-
152
- # GET /admin/block-types/field-type-options
151
+
152
+ # @route_priority 1
153
+ # @route GET /admin/block-types/:field-options
154
+ # @route GET /admin/block-types/options
155
+ # @route GET /admin/block-types/:id/options
153
156
  def admin_field_type_options
154
- return unless user_is_allowed('pages', 'edit')
155
- options = [
156
- { 'value' => 'checkbox' , 'text' => 'Checkbox' },
157
- { 'value' => 'checkbox_multiple' , 'text' => 'Checkbox (multiple)' },
158
- { 'value' => 'image' , 'text' => 'Image' },
159
- { 'value' => 'file' , 'text' => 'File' },
160
- { 'value' => 'richtext' , 'text' => 'Rich Text' },
161
- { 'value' => 'select' , 'text' => 'Multiple choice (select box)' },
162
- { 'value' => 'text' , 'text' => 'Textbox' },
163
- { 'value' => 'textarea' , 'text' => 'Textarea' },
164
- { 'value' => 'block' , 'text' => 'Block' }
165
- ]
166
- render :json => options
167
- end
168
-
169
- # GET /admin/block-types/site-options
170
- def admin_site_options
171
- return unless user_is_allowed('pages', 'edit')
172
- options = Site.reorder("description, name").all.collect do |s|
173
- {
174
- 'value' => s.id,
175
- 'text' => s.description && s.description.strip.length > 0 ? s.description : s.name
176
- }
177
- end
178
- render :json => options
179
- end
180
-
181
- # GET /admin/block-types/:id/options
182
- def admin_value_options
183
157
  return unless user_is_allowed('pages', 'edit')
184
- bt = BlockType.find(params[:id])
158
+
185
159
  options = []
186
- if bt.options_function
187
- options = bt.render_options
188
- elsif bt.options
189
- options = bt.options.strip.split("\n").collect { |line| { 'value' => line, 'text' => line }}
160
+ case params[:field]
161
+ when nil
162
+ if params[:id]
163
+ bt = BlockType.find(params[:id])
164
+ options = []
165
+ if bt.options_function
166
+ options = bt.render_options
167
+ elsif bt.options
168
+ options = bt.options.strip.split("\n").collect { |line| { 'value' => line, 'text' => line }}
169
+ end
170
+ else
171
+ options = BlockType.where("parent_id is null").reorder(:name).all.collect do |bt|
172
+ { 'value' => bt.id, 'text' => bt.description }
173
+ end
174
+ end
175
+ when 'field-type'
176
+ options = [
177
+ { 'value' => 'checkbox' , 'text' => 'Checkbox' },
178
+ { 'value' => 'checkbox_multiple' , 'text' => 'Checkbox (multiple)' },
179
+ { 'value' => 'image' , 'text' => 'Image' },
180
+ { 'value' => 'file' , 'text' => 'File' },
181
+ { 'value' => 'richtext' , 'text' => 'Rich Text' },
182
+ { 'value' => 'select' , 'text' => 'Multiple choice (select box)' },
183
+ { 'value' => 'text' , 'text' => 'Textbox' },
184
+ { 'value' => 'textarea' , 'text' => 'Textarea' },
185
+ { 'value' => 'block' , 'text' => 'Block' }
186
+ ]
187
+ when 'site'
188
+ options = Site.reorder("description, name").all.collect{ |s| { 'value' => s.id, 'text' => s.description && s.description.strip.length > 0 ? s.description : s.name }}
189
+ when 'tree'
190
+ options = []
191
+ BlockType.where("parent_id is null or parent_id = 0").reorder(:name).all.each do |bt|
192
+ admin_tree_options_helper(options, bt, '')
193
+ end
190
194
  end
191
195
  render :json => options
192
196
  end
193
197
 
194
- # GET /admin/block-types/options
195
- def admin_options
196
- return unless user_is_allowed('pages', 'edit')
197
- options = BlockType.where("parent_id is null").reorder(:name).all.collect do |bt|
198
- { 'value' => bt.id, 'text' => bt.description }
199
- end
200
- render :json => options
201
- end
202
-
203
- # GET /admin/block-types/tree-options
204
- def admin_tree_options
205
- return unless user_is_allowed('pages', 'edit')
206
- options = []
207
- BlockType.where("parent_id is null or parent_id = 0").reorder(:name).all.each do |bt|
208
- admin_tree_options_helper(options, bt, '')
209
- end
210
- render :json => options
211
- end
212
-
213
198
  def admin_tree_options_helper(options, bt, prefix)
214
199
  options << { 'value' => bt.id, 'text' => "#{prefix}#{bt.description}" }
215
200
  bt.children.each do |bt2|
@@ -221,7 +206,7 @@ module Caboose
221
206
  # Store Actions
222
207
  #===========================================================================
223
208
 
224
- # GET /admin/block-types/store
209
+ # @route GET /admin/block-types/store
225
210
  def admin_store_index
226
211
  return unless user_is_allowed('blocktypestore', 'add')
227
212
  @pager = PageBarGenerator.new(params, {
@@ -239,14 +224,7 @@ module Caboose
239
224
  render :layout => 'caboose/admin'
240
225
  end
241
226
 
242
- # GET /admin/block-types/store/:block_type_summary_id
243
- def admin_store_details
244
- return unless user_is_allowed('blocktypestore', 'add')
245
- @block_type_summary = BlockTypeSummary::find(params[:block_type_summary_id])
246
- render :layout => 'caboose/admin'
247
- end
248
-
249
- # GET /admin/block-types/store/:block_type_summary_id/download
227
+ # @route GET /admin/block-types/store/:block_type_summary_id/download
250
228
  def admin_store_download
251
229
  return unless user_is_allowed('blocktypestore', 'add')
252
230
 
@@ -257,11 +235,18 @@ module Caboose
257
235
  render :json => resp
258
236
  end
259
237
 
238
+ # @route GET /admin/block-types/store/:block_type_summary_id
239
+ def admin_store_details
240
+ return unless user_is_allowed('blocktypestore', 'add')
241
+ @block_type_summary = BlockTypeSummary::find(params[:block_type_summary_id])
242
+ render :layout => 'caboose/admin'
243
+ end
244
+
260
245
  #===========================================================================
261
246
  # Public Repo Actions
262
247
  #===========================================================================
263
248
 
264
- # GET /caboose/block-types
249
+ # @route GET /caboose/block-types
265
250
  def api_block_type_list
266
251
  arr = BlockType.where("parent_id is null and share = ?", true).reorder(:name).all.collect do |bt|
267
252
  { 'name' => bt.name, 'description' => bt.description }
@@ -269,7 +254,7 @@ module Caboose
269
254
  render :json => arr
270
255
  end
271
256
 
272
- # GET /caboose/block-types/:name
257
+ # @route GET /caboose/block-types/:name
273
258
  def api_block_type
274
259
  bt = BlockType.where(:name => params[:name]).first
275
260
  render :json => { 'error' => 'Invalid block type.' } if bt.nil?
@@ -18,8 +18,8 @@ module Caboose
18
18
  # Admin actions
19
19
  #===========================================================================
20
20
 
21
- # GET /admin/pages/:page_id/blocks
22
- # GET /admin/posts/:post_id/blocks
21
+ # @route GET /admin/pages/:page_id/blocks
22
+ # @route GET /admin/posts/:post_id/blocks
23
23
  def admin_index
24
24
  return if !user_is_allowed('pages', 'view')
25
25
  #h = params[:post_id] ? { :post_id => params[:post_id] } : { :page_id => params[:page_id] }
@@ -28,10 +28,10 @@ module Caboose
28
28
  render :json => @p.block
29
29
  end
30
30
 
31
- # GET /admin/pages/:page_id/blocks/:id/new
32
- # GET /admin/pages/:page_id/blocks/new
33
- # GET /admin/posts/:post_id/blocks/:id/new
34
- # GET /admin/posts/:post_id/blocks/new
31
+ # @route GET /admin/pages/:page_id/blocks/:id/new
32
+ # @route GET /admin/pages/:page_id/blocks/new
33
+ # @route GET /admin/posts/:post_id/blocks/:id/new
34
+ # @route GET /admin/posts/:post_id/blocks/new
35
35
  def admin_new
36
36
  return unless user_is_allowed('pages', 'add')
37
37
 
@@ -67,18 +67,18 @@ module Caboose
67
67
  render :layout => 'caboose/modal'
68
68
  end
69
69
 
70
- # GET /admin/pages/:page_id/blocks/:id
71
- # GET /admin/posts/:post_id/blocks/:id
70
+ # @route GET /admin/pages/:page_id/blocks/:id
71
+ # @route GET /admin/posts/:post_id/blocks/:id
72
72
  def admin_show
73
73
  return unless user_is_allowed('pages', 'edit')
74
74
  block = Block.find(params[:id])
75
75
  render :json => block
76
76
  end
77
77
 
78
- # GET /admin/pages/:page_id/blocks/tree
79
- # GET /admin/pages/:page_id/blocks/:id/tree
80
- # GET /admin/posts/:post_id/blocks/tree
81
- # GET /admin/posts/:post_id/blocks/:id/tree
78
+ # @route GET /admin/pages/:page_id/blocks/tree
79
+ # @route GET /admin/pages/:page_id/blocks/:id/tree
80
+ # @route GET /admin/posts/:post_id/blocks/tree
81
+ # @route GET /admin/posts/:post_id/blocks/:id/tree
82
82
  def admin_tree
83
83
  return unless user_is_allowed('pages', 'edit')
84
84
 
@@ -103,8 +103,8 @@ module Caboose
103
103
  return arr
104
104
  end
105
105
 
106
- # GET /admin/pages/:page_id/blocks/:id/render
107
- # GET /admin/posts/:post_id/blocks/:id/render
106
+ # @route GET /admin/pages/:page_id/blocks/:id/render
107
+ # @route GET /admin/posts/:post_id/blocks/:id/render
108
108
  def admin_render
109
109
  return unless user_is_allowed('pages', 'edit')
110
110
  b = Block.find(params[:id])
@@ -133,8 +133,8 @@ module Caboose
133
133
  render :json => html
134
134
  end
135
135
 
136
- # GET /admin/pages/:page_id/blocks/render
137
- # GET /admin/posts/:post_id/blocks/render
136
+ # @route GET /admin/pages/:page_id/blocks/render
137
+ # @route GET /admin/posts/:post_id/blocks/render
138
138
  def admin_render_all
139
139
  return unless user_is_allowed('pages', 'edit')
140
140
  blocks = Block.where("#{page_or_post}_id = ? and parent_id is null", @p.id).reorder(:sort_order).collect do |b|
@@ -163,8 +163,8 @@ module Caboose
163
163
  render :json => blocks
164
164
  end
165
165
 
166
- # GET /admin/pages/:page_id/blocks/render-second-level
167
- # GET /admin/posts/:post_id/blocks/render-second-level
166
+ # @route GET /admin/pages/:page_id/blocks/render-second-level
167
+ # @route GET /admin/posts/:post_id/blocks/render-second-level
168
168
  def admin_render_second_level
169
169
  return unless user_is_allowed('pages', 'edit')
170
170
  view = ActionView::Base.new(ActionController::Base.view_paths)
@@ -195,8 +195,8 @@ module Caboose
195
195
  render :json => blocks
196
196
  end
197
197
 
198
- # GET /admin/pages/:page_id/blocks/:id/edit
199
- # GET /admin/posts/:post_id/blocks/:id/edit
198
+ # @route GET /admin/pages/:page_id/blocks/:id/edit
199
+ # @route GET /admin/posts/:post_id/blocks/:id/edit
200
200
  def admin_edit
201
201
  return unless user_is_allowed('pages', 'edit')
202
202
  @page = Page.find(params[:page_id]) if params[:page_id]
@@ -185,11 +185,22 @@ module Caboose
185
185
  # GET /checkout/total
186
186
  def verify_total
187
187
  total = 0.00
188
- if logged_in?
188
+ if logged_in?
189
189
  @order.calculate
190
190
  total = @order.total
191
191
  end
192
- render :json => total
192
+ #render :json => total.to_f
193
+ ap @order
194
+
195
+ render :json => {
196
+ :subtotal => @order.calculate_subtotal.to_f ,
197
+ :tax => @order.calculate_tax.to_f ,
198
+ :shipping => @order.calculate_shipping.to_f ,
199
+ :handling => @order.calculate_handling.to_f ,
200
+ :gift_wrap => @order.calculate_gift_wrap.to_f ,
201
+ :discount => @order.calculate_discount.to_f ,
202
+ :total => @order.calculate_total.to_f
203
+ }
193
204
  end
194
205
 
195
206
  # GET /checkout/address
@@ -356,10 +367,10 @@ module Caboose
356
367
  # Take funds from any gift cards that were used on the order
357
368
  order.take_gift_card_funds
358
369
 
359
- # Send out emails
360
- OrdersMailer.configure_for_site(@site.id).customer_new_order(order).deliver
361
- OrdersMailer.configure_for_site(@site.id).fulfillment_new_order(order).deliver
362
-
370
+ # Send out emails
371
+ OrdersMailer.delay.configure_for_site(@site.id).customer_new_order(order).deliver
372
+ OrdersMailer.delay.configure_for_site(@site.id).fulfillment_new_order(order).deliver
373
+
363
374
  # Emit order event
364
375
  Caboose.plugin_hook('order_authorized', order)
365
376
  else
@@ -2,63 +2,82 @@ module Caboose
2
2
  class CommentRoutes
3
3
 
4
4
  def CommentRoutes.parse_controllers
5
-
6
- classes = []
7
- files = Dir.glob(Rails.root.join('app', 'controllers','*.rb'))
8
- for file in files
9
- f = Rails.root.join('app', 'controllers', file)
10
- f2 = File.open(f, "r")
11
-
12
- class_name = nil
13
- class_priority = 20
14
- route_priority = 20
15
- uris = []
16
- actions = []
17
- f2.each_line do |line|
18
- line = line.strip
19
- if line =~ /^(.*?)class (.*?)Controller(.*?)$/
20
- class_name = line.gsub(/^(.*?)class (.*?)Controller(.*?)$/, '\2').gsub(/([A-Z])/, '_\1').downcase
21
- class_name[0] = '' if class_name[0] == '_'
22
- elsif line =~ /# @class_route_priority \d/
23
- class_priority = line.gsub(/# @class_route_priority (\d*?)$/, '\1').to_i
24
- elsif line =~ /# @route_priority \d/
25
- route_priority = line.gsub(/# @route_priority (\d*?)$/, '\1').to_i
26
- elsif line.starts_with?('def ')
27
- actions << [line.gsub('def ', ''), uris, route_priority]
28
- uris = []
29
- route_priority = 20
30
- elsif line =~ /# @route GET (.*?)/ then uris << "get \"#{line.gsub(/# @route GET (.*?)/ , '\1')}\""
31
- elsif line =~ /# @route POST (.*?)/ then uris << "post \"#{line.gsub(/# @route POST (.*?)/ , '\1')}\""
32
- elsif line =~ /# @route PUT (.*?)/ then uris << "put \"#{line.gsub(/# @route PUT (.*?)/ , '\1')}\""
33
- elsif line =~ /# @route DELETE (.*?)/ then uris << "delete \"#{line.gsub(/# @route DELETE (.*?)/ , '\1')}\""
5
+
6
+ classes = {'zzz_all_domains' => []}
7
+ Rails.application.config.paths['app/controllers'].each do |controller_path|
8
+ files = Dir.glob(Rails.root.join(controller_path, '*.rb'))
9
+ for file in files
10
+ f = Rails.root.join('app', 'controllers', file)
11
+ f2 = File.open(f, "r")
12
+
13
+ domains = []
14
+ class_name = nil
15
+ class_priority = 20
16
+ route_priority = 20
17
+ uris = []
18
+ actions = []
19
+ f2.each_line do |line|
20
+ line = line.strip
21
+ if line =~ /^(.*?)class (.*?)Controller(.*?)$/
22
+ class_name = line.gsub(/^(.*?)class (.*?)Controller(.*?)$/, '\2').gsub(/([A-Z])/, '_\1').downcase
23
+ class_name[0] = '' if class_name[0] == '_'
24
+ elsif line =~ /# @route_domain (.*?)$/
25
+ domain = line.gsub(/# @route_domain (.*?)$/, '\1')
26
+ domains << domain if !domains.include?(domain)
27
+ elsif line =~ /# @class_route_priority \d/
28
+ class_priority = line.gsub(/# @class_route_priority (\d*?)$/, '\1').to_i
29
+ elsif line =~ /# @route_priority \d/
30
+ route_priority = line.gsub(/# @route_priority (\d*?)$/, '\1').to_i
31
+ elsif line.starts_with?('def ')
32
+ actions << [line.gsub('def ', ''), uris, route_priority]
33
+ uris = []
34
+ route_priority = 20
35
+ elsif line =~ /# @route GET (.*?)/ then uris << "get \"#{line.gsub(/# @route GET (.*?)/ , '\1')}\""
36
+ elsif line =~ /# @route POST (.*?)/ then uris << "post \"#{line.gsub(/# @route POST (.*?)/ , '\1')}\""
37
+ elsif line =~ /# @route PUT (.*?)/ then uris << "put \"#{line.gsub(/# @route PUT (.*?)/ , '\1')}\""
38
+ elsif line =~ /# @route DELETE (.*?)/ then uris << "delete \"#{line.gsub(/# @route DELETE (.*?)/ , '\1')}\""
39
+ end
40
+ end
41
+ if domains.count > 0
42
+ domains.each do |domain|
43
+ classes[domain] = [] if classes[domain].nil?
44
+ classes[domain] << [class_name, actions, class_priority]
45
+ end
46
+ else
47
+ classes['zzz_all_domains'] << [class_name, actions, class_priority]
34
48
  end
35
- end
36
- classes << [class_name, actions, class_priority]
49
+ end
37
50
  end
38
-
51
+
39
52
  routes = []
40
- classes.sort_by{ |arr| arr[2] }.each do |carr|
41
-
42
- class_name = carr[0]
43
- actions = carr[1]
44
-
45
- # Get the longest URI so we can make routes that line up vertically
46
- longest = ''
47
- actions.each{ |action, uris| uris.each{ |uri| longest = uri if uri.length > longest.length }}
48
- length = longest.length + 1
53
+ classes.sort_by{ |domain, domain_classes| domain }.to_h.each do |domain, domain_classes|
54
+
55
+ routes << "constraints Caboose::DomainConstraint.new('#{domain}') do" if domain != 'zzz_all_domains'
56
+ domain_classes.sort_by{ |arr| arr[2] }.each do |carr|
49
57
 
50
- # Make the route line
51
- actions.sort_by{ |arr| arr[2] }.each do |arr|
52
- action = arr[0]
53
- uris = arr[1]
54
- uris.each do |uri|
55
- #puts "#{uri.ljust(length, ' ')} => \"#{class_name}\##{action}\""
56
- routes << "#{uri.ljust(length, ' ')} => \"#{class_name}\##{action}\""
58
+ class_name = carr[0]
59
+ actions = carr[1]
60
+
61
+ # Get the longest URI so we can make routes that line up vertically
62
+ longest = ''
63
+ actions.each{ |action, uris| uris.each{ |uri| longest = uri if uri.length > longest.length }}
64
+ length = longest.length + 1
65
+
66
+ # Make the route line
67
+ actions.sort_by{ |arr| arr[2] }.each do |arr|
68
+ action = arr[0]
69
+ uris = arr[1]
70
+ uris.each do |uri|
71
+ #puts "#{uri.ljust(length, ' ')} => \"#{class_name}\##{action}\""
72
+ routes << "#{uri.ljust(length, ' ')} => \"#{class_name}\##{action}\""
73
+ end
57
74
  end
75
+ puts ""
58
76
  end
59
- puts ""
77
+ routes << "end" if domain != 'zzz_all_domains'
60
78
  end
61
- return routes
79
+ puts routes
80
+ return routes.join("\n")
62
81
  end
63
82
 
64
83
  end
@@ -0,0 +1,9 @@
1
+ class Caboose::DomainConstraint
2
+ def initialize(domain)
3
+ @domains = [domain].flatten
4
+ end
5
+
6
+ def matches?(request)
7
+ return @domains.include?(request.host)
8
+ end
9
+ end
@@ -144,24 +144,14 @@ module Caboose
144
144
  g.helper false
145
145
  end
146
146
 
147
+ #initializer 'caboose.site_mvc', :after => :finish_hook do |app|
148
+ # # Add the MVC files for each site
149
+ # Caboose::Site.reorder(:name).all.each do |site|
150
+ # Rails.application.config.paths['app/controllers'] << "sites/#{site.name}/controllers"
151
+ # Rails.application.config.paths['app/models'] << "sites/#{site.name}/models"
152
+ # Rails.application.config.paths['app/views'] << "sites/#{site.name}/views"
153
+ # end
154
+ #end
155
+
147
156
  end
148
157
  end
149
-
150
- #initializer 'caboose_store.payment_processor', :after => :finish_hook do |app|
151
- # case Caboose::payment_processor
152
- # when 'authorize.net'
153
- # Caboose::PaymentProcessor = Caboose::PaymentProcessors::Authorizenet
154
- # when 'payscape'
155
- # Caboose::PaymentProcessor = Caboose::PaymentProcessors::Payscape
156
- # end
157
- #end
158
- #
159
- #initializer 'caboose_store.cart', :after => :finish_hook do |app|
160
- # ActiveSupport.on_load(:action_controller) do
161
- # include Caboose::BootStrapper
162
- # end
163
- #
164
- # Caboose::User.class_eval do
165
- # self.primary_key = :id
166
- # end
167
- #end
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.7.28'
2
+ VERSION = '0.7.29'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.28
4
+ version: 0.7.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-08 00:00:00.000000000 Z
11
+ date: 2015-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -791,6 +791,7 @@ files:
791
791
  - app/models/caboose/database_session.rb
792
792
  - app/models/caboose/discount.rb
793
793
  - app/models/caboose/domain.rb
794
+ - app/models/caboose/domain_constraint.rb
794
795
  - app/models/caboose/font.rb
795
796
  - app/models/caboose/font_family.rb
796
797
  - app/models/caboose/font_variant.rb