spontaneous 0.2.0.beta4 → 0.2.0.beta5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +39 -0
  3. data/Gemfile +11 -6
  4. data/Readme.markdown +136 -69
  5. data/application/css/core.css.scss +27 -7
  6. data/application/css/editing.css.scss +4 -26
  7. data/application/css/schema_error.css.scss +22 -0
  8. data/application/js/content.js +11 -3
  9. data/application/js/edit_panel.js +1 -4
  10. data/application/js/field/file.js +17 -0
  11. data/application/js/field/image.js +30 -21
  12. data/application/js/field/string.js +4 -1
  13. data/application/js/field_preview.js +21 -16
  14. data/application/js/publish.js +6 -6
  15. data/application/js/types.js +5 -13
  16. data/application/js/views.js +2 -2
  17. data/application/js/views/box_view.js +3 -2
  18. data/application/js/views/page_piece_view.js +1 -1
  19. data/application/js/views/piece_view.js +1 -1
  20. data/application/views/schema_modification_error.html.erb +13 -3
  21. data/db/migrations/20131104101935_site_must_publish_all.rb +14 -0
  22. data/lib/spontaneous.rb +0 -1
  23. data/lib/spontaneous/box_style.rb +15 -9
  24. data/lib/spontaneous/capistrano/deploy.rb +13 -1
  25. data/lib/spontaneous/change.rb +11 -13
  26. data/lib/spontaneous/cli.rb +5 -2
  27. data/lib/spontaneous/cli/assets.rb +7 -1
  28. data/lib/spontaneous/cli/console.rb +7 -1
  29. data/lib/spontaneous/cli/content.rb +35 -0
  30. data/lib/spontaneous/cli/fields.rb +3 -2
  31. data/lib/spontaneous/cli/generate.rb +5 -2
  32. data/lib/spontaneous/cli/server.rb +12 -8
  33. data/lib/spontaneous/cli/site.rb +12 -12
  34. data/lib/spontaneous/cli/user.rb +28 -14
  35. data/lib/spontaneous/collections/box_set.rb +4 -4
  36. data/lib/spontaneous/collections/field_set.rb +4 -4
  37. data/lib/spontaneous/collections/prototype_set.rb +12 -4
  38. data/lib/spontaneous/data_mapper.rb +11 -7
  39. data/lib/spontaneous/data_mapper/content_model.rb +8 -0
  40. data/lib/spontaneous/data_mapper/content_model/associations.rb +1 -1
  41. data/lib/spontaneous/data_mapper/dataset.rb +14 -2
  42. data/lib/spontaneous/data_mapper/scope.rb +33 -13
  43. data/lib/spontaneous/facet.rb +4 -0
  44. data/lib/spontaneous/field.rb +12 -12
  45. data/lib/spontaneous/field/base.rb +27 -22
  46. data/lib/spontaneous/field/boolean.rb +4 -4
  47. data/lib/spontaneous/field/date.rb +2 -2
  48. data/lib/spontaneous/field/file.rb +24 -18
  49. data/lib/spontaneous/field/html.rb +1 -1
  50. data/lib/spontaneous/field/image.rb +6 -19
  51. data/lib/spontaneous/field/location.rb +1 -1
  52. data/lib/spontaneous/field/long_string.rb +3 -3
  53. data/lib/spontaneous/field/markdown.rb +3 -3
  54. data/lib/spontaneous/field/select.rb +2 -2
  55. data/lib/spontaneous/field/string.rb +2 -2
  56. data/lib/spontaneous/field/tags.rb +2 -2
  57. data/lib/spontaneous/field/update.rb +21 -20
  58. data/lib/spontaneous/field/webvideo.rb +6 -6
  59. data/lib/spontaneous/field/webvideo/fallback.rb +2 -2
  60. data/lib/spontaneous/field/webvideo/vimeo.rb +7 -7
  61. data/lib/spontaneous/generators/site.rb +2 -2
  62. data/lib/spontaneous/generators/site/Gemfile.tt +5 -1
  63. data/lib/spontaneous/layout.rb +2 -2
  64. data/lib/spontaneous/media.rb +1 -0
  65. data/lib/spontaneous/media/file.rb +6 -5
  66. data/lib/spontaneous/media/image/attributes.rb +4 -0
  67. data/lib/spontaneous/media/image/renderable.rb +4 -4
  68. data/lib/spontaneous/media/store.rb +22 -0
  69. data/lib/spontaneous/{storage → media/store}/backend.rb +1 -1
  70. data/lib/spontaneous/{storage → media/store}/cloud.rb +1 -1
  71. data/lib/spontaneous/{storage → media/store}/local.rb +1 -1
  72. data/lib/spontaneous/media/temp_file.rb +1 -1
  73. data/lib/spontaneous/model.rb +10 -7
  74. data/lib/spontaneous/model/action.rb +7 -0
  75. data/lib/spontaneous/model/action/clean.rb +87 -0
  76. data/lib/spontaneous/model/box/allowed_types.rb +15 -1
  77. data/lib/spontaneous/model/core.rb +10 -0
  78. data/lib/spontaneous/model/core/aliases.rb +1 -1
  79. data/lib/spontaneous/model/core/content_groups.rb +1 -1
  80. data/lib/spontaneous/model/core/fields.rb +1 -1
  81. data/lib/spontaneous/model/core/modifications.rb +2 -2
  82. data/lib/spontaneous/model/core/page_search.rb +4 -0
  83. data/lib/spontaneous/model/core/publishing.rb +4 -17
  84. data/lib/spontaneous/model/core/render.rb +4 -4
  85. data/lib/spontaneous/model/core/styles.rb +2 -2
  86. data/lib/spontaneous/model/core/visibility.rb +6 -2
  87. data/lib/spontaneous/model/page.rb +6 -2
  88. data/lib/spontaneous/model/page/controllers.rb +55 -17
  89. data/lib/spontaneous/model/page/formats.rb +12 -7
  90. data/lib/spontaneous/model/page/layouts.rb +2 -2
  91. data/lib/spontaneous/model/page/locks.rb +4 -1
  92. data/lib/spontaneous/model/page/page_tree.rb +40 -6
  93. data/lib/spontaneous/output.rb +14 -52
  94. data/lib/spontaneous/output/context.rb +11 -39
  95. data/lib/spontaneous/output/context/navigation.rb +31 -0
  96. data/lib/spontaneous/output/format.rb +15 -19
  97. data/lib/spontaneous/output/renderable.rb +99 -0
  98. data/lib/spontaneous/output/store.rb +24 -0
  99. data/lib/spontaneous/output/store/backend.rb +52 -0
  100. data/lib/spontaneous/output/store/file.rb +77 -0
  101. data/lib/spontaneous/output/store/moneta.rb +117 -0
  102. data/lib/spontaneous/output/store/revision.rb +34 -0
  103. data/lib/spontaneous/output/store/store.rb +15 -0
  104. data/lib/spontaneous/output/store/transaction.rb +44 -0
  105. data/lib/spontaneous/output/template/engine.rb +17 -7
  106. data/lib/spontaneous/output/template/renderer.rb +66 -40
  107. data/lib/spontaneous/page_lock.rb +5 -7
  108. data/lib/spontaneous/page_piece.rb +2 -2
  109. data/lib/spontaneous/permissions/user.rb +14 -7
  110. data/lib/spontaneous/plugins/application/features.rb +8 -4
  111. data/lib/spontaneous/plugins/application/state.rb +12 -6
  112. data/lib/spontaneous/prototypes/box_prototype.rb +9 -10
  113. data/lib/spontaneous/prototypes/field_prototype.rb +66 -15
  114. data/lib/spontaneous/publishing/immediate.rb +30 -26
  115. data/lib/spontaneous/rack.rb +12 -7
  116. data/lib/spontaneous/rack/back.rb +43 -37
  117. data/lib/spontaneous/rack/back/base.rb +4 -4
  118. data/lib/spontaneous/rack/back/changes.rb +2 -2
  119. data/lib/spontaneous/rack/back/file.rb +16 -24
  120. data/lib/spontaneous/rack/back/map.rb +5 -5
  121. data/lib/spontaneous/rack/back/preview.rb +3 -4
  122. data/lib/spontaneous/rack/back/schema.rb +1 -1
  123. data/lib/spontaneous/rack/back/site.rb +6 -7
  124. data/lib/spontaneous/rack/front.rb +19 -16
  125. data/lib/spontaneous/rack/middleware/authenticate.rb +3 -3
  126. data/lib/spontaneous/rack/middleware/reloader.rb +3 -2
  127. data/lib/spontaneous/rack/middleware/scope.rb +25 -19
  128. data/lib/spontaneous/rack/page_controller.rb +164 -13
  129. data/lib/spontaneous/rack/public.rb +23 -62
  130. data/lib/spontaneous/rack/static.rb +2 -3
  131. data/lib/spontaneous/schema.rb +27 -8
  132. data/lib/spontaneous/schema/schema_modification.rb +9 -1
  133. data/lib/spontaneous/schema/uid.rb +2 -2
  134. data/lib/spontaneous/schema/uid_map.rb +3 -2
  135. data/lib/spontaneous/search/database.rb +2 -2
  136. data/lib/spontaneous/search/field.rb +5 -3
  137. data/lib/spontaneous/search/index.rb +12 -7
  138. data/lib/spontaneous/search/results.rb +5 -3
  139. data/lib/spontaneous/server.rb +2 -2
  140. data/lib/spontaneous/site.rb +10 -3
  141. data/lib/spontaneous/site/features.rb +26 -6
  142. data/lib/spontaneous/site/helpers.rb +9 -12
  143. data/lib/spontaneous/site/level.rb +7 -9
  144. data/lib/spontaneous/site/map.rb +9 -11
  145. data/lib/spontaneous/site/paths.rb +5 -5
  146. data/lib/spontaneous/site/publishing.rb +83 -80
  147. data/lib/spontaneous/site/schema.rb +1 -7
  148. data/lib/spontaneous/site/search.rb +8 -18
  149. data/lib/spontaneous/site/selectors.rb +60 -54
  150. data/lib/spontaneous/site/state.rb +36 -30
  151. data/lib/spontaneous/site/storage.rb +10 -16
  152. data/lib/spontaneous/state.rb +8 -0
  153. data/lib/spontaneous/style.rb +32 -33
  154. data/lib/spontaneous/version.rb +1 -1
  155. data/spontaneous.gemspec +22 -21
  156. data/test/fixtures/public/templates/layouts/default.html.cut +1 -1
  157. data/test/fixtures/public/templates/layouts/default.pdf.cut +1 -1
  158. data/test/fixtures/public/templates/layouts/default.rss.cut +1 -1
  159. data/test/fixtures/search/config/indexes.rb +1 -1
  160. data/test/fixtures/serialisation/class_hash.yaml.erb +13 -1
  161. data/test/fixtures/serialisation/root_hash.yaml.erb +10 -0
  162. data/test/functional/test_application.rb +20 -24
  163. data/test/functional/test_back.rb +26 -27
  164. data/test/functional/test_cli.rb +146 -0
  165. data/test/functional/test_front.rb +287 -216
  166. data/test/functional/test_user_manager.rb +1 -1
  167. data/test/test_helper.rb +15 -11
  168. data/test/unit/test_alias.rb +32 -25
  169. data/test/unit/test_asset_bundler.rb +1 -1
  170. data/test/unit/test_assets.rb +34 -33
  171. data/test/unit/test_authentication.rb +1 -1
  172. data/test/unit/test_boxes.rb +16 -2
  173. data/test/unit/test_changesets.rb +23 -11
  174. data/test/unit/test_content.rb +15 -0
  175. data/test/unit/test_context.rb +139 -0
  176. data/test/unit/test_controllers.rb +374 -0
  177. data/test/{experimental → unit}/test_crypt.rb +0 -0
  178. data/test/unit/test_datamapper.rb +260 -237
  179. data/test/unit/test_datamapper_content.rb +42 -12
  180. data/test/{experimental → unit}/test_features.rb +85 -3
  181. data/test/unit/test_fields.rb +117 -42
  182. data/test/unit/test_formats.rb +11 -1
  183. data/test/unit/test_generators.rb +2 -2
  184. data/test/unit/test_helpers.rb +7 -8
  185. data/test/unit/test_images.rb +39 -2
  186. data/test/unit/test_layouts.rb +14 -12
  187. data/test/unit/test_media.rb +32 -23
  188. data/test/unit/test_output_store.rb +342 -0
  189. data/test/unit/test_page.rb +8 -1
  190. data/test/unit/test_permissions.rb +11 -7
  191. data/test/unit/test_plugins.rb +3 -3
  192. data/test/unit/test_prototype_set.rb +8 -1
  193. data/test/unit/test_publishing.rb +67 -54
  194. data/test/unit/test_render.rb +91 -38
  195. data/test/unit/test_revisions.rb +4 -4
  196. data/test/unit/test_schema.rb +109 -84
  197. data/test/unit/test_search.rb +42 -42
  198. data/test/unit/test_serialisation.rb +3 -2
  199. data/test/unit/test_site.rb +39 -27
  200. data/test/unit/test_storage.rb +9 -6
  201. data/test/unit/test_styles.rb +25 -32
  202. data/test/unit/test_templates.rb +8 -4
  203. metadata +89 -54
  204. data/lib/spontaneous/model/page/request.rb +0 -105
  205. data/lib/spontaneous/storage.rb +0 -22
@@ -25,7 +25,7 @@ Spontaneous.Content = (function($, S) {
25
25
  return this.content.target;
26
26
  },
27
27
  developer_description: function() {
28
- return this.type().type + "["+this.id()+']'
28
+ return this.type().type + "["+this.id()+']';
29
29
  },
30
30
  developer_edit_url: function() {
31
31
  return this.type().edit_url();
@@ -68,8 +68,16 @@ Spontaneous.Content = (function($, S) {
68
68
  return this.filter_fields(function(f) { return !f.is_image(); });
69
69
  },
70
70
  // fields that should be saved as strings
71
- string_fields: function() {
72
- return this.filter_fields(function(f) { return !f.is_file(); });
71
+ string_values: function() {
72
+ var i, ii, v, values = [], fields = this.field_list();
73
+ for (i = 0, ii = fields.length; i < ii; i++) {
74
+ v = fields[i].stringValue();
75
+ if (v) {
76
+ values.push(v);
77
+ }
78
+ }
79
+ // return this.filter_fields(function(f) { return !f.is_file(); });
80
+ return values;
73
81
  },
74
82
  image_fields: function() {
75
83
  return this.filter_fields(function(f) { return f.is_image(); });
@@ -32,10 +32,7 @@ Spontaneous.EditPanel = (function($, S) {
32
32
  },
33
33
 
34
34
  upload_values: function() {
35
- var fields = this.parent_view.string_fields();
36
- var values = fields.map(function(field) {
37
- return field.serializedValue();
38
- });
35
+ var values = this.parent_view.string_values();
39
36
  // console.log("field values", values)
40
37
  // var values = this.form.serializeArray();
41
38
  var field_data = new FormData();
@@ -272,7 +272,24 @@ Spontaneous.Field.File = (function($, S) {
272
272
  this.selected_files = null;
273
273
  this.set('value', value);
274
274
  }
275
+ },
276
+ stringValue: function() {
277
+ if (this.mark_cleared) {
278
+ this.mark_cleared = false;
279
+ return { name: this.form_name(), value: '' };
280
+ }
281
+ return false; // don't upload this field as text
282
+ },
283
+
284
+ mark_cleared: false,
285
+
286
+ clear_file: function() {
287
+ // this.set('value', {});
288
+ this.mark_cleared = true;
289
+ this.selected_files = null;
290
+ this.mark_modified();
275
291
  }
292
+
276
293
  });
277
294
  return FileField;
278
295
  })(jQuery, Spontaneous);
@@ -24,7 +24,7 @@ Spontaneous.Field.Image = (function($, S) {
24
24
  edited.addClass('selected');
25
25
  }.bind(this));
26
26
  labels.append(local_label, server_label);
27
- image_outer.append(original, edited)
27
+ image_outer.append(original, edited);
28
28
  outer.append(labels, image_outer);
29
29
  return outer;
30
30
  }
@@ -64,7 +64,7 @@ Spontaneous.Field.Image = (function($, S) {
64
64
  pending['path'] = pending['src'];
65
65
  return pending['value'];
66
66
  }
67
- return v['__ui__'] || v['original'];
67
+ return v['__ui__'] || v['original'] || {};
68
68
  },
69
69
 
70
70
  currentEditValue: function() {
@@ -81,8 +81,8 @@ Spontaneous.Field.Image = (function($, S) {
81
81
  },
82
82
 
83
83
  currentFilename: function() {
84
- var v = this.currentValue();
85
- return v['filename'];
84
+ var v = this.get('value');
85
+ return (v['__pending__'] || v['original'])['filename'];
86
86
  },
87
87
  /*
88
88
  * HACK: The async nature of image updates means that the version setting
@@ -106,24 +106,24 @@ Spontaneous.Field.Image = (function($, S) {
106
106
  return this.data.version;
107
107
  },
108
108
 
109
- preview: function(container) {
109
+ preview: function() {
110
110
  Spontaneous.UploadManager.register(this);
111
111
  var self = this
112
112
  , value = this.currentValue()
113
113
  , src = value.src
114
114
  , img = null
115
- , dim = 45
116
- , container = container.parent('li');
115
+ , dim = 45;
116
+ // , container = container.parent('li');
117
117
 
118
118
  if (src === "") {
119
- img = dom.img('.missing-image', {'src':'/@spontaneous/static/px.gif'});
119
+ img = dom.img('.missing-image', {'src':''});
120
120
  } else {
121
121
  img = dom.img();
122
122
  img.load(function() {
123
123
  var r = this.width/this.height, $this = $(this), h = $this.height(), dh = 0;
124
124
  if (r >= 1) { // landscape -- fit image vertically
125
125
  // tag for extra css styles applicable to landscape images
126
- container.addClass('landscape');
126
+ // container.addClass('landscape');
127
127
  if (h <= dim) {
128
128
  dh = (dim - h)/2;
129
129
  }
@@ -171,9 +171,9 @@ Spontaneous.Field.Image = (function($, S) {
171
171
  }
172
172
  var img = image[0], w = img.width, h = img.height, r = w/h;
173
173
  if (r > 1) {
174
- container.addClass('landscape');
174
+ // container.addClass('landscape');
175
175
  } else {
176
- container.removeClass('landscape');
176
+ // container.removeClass('landscape');
177
177
  }
178
178
  }.bind(this))
179
179
  image.attr('src', url)
@@ -263,7 +263,8 @@ Spontaneous.Field.Image = (function($, S) {
263
263
  return 0;
264
264
  },
265
265
  edit: function() {
266
- var wrap = dom.div({'style':'position:relative;'}),
266
+ var wrap = dom.div(),
267
+ drop_wrap = dom.div({'style':'position:relative;'}),
267
268
  value = this.currentEditValue(),
268
269
  src = value.src,
269
270
  img = dom.img({'src':src}),
@@ -296,7 +297,10 @@ Spontaneous.Field.Image = (function($, S) {
296
297
  filename_info.text(filename);
297
298
  if (filesize) {
298
299
  filesize_info.text(parseFloat(filesize, 10).to_filesize());
300
+ } else if (filesize === 0 || filesize === "0") {
301
+ filesize_info.text('');
299
302
  }
303
+
300
304
  set_dimensions(width, height);
301
305
  };
302
306
 
@@ -305,11 +309,11 @@ Spontaneous.Field.Image = (function($, S) {
305
309
  var file = files[0], url = window.URL.createObjectURL(file);
306
310
  img.attr('src', url).removeClass('empty');
307
311
  this.select_files(files);
308
- img.attr('src', url)
312
+ img.attr('src', url);
309
313
  this._edited_value = url;
310
- this.image.attr('src', url)
314
+ this.image.attr('src', url);
311
315
  window.URL.revokeObjectURL(url);
312
- set_info(File.filename(file), file.fileSize, null, null)
316
+ set_info(File.filename(file), file.fileSize, null, null);
313
317
  }
314
318
  }.bind(this);
315
319
 
@@ -324,14 +328,18 @@ Spontaneous.Field.Image = (function($, S) {
324
328
  return false;
325
329
  };
326
330
 
327
- if (src == '') { img.addClass('empty'); }
331
+ if (src === '') { img.addClass('empty'); }
328
332
 
329
333
  var dropper = dom.div('.image-drop').click(onclick);
330
334
 
331
335
  var actions = dom.div('.actions');
332
- // var clear = dom.a('.button.clear').text('Clear');
333
- actions.append(input)//.append(clear);
334
- wrap.append(dropper);
336
+ var clear = dom.a('.button.clear').text('Clear').click(function() {
337
+ img.css({width: dom.px(img.width()), height: dom.px(img.height())}).attr('src', '/@spontaneous/static/px.gif');
338
+ set_info('', 0, null, null);
339
+ this.clear_file();
340
+ }.bind(this));
341
+ actions.append(input, clear);
342
+ drop_wrap.append(dropper);
335
343
 
336
344
 
337
345
  var drop = function(event) {
@@ -366,7 +374,8 @@ Spontaneous.Field.Image = (function($, S) {
366
374
  dropper.get(0).addEventListener('drop', drop, true);
367
375
  dropper.bind('dragenter', drag_enter).bind('dragover', drag_over).bind('dragleave', drag_leave);
368
376
 
369
- wrap.append(img, actions, info);
377
+ drop_wrap.append(img, info);
378
+ wrap.append(drop_wrap, actions);
370
379
 
371
380
  if (value) {
372
381
  // var s = value.path.split('/'), filename = s[s.length - 1];
@@ -402,7 +411,7 @@ Spontaneous.Field.Image = (function($, S) {
402
411
  this.preview_img.attr('src', value);
403
412
  this.callSuper(value);
404
413
  },
405
- accept_mimetype: "image/*",
414
+ accept_mimetype: "image/*"
406
415
  });
407
416
 
408
417
  ImageField.ConflictView = ImageFieldConflictView;
@@ -78,7 +78,7 @@ Spontaneous.Field.String = (function($, S) {
78
78
  this.set('unprocessed_value', values.unprocessed_value);
79
79
  },
80
80
  preview: function() {
81
- return this.get('value')
81
+ return this.get('value');
82
82
  },
83
83
  activate: function(el) {
84
84
  el.find('a[href^="/"]').click(function() {
@@ -196,6 +196,9 @@ Spontaneous.Field.String = (function($, S) {
196
196
  conflict_view: function(dialogue, conflict) {
197
197
  return new StringFieldConflictView(dialogue, conflict);
198
198
  },
199
+ stringValue: function() {
200
+ return this.serializedValue();
201
+ },
199
202
  serializedValue: function() {
200
203
  return {
201
204
  name: this.form_name(),
@@ -4,9 +4,10 @@ Spontaneous.FieldPreview = (function($, S) {
4
4
  var dom = S.Dom;
5
5
 
6
6
  var FieldPreview = new JS.Class({
7
- initialize: function(view, wrap_id) {
7
+ initialize: function(view, wrap_id, listView) {
8
8
  this.view = view;
9
9
  this.wrap_id = wrap_id;
10
+ this.listView = listView;
10
11
  },
11
12
 
12
13
  depth_class: function() {
@@ -16,39 +17,43 @@ Spontaneous.FieldPreview = (function($, S) {
16
17
  return this.view.has_fields();
17
18
  },
18
19
  panel: function() {
19
- var wrapper = dom.div([dom.id(this.wrap_id), 'fields-preview', this.depth_class()])
20
+ var wrapper = dom.div([dom.id(this.wrap_id), 'fields-preview', this.depth_class()]);
20
21
  // $(dom.div, {'id':this.wrap_id, 'class':'fields-preview ' + this.depth_class()});
21
22
  wrapper.append(this.fields_panel(this.view.text_fields(), 'text'));
22
23
  wrapper.append(this.fields_panel(this.view.image_fields(), 'image', true));
23
24
  if (this.view.mouseover) {
24
- wrapper.mouseover(this.view.mouseover.bind(this.view))
25
+ wrapper.mouseover(this.view.mouseover.bind(this.view));
25
26
  }
26
27
  if (this.view.mouseout) {
27
- wrapper.mouseout(this.view.mouseout.bind(this.view))
28
+ wrapper.mouseout(this.view.mouseout.bind(this.view));
28
29
  }
29
30
  wrapper.click(function() {
30
31
  this.view.edit(this.field_to_edit);
31
- }.bind(this))
32
+ }.bind(this));
32
33
  return wrapper;
33
34
  },
34
35
  fields_panel: function(fields, type, ignore_changes) {
35
36
  var wrapper = dom.ul('.fields-preview-'+type), __this = this;
36
37
  if (fields.length === 0) { wrapper.addClass('empty'); }
37
38
  $.each(fields, function(i, field) {
38
- var li = dom.li();
39
- var name = dom.div('.name').text(field.title);
40
- var value = dom.div('.value');
41
- li.click(function() {
42
- __this.field_to_edit = field;
43
- })
44
- field.activate(value);
45
- if (!ignore_changes) {
46
- field.watch('value', function(field, v) { $(this).html(field.preview()) }.bind(value, field));
47
- }
39
+ if (!__this.listView || field.type.list) {
40
+ var li = dom.li();
41
+ var name = dom.div('.name').text(field.title);
42
+ var value = dom.div('.value');
43
+ li.click(function() {
44
+ __this.field_to_edit = field;
45
+ });
46
+ field.activate(value);
47
+ // if (!ignore_changes) {
48
+ field.watch('value', function(field, v) {
49
+ $(this).html(field.preview());
50
+ }.bind(value, field));
51
+ // }
48
52
  li.append(name).append(value);
49
53
  wrapper.append(li);
50
54
  value.html(field.preview(value));
51
- });
55
+ }
56
+ });
52
57
  return wrapper;
53
58
  }
54
59
  });
@@ -76,10 +76,10 @@ Spontaneous.Publishing = (function($, S) {
76
76
  , self = this
77
77
  , changed_wrap = dom.div("#changes.change-list").css("opacity", 0)
78
78
  , publish_wrap = dom.div("#to-publish.change-list").css("opacity", 0)
79
- , first_publish = outstanding.first_publish
79
+ , must_publish_all = outstanding.first_publish || outstanding.must_publish_all
80
80
  , spinner = this.spinner
81
81
  , append_to;
82
- if (first_publish) {
82
+ if (must_publish_all) {
83
83
  w.addClass("first-publish");
84
84
  }
85
85
  if (change_list.length === 0) {
@@ -96,22 +96,22 @@ Spontaneous.Publishing = (function($, S) {
96
96
 
97
97
  var changed_toolbar = dom.div('.actions').append(dom.div().text("Modified pages")).append(publish_all);
98
98
  var publish_toolbar = dom.div('.actions').append(dom.div().text("Publish pages"));
99
- if (!first_publish) {
99
+ if (!must_publish_all) {
100
100
  publish_toolbar.append(clear_all);
101
101
  }
102
102
  var changed_entries = dom.div('.change-sets'), publish_entries = dom.div('.change-sets')
103
103
  changed_wrap.append(changed_toolbar, changed_entries);
104
104
  publish_wrap.append(publish_toolbar, publish_entries);
105
105
  append_to = changed_entries;
106
- if (first_publish) {
106
+ if (must_publish_all) {
107
107
  append_to = publish_entries;
108
108
  }
109
109
  for (var i = 0, ii = change_list.length; i < ii; i++) {
110
- var cs = new ChangeSet(i, self, change_list[i], first_publish);
110
+ var cs = new ChangeSet(i, self, change_list[i], must_publish_all);
111
111
  self.change_sets.push(cs);
112
112
  append_to.append(cs.panel())
113
113
  }
114
- if (!first_publish) {
114
+ if (!must_publish_all) {
115
115
  publish_entries.append(dom.div('.instructions').text('Add pages to publish from the list on the left'));
116
116
  }
117
117
  spinner.stop();
@@ -19,10 +19,11 @@ Spontaneous.Types = (function($, S) {
19
19
  }
20
20
  },
21
21
  allowed_types: function() {
22
- var types = [];
23
- if (this.data.allowed_types.length > 0) {
24
- for (var i = 0, ii = this.data.allowed_types.length; i < ii; i++) {
25
- types.push(Spontaneous.Types.type(this.data.allowed_types[i]));
22
+ var allowed_types = this.data.allowed_types, types = [], a;
23
+ if (allowed_types.length > 0) {
24
+ for (var i = 0, ii = allowed_types.length; i < ii; i++) {
25
+ a = allowed_types[i];
26
+ types.push({type: Spontaneous.Types.type(a.type), as: a.as});
26
27
  }
27
28
  }
28
29
  return types;
@@ -55,15 +56,6 @@ Spontaneous.Types = (function($, S) {
55
56
  box_prototype: function(box_id) {
56
57
  return this.box_prototypes[box_id];
57
58
  },
58
- allowed_types: function() {
59
- var types = [];
60
- if (this.data.allowed_types.length > 0) {
61
- for (var i = 0, ii = this.data.allowed_types.length; i < ii; i++) {
62
- types.push(Spontaneous.Types.type(this.data.allowed_types[i]));
63
- }
64
- }
65
- return types;
66
- },
67
59
  is_page: function() {
68
60
  return this.data.is_page;
69
61
  },
@@ -37,8 +37,8 @@ Spontaneous.Views = (function($, S) {
37
37
  text_fields: function() {
38
38
  return this.content.text_fields();
39
39
  },
40
- string_fields: function() {
41
- return this.content.string_fields();
40
+ string_values: function() {
41
+ return this.content.string_values();
42
42
  },
43
43
  file_fields: function() {
44
44
  return this.content.file_fields();
@@ -152,8 +152,9 @@ Spontaneous.Views.BoxView = (function($, S) {
152
152
  dropper.get(0).addEventListener('drop', drop, true);
153
153
  dropper.bind('dragenter', drag_enter).bind('dragover', drag_over).bind('dragleave', drag_leave);
154
154
 
155
- $.each(allowed, function(i, type) {
156
- var a = dom.a().text(type.title), add_allowed;
155
+ $.each(allowed, function(i, allow) {
156
+ var type = allow.type, as = allow.as || type.title;
157
+ var a = dom.a().text(as), add_allowed;
157
158
  if (type.is_alias()) {
158
159
  a.addClass('alias')
159
160
  add_allowed = function(type) {
@@ -19,7 +19,7 @@ Spontaneous.Views.PagePieceView = (function($, S) {
19
19
 
20
20
  contents.append(this.page_title_panel());
21
21
  var entry = dom.div('.entry');
22
- var fields = new Spontaneous.FieldPreview(this, '');
22
+ var fields = new Spontaneous.FieldPreview(this, '', true);
23
23
  var fields_panel = fields.panel();
24
24
  entry.append(fields_panel);
25
25
  inside.append(entry);
@@ -68,7 +68,7 @@ Spontaneous.Views.PieceView = (function($, S) {
68
68
  // this.dialogue_box = $(dom.div, {'class':'dialogue', 'style':'display: none'});
69
69
  // contents.append(this.dialogue_box);
70
70
  var entry = dom.div('.entry');
71
- var fields = new Spontaneous.FieldPreview(this, '');
71
+ var fields = new Spontaneous.FieldPreview(this, '', true);
72
72
  if (fields.has_fields()) {
73
73
  var fields_panel = fields.panel();
74
74
  entry.append(fields_panel);
@@ -30,10 +30,10 @@
30
30
  <div id="container">
31
31
 
32
32
  <%
33
- types = modification.actions.map { |a| a.source.owner}.uniq
33
+ types = modification.actions.map { |a| a.source.owner}.uniq.compact
34
34
  %>
35
35
 
36
- <h1>There are unresolved changes to <%= types.length > 1 ? "s" : "" %> <%= types.map { |o| "<strong>&lsquo;#{o}&rsquo;</strong>"}.join(', ')%></h1>
36
+ <h1>There are unresolved changes to <%= types.length == 0 ? "the schema" : types.map { |o| "<strong>&lsquo;#{o}&rsquo;</strong>"}.join(', ')%></h1>
37
37
  <% source_file = modification.actions[0].source.source_file %>
38
38
  <p class="src"><a href="mvim://open?url=file://<%= source_file %>"><%= source_file %></a></p>
39
39
 
@@ -55,7 +55,17 @@
55
55
  to &lsquo;<em><%= action.dest.name %></em>&rsquo;
56
56
  <% end %>
57
57
  </a>
58
- <p id="<%= id %>" style="display: none">Are you sure? <a class="button cancel" onclick="_cancel('#<%= id %>')">No</a> <button class="button" onclick="solution('<%= action.action %>', '<%= action.source.name %>', '<%= action.dest ? action.dest.name : '' %>')">Yes</button></p>
58
+ <div id="<%= id %>" style="display: none">
59
+ <% if action.action == :delete %>
60
+ <% case action.category %>
61
+ <% when :type %>
62
+ <p class="warning">Deleting a type will delete all instances of it from the db and any of their descendents. This cannot be undone so snapshot your database with <code>spot site dump</code> before proceeding.</p>
63
+ <% when :box %>
64
+ <p class="warning">Deleting a box will delete the contents of all boxes of that type. This cannot be undone so snapshot your database with <code>spot site dump</code> before proceeding.</p>
65
+ <% end %>
66
+ <% end %>
67
+ <p>Are you sure? <a class="button cancel" onclick="_cancel('#<%= id %>')">No</a> <button class="button" onclick="solution('<%= action.action %>', '<%= action.source.name %>', '<%= action.dest ? action.dest.name : '' %>')">Yes</button></p>
68
+ </div>
59
69
  </form>
60
70
  </li>
61
71
  <% end %>