spontaneous 0.2.0.beta5 → 0.2.0.beta6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (227) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +39 -0
  4. data/Gemfile +2 -0
  5. data/Readme.markdown +4 -4
  6. data/application/css/core.css.scss +144 -43
  7. data/application/css/definitions.css.scss +50 -16
  8. data/application/css/dialogue.css.scss +5 -2
  9. data/application/css/editing.css.scss +7 -7
  10. data/application/css/font.css.scss +1 -1
  11. data/application/css/meta.css.scss +6 -6
  12. data/application/css/popover.css.scss +6 -6
  13. data/application/css/top.css.scss +8 -1
  14. data/application/js/add_alias_dialogue.js +137 -36
  15. data/application/js/add_home_dialogue.js +10 -10
  16. data/application/js/ajax.js +26 -26
  17. data/application/js/authentication.js +2 -2
  18. data/application/js/box.js +21 -10
  19. data/application/js/box_container.js +13 -7
  20. data/application/js/compatibility.js +19 -17
  21. data/application/js/conflicted_field_dialogue.js +5 -5
  22. data/application/js/content.js +22 -16
  23. data/application/js/content_area.js +62 -33
  24. data/application/js/dialogue.js +16 -16
  25. data/application/js/dom.js +9 -10
  26. data/application/js/edit_panel.js +25 -20
  27. data/application/js/editing.js +21 -8
  28. data/application/js/entry.js +1 -1
  29. data/application/js/extensions.js +11 -11
  30. data/application/js/field/boolean.js +6 -6
  31. data/application/js/field/date.js +1 -1
  32. data/application/js/field/file.js +17 -17
  33. data/application/js/field/image.js +27 -27
  34. data/application/js/field/markdown.js +72 -71
  35. data/application/js/field/select.js +9 -9
  36. data/application/js/field/string.js +3 -3
  37. data/application/js/field/webvideo.js +2 -2
  38. data/application/js/field_preview.js +3 -0
  39. data/application/js/init.js +3 -2
  40. data/application/js/jquery-selection-position.js +13 -13
  41. data/application/js/location.js +17 -12
  42. data/application/js/login.js +2 -2
  43. data/application/js/meta_view/user_admin.js +101 -101
  44. data/application/js/metadata.js +1 -1
  45. data/application/js/page.js +2 -2
  46. data/application/js/page_browser.js +13 -13
  47. data/application/js/page_entry.js +1 -1
  48. data/application/js/panel/root_menu.js +10 -10
  49. data/application/js/popover.js +6 -5
  50. data/application/js/popover_view.js +5 -5
  51. data/application/js/preview.js +10 -4
  52. data/application/js/progress.js +6 -6
  53. data/application/js/properties.js +35 -6
  54. data/application/js/publish.js +43 -43
  55. data/application/js/require.js +14 -14
  56. data/application/js/services.js +3 -3
  57. data/application/js/sharded_upload.js +9 -8
  58. data/application/js/side_bar.js +5 -5
  59. data/application/js/state.js +2 -2
  60. data/application/js/status_bar.js +6 -6
  61. data/application/js/top_bar.js +97 -65
  62. data/application/js/types.js +9 -6
  63. data/application/js/upload.js +4 -4
  64. data/application/js/upload_manager.js +21 -21
  65. data/application/js/user.js +1 -1
  66. data/application/js/vendor/jquery.velocity.min.js +7 -0
  67. data/application/js/views.js +32 -8
  68. data/application/js/views/box_view.js +51 -31
  69. data/application/js/views/page_piece_view.js +17 -15
  70. data/application/js/views/page_view.js +54 -43
  71. data/application/js/views/piece_view.js +44 -37
  72. data/application/static/font/fontawesome-webfont-4f0022f25672c7f501c339cbf98d9117.ttf +0 -0
  73. data/application/views/index.erb +1 -0
  74. data/db/migrations/20130114120000_create_revision_tables.rb +2 -1
  75. data/db/migrations/20130813111009_increase_path_length.rb +11 -2
  76. data/db/migrations/20140506171823_add_index_to_target_id.rb +11 -0
  77. data/db/migrations/20140514090204_add_content_hash.rb +59 -0
  78. data/db/migrations/20140519150253_add_content_hash_timestamp.rb +20 -0
  79. data/lib/spontaneous.rb +0 -1
  80. data/lib/spontaneous/asset/environment.rb +77 -15
  81. data/lib/spontaneous/box.rb +21 -0
  82. data/lib/spontaneous/capistrano/deploy.rb +1 -1
  83. data/lib/spontaneous/capistrano/sync.rb +8 -7
  84. data/lib/spontaneous/change.rb +4 -2
  85. data/lib/spontaneous/cli/fields.rb +7 -3
  86. data/lib/spontaneous/cli/generate.rb +2 -0
  87. data/lib/spontaneous/cli/init.rb +24 -93
  88. data/lib/spontaneous/cli/init/db.rb +94 -0
  89. data/lib/spontaneous/cli/init/mysql.rb +17 -0
  90. data/lib/spontaneous/cli/init/postgresql.rb +33 -0
  91. data/lib/spontaneous/cli/init/sqlite.rb +14 -0
  92. data/lib/spontaneous/cli/site.rb +45 -20
  93. data/lib/spontaneous/collections/box_set.rb +3 -0
  94. data/lib/spontaneous/collections/entry_set.rb +43 -4
  95. data/lib/spontaneous/collections/field_set.rb +14 -2
  96. data/lib/spontaneous/data_mapper.rb +40 -7
  97. data/lib/spontaneous/data_mapper/content_model.rb +1 -1
  98. data/lib/spontaneous/data_mapper/content_model/associations.rb +63 -12
  99. data/lib/spontaneous/data_mapper/content_model/timestamps.rb +9 -14
  100. data/lib/spontaneous/data_mapper/content_table.rb +4 -2
  101. data/lib/spontaneous/data_mapper/dataset.rb +31 -2
  102. data/lib/spontaneous/data_mapper/scope.rb +37 -20
  103. data/lib/spontaneous/errors.rb +6 -0
  104. data/lib/spontaneous/facet.rb +20 -10
  105. data/lib/spontaneous/field/base.rb +8 -1
  106. data/lib/spontaneous/field/file.rb +28 -3
  107. data/lib/spontaneous/field/image.rb +2 -0
  108. data/lib/spontaneous/field/update.rb +6 -0
  109. data/lib/spontaneous/field/webvideo/vimeo.rb +6 -1
  110. data/lib/spontaneous/field/webvideo/vine.rb +1 -1
  111. data/lib/spontaneous/field/webvideo/youtube.rb +1 -1
  112. data/lib/spontaneous/generators/site.rb +6 -4
  113. data/lib/spontaneous/generators/site/.gitignore +1 -0
  114. data/lib/spontaneous/generators/site/Gemfile.tt +3 -3
  115. data/lib/spontaneous/generators/site/config/{indexes.rb.tt → initializers/indexes.rb.tt} +0 -0
  116. data/lib/spontaneous/generators/site/config/initializers/publishing.rb.tt +78 -0
  117. data/lib/spontaneous/generators/site/{config/database.yml.tt → db/mysql2.yml.tt} +7 -6
  118. data/lib/spontaneous/generators/site/db/postgres.yml.tt +25 -0
  119. data/lib/spontaneous/generators/site/db/sqlite3.yml.tt +18 -0
  120. data/lib/spontaneous/generators/site/public/humans.txt.tt +14 -0
  121. data/lib/spontaneous/generators/site/templates/layouts/standard.html.cut.tt +51 -0
  122. data/lib/spontaneous/loader.rb +1 -1
  123. data/lib/spontaneous/logger.rb +1 -1
  124. data/lib/spontaneous/media/image/optimizer.rb +1 -1
  125. data/lib/spontaneous/media/image/processor.rb +11 -2
  126. data/lib/spontaneous/media/image/renderable.rb +2 -0
  127. data/lib/spontaneous/model.rb +3 -0
  128. data/lib/spontaneous/model/box/allowed_types.rb +17 -4
  129. data/lib/spontaneous/model/core.rb +36 -3
  130. data/lib/spontaneous/model/core/aliases.rb +5 -2
  131. data/lib/spontaneous/model/core/boxes.rb +6 -0
  132. data/lib/spontaneous/model/core/cascading_change.rb +38 -0
  133. data/lib/spontaneous/model/core/content_hash.rb +171 -0
  134. data/lib/spontaneous/model/core/entries.rb +0 -19
  135. data/lib/spontaneous/model/core/fields.rb +11 -0
  136. data/lib/spontaneous/model/core/modifications.rb +22 -21
  137. data/lib/spontaneous/model/core/render.rb +3 -0
  138. data/lib/spontaneous/model/core/serialisation.rb +18 -17
  139. data/lib/spontaneous/model/page.rb +35 -8
  140. data/lib/spontaneous/model/page/page_tree.rb +20 -8
  141. data/lib/spontaneous/model/page/paths.rb +79 -50
  142. data/lib/spontaneous/model/page/singleton.rb +71 -0
  143. data/lib/spontaneous/model/page/site_map.rb +2 -1
  144. data/lib/spontaneous/model/page/site_timestamps.rb +2 -2
  145. data/lib/spontaneous/model/piece.rb +10 -0
  146. data/lib/spontaneous/output/context.rb +13 -6
  147. data/lib/spontaneous/output/format.rb +30 -5
  148. data/lib/spontaneous/output/helpers/script_helper.rb +8 -0
  149. data/lib/spontaneous/output/helpers/stylesheet_helper.rb +7 -0
  150. data/lib/spontaneous/output/renderable.rb +16 -0
  151. data/lib/spontaneous/output/store.rb +1 -1
  152. data/lib/spontaneous/output/template/renderer.rb +2 -2
  153. data/lib/spontaneous/page_piece.rb +25 -1
  154. data/lib/spontaneous/prototypes/box_prototype.rb +13 -0
  155. data/lib/spontaneous/prototypes/field_prototype.rb +7 -4
  156. data/lib/spontaneous/publishing.rb +10 -5
  157. data/lib/spontaneous/publishing/immediate.rb +32 -349
  158. data/lib/spontaneous/publishing/pipeline.rb +43 -0
  159. data/lib/spontaneous/publishing/progress.rb +186 -0
  160. data/lib/spontaneous/publishing/publish.rb +107 -0
  161. data/lib/spontaneous/publishing/rerender.rb +17 -0
  162. data/lib/spontaneous/publishing/revision.rb +53 -18
  163. data/lib/spontaneous/publishing/simultaneous.rb +1 -1
  164. data/lib/spontaneous/publishing/steps.rb +154 -0
  165. data/lib/spontaneous/publishing/steps/activate_revision.rb +45 -0
  166. data/lib/spontaneous/publishing/steps/archive_old_revisions.rb +22 -0
  167. data/lib/spontaneous/publishing/steps/base_step.rb +49 -0
  168. data/lib/spontaneous/publishing/steps/copy_static_files.rb +74 -0
  169. data/lib/spontaneous/publishing/steps/create_revision_directory.rb +24 -0
  170. data/lib/spontaneous/publishing/steps/generate_rackup_file.rb +51 -0
  171. data/lib/spontaneous/publishing/steps/generate_search_indexes.rb +24 -0
  172. data/lib/spontaneous/publishing/steps/render_revision.rb +69 -0
  173. data/lib/spontaneous/publishing/steps/write_revision_file.rb +43 -0
  174. data/lib/spontaneous/rack/back.rb +3 -1
  175. data/lib/spontaneous/rack/back/alias.rb +9 -8
  176. data/lib/spontaneous/rack/front.rb +1 -1
  177. data/lib/spontaneous/rack/middleware.rb +7 -4
  178. data/lib/spontaneous/rack/middleware/transaction.rb +14 -0
  179. data/lib/spontaneous/rack/page_controller.rb +23 -8
  180. data/lib/spontaneous/revision.rb +5 -10
  181. data/lib/spontaneous/schema.rb +5 -0
  182. data/lib/spontaneous/server.rb +3 -1
  183. data/lib/spontaneous/site.rb +17 -10
  184. data/lib/spontaneous/site/publishing.rb +25 -3
  185. data/lib/spontaneous/site/state.rb +7 -3
  186. data/lib/spontaneous/tasks/database.rake +5 -10
  187. data/lib/spontaneous/utils/database/mysql_dumper.rb +5 -1
  188. data/lib/spontaneous/version.rb +1 -1
  189. data/spontaneous.gemspec +4 -3
  190. data/test/fixtures/example_application/config/initializers/initializer1.rb +1 -0
  191. data/test/fixtures/example_application/config/initializers/initializer2.rb +1 -0
  192. data/test/fixtures/example_application/config/initializers/publishing.rb +13 -0
  193. data/test/fixtures/search/config/{indexes.rb → initializers/indexes.rb} +0 -0
  194. data/test/fixtures/serialisation/root_hash.yaml.erb +10 -4
  195. data/test/functional/test_application.rb +10 -0
  196. data/test/functional/test_back.rb +23 -5
  197. data/test/functional/test_cli.rb +98 -34
  198. data/test/functional/test_front.rb +7 -3
  199. data/test/test_helper.rb +35 -28
  200. data/test/unit/test_alias.rb +20 -3
  201. data/test/unit/test_assets.rb +58 -30
  202. data/test/unit/test_changesets.rb +20 -12
  203. data/test/unit/test_content_hash.rb +496 -0
  204. data/test/unit/test_context.rb +28 -1
  205. data/test/unit/test_controllers.rb +96 -61
  206. data/test/unit/test_crypt.rb +1 -8
  207. data/test/unit/test_datamapper.rb +95 -19
  208. data/test/unit/test_features.rb +1 -4
  209. data/test/unit/test_fields.rb +61 -12
  210. data/test/unit/test_generators.rb +39 -2
  211. data/test/unit/test_images.rb +3 -1
  212. data/test/unit/test_modifications.rb +224 -219
  213. data/test/unit/test_output_store.rb +10 -0
  214. data/test/unit/{test_formats.rb → test_outputs.rb} +75 -6
  215. data/test/unit/test_page.rb +61 -15
  216. data/test/unit/test_plugins.rb +2 -42
  217. data/test/unit/test_publishing_pipeline.rb +1050 -0
  218. data/test/unit/test_render.rb +30 -0
  219. data/test/unit/test_revisions.rb +110 -2
  220. data/test/unit/test_schema.rb +4 -0
  221. data/test/unit/test_search.rb +1 -1
  222. data/test/unit/test_serialisation.rb +6 -1
  223. data/test/unit/test_singletons.rb +159 -0
  224. data/test/unit/test_site.rb +71 -44
  225. metadata +140 -86
  226. data/application/static/font/fontawesome-webfont-1c66a4738b40ef0f6b1abca0ba9a796d.ttf +0 -0
  227. data/test/unit/test_publishing.rb +0 -330
@@ -1,34 +1,36 @@
1
1
  // console.log('Loading PageEntry...')
2
2
 
3
3
  Spontaneous.Views.PagePieceView = (function($, S) {
4
- "use strict";
4
+ 'use strict';
5
5
  var dom = S.Dom;
6
6
 
7
7
  var PagePieceView = new JS.Class(Spontaneous.Views.PieceView, {
8
8
  // will eventually overwrite panel()
9
9
  panel: function() {
10
- var wrapper = dom.div(['entry-wrap page no-boxes', this.depth_class(), this.visibility_class()])
10
+ var self = this;
11
+ var wrapper = dom.div(['entry-wrap page no-boxes', self.alias_class(), self.fields_class(), self.depth_class(), self.visibility_class()]);
11
12
  var contents = dom.div('.entry-contents');
12
13
  var inside = dom.div('.entry-inner');
13
- var outline = dom.div('.white-bg').mouseover(this.mouseover.bind(this)).mouseout(this.mouseout.bind(this)).click(this.edit.bind(this))
14
- inside.append(outline)
15
- contents.append(this.action_buttons(contents));
16
- if (this.content.type().is_alias()) {
17
- contents.append(this.alias_target_panel());
14
+ var outline = dom.div('.white-bg').mouseover(self.mouseover.bind(self)).mouseout(self.mouseout.bind(self)).click(self.edit.bind(self));
15
+ inside.append(outline);
16
+ contents.append(self.action_buttons(contents));
17
+ if (self.content.type().is_alias()) {
18
+ contents.append(self.alias_target_panel());
19
+ } else {
20
+ contents.append(self.page_title_panel());
18
21
  }
19
22
 
20
- contents.append(this.page_title_panel());
21
23
  var entry = dom.div('.entry');
22
- var fields = new Spontaneous.FieldPreview(this, '', true);
24
+ var fields = new Spontaneous.FieldPreview(self, '', true);
23
25
  var fields_panel = fields.panel();
24
26
  entry.append(fields_panel);
25
27
  inside.append(entry);
26
- var preview_area = this.create_edit_wrapper(inside);
28
+ var preview_area = self.create_edit_wrapper(inside);
27
29
  contents.append(preview_area);
28
- wrapper.append(contents, this.entry_spacer());
29
- this.wrapper = wrapper;
30
- this.outline = outline;
31
- this.fields_preview = fields_panel;
30
+ wrapper.append(contents, self.entry_spacer());
31
+ self.wrapper = wrapper;
32
+ self.outline = outline;
33
+ self.fields_preview = fields_panel;
32
34
  return wrapper;
33
35
  },
34
36
  page_title_panel: function() {
@@ -38,7 +40,7 @@ Spontaneous.Views.PagePieceView = (function($, S) {
38
40
  self = this,
39
41
  content = self.content,
40
42
  title = dom.a().html(this.content.title()),
41
- type = dom.span(".content-type").text(content.type().display_title(content));
43
+ type = dom.span('.content-type').text(content.type().display_title(content));
42
44
  this.content.title_field().watch('value', function(t) { title.html(t); }.bind(this));
43
45
  wrapper.append(title, type);
44
46
  return wrapper;
@@ -28,19 +28,20 @@ Spontaneous.Views.PageView = (function($, S) {
28
28
  path_wrap.append(path_text);
29
29
 
30
30
  if (!self.page.is_root()) {
31
- var resync = dom.a({ "title":"Sync the path to the page title"}).click(function() {
32
- Spontaneous.Ajax.put(['/page', self.page.id(), "slug/sync"].join("/"), {}, self.save_complete.bind(self));
31
+ var resync = dom.a({ 'title':'Sync the path to the page title'}).click(function() {
32
+ Spontaneous.Ajax.put(['/page', self.page.id(), 'slug/sync'].join('/'), {}, self.save_complete.bind(self));
33
33
  });
34
- path_wrap.append( dom.h3('.titlesync').append(resync));
34
+ path_wrap.append(dom.h3('.titlesync').append(resync));
35
35
  }
36
36
 
37
+ path_wrap.append(dom.div('.path-spacer'));
37
38
 
38
39
  if (user.is_developer()) {
39
- var uid_text = dom.h3('.developer.uid' + (!this.page.content.uid ? '.missing' : '')).text('#' + (this.page.content.uid || "----")).click(function() {
40
- this.open_uid_editor();
41
- }.bind(this));
40
+ // var uid_text = dom.h3('.developer.uid' + (!this.page.content.uid ? '.missing' : '')).text('#' + (this.page.content.uid || "----")).click(function() {
41
+ // this.open_uid_editor();
42
+ // }.bind(this));
42
43
  var dev_desc = dom.h3('.developer').append(dom.a().attr('href', this.page.developer_edit_url()).text(this.page.developer_description()));
43
- path_wrap.append(uid_text, dev_desc);
44
+ path_wrap.append(dev_desc);
44
45
  }
45
46
 
46
47
  path_wrap.append(dom.div('.edit'));
@@ -50,9 +51,12 @@ Spontaneous.Views.PageView = (function($, S) {
50
51
  }.bind(this));
51
52
 
52
53
  this.panel.append(path_wrap);
53
- this.path_wrap = path_wrap
54
+ this.path_wrap = path_wrap;
54
55
  return this.panel;
55
56
  },
57
+ unload: function() {
58
+ // fit with the view prototype
59
+ },
56
60
  set_title: function(title) {
57
61
  var self = this;
58
62
  title = title || this.page.title();
@@ -63,9 +67,8 @@ Spontaneous.Views.PageView = (function($, S) {
63
67
  var maxHeight = 36;
64
68
  window.setTimeout(function() {
65
69
  var t = self.title
66
- , height = function() { return t.height(); }
67
- , fs = window.parseInt(t.css('font-size'), 10);
68
- ;
70
+ , height = function() { return t.height(); }
71
+ , fs = window.parseInt(t.css('font-size'), 10);
69
72
  while (height() > maxHeight && fs > 10) {
70
73
  t.css('font-size', --fs);
71
74
  }
@@ -79,7 +82,7 @@ Spontaneous.Views.PageView = (function($, S) {
79
82
  this.unavailable = u;
80
83
  },
81
84
  open_uid_editor: function() {
82
- this.panel.animate({'height': '+=14'}, 200, function() {
85
+ this.panel.velocity({'height': '+=14'}, { duration: 200, complete: function() {
83
86
  var view = $('h3', this.panel), edit = $('.edit', this.panel);
84
87
  view.hide();
85
88
  edit.hide().empty();
@@ -114,15 +117,15 @@ Spontaneous.Views.PageView = (function($, S) {
114
117
  }.bind(this)).keydown(function(event) {
115
118
  if (event.keyCode === 27) { this.close(); }
116
119
  }.bind(this));
117
- edit.fadeIn(200);
118
- }.bind(this));
120
+ edit.velocity('fadeIn', 200);
121
+ }.bind(this)});
119
122
  },
120
123
  save_uid: function(uid) {
121
- Spontaneous.Ajax.put(['/page',this.page.id(), "uid"].join("/"), {'uid':uid}, this.uid_save_complete.bind(this));
124
+ Spontaneous.Ajax.put(['/page',this.page.id(), 'uid'].join('/'), {'uid':uid}, this.uid_save_complete.bind(this));
122
125
  },
123
126
  uid_save_complete: function(response, status, xhr) {
124
127
  if (status === 'success') {
125
- var view = $('h3.uid', this.panel), edit = $('.edit', this.panel), uid = (response.uid == "" ? "----" : response.uid);
128
+ var view = $('h3.uid', this.panel), edit = $('.edit', this.panel), uid = (response.uid === '' ? '----' : response.uid);
126
129
  // nasty but the value is only used for display
127
130
  this.page.content.uid = response.uid;
128
131
  view.text('#'+uid);
@@ -133,20 +136,21 @@ Spontaneous.Views.PageView = (function($, S) {
133
136
  this.unavailable = false;
134
137
  this.url_editor_open = true;
135
138
  Spontaneous.Ajax.get(['/page', this.page.id(), 'slug/unavailable'].join('/'), this.unavailable_loaded.bind(this));
136
- this.panel.animate({'height': '+=14'}, 200, function() {
137
- var view = $('h3', this.panel), edit = $('.edit', this.panel);
138
- view.hide();
139
+ this.panel.velocity({'height': '+=14'}, {duration: 200, complete: function() {
140
+ var view = $('h3', this.panel), edit = $('.edit', this.panel), spacer = $('.path-spacer', this.panel);
141
+ spacer.add(view).hide();
139
142
  edit.hide().empty();
140
- var path = [""], parts = this.page.get('path').split('/'), slug = parts.pop();
143
+ var path = [''], parts = this.page.get('path').split('/'), slug = parts.pop();
141
144
  parts.shift(); // remove empty entry caused by leading '/'
142
- edit.append(dom.span().text('/'))
145
+ edit.append(dom.span().text('/'));
146
+ var click = function() {
147
+ S.Location.load_path($(this).attr('href'));
148
+ return false;
149
+ };
143
150
  for (var i = 0, ii = parts.length; i < ii; i++) {
144
151
  var p = parts[i];
145
- path.push(p)
146
- edit.append(dom.a('.path').text(p).attr('href', path.join('/')).click(function() {
147
- S.Location.load_path($(this).attr('href'));
148
- return false;
149
- }));
152
+ path.push(p);
153
+ edit.append(dom.a('.path').text(p).attr('href', path.join('/')).click(click));
150
154
  edit.append(dom.span().text('/'));
151
155
  }
152
156
  var input_and_error = dom.span('.input-error');
@@ -204,25 +208,25 @@ Spontaneous.Views.PageView = (function($, S) {
204
208
  if (event.keyCode === 27) { close(); }
205
209
  }.bind(this));
206
210
 
207
- edit.fadeIn(200, function() {
211
+ edit.velocity({opacity: 1}, {duration: 200, display: 'flex', complete: function() {
208
212
  input.focus();
209
- });
213
+ }});
210
214
  this.input = input;
211
215
  this.error = error;
212
- }.bind(this));
216
+ }.bind(this)});
213
217
  },
214
218
  show_path_error: function(error_text) {
215
- error_text = (error_text || "Duplicate URL");
216
- this.error.text(error_text).fadeIn(100);
219
+ error_text = (error_text || 'Duplicate URL');
220
+ this.error.text(error_text).velocity('fadeIn', 100);
217
221
  this.input.addClass('error');
218
222
  },
219
223
  hide_path_error: function(error_text) {
220
- if (this.error) { this.error.fadeOut(100); }
224
+ if (this.error) { this.error.velocity('fadeOut', 100); }
221
225
 
222
226
  if (this.input && this.input.hasClass('error')) { this.input.removeClass('error'); }
223
227
  },
224
228
  save: function(slug) {
225
- Spontaneous.Ajax.put(['/page',this.page.id(), "slug"].join("/"), {'slug':slug}, this.save_complete.bind(this));
229
+ Spontaneous.Ajax.put(['/page',this.page.id(), 'slug'].join('/'), {'slug':slug}, this.save_complete.bind(this));
226
230
  },
227
231
 
228
232
  save_complete: function(response, status, xhr) {
@@ -236,7 +240,7 @@ Spontaneous.Views.PageView = (function($, S) {
236
240
  this.page.set('path', response.path);
237
241
  this.page.set('slug', response.slug);
238
242
  // HACK: see preview.js (Preview.display)
239
- Spontaneous.Location.set('path', this.page.get('path'))
243
+ Spontaneous.Location.set('path', this.page.get('path'));
240
244
  } else {
241
245
  if (xhr.status === 409) { // duplicate path
242
246
  this.show_path_error();
@@ -248,10 +252,10 @@ Spontaneous.Views.PageView = (function($, S) {
248
252
  },
249
253
  close: function() {
250
254
  this.url_editor_open = false;
251
- var view = $('h3', this.panel), edit = $('.edit', this.panel);
252
- view.show();
255
+ var view = $('h3', this.panel), edit = $('.edit', this.panel), spacer = $('.path-spacer', this.panel);
256
+ view.add(spacer).show();
253
257
  edit.hide();
254
- this.panel.animate({'height': '-=14'}, 200)
258
+ this.panel.velocity({'height': '-=14'}, 200);
255
259
  }
256
260
  };
257
261
  var PageView = new JS.Class(Spontaneous.Views.View, {
@@ -263,19 +267,24 @@ Spontaneous.Views.PageView = (function($, S) {
263
267
  panel: function() {
264
268
  this.panel = dom.div('#page-content');
265
269
  if (this.page.hidden()) {
266
- this.panel.addClass('hidden')
270
+ this.panel.addClass('hidden');
267
271
  }
268
- this.panel.append(new FunctionBar(this.page).panel());
272
+ var functionbar = new FunctionBar(this.page);
273
+ this._subviews.push(functionbar);
274
+ this.panel.append(functionbar.panel());
269
275
 
270
- var fields = dom.div('#page-fields')
276
+ var fields = dom.div('#page-fields');
271
277
  var fp = new Spontaneous.FieldPreview(this, '');
278
+ this._subviews.push(fp);
272
279
  var p = fp.panel();
273
- p.prepend(dom.div('.overlay'))
280
+ p.prepend(dom.div('.overlay'));
274
281
 
275
282
  var preview_area = this.create_edit_wrapper(p);
276
- fields.append(preview_area)
283
+ fields.append(preview_area);
277
284
  this.panel.append(fields);
278
- this.panel.append(new Spontaneous.BoxContainer(this.page, 'page-slots').panel());
285
+ var boxes = new Spontaneous.BoxContainer(this.page, 'page-slots');
286
+ this._subviews.push(boxes);
287
+ this.panel.append(boxes.panel());
279
288
  this.fields_preview = p;
280
289
  return this.panel;
281
290
  },
@@ -291,6 +300,8 @@ Spontaneous.Views.PageView = (function($, S) {
291
300
  },
292
301
  depth: function() {
293
302
  return this.page.depth();
303
+ },
304
+ unloadView: function() {
294
305
  }
295
306
  });
296
307
 
@@ -17,11 +17,13 @@ Spontaneous.Views.PieceView = (function($, S) {
17
17
  return false;
18
18
  },
19
19
  title: function() {
20
- return "Delete this " + (this.parent_view.content.is_page() ? "Page?" : "Piece?");
20
+ return 'Delete this ' + (this.parent_view.content.is_page() ? 'Page?' : 'Piece?');
21
+ },
22
+ position_from_event: function(event) {
23
+ var p = this.callSuper();
24
+ p.left = p.left - 3;
25
+ return p;
21
26
  },
22
- // position_from_event: function(event) {
23
- // return this.position_from_element(event);
24
- // },
25
27
  view: function() {
26
28
  var __entry = this.parent_view;
27
29
  var w = dom.div('#popover-delete').click(function() {
@@ -29,12 +31,12 @@ Spontaneous.Views.PieceView = (function($, S) {
29
31
  return false;
30
32
  });
31
33
 
32
- var ok = dom.a('.ok').text("Delete").click(function() {
34
+ var ok = dom.a('.ok').text('Delete').click(function() {
33
35
  __entry.destroy();
34
36
  return false;
35
37
  });
36
- var cancel = dom.a('.cancel').text("Cancel");
37
- w.append(cancel, ok)
38
+ var cancel = dom.a('.cancel').text('Cancel');
39
+ w.append(cancel, ok);
38
40
  return w;
39
41
  },
40
42
  scroll: true
@@ -46,7 +48,7 @@ Spontaneous.Views.PieceView = (function($, S) {
46
48
  this.container_view = container_view;
47
49
  },
48
50
  panel: function() {
49
- var wrapper = dom.div(['entry-wrap', this.depth_class(), this.visibility_class(), this.boxes_class()])
51
+ var wrapper = dom.div(['entry-wrap', this.fields_class(), this.alias_class(), this.depth_class(), this.visibility_class(), this.boxes_class()]);
50
52
  var contents = dom.div('.entry-contents');
51
53
  var inside = dom.div('.entry-inner');
52
54
  var outline = dom.div('.white-bg').
@@ -59,9 +61,9 @@ Spontaneous.Views.PieceView = (function($, S) {
59
61
  }
60
62
 
61
63
  if (!this.content.type().is_alias()) {
62
- wrapper.append(this.content_type_info());
64
+ contents.append(this.content_type_info());
63
65
  }
64
- contents.append( this.action_buttons(contents));
66
+ contents.append(this.action_buttons(contents));
65
67
  if (this.content.type().is_alias()) {
66
68
  contents.append(this.alias_target_panel());
67
69
  }
@@ -69,8 +71,9 @@ Spontaneous.Views.PieceView = (function($, S) {
69
71
  // contents.append(this.dialogue_box);
70
72
  var entry = dom.div('.entry');
71
73
  var fields = new Spontaneous.FieldPreview(this, '', true);
74
+ var fields_panel;
72
75
  if (fields.has_fields()) {
73
- var fields_panel = fields.panel();
76
+ fields_panel = fields.panel();
74
77
  entry.append(fields_panel);
75
78
  }
76
79
  var box_container = new Spontaneous.BoxContainer(this.content);
@@ -94,7 +97,8 @@ Spontaneous.Views.PieceView = (function($, S) {
94
97
  return entry_spacer;
95
98
  },
96
99
  edit: function(focus_field) {
97
- this.wrapper.addClass('editing')
100
+ if (!this.content.has_fields()) { return; }
101
+ this.wrapper.addClass('editing');
98
102
  this.callSuper(focus_field);
99
103
  },
100
104
  edit_closed: function() {
@@ -103,46 +107,48 @@ Spontaneous.Views.PieceView = (function($, S) {
103
107
  },
104
108
  alias_target_panel: function() {
105
109
  var content = this.content,
106
- click = function() { S.Location.load_id(content.target().id); },
110
+ click = function() { S.Location.load_id(content.target().page_id); },
107
111
  wrap = dom.div('.alias-target').click(click),
108
112
  icon = content.alias_icon,
109
- type = dom.span(".content-type").text(content.type().display_title(content));
113
+ type = dom.span('.content-type').text(content.type().display_title(content));
110
114
  title = dom.a().html(content.content.alias_title);
111
115
 
112
116
  if (!content.has_fields()) { wrap.addClass('no-fields'); }
113
117
 
114
118
  if (icon) {
115
119
  var img = new Spontaneous.Image(icon);
116
- wrap.append(img.icon(60, 60).click(click))
120
+ wrap.append(img.icon(60, 60).click(click));
117
121
  }
118
122
 
119
- return wrap.append(title, type)
123
+ return wrap.append(title, type);
120
124
  },
121
125
  content_type_info: function() {
122
- var type = dom.div(".content-type.piece").text(this.content.type().display_title(this.content));
126
+ var type = dom.div('.content-type.piece').text(this.content.type().display_title(this.content));
123
127
  return type;
124
128
  },
125
129
  action_buttons: function(wrapper) {
126
- if (!this._title_bar) {
127
- var label = user.is_developer() ? dom.a('.developer.source').attr('href', this.content.developer_edit_url()).text(this.content.developer_description()) : (this.content.type().title);
128
- var action_buttons = dom.div('.title-bar');//.append(label);
129
- var actions = dom.div('.actions', {'xstyle':'display: none'});
130
- var destroy = dom.a('.delete');
131
- var visibility = dom.a('.visibility');
132
- actions.append(destroy);
133
- actions.append(visibility);
134
- action_buttons.append(actions);
135
- var _hide_pause;
136
- // wrapper.mouseenter(function() {
137
- // if (_hide_pause) { window.clearTimeout(_hide_pause); }
138
- // actions.slideDown(50);
139
- // }).mouseleave(function() {
140
- // _hide_pause = window.setTimeout(function() { actions.slideUp(100) }, 200);
141
- // });
142
- destroy.click(this.confirm_destroy.bind(this));
143
- this.content.watch('hidden', this.visibility_changed.bind(this));
144
- visibility.click(this.toggle_visibility.bind(this));
145
- this._action_buttons = action_buttons;
130
+ if (!this._action_buttons) {
131
+ if (this.content.container.isWritable()) {
132
+ // var label = user.is_developer() ? dom.a('.developer.source').attr('href', this.content.developer_edit_url()).text(this.content.developer_description()) : (this.content.type().title);
133
+ var action_buttons = dom.div('.title-bar');//.append(label);
134
+ var actions = dom.div('.actions');
135
+ var destroy = dom.a('.delete');
136
+ var visibility = dom.a('.visibility');
137
+ actions.append(destroy);
138
+ actions.append(visibility);
139
+ action_buttons.append(actions);
140
+ var _hide_pause;
141
+ // wrapper.mouseenter(function() {
142
+ // if (_hide_pause) { window.clearTimeout(_hide_pause); }
143
+ // actions.slideDown(50);
144
+ // }).mouseleave(function() {
145
+ // _hide_pause = window.setTimeout(function() { actions.slideUp(100) }, 200);
146
+ // });
147
+ destroy.click(this.confirm_destroy.bind(this));
148
+ this.content.watch('hidden', this.visibility_changed.bind(this));
149
+ visibility.click(this.toggle_visibility.bind(this));
150
+ this._action_buttons = action_buttons;
151
+ }
146
152
  }
147
153
  return this._action_buttons;
148
154
  },
@@ -163,6 +169,7 @@ Spontaneous.Views.PieceView = (function($, S) {
163
169
  }
164
170
  },
165
171
  mouseover: function() {
172
+ if (!this.content.has_fields()) { return; }
166
173
  this.outline.addClass('active');
167
174
  if (this.fields_preview) {
168
175
  this.fields_preview.addClass('hover');
@@ -9,6 +9,7 @@
9
9
 
10
10
  <link rel="stylesheet" href="<%= style_url("spontaneous") %>" type="text/css" media="screen" charset="utf-8" />
11
11
  <script type="text/javascript" charset="utf-8" src="<%= script_url("vendor/jquery") %>"></script>
12
+ <script type="text/javascript" charset="utf-8" src="<%= script_url("vendor/jquery.velocity.min") %>"></script>
12
13
  <script type="text/javascript" charset="utf-8">
13
14
  Spontaneous = {
14
15
  site_domain: '<%= Spontaneous::Site.config.site_domain %>',
@@ -2,6 +2,7 @@
2
2
  require 'logger'
3
3
  require 'spontaneous'
4
4
  require 'benchmark'
5
+ require 'spontaneous/publishing/revision'
5
6
 
6
7
  Sequel.migration do
7
8
  ::ContentTable = S::DataMapper::ContentTable unless defined?(::ContentTable)
@@ -23,7 +24,7 @@ Sequel.migration do
23
24
 
24
25
  [revision_table, archive_table].each do |table|
25
26
  drop_table?(table)
26
- run %(CREATE TABLE #{literal(table)} AS (SELECT * FROM #{literal(content_table)} LIMIT 1);)
27
+ Spontaneous::Publishing.create_content_table(self, content_table, table)
27
28
  end
28
29
 
29
30