caboose-cms 0.8.54 → 0.8.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 52aaaaf1b36fe04e4a238a7eb012bf091ea70dcf
4
- data.tar.gz: d144b7f4c53b1e545faf238011a8b05bd76a7496
3
+ metadata.gz: 0a7f9a70370e9c5d99ac4c0f78557687c76d7069
4
+ data.tar.gz: 8a20215e7e1b15d4e5b17fb0c6c65e9f0c6bd565
5
5
  SHA512:
6
- metadata.gz: 477fb721643da72cb55421bb70444863a708ca51cb30ce5ce8e542e1e261db551fcaeb119c2ba550d8bde5638c9fff85dcd6673054c7147bfae1bc71733c2e11
7
- data.tar.gz: 677d0f114bfd8591062f6a3a8dd4d57768e056fa2f3e18bb832921f527ee08bbebebdd486cc419a8399b01ce69a1d87110d9b32787838178a74197c7a9efc962
6
+ metadata.gz: 4acc6e7c193095541e742edd809d74a0f0a60285ac6021366cb74d05b009c08b7082522f8cd63abe88c42735206b404d9d8dfc003d1f8be63f26017c0d006a07
7
+ data.tar.gz: 9bfd52b6631c64cd893cdba29b61e02d3c1782cf5b28b67e51b8e219bbc7d4e316cea8306e6af09beecfff6f611b3736104ad0388290d6d06bd67a54ae13255f
@@ -48,12 +48,15 @@ PageContentController.prototype = {
48
48
  var that = this;
49
49
  var b = that.block_with_id(block_id);
50
50
  var modal_controller = '';
51
- if (b.block_type.use_js_for_modal == true) {
52
- $.each(b.name.split('_'), function(j, word) { modal_controller += word.charAt(0).toUpperCase() + word.toLowerCase().slice(1); });
53
- }
51
+ if (b.block_type.use_js_for_modal == true) {
52
+ if (b.name)
53
+ $.each(b.name.split('_'), function(j, word) { modal_controller += word.charAt(0).toUpperCase() + word.toLowerCase().slice(1); });
54
+ else
55
+ $.each(b.block_type.name.split('_'), function(j, word) { modal_controller += word.charAt(0).toUpperCase() + word.toLowerCase().slice(1); });
56
+ }
54
57
  else if (b.block_type.field_type == 'image') { modal_controller = 'Media'; }
55
58
  else if (b.block_type.field_type == 'richtext') { modal_controller = 'Richtext'; }
56
- else { modal_controller = 'Block'; }
59
+ else { modal_controller = 'Block'; }
57
60
  that.modal = eval("new " + modal_controller + "ModalController({ " +
58
61
  " page_id: " + that.page_id + ", " +
59
62
  " block_id: " + block_id + ", " +
@@ -1,7 +1,76 @@
1
1
 
2
- var BlockModalController = DefaultBlockModalController.extend({
2
+ var BlockModalController = ModalController.extend({
3
3
 
4
- block_types: false,
4
+ page_id: false,
5
+ block_id: false,
6
+ block: false,
7
+ block_types: false,
8
+ authenticity_token: false,
9
+ new_block_on_init: false,
10
+ assets_path: false,
11
+ block_types: false,
12
+ complex_field_types: ['block', 'richtext', 'image', 'file'],
13
+
14
+ init: function(params)
15
+ {
16
+ var that = this;
17
+ for (var i in params)
18
+ that[i] = params[i];
19
+ that.include_assets();
20
+ if (that.new_block_on_init == true)
21
+ that.refresh_block(function() { that.add_block(); });
22
+ else
23
+ that.print();
24
+ },
25
+
26
+ refresh: function(callback)
27
+ {
28
+ var that = this;
29
+ that.refresh_block(function() {
30
+ if (callback) callback();
31
+ });
32
+ },
33
+
34
+ refresh_block: function(callback)
35
+ {
36
+ var that = this
37
+ $.ajax({
38
+ url: '/admin/pages/' + that.page_id + '/blocks/' + that.block_id + '/tree',
39
+ type: 'get',
40
+ success: function(arr) {
41
+ that.block = arr[0];
42
+ if (callback) callback();
43
+ }
44
+ });
45
+ },
46
+
47
+ /*****************************************************************************
48
+ Printing
49
+ *****************************************************************************/
50
+
51
+ print: function()
52
+ {
53
+ var that = this;
54
+ if (!that.block)
55
+ {
56
+ var div = $('<div/>')
57
+ .append($('<div/>').attr('id', 'modal_crumbtrail' ))
58
+ .append($('<div/>').attr('id', 'modal_content' ))
59
+ .append($('<div/>').attr('id', 'modal_message' ))
60
+ .append($('<div/>').attr('id', 'modal_controls' ));
61
+ that.modal(div, 800);
62
+ that.refresh(function() { that.print(); });
63
+ return;
64
+ }
65
+
66
+ that.print_content();
67
+ that.print_crumbtrail();
68
+ that.print_controls();
69
+ that.autosize();
70
+ },
71
+
72
+ add_child_link_text: false,
73
+ child_block_header_text: false,
5
74
 
6
75
  print_content: function()
7
76
  {
@@ -13,30 +82,113 @@ var BlockModalController = DefaultBlockModalController.extend({
13
82
  {
14
83
  if (that.block.children.length > 0)
15
84
  {
16
- var complex_field_types = ['block', 'richtext', 'image', 'file'];
85
+ var separate_children = that.block.block_type.allow_child_blocks && that.block.block_type.default_child_block_type_id;
86
+ var separate_child_id = separate_children ? that.block.block_type.default_child_block_type_id : false;
87
+
17
88
  $.each(that.block.children, function(i, b) {
18
- var div_id = 'block_' + b.id + (complex_field_types.indexOf(b.block_type.field_type) == -1 ? '_value' : '');
89
+ if (separate_children && b.block_type.id == separate_child_id) return;
90
+ var div_id = 'block_' + b.id + (that.complex_field_types.indexOf(b.block_type.field_type) == -1 ? '_value' : '');
19
91
  div.append($('<div/>').css('margin-bottom', '10px').append($('<div/>').attr('id', div_id)));
20
92
  });
93
+ if (separate_children)
94
+ {
95
+ if (that.child_block_header_text) div.append($('<h2/>').append(that.child_block_header_text));
96
+ $.each(that.block.children, function(i, b) {
97
+ if (b.block_type.id == separate_child_id)
98
+ {
99
+ var div_id = 'block_' + b.id + (that.complex_field_types.indexOf(b.block_type.field_type) == -1 ? '_value' : '');
100
+ div.append($('<div/>').css('margin-bottom', '10px').append($('<div/>').attr('id', div_id)));
101
+ }
102
+ });
103
+ }
21
104
  }
22
105
  else
23
106
  {
24
107
  div.append($('<p/>').append("This block doesn't have any content yet."));
25
108
  }
26
109
  if (that.block.block_type.allow_child_blocks)
27
- {
28
- div.append($('<p/>').css('clear', 'both').append($('<a/>').attr('href', '#').html("Add a child block!").click(function(e) {
110
+ {
111
+ div.append($('<p/>').css('clear', 'both').append($('<a/>').attr('href', '#').html(that.add_child_link_text ? that.add_child_link_text : "Add a child block!").click(function(e) {
29
112
  e.preventDefault();
30
113
  that.add_block();
31
- })));
114
+ })));
32
115
  }
33
116
  }
34
117
  $('#modal_content').replaceWith(div);
35
- that.render_blocks();
36
- that.set_editable();
118
+ that.render_blocks();
37
119
  that.autosize();
38
120
  },
121
+
122
+ print_controls: function()
123
+ {
124
+ var that = this;
125
+ var p = $('<p/>').css('clear', 'both')
126
+ .append($('<input/>').attr('type', 'button').addClass('btn').val('Close').click(function() { that.close(); that.parent_controller.render_blocks(); })).append(' ');
127
+ if (!that.block.name)
128
+ {
129
+ p.append($('<input/>').attr('type', 'button').addClass('btn').val('Delete Block').click(function() { that.delete_block(); })).append(' ');
130
+ }
131
+ p.append($('<input/>').attr('type', 'button').addClass('btn').val('Move Up' ).click(function() { that.move_up(); })).append(' ');
132
+ p.append($('<input/>').attr('type', 'button').addClass('btn').val('Move Down' ).click(function() { that.move_down(); })).append(' ');
133
+ p.append($('<input/>').attr('type', 'button').addClass('btn').val('Advanced' ).attr('id', 'btn_advanced').click(function() { that.print_advanced(); }));
134
+ $('#modal_controls').empty().append(p);
135
+ },
136
+
137
+ before_crumbtrail_click: false,
138
+ print_crumbtrail: function()
139
+ {
140
+ var that = this;
141
+ var crumbs = $('<h2/>').css('margin-top', '0').css('padding-top', '0');
142
+ $.each(that.block.crumbtrail, function(i, h) {
143
+ if (i > 0) crumbs.append(' > ');
144
+ crumbs.append($('<a/>').attr('href', '#').html(h['text']).data('block_id', h['block_id']).click(function(e) {
145
+ e.preventDefault();
146
+ if (that.before_crumbtrail_click) that.before_crumbtrail_click();
147
+ that.parent_controller.edit_block(parseInt($(this).data('block_id')));
148
+ }));
149
+ });
150
+ $('#modal_crumbtrail').empty().append(crumbs);
151
+ },
152
+
153
+ before_print_advanced: false,
154
+ print_advanced: function()
155
+ {
156
+ var that = this;
157
+ if (that.before_print_advanced) that.before_print_advanced();
39
158
 
159
+ var b = that.block;
160
+ $('#modal_content').empty()
161
+ .append($('<p/>').append($('<div/>').attr('id', 'block_' + b.id + '_block_type_id' )))
162
+ .append($('<p/>').append($('<div/>').attr('id', 'block_' + b.id + '_parent_id' )))
163
+ .append($('<p/>').append($('<div/>').attr('id', 'block_' + b.id + '_constrain' )))
164
+ .append($('<p/>').append($('<div/>').attr('id', 'block_' + b.id + '_full_width' )))
165
+ $('#modal_controls').empty()
166
+ .append($('<p/>')
167
+ .append($('<input/>').attr('type', 'button').addClass('btn').val('Close').click(function() {
168
+ that.close();
169
+ that.parent_controller.render_blocks();
170
+ })).append(' ')
171
+ .append($('<input/>').attr('type', 'button').addClass('btn').val('Back' ).click(function() {
172
+ that.print_content();
173
+ that.print_controls();
174
+ }))
175
+ );
176
+
177
+ var m = new ModelBinder({
178
+ name: 'Block',
179
+ id: b.id,
180
+ update_url: that.block_url(b),
181
+ authenticity_token: that.authenticity_token,
182
+ attributes: [
183
+ { name: 'block_type_id' , nice_name: 'Block type' , type: 'select' , value: b.block_type.id , text: b.block_type.name , width: 400, fixed_placeholder: true, options_url: '/admin/block-types/options' , after_update: function() { that.parent_controller.render_blocks(); that.block.block_type.id = this.value; }, after_cancel: function() { that.parent_controller.render_blocks(); }, on_load: function() { that.modal.autosize(); }},
184
+ { name: 'parent_id' , nice_name: 'Parent ID' , type: 'select' , value: b.parent_id , text: b.parent ? b.parent.title : '' , width: 400, fixed_placeholder: true, options_url: '/admin/pages/' + that.page_id + '/block-options' , after_update: function() { that.parent_controller.render_blocks(); that.block.parent_id = this.value; }, after_cancel: function() { that.parent_controller.render_blocks(); }, on_load: function() { that.modal.autosize(); }},
185
+ { name: 'constrain' , nice_name: 'Constrain' , type: 'checkbox' , value: b.constrain ? 1 : 0 , width: 400, fixed_placeholder: true, after_update: function() { that.parent_controller.render_blocks(); that.block.constrain = this.value; }, after_cancel: function() { that.parent_controller.render_blocks(); }, on_load: function() { that.modal.autosize(); }},
186
+ { name: 'full_width' , nice_name: 'Full Width' , type: 'checkbox' , value: b.full_width ? 1 : 0 , width: 400, fixed_placeholder: true, after_update: function() { that.parent_controller.render_blocks(); that.block.full_width = this.value; }, after_cancel: function() { that.parent_controller.render_blocks(); }, on_load: function() { that.modal.autosize(); }}
187
+ ]
188
+ });
189
+ that.autosize();
190
+ },
191
+
40
192
  /*****************************************************************************
41
193
  Block Rendering
42
194
  *****************************************************************************/
@@ -47,85 +199,47 @@ var BlockModalController = DefaultBlockModalController.extend({
47
199
  if (that.block.block_type.field_type != 'block' && that.block.children.length == 0)
48
200
  return;
49
201
 
50
- $.each(that.block.children, function(i, b) {
51
- var ft = b.block_type.field_type;
52
- if (ft == 'block' || ft == 'richtext' || ft == 'image' || ft == 'file')
53
- {
54
- if (!b.rendered_value)
55
- {
56
- $.ajax({
57
- block_id: b.id, // Used in the success function
58
- url: that.block_url(b) + '/render',
59
- type: 'get',
60
- success: function(html) {
61
- $('#the_modal #block_' + this.block_id).replaceWith(html);
62
-
63
- var b2 = that.block_with_id(this.block_id);
64
- b2.rendered_value = html;
65
- that.set_clickable(b2);
66
- that.autosize();
67
- },
68
- });
69
- }
70
- else
71
- $('#the_modal #block_' + b.id).replaceWith(b.rendered_value);
72
- }
73
- });
202
+ $.each(that.block.children, function(i, b) { that.render_block(b); });
74
203
  },
75
204
 
76
- /****************************************************************************/
77
-
78
- set_clickable: function(b)
79
- {
80
- var that = this;
81
-
82
- if (!b)
205
+ render_block: function(b)
206
+ {
207
+ var that = this;
208
+ if (that.complex_field_types.indexOf(b.block_type.field_type) > -1)
83
209
  {
84
- $.each(that.block.children, function(i,b) {
85
- that.set_clickable(b);
86
- });
210
+ if (!b.rendered_value)
211
+ {
212
+ $.ajax({
213
+ block_id: b.id, // Used in the success function
214
+ url: that.block_url(b) + '/render',
215
+ type: 'get',
216
+ success: function(html) {
217
+ $('#the_modal #block_' + this.block_id).replaceWith(html);
218
+
219
+ var b2 = that.block_with_id(this.block_id);
220
+ b2.rendered_value = html;
221
+ that.set_clickable(b2);
222
+ that.autosize();
223
+ },
224
+ });
225
+ }
226
+ else
227
+ $('#the_modal #block_' + b.id).replaceWith(b.rendered_value);
87
228
  }
88
-
89
- $('#the_modal #block_' + b.id).attr('onclick','').unbind('click');
90
- $('#the_modal #block_' + b.id).click(function(e) {
91
- e.stopPropagation();
92
- that.parent_controller.edit_block(b.id);
93
- });
94
- //if (b.allow_child_blocks == true)
95
- //{
96
- // $('#new_block_' + b.id).replaceWith($('<input/>')
97
- // .attr('type', 'button')
98
- // .val('New Block')
99
- // .click(function(e) { e.stopPropagation(); that.new_block(b.id);
100
- // })
101
- // );
102
- //}
103
- var show_mouseover = true;
104
- if (b.children && b.children.length > 0)
105
- {
106
- $.each(b.children, function(i, b2) {
107
- if (b2.block_type.id = 34)
108
- show_mouseover = false;
109
- that.set_clickable(b2);
110
- });
111
- }
112
- if (show_mouseover)
113
- {
114
- $('#the_modal #block_' + b.id).mouseover(function(el) { $('#the_modal #block_' + b.id).addClass( 'block_over'); });
115
- $('#the_modal #block_' + b.id).mouseout(function(el) { $('#the_modal #block_' + b.id).removeClass('block_over'); });
116
- }
229
+ else
230
+ that.set_block_value_editable(b);
117
231
  },
118
-
232
+
119
233
  /****************************************************************************/
120
234
 
121
- set_editable: function()
122
- {
123
- var that = this;
124
- that.set_block_value_editable(that.block);
125
- $.each(that.block.children, function(i, b) {
126
- that.set_block_value_editable(b);
127
- });
128
- },
235
+ //set_editable: function()
236
+ //{
237
+ // var that = this;
238
+ // that.set_block_value_editable(that.block);
239
+ // $.each(that.block.children, function(i, b) {
240
+ // that.set_block_value_editable(b);
241
+ // });
242
+ //},
129
243
 
130
244
  set_block_value_editable: function(b)
131
245
  {
@@ -166,7 +280,50 @@ var BlockModalController = DefaultBlockModalController.extend({
166
280
  });
167
281
  },
168
282
 
169
- /****************************************************************************/
283
+ set_clickable: function(b)
284
+ {
285
+ var that = this;
286
+
287
+ if (!b)
288
+ {
289
+ $.each(that.block.children, function(i,b) {
290
+ that.set_clickable(b);
291
+ });
292
+ }
293
+
294
+ $('#the_modal #block_' + b.id).attr('onclick','').unbind('click');
295
+ $('#the_modal #block_' + b.id).click(function(e) {
296
+ e.stopPropagation();
297
+ that.parent_controller.edit_block(b.id);
298
+ });
299
+ //if (b.allow_child_blocks == true)
300
+ //{
301
+ // $('#new_block_' + b.id).replaceWith($('<input/>')
302
+ // .attr('type', 'button')
303
+ // .val('New Block')
304
+ // .click(function(e) { e.stopPropagation(); that.new_block(b.id);
305
+ // })
306
+ // );
307
+ //}
308
+ var show_mouseover = true;
309
+ if (b.children && b.children.length > 0)
310
+ {
311
+ $.each(b.children, function(i, b2) {
312
+ if (b2.block_type.id = 34)
313
+ show_mouseover = false;
314
+ that.set_clickable(b2);
315
+ });
316
+ }
317
+ if (show_mouseover)
318
+ {
319
+ $('#the_modal #block_' + b.id).mouseover(function(el) { $('#the_modal #block_' + b.id).addClass( 'block_over'); });
320
+ $('#the_modal #block_' + b.id).mouseout(function(el) { $('#the_modal #block_' + b.id).removeClass('block_over'); });
321
+ }
322
+ },
323
+
324
+ /*****************************************************************************
325
+ CRUD
326
+ *****************************************************************************/
170
327
 
171
328
  add_block: function(block_type_id)
172
329
  {
@@ -255,4 +412,124 @@ var BlockModalController = DefaultBlockModalController.extend({
255
412
  });
256
413
  },
257
414
 
415
+ delete_block: function(confirm)
416
+ {
417
+ var that = this;
418
+ if (!confirm)
419
+ {
420
+ var p = $('<p/>').addClass('note warning')
421
+ .append("Are you sure you want to delete the block? This can't be undone.<br />")
422
+ .append($('<input/>').attr('type','button').val('Yes').click(function() { that.delete_block(true); })).append(' ')
423
+ .append($('<input/>').attr('type','button').val('No').click(function() { $('#modal_message').empty(); that.autosize();
424
+ }));
425
+ that.autosize(p);
426
+ return;
427
+ }
428
+ that.autosize("<p class='loading'>Deleting block...</p>");
429
+ $.ajax({
430
+ url: that.block_url(that.block),
431
+ type: 'delete',
432
+ success: function(resp) {
433
+ if (resp.error) that.autosize("<p class='note error'>" + resp.error + "</p>");
434
+ if (resp.redirect)
435
+ {
436
+ that.close();
437
+ that.parent_controller.render_blocks();
438
+ }
439
+ }
440
+ });
441
+ },
442
+
443
+ move_up: function()
444
+ {
445
+ var that = this;
446
+ that.autosize("<p class='loading'>Moving up...</p>");
447
+ $.ajax({
448
+ url: that.block_url(that.block) + '/move-up',
449
+ type: 'put',
450
+ success: function(resp) {
451
+ if (resp.error) that.autosize("<p class='note error'>" + resp.error + "</p>");
452
+ if (resp.success)
453
+ {
454
+ that.autosize("<p class='note success'>" + resp.success + "</p>");
455
+ that.parent_controller.render_blocks();
456
+ }
457
+ }
458
+ });
459
+ },
460
+
461
+ move_down: function()
462
+ {
463
+ var that = this;
464
+ that.autosize("<p class='loading'>Moving down...</p>");
465
+ $.ajax({
466
+ url: that.block_url(that.block) + '/move-down',
467
+ type: 'put',
468
+ success: function(resp) {
469
+ if (resp.error) that.autosize("<p class='note error'>" + resp.error + "</p>");
470
+ if (resp.success)
471
+ {
472
+ that.autosize("<p class='note success'>" + resp.success + "</p>");
473
+ that.parent_controller.render_blocks();
474
+ }
475
+ }
476
+ });
477
+ },
478
+
479
+ /*****************************************************************************
480
+ Helper methods
481
+ *****************************************************************************/
482
+
483
+ block_with_id: function(block_id, b)
484
+ {
485
+ var that = this;
486
+ if (!b) b = that.block;
487
+ if (b.id == block_id) return b;
488
+
489
+ var the_block = false;
490
+ $.each(b.children, function(i, b2) {
491
+ the_block = that.block_with_id(block_id, b2);
492
+ if (the_block)
493
+ return false;
494
+ });
495
+ return the_block;
496
+ },
497
+
498
+ base_url: function(b)
499
+ {
500
+ var that = this;
501
+ if (!b) b = that.block;
502
+ return '/admin/' + (b.page_id ? 'pages/' + b.page_id : 'posts/' + b.post_id) + '/blocks';
503
+ },
504
+
505
+ block_url: function(b)
506
+ {
507
+ var that = this;
508
+ if (!b) b = that.block;
509
+ return this.base_url(b) + '/' + b.id;
510
+ },
511
+
512
+ child_block: function(name, b)
513
+ {
514
+ var that = this;
515
+ if (!b) b = that.block;
516
+ var the_block = false;
517
+ $.each(b.children, function(i, b2) {
518
+ if (b2.name == name)
519
+ {
520
+ the_block = b2;
521
+ return false;
522
+ }
523
+ });
524
+ return the_block;
525
+ },
526
+
527
+ child_block_value: function(name, b)
528
+ {
529
+ var that = this;
530
+ var b2 = that.child_block(name, b);
531
+ if (!b2) return false;
532
+ return b2.value;
533
+ },
534
+
258
535
  });
@@ -1,5 +1,5 @@
1
1
 
2
- var ButtonModalController = DefaultBlockModalController.extend({
2
+ var ButtonModalController = BlockModalController.extend({
3
3
 
4
4
  print: function()
5
5
  {
@@ -1,5 +1,5 @@
1
1
 
2
- var MediaModalController = DefaultBlockModalController.extend({
2
+ var MediaModalController = BlockModalController.extend({
3
3
 
4
4
  media_id: false,
5
5
  top_cat_id: false,
@@ -1,5 +1,5 @@
1
1
 
2
- var RichtextModalController = DefaultBlockModalController.extend({
2
+ var RichtextModalController = BlockModalController.extend({
3
3
 
4
4
  tinymce_initialized: false,
5
5
  modal_width: 820,
@@ -1,6 +1,8 @@
1
1
  module Caboose
2
2
  class AssetManifest
3
3
 
4
+ #@@bucket = nil
5
+ #
4
6
  #def AssetManifest.bucket
5
7
  # if @@bucket.nil?
6
8
  # config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
@@ -19,9 +21,17 @@ module Caboose
19
21
  # return { :error => "Can't write to file." } if !file.write(str)
20
22
  #
21
23
  # # Compile the file
22
- # str_compiled = Uglifier.compile(str)
24
+ # str_compiled = ''
25
+ # begin
26
+ # str_compiled = Uglifier.compile(str)
27
+ # rescue Exception => e
28
+ # return { :error => e.message }
29
+ # end
23
30
  #
24
- # # Compute the digest for the compiled file
31
+ # # Compute the digest for the compiled file
32
+ # # Note: digest must be generated with environment set to 'production' (sprockets changes digests per environment)
33
+ # digest = Rails.application.assets.file_digest('/Users/william/Sites/caboosecms.com/sites/benttree/images/icons/loading.gif')
34
+ # digest = Rails.application.assets.digest.hexdigest(str_compiled)
25
35
  # digest = Digest::SHA2.hexdigest(str_compiled)
26
36
  #
27
37
  # # See if the digest file for the compiled file exists
@@ -33,17 +43,23 @@ module Caboose
33
43
  #
34
44
  # # See if the digest is in the manifest
35
45
  # manifest = self.bucket.objects['assets/manifest.yml']
36
- # changed = false
46
+ # exists = false
47
+ # changed = false
37
48
  # new_lines = []
38
49
  # manifest.read.split("\n").each do|line|
39
- # if line.starts_with?("#{path}: ") && line != "#{path}: #{digest_path}"
50
+ # if line.starts_with?("#{path}: ")
51
+ # exists = true
52
+ # changed = true if line != "#{path}: #{digest_path}"
40
53
  # new_lines << "#{path}: #{digest_path}"
41
- # changed = true
42
54
  # else
43
55
  # new_lines << line
44
56
  # end
45
57
  # end
46
- #
58
+ # if !exists
59
+ # new_lines << "#{path}: #{digest_path}"
60
+ # changed = true
61
+ # end
62
+ #
47
63
  # # If the digest has changed, update the manifest and set the app asset digests
48
64
  # if changed
49
65
  # manifest.write(new_lines.join("\n"))
@@ -196,7 +196,7 @@ function update_card()
196
196
  type: 'put',
197
197
  data: { token: resp.id, card: resp.card },
198
198
  success: function(resp2) {
199
- if (resp2.error) $('#payment_message').html("<p class='note error'>" + resp2.error + "</p>");
199
+ if (resp2.error) $('#message').html("<p class='note error'>" + resp2.error + "</p>");
200
200
  if (resp2.success) window.location.reload(true);
201
201
  }
202
202
  });
@@ -62,7 +62,6 @@
62
62
  <%= javascript_include_tag 'caboose/admin_page_edit_content' %>
63
63
  <%= javascript_include_tag "caboose/class" %>
64
64
  <%= javascript_include_tag "caboose/modal_controller" %>
65
- <%= javascript_include_tag "caboose/block_modal_controllers/default_block_modal_controller" %>
66
65
  <%= javascript_include_tag "caboose/block_modal_controllers/block_modal_controller" %>
67
66
  <%= javascript_include_tag "caboose/block_modal_controllers/media_modal_controller" %>
68
67
  <%= javascript_include_tag "caboose/block_modal_controllers/richtext_modal_controller" %>
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.8.54'
2
+ VERSION = '0.8.55'
3
3
  end
@@ -3,6 +3,38 @@ require 'aws-sdk'
3
3
 
4
4
  namespace :caboose do
5
5
 
6
+ desc "Save sample asset"
7
+ task :save_sample_asset => :environment do
8
+
9
+ #file = "benttree/images/icons/loading.gif"
10
+ #Digest::MD5.new.update("2.0.0.beta.13").update("")
11
+
12
+ #puts Rails.application.assets.find_asset(file).digest_path
13
+ #benttree/images/icons/loading.gif: benttree/images/icons/loading-ff6f6c33c614d972df49796e54c2bf53.gif
14
+
15
+ #a = Rails.application.assets.find_asset(file)
16
+ #puts a.inspect
17
+
18
+ file = "/Users/william/Sites/caboosecms.com/sites/benttree/images/icons/loading.gif"
19
+ str = File.read(file)
20
+
21
+ temp_file = Rails.root.join('tmp', Caboose.random_string(20))
22
+ File.write(temp_file, str)
23
+
24
+ #Digest::MD5.new.update("2.0.0.beta.13").update("")
25
+
26
+ #puts "ff6f6c33c614d972df49796e54c2bf53"
27
+ #puts "MD5: #{Digest::MD5.hexdigest(str)}"
28
+ #puts Rails.application.config.assets.digest.file('/Users/william/Sites/caboosecms.com/sites/benttree/images/icons/loading.gif')
29
+ #puts Rails.application.config.assets.stat('benttree/images/icons/loading.gif').inspect
30
+ puts Rails.application.assets.file_digest(file)
31
+ puts Rails.application.assets.file_digest(temp_file)
32
+ #puts Rails.application.config.assets.digests['benttree/images/icons/loading.gif']
33
+
34
+ #resp = Caboose::AssetManifest.save_asset('assets/william/test1.js', 'var x = 32;')
35
+ #puts resp
36
+ end
37
+
6
38
  desc "Refresh invoice transactions"
7
39
  task :refresh_invoice_transactions => :environment do
8
40
  inv = Caboose::Invoice.where(:status => 'pending').reorder("id desc").first
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.8.54
4
+ version: 0.8.55
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-26 00:00:00.000000000 Z
11
+ date: 2016-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -527,7 +527,6 @@ files:
527
527
  - app/assets/javascripts/caboose/block_media_controller.js
528
528
  - app/assets/javascripts/caboose/block_modal_controllers/block_modal_controller.js
529
529
  - app/assets/javascripts/caboose/block_modal_controllers/button_modal_controller.js
530
- - app/assets/javascripts/caboose/block_modal_controllers/default_block_modal_controller.js
531
530
  - app/assets/javascripts/caboose/block_modal_controllers/media_modal_controller.js
532
531
  - app/assets/javascripts/caboose/block_modal_controllers/richtext_modal_controller.js
533
532
  - app/assets/javascripts/caboose/card.js
@@ -1,237 +0,0 @@
1
-
2
- var DefaultBlockModalController = ModalController.extend({
3
-
4
- page_id: false,
5
- block_id: false,
6
- block: false,
7
- block_types: false,
8
- authenticity_token: false,
9
- new_block_on_init: false,
10
- assets_path: false,
11
-
12
- init: function(params)
13
- {
14
- var that = this;
15
- for (var i in params)
16
- that[i] = params[i];
17
- that.include_assets();
18
- if (that.new_block_on_init == true)
19
- that.refresh_block(function() { that.add_block(); });
20
- else
21
- that.print();
22
- },
23
-
24
- refresh: function(callback)
25
- {
26
- var that = this;
27
- that.refresh_block(function() {
28
- if (callback) callback();
29
- });
30
- },
31
-
32
- refresh_block: function(callback)
33
- {
34
- var that = this
35
- $.ajax({
36
- url: '/admin/pages/' + that.page_id + '/blocks/' + that.block_id + '/tree',
37
- type: 'get',
38
- success: function(arr) {
39
- that.block = arr[0];
40
- if (callback) callback();
41
- }
42
- });
43
- },
44
-
45
- /*****************************************************************************
46
- Printing
47
- *****************************************************************************/
48
-
49
- print: function()
50
- {
51
- var that = this;
52
- if (!that.block)
53
- {
54
- var div = $('<div/>')
55
- .append($('<div/>').attr('id', 'modal_crumbtrail' ))
56
- .append($('<div/>').attr('id', 'modal_content' ))
57
- .append($('<div/>').attr('id', 'modal_message' ))
58
- .append($('<div/>').attr('id', 'modal_controls' ));
59
- that.modal(div, 800);
60
- that.refresh(function() { that.print(); });
61
- return;
62
- }
63
-
64
- that.print_content();
65
- that.print_crumbtrail();
66
- that.print_controls();
67
- that.autosize();
68
- },
69
-
70
- print_content: function() {},
71
-
72
- print_controls: function()
73
- {
74
- var that = this;
75
- var p = $('<p/>').css('clear', 'both')
76
- .append($('<input/>').attr('type', 'button').addClass('btn').val('Close').click(function() { that.close(); that.parent_controller.render_blocks(); })).append(' ');
77
- if (!that.block.name)
78
- {
79
- p.append($('<input/>').attr('type', 'button').addClass('btn').val('Delete Block').click(function() { that.delete_block(); })).append(' ');
80
- }
81
- p.append($('<input/>').attr('type', 'button').addClass('btn').val('Move Up' ).click(function() { that.move_up(); })).append(' ');
82
- p.append($('<input/>').attr('type', 'button').addClass('btn').val('Move Down' ).click(function() { that.move_down(); })).append(' ');
83
- p.append($('<input/>').attr('type', 'button').addClass('btn').val('Advanced' ).attr('id', 'btn_advanced').click(function() { that.print_advanced(); }));
84
- $('#modal_controls').empty().append(p);
85
- },
86
-
87
- before_crumbtrail_click: false,
88
- print_crumbtrail: function()
89
- {
90
- var that = this;
91
- var crumbs = $('<h2/>').css('margin-top', '0').css('padding-top', '0');
92
- $.each(that.block.crumbtrail, function(i, h) {
93
- if (i > 0) crumbs.append(' > ');
94
- crumbs.append($('<a/>').attr('href', '#').html(h['text']).data('block_id', h['block_id']).click(function(e) {
95
- e.preventDefault();
96
- if (that.before_crumbtrail_click) that.before_crumbtrail_click();
97
- that.parent_controller.edit_block(parseInt($(this).data('block_id')));
98
- }));
99
- });
100
- $('#modal_crumbtrail').empty().append(crumbs);
101
- },
102
-
103
- before_print_advanced: false,
104
- print_advanced: function()
105
- {
106
- var that = this;
107
- if (that.before_print_advanced) that.before_print_advanced();
108
-
109
- var b = that.block;
110
- $('#modal_content').empty()
111
- .append($('<p/>').append($('<div/>').attr('id', 'block_' + b.id + '_block_type_id' )))
112
- .append($('<p/>').append($('<div/>').attr('id', 'block_' + b.id + '_parent_id' )))
113
- .append($('<p/>').append($('<div/>').attr('id', 'block_' + b.id + '_constrain' )))
114
- .append($('<p/>').append($('<div/>').attr('id', 'block_' + b.id + '_full_width' )))
115
- $('#modal_controls').empty()
116
- .append($('<p/>')
117
- .append($('<input/>').attr('type', 'button').addClass('btn').val('Close').click(function() {
118
- that.close();
119
- that.parent_controller.render_blocks();
120
- })).append(' ')
121
- .append($('<input/>').attr('type', 'button').addClass('btn').val('Back' ).click(function() {
122
- that.print_content();
123
- that.print_controls();
124
- }))
125
- );
126
-
127
- var m = new ModelBinder({
128
- name: 'Block',
129
- id: b.id,
130
- update_url: that.block_url(b),
131
- authenticity_token: that.authenticity_token,
132
- attributes: [
133
- { name: 'block_type_id' , nice_name: 'Block type' , type: 'select' , value: b.block_type.id , text: b.block_type.name , width: 400, fixed_placeholder: true, options_url: '/admin/block-types/options' , after_update: function() { that.parent_controller.render_blocks(); that.block.block_type.id = this.value; }, after_cancel: function() { that.parent_controller.render_blocks(); }, on_load: function() { that.modal.autosize(); }},
134
- { name: 'parent_id' , nice_name: 'Parent ID' , type: 'select' , value: b.parent_id , text: b.parent ? b.parent.title : '' , width: 400, fixed_placeholder: true, options_url: '/admin/pages/' + that.page_id + '/block-options' , after_update: function() { that.parent_controller.render_blocks(); that.block.parent_id = this.value; }, after_cancel: function() { that.parent_controller.render_blocks(); }, on_load: function() { that.modal.autosize(); }},
135
- { name: 'constrain' , nice_name: 'Constrain' , type: 'checkbox' , value: b.constrain ? 1 : 0 , width: 400, fixed_placeholder: true, after_update: function() { that.parent_controller.render_blocks(); that.block.constrain = this.value; }, after_cancel: function() { that.parent_controller.render_blocks(); }, on_load: function() { that.modal.autosize(); }},
136
- { name: 'full_width' , nice_name: 'Full Width' , type: 'checkbox' , value: b.full_width ? 1 : 0 , width: 400, fixed_placeholder: true, after_update: function() { that.parent_controller.render_blocks(); that.block.full_width = this.value; }, after_cancel: function() { that.parent_controller.render_blocks(); }, on_load: function() { that.modal.autosize(); }}
137
- ]
138
- });
139
- that.autosize();
140
- },
141
-
142
- /****************************************************************************/
143
-
144
- delete_block: function(confirm)
145
- {
146
- var that = this;
147
- if (!confirm)
148
- {
149
- var p = $('<p/>').addClass('note warning')
150
- .append("Are you sure you want to delete the block? This can't be undone.<br />")
151
- .append($('<input/>').attr('type','button').val('Yes').click(function() { that.delete_block(true); })).append(' ')
152
- .append($('<input/>').attr('type','button').val('No').click(function() { $('#modal_message').empty(); that.autosize();
153
- }));
154
- that.autosize(p);
155
- return;
156
- }
157
- that.autosize("<p class='loading'>Deleting block...</p>");
158
- $.ajax({
159
- url: that.block_url(that.block),
160
- type: 'delete',
161
- success: function(resp) {
162
- if (resp.error) that.autosize("<p class='note error'>" + resp.error + "</p>");
163
- if (resp.redirect)
164
- {
165
- that.close();
166
- that.parent_controller.render_blocks();
167
- }
168
- }
169
- });
170
- },
171
-
172
- move_up: function()
173
- {
174
- var that = this;
175
- that.autosize("<p class='loading'>Moving up...</p>");
176
- $.ajax({
177
- url: that.block_url(that.block) + '/move-up',
178
- type: 'put',
179
- success: function(resp) {
180
- if (resp.error) that.autosize("<p class='note error'>" + resp.error + "</p>");
181
- if (resp.success)
182
- {
183
- that.autosize("<p class='note success'>" + resp.success + "</p>");
184
- that.parent_controller.render_blocks();
185
- }
186
- }
187
- });
188
- },
189
-
190
- move_down: function()
191
- {
192
- var that = this;
193
- that.autosize("<p class='loading'>Moving down...</p>");
194
- $.ajax({
195
- url: that.block_url(that.block) + '/move-down',
196
- type: 'put',
197
- success: function(resp) {
198
- if (resp.error) that.autosize("<p class='note error'>" + resp.error + "</p>");
199
- if (resp.success)
200
- {
201
- that.autosize("<p class='note success'>" + resp.success + "</p>");
202
- that.parent_controller.render_blocks();
203
- }
204
- }
205
- });
206
- },
207
-
208
- block_with_id: function(block_id, b)
209
- {
210
- var that = this;
211
- if (!b) b = that.block;
212
- if (b.id == block_id) return b;
213
-
214
- var the_block = false;
215
- $.each(b.children, function(i, b2) {
216
- the_block = that.block_with_id(block_id, b2);
217
- if (the_block)
218
- return false;
219
- });
220
- return the_block;
221
- },
222
-
223
- base_url: function(b)
224
- {
225
- var that = this;
226
- if (!b) b = that.block;
227
- return '/admin/' + (b.page_id ? 'pages/' + b.page_id : 'posts/' + b.post_id) + '/blocks';
228
- },
229
-
230
- block_url: function(b)
231
- {
232
- var that = this;
233
- if (!b) b = that.block;
234
- return this.base_url(b) + '/' + b.id;
235
- },
236
-
237
- });