spontaneous 0.2.0.alpha2 → 0.2.0.alpha3

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.
Files changed (404) hide show
  1. data/Gemfile +3 -40
  2. data/Rakefile +29 -41
  3. data/Readme.markdown +21 -8
  4. data/application/css/add_alias_dialogue.css.scss +79 -0
  5. data/application/css/{v2.scss → core.css.scss} +537 -550
  6. data/application/css/{definitions.scss → definitions.css.scss} +121 -33
  7. data/application/css/dialogue.css.scss +409 -0
  8. data/application/css/{editing.scss → editing.css.scss} +25 -262
  9. data/application/css/font.css.scss +8 -0
  10. data/application/css/jquery-ui-1.8.21.custom/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  11. data/application/css/jquery-ui-1.8.21.custom/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  12. data/application/css/jquery-ui-1.8.21.custom/images/ui-bg_flat_10_000000_40x100.png +0 -0
  13. data/application/css/jquery-ui-1.8.21.custom/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  14. data/application/css/jquery-ui-1.8.21.custom/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  15. data/application/css/jquery-ui-1.8.21.custom/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  16. data/application/css/jquery-ui-1.8.21.custom/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  17. data/application/css/jquery-ui-1.8.21.custom/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  18. data/application/css/jquery-ui-1.8.21.custom/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  19. data/application/css/jquery-ui-1.8.21.custom/images/ui-icons_222222_256x240.png +0 -0
  20. data/application/css/jquery-ui-1.8.21.custom/images/ui-icons_228ef1_256x240.png +0 -0
  21. data/application/css/jquery-ui-1.8.21.custom/images/ui-icons_ef8c08_256x240.png +0 -0
  22. data/application/css/jquery-ui-1.8.21.custom/images/ui-icons_ffd27a_256x240.png +0 -0
  23. data/application/css/jquery-ui-1.8.21.custom/images/ui-icons_ffffff_256x240.png +0 -0
  24. data/application/css/jquery-ui-1.8.21.custom/ui-lightness.css.scss +565 -0
  25. data/application/css/{login.scss → login.css.scss} +4 -4
  26. data/application/css/meta.css.scss +331 -0
  27. data/application/css/{popover.scss → popover.css.scss} +9 -8
  28. data/application/css/{schema_error.scss → schema_error.css.scss} +4 -4
  29. data/application/css/spontaneous.css +5 -0
  30. data/application/css/unsupported.css.scss +42 -0
  31. data/application/js/add_alias_dialogue.js +72 -10
  32. data/application/js/ajax.js +50 -16
  33. data/application/js/compatibility.js +19 -15
  34. data/application/js/content.js +39 -36
  35. data/application/js/content_area.js +53 -5
  36. data/application/js/dialogue.js +17 -0
  37. data/application/js/dom.js +1 -1
  38. data/application/js/edit_panel.js +23 -8
  39. data/application/js/extensions.js +7 -2
  40. data/application/js/field_preview.js +2 -1
  41. data/application/js/field_types/date_field.js +11 -8
  42. data/application/js/field_types/file_field.js +188 -9
  43. data/application/js/field_types/image_field.js +46 -29
  44. data/application/js/field_types/markdown_field.js +57 -14
  45. data/application/js/field_types/select_field.js +72 -0
  46. data/application/js/field_types/string_field.js +8 -0
  47. data/application/js/field_types/webvideo_field.js +8 -0
  48. data/application/js/init.js +1 -7
  49. data/application/js/location.js +41 -13
  50. data/application/js/login.js +3 -0
  51. data/application/js/meta_view/user_admin.js +543 -0
  52. data/application/js/meta_view.js +1 -0
  53. data/application/js/metadata.js +20 -0
  54. data/application/js/page.js +17 -3
  55. data/application/js/page_browser.js +40 -30
  56. data/application/js/page_entry.js +4 -0
  57. data/application/js/panel/root_menu.js +66 -0
  58. data/application/js/popover.js +2 -2
  59. data/application/js/preview.js +1 -1
  60. data/application/js/publish.js +138 -30
  61. data/application/js/services.js +43 -0
  62. data/application/js/sharded_upload.js +2 -2
  63. data/application/js/spontaneous.js +64 -5
  64. data/application/js/state.js +20 -9
  65. data/application/js/top_bar.js +273 -150
  66. data/application/js/types.js +20 -15
  67. data/application/js/upload.js +1 -2
  68. data/application/js/user.js +18 -4
  69. data/application/js/vendor/date.js +104 -0
  70. data/application/js/vendor/jquery-ui-1.8.18.custom.min.js +356 -0
  71. data/application/js/views/box_view.js +15 -8
  72. data/application/js/views/page_piece_view.js +11 -8
  73. data/application/js/views/page_view.js +21 -3
  74. data/application/js/views/piece_view.js +19 -10
  75. data/application/js/views.js +3 -0
  76. data/application/static/chromelogo-200x52-45c7cbc93be080bea342df5fcda2ef8b.png +0 -0
  77. data/application/static/dot-texture-9eea29e4ac7ad9a772285252078ec127.png +0 -0
  78. data/application/static/editing-textarea-resize-s-b5af62365eb7e19ea4beccf7242d508e.png +0 -0
  79. data/application/static/editing-texture-1-42b06a3439752490988f30f2a06d5e7c.png +0 -0
  80. data/application/static/font/fontawesome-webfont-5c5c21100a346972a82c34c5e96ffcfe.ttf +0 -0
  81. data/application/static/loop_alt1-white-7894b458528e92216196cae26b4c2c96.svg +12 -0
  82. data/application/static/spontaneous-states-e91ec89db525c62da0105b97cdd781ce.png +0 -0
  83. data/application/views/index.erb +2 -2
  84. data/application/views/login.erb +4 -8
  85. data/application/views/schema_modification_error.html.erb +1 -4
  86. data/application/views/unsupported.erb +9 -7
  87. data/bin/spot +1 -1
  88. data/db/migrations/20110209152710_users_and_groups.rb +10 -10
  89. data/db/migrations/20120305112647_site_modification_time.rb +11 -0
  90. data/db/migrations/20120418153903_add_ownership_of_content.rb +14 -0
  91. data/db/migrations/20120423175416_add_pending_modifications.rb +21 -0
  92. data/db/migrations/20120525164947_add_field_versions.rb +27 -0
  93. data/lib/sequel/plugins/scoped_table_name.rb +10 -1
  94. data/lib/spontaneous/asset/file.rb +25 -0
  95. data/lib/spontaneous/asset/source.rb +28 -0
  96. data/lib/spontaneous/asset.rb +75 -0
  97. data/lib/spontaneous/box.rb +6 -4
  98. data/lib/spontaneous/capistrano/deploy.rb +47 -0
  99. data/lib/spontaneous/capistrano/sync.rb +81 -0
  100. data/lib/spontaneous/capistrano.rb +13 -0
  101. data/lib/spontaneous/change.rb +60 -68
  102. data/lib/spontaneous/cli/assets.rb +29 -0
  103. data/lib/spontaneous/cli/base.rb +0 -48
  104. data/lib/spontaneous/cli/console.rb +1 -1
  105. data/lib/spontaneous/cli/server.rb +6 -4
  106. data/lib/spontaneous/cli/site.rb +28 -17
  107. data/lib/spontaneous/cli/user.rb +107 -0
  108. data/lib/spontaneous/cli.rb +100 -4
  109. data/lib/spontaneous/collections/entry_set.rb +2 -2
  110. data/lib/spontaneous/collections/field_set.rb +48 -22
  111. data/lib/spontaneous/collections/prototype_set.rb +20 -13
  112. data/lib/spontaneous/constants.rb +3 -0
  113. data/lib/spontaneous/content.rb +22 -5
  114. data/lib/spontaneous/errors.rb +3 -3
  115. data/lib/spontaneous/extensions/array.rb +12 -0
  116. data/lib/spontaneous/extensions/enumerable.rb +30 -0
  117. data/lib/spontaneous/extensions/nil.rb +3 -1
  118. data/lib/spontaneous/extensions/string.rb +16 -0
  119. data/lib/spontaneous/field_types/date_field.rb +45 -2
  120. data/lib/spontaneous/field_types/field.rb +42 -9
  121. data/lib/spontaneous/field_types/file_field.rb +68 -0
  122. data/lib/spontaneous/field_types/image_field.rb +63 -0
  123. data/lib/spontaneous/field_types/select_field.rb +109 -0
  124. data/lib/spontaneous/field_types/string_field.rb +6 -1
  125. data/lib/spontaneous/field_types/webvideo_field.rb +85 -27
  126. data/lib/spontaneous/field_types.rb +1 -1
  127. data/lib/spontaneous/field_version.rb +8 -0
  128. data/lib/spontaneous/generators/page.rb +1 -1
  129. data/lib/spontaneous/generators/site/Capfile.tt +1 -4
  130. data/lib/spontaneous/generators/site/Gemfile.tt +13 -6
  131. data/lib/spontaneous/generators/site/config/deploy.rb.tt +28 -0
  132. data/lib/spontaneous/generators/site/config/environments/production.rb.tt +7 -2
  133. data/lib/spontaneous/generators/site.rb +1 -0
  134. data/lib/spontaneous/json.rb +34 -11
  135. data/lib/spontaneous/layout.rb +22 -0
  136. data/lib/spontaneous/media/file.rb +4 -0
  137. data/lib/spontaneous/output/assets/compression.rb +58 -0
  138. data/lib/spontaneous/output/assets.rb +32 -0
  139. data/lib/spontaneous/output/context.rb +179 -0
  140. data/lib/spontaneous/output/format/html.rb +5 -0
  141. data/lib/spontaneous/output/format/plain.rb +5 -0
  142. data/lib/spontaneous/output/format.rb +180 -0
  143. data/lib/spontaneous/output/helpers/classes_helper.rb +18 -0
  144. data/lib/spontaneous/{render/helpers/html_helper.rb → output/helpers/conditional_comment_helper.rb} +3 -12
  145. data/lib/spontaneous/output/helpers/script_helper.rb +73 -0
  146. data/lib/spontaneous/output/helpers/stylesheet_helper.rb +61 -0
  147. data/lib/spontaneous/output/helpers.rb +28 -0
  148. data/lib/spontaneous/output/template/engine.rb +59 -0
  149. data/lib/spontaneous/output/template/renderer.rb +153 -0
  150. data/lib/spontaneous/output/template.rb +21 -0
  151. data/lib/spontaneous/output.rb +163 -0
  152. data/lib/spontaneous/page.rb +2 -1
  153. data/lib/spontaneous/paths.rb +6 -1
  154. data/lib/spontaneous/permissions/access_key.rb +5 -5
  155. data/lib/spontaneous/permissions/user.rb +81 -35
  156. data/lib/spontaneous/permissions/user_level.rb +26 -22
  157. data/lib/spontaneous/plugins/aliases.rb +76 -12
  158. data/lib/spontaneous/plugins/allowed_types.rb +60 -18
  159. data/lib/spontaneous/plugins/application/paths.rb +0 -28
  160. data/lib/spontaneous/plugins/application/system.rb +35 -0
  161. data/lib/spontaneous/plugins/boxes.rb +4 -0
  162. data/lib/spontaneous/plugins/content_groups.rb +16 -0
  163. data/lib/spontaneous/plugins/entries.rb +50 -30
  164. data/lib/spontaneous/plugins/fields.rb +15 -0
  165. data/lib/spontaneous/plugins/layouts.rb +8 -2
  166. data/lib/spontaneous/plugins/modifications.rb +228 -0
  167. data/lib/spontaneous/plugins/page/formats.rb +67 -42
  168. data/lib/spontaneous/plugins/page/request.rb +10 -0
  169. data/lib/spontaneous/plugins/page/site_timestamps.rb +28 -0
  170. data/lib/spontaneous/plugins/paths.rb +15 -3
  171. data/lib/spontaneous/plugins/publishing.rb +124 -45
  172. data/lib/spontaneous/plugins/render.rb +13 -8
  173. data/lib/spontaneous/plugins/schema_hierarchy.rb +18 -6
  174. data/lib/spontaneous/plugins/site/helpers.rb +53 -0
  175. data/lib/spontaneous/plugins/site/hooks.rb +50 -0
  176. data/lib/spontaneous/plugins/site/map.rb +1 -1
  177. data/lib/spontaneous/plugins/site/paths.rb +13 -0
  178. data/lib/spontaneous/plugins/site/publishing.rb +6 -2
  179. data/lib/spontaneous/plugins/site/{revisions.rb → state.rb} +5 -1
  180. data/lib/spontaneous/plugins/site/storage.rb +4 -0
  181. data/lib/spontaneous/plugins/site/url.rb +15 -0
  182. data/lib/spontaneous/plugins/site_map.rb +13 -3
  183. data/lib/spontaneous/plugins/styles.rb +5 -1
  184. data/lib/spontaneous/plugins/visibility.rb +39 -12
  185. data/lib/spontaneous/prototypes/box_prototype.rb +4 -0
  186. data/lib/spontaneous/prototypes/field_prototype.rb +15 -10
  187. data/lib/spontaneous/publishing/event_client.rb +46 -0
  188. data/lib/spontaneous/publishing/immediate.rb +81 -44
  189. data/lib/spontaneous/publishing/simultaneous.rb +23 -6
  190. data/lib/spontaneous/publishing.rb +4 -3
  191. data/lib/spontaneous/rack/around_back.rb +1 -5
  192. data/lib/spontaneous/rack/around_front.rb +4 -4
  193. data/lib/spontaneous/rack/around_preview.rb +4 -3
  194. data/lib/spontaneous/rack/assets.rb +81 -54
  195. data/lib/spontaneous/rack/authentication.rb +0 -1
  196. data/lib/spontaneous/rack/back.rb +160 -72
  197. data/lib/spontaneous/rack/cookie_authentication.rb +2 -2
  198. data/lib/spontaneous/rack/css.rb +18 -15
  199. data/lib/spontaneous/rack/event_source.rb +9 -21
  200. data/lib/spontaneous/rack/fiber_pool.rb +26 -0
  201. data/lib/spontaneous/rack/front.rb +12 -4
  202. data/lib/spontaneous/rack/helpers.rb +35 -13
  203. data/lib/spontaneous/rack/js.rb +41 -0
  204. data/lib/spontaneous/rack/public.rb +34 -44
  205. data/lib/spontaneous/rack/sse.rb +18 -0
  206. data/lib/spontaneous/rack/static.rb +3 -0
  207. data/lib/spontaneous/rack/user_admin.rb +100 -0
  208. data/lib/spontaneous/rack/user_helpers.rb +1 -1
  209. data/lib/spontaneous/rack.rb +6 -2
  210. data/lib/spontaneous/schema.rb +31 -4
  211. data/lib/spontaneous/search/index.rb +19 -3
  212. data/lib/spontaneous/search/results.rb +1 -1
  213. data/lib/spontaneous/sequel.rb +17 -0
  214. data/lib/spontaneous/site.rb +11 -4
  215. data/lib/spontaneous/state.rb +11 -0
  216. data/lib/spontaneous/storage/cloud.rb +4 -0
  217. data/lib/spontaneous/storage/local.rb +11 -0
  218. data/lib/spontaneous/style.rb +2 -2
  219. data/lib/spontaneous/tasks/database.rake +21 -22
  220. data/lib/spontaneous/utils/database/mysql_dumper.rb +4 -0
  221. data/lib/spontaneous/utils/database/postgres_dumper.rb +78 -0
  222. data/lib/spontaneous/utils/database.rb +6 -3
  223. data/lib/spontaneous/utils/smart_quotes.rb +499 -0
  224. data/lib/spontaneous/utils/smush_it.rb +66 -0
  225. data/lib/spontaneous/utils.rb +3 -1
  226. data/lib/spontaneous/version.rb +2 -2
  227. data/lib/spontaneous.rb +25 -29
  228. data/spontaneous.gemspec +186 -106
  229. data/test/experimental/test_features.rb +1 -1
  230. data/test/fixtures/asset_pipeline/application/css/basic.css.scss +4 -0
  231. data/test/fixtures/asset_pipeline/application/css/complex.css.scss.erb +6 -0
  232. data/test/fixtures/asset_pipeline/application/css/simple.css +3 -0
  233. data/test/fixtures/asset_pipeline/application/css/spontaneous.css +7 -0
  234. data/test/fixtures/asset_pipeline/application/css/subdir/complex.css.scss.erb +6 -0
  235. data/test/fixtures/asset_pipeline/application/css/subdir/library.css.scss +1 -0
  236. data/test/fixtures/asset_pipeline/application/css/subdir/simple.css +3 -0
  237. data/test/fixtures/asset_pipeline/application/js/basic.js.coffee +1 -0
  238. data/test/fixtures/asset_pipeline/application/js/complex.js.coffee.erb +1 -0
  239. data/test/fixtures/asset_pipeline/application/js/login.js +1 -0
  240. data/test/fixtures/asset_pipeline/application/js/require.js +1 -0
  241. data/test/fixtures/asset_pipeline/application/js/simple.js +1 -0
  242. data/test/fixtures/asset_pipeline/application/js/spontaneous.js +5 -0
  243. data/test/fixtures/asset_pipeline/application/js/subdir/complex.js.coffee.erb +1 -0
  244. data/test/fixtures/asset_pipeline/application/js/subdir/library.js.coffee +1 -0
  245. data/test/fixtures/asset_pipeline/application/js/subdir/simple.js +1 -0
  246. data/test/fixtures/asset_pipeline/application/js/vendor/jquery.js +1 -0
  247. data/test/fixtures/asset_pipeline/application/static/dot-texture.png +0 -0
  248. data/test/fixtures/asset_pipeline/application/static/subdir/px.gif +0 -0
  249. data/test/fixtures/assets/public1/css/a.scss +1 -0
  250. data/test/fixtures/assets/public1/js/a.js +1 -0
  251. data/test/fixtures/assets/public1/js/m.coffee +1 -0
  252. data/test/fixtures/assets/public2/css/b.scss +1 -0
  253. data/test/fixtures/assets/public2/css/c.css +1 -0
  254. data/test/fixtures/assets/public2/js/b.js +1 -0
  255. data/test/fixtures/assets/public2/js/c.js +1 -0
  256. data/test/fixtures/assets/public2/js/n.coffee +1 -0
  257. data/test/fixtures/back/config/user_levels.yml +3 -0
  258. data/test/fixtures/back/public/js/coffeescript.coffee +1 -0
  259. data/test/fixtures/back/templates/layouts/standard.css.cut +1 -0
  260. data/test/fixtures/back/templates/layouts/standard.js.cut +1 -0
  261. data/test/fixtures/example_application/config/database.yml +4 -4
  262. data/test/fixtures/helpers/templates/layouts/standard.html.cut +1 -0
  263. data/test/fixtures/helpers/templates/layouts/standard.mobile.cut +1 -0
  264. data/test/fixtures/images/vimlogo.pdf +0 -0
  265. data/test/fixtures/outputs/templates/layouts/standard.atom.cut +1 -0
  266. data/test/fixtures/permissions/config/user_levels.yml +6 -3
  267. data/test/fixtures/serialisation/class_hash.yaml.erb +1 -0
  268. data/test/fixtures/serialisation/root_hash.yaml.erb +2 -2
  269. data/test/fixtures/templates/extended/grandparent.html.cut +7 -7
  270. data/test/fixtures/templates/extended/main.html.cut +5 -5
  271. data/test/fixtures/templates/extended/parent.html.cut +8 -8
  272. data/test/fixtures/templates/extended/partial_with_locals.html.cut +1 -1
  273. data/test/fixtures/templates/extended/with_includes.html.cut +6 -6
  274. data/test/fixtures/templates/extended/with_includes_and_locals.html.cut +6 -7
  275. data/test/fixtures/templates/layouts/entries.html.cut +4 -4
  276. data/test/fixtures/templates/layouts/standard.html.cut +1 -0
  277. data/test/fixtures/templates/layouts/variables.html.cut +1 -1
  278. data/test/fixtures/templates/publishing/templates/layouts/static.html.cut +1 -1
  279. data/test/fixtures/templates/publishing/templates/layouts/static.rtf.cut +1 -0
  280. data/test/fixtures/templates/template_class/complex_template.html.cut +2 -2
  281. data/test/fixtures/templates/template_class/complex_template.pdf.cut +2 -2
  282. data/test/fixtures/templates/template_class/default_template_style.html.cut +1 -1
  283. data/test/fixtures/templates/template_class/images_with_template.html.cut +2 -2
  284. data/test/fixtures/templates/template_class/slots_template.html.cut +2 -2
  285. data/test/fixtures/templates/template_class/slots_template.pdf.cut +2 -2
  286. data/test/fixtures/user_manager/config/user_levels.yml +9 -0
  287. data/test/functional/test_application.rb +7 -7
  288. data/test/functional/test_back.rb +352 -97
  289. data/test/functional/test_front.rb +71 -20
  290. data/test/functional/test_user_manager.rb +284 -0
  291. data/test/javascript/env.js +13505 -0
  292. data/test/javascript/test_markdown.rb +43 -3
  293. data/test/support/custom_matchers.rb +3 -2
  294. data/test/test_helper.rb +50 -9
  295. data/test/test_javascript.rb +13 -13
  296. data/test/ui_helper.rb +1 -1
  297. data/test/unit/test_alias.rb +79 -8
  298. data/test/unit/test_asset_bundler.rb +220 -0
  299. data/test/unit/test_assets.rb +213 -0
  300. data/test/unit/test_async.rb +55 -0
  301. data/test/unit/test_authentication.rb +52 -39
  302. data/test/unit/test_boxes.rb +20 -15
  303. data/test/unit/test_changesets.rb +261 -0
  304. data/test/unit/test_content.rb +73 -33
  305. data/test/unit/test_content_inheritance.rb +18 -18
  306. data/test/unit/test_extensions.rb +26 -0
  307. data/test/unit/test_fields.rb +303 -16
  308. data/test/unit/test_formats.rb +267 -34
  309. data/test/unit/test_helpers.rb +79 -2
  310. data/test/unit/test_images.rb +10 -0
  311. data/test/unit/test_layouts.rb +21 -13
  312. data/test/unit/test_modifications.rb +648 -0
  313. data/test/unit/test_page.rb +6 -2
  314. data/test/unit/test_permissions.rb +101 -27
  315. data/test/unit/test_piece.rb +4 -4
  316. data/test/unit/test_plugins.rb +3 -2
  317. data/test/unit/test_publishing.rb +332 -0
  318. data/test/unit/test_render.rb +118 -67
  319. data/test/unit/test_revisions.rb +546 -0
  320. data/test/unit/test_schema.rb +83 -1
  321. data/test/unit/test_search.rb +59 -0
  322. data/test/unit/test_serialisation.rb +2 -47
  323. data/test/unit/test_site.rb +217 -108
  324. data/test/unit/test_storage.rb +26 -0
  325. data/test/unit/test_structure.rb +2 -2
  326. data/test/unit/test_styles.rb +90 -75
  327. data/test/unit/test_table_scoping.rb +21 -17
  328. data/test/unit/test_templates.rb +75 -69
  329. data/test/{slow → unit}/test_visibility.rb +78 -22
  330. metadata +528 -221
  331. data/application/css/add_alias_dialogue.scss +0 -27
  332. data/application/css/min/14c2a35812c443001b15d8b12a4780f88c678035.css +0 -1
  333. data/application/css/min/565d4c25e82148acb01c45c8d675b37a08676d77.css +0 -1
  334. data/application/css/min/84dbe894ea96eafd321c30823d630817bfc4b03b.css +0 -1
  335. data/application/css/spontaneous.scss +0 -111
  336. data/application/css/unsupported.scss +0 -16
  337. data/application/css/variables.scss +0 -80
  338. data/application/js/min/2a0c2962537a3181fedfff5c92596ba6d3122dc9.js +0 -3
  339. data/application/js/min/4cf1c493d3379ecba5287758c61238034c0893f9.js +0 -2
  340. data/application/js/min/78ac6b99d96750bb6b9f9aad4cb9cd91cd03f391.js +0 -3
  341. data/application/js/min/b8abf302a824c35385ff517b34111e1710ff3b37.js +0 -2
  342. data/application/js/min/c8efb9b9f7c3f6613fcebc6be60f605b6570a382.js +0 -90
  343. data/application/static/diagonal-texture.png +0 -0
  344. data/application/static/editing-0-noise.png +0 -0
  345. data/application/static/editing-1-noise.png +0 -0
  346. data/application/static/editing-texture-1.png +0 -0
  347. data/application/static/editing-texture.png +0 -0
  348. data/application/static/editing-toolbar-shadow-bottom.png +0 -0
  349. data/application/static/editing-toolbar-shadow-top.png +0 -0
  350. data/application/static/inner-glow.png +0 -0
  351. data/application/static/item-buttons-highlight.png +0 -0
  352. data/application/static/item-buttons.png +0 -0
  353. data/application/static/paper-texture-dark.png +0 -0
  354. data/application/static/plus_alt.svg +0 -8
  355. data/application/static/select-arrow-root.png +0 -0
  356. data/application/static/slot-up-arrow.png +0 -0
  357. data/application/static/spontaneous.png +0 -0
  358. data/lib/cutaneous/context_helper.rb +0 -187
  359. data/lib/cutaneous/preview_context.rb +0 -32
  360. data/lib/cutaneous/preview_renderer.rb +0 -10
  361. data/lib/cutaneous/publish_context.rb +0 -10
  362. data/lib/cutaneous/publish_renderer.rb +0 -14
  363. data/lib/cutaneous/publish_template.rb +0 -62
  364. data/lib/cutaneous/publish_token_parser.rb +0 -8
  365. data/lib/cutaneous/renderer.rb +0 -124
  366. data/lib/cutaneous/request_context.rb +0 -9
  367. data/lib/cutaneous/request_renderer.rb +0 -15
  368. data/lib/cutaneous/request_template.rb +0 -11
  369. data/lib/cutaneous/request_token_parser.rb +0 -9
  370. data/lib/cutaneous/token_parser.rb +0 -125
  371. data/lib/cutaneous.rb +0 -48
  372. data/lib/spontaneous/render/context_base.rb +0 -143
  373. data/lib/spontaneous/render/development_renderer.rb +0 -14
  374. data/lib/spontaneous/render/engine.rb +0 -19
  375. data/lib/spontaneous/render/format/html.rb +0 -5
  376. data/lib/spontaneous/render/format.rb +0 -75
  377. data/lib/spontaneous/render/helpers/script_helper.rb +0 -17
  378. data/lib/spontaneous/render/helpers/stylesheet_helper.rb +0 -16
  379. data/lib/spontaneous/render/helpers.rb +0 -14
  380. data/lib/spontaneous/render/preview_context.rb +0 -8
  381. data/lib/spontaneous/render/preview_renderer.rb +0 -24
  382. data/lib/spontaneous/render/publish_context.rb +0 -22
  383. data/lib/spontaneous/render/published_renderer.rb +0 -53
  384. data/lib/spontaneous/render/publishing_renderer.rb +0 -16
  385. data/lib/spontaneous/render/render_cache.rb +0 -26
  386. data/lib/spontaneous/render/renderer.rb +0 -50
  387. data/lib/spontaneous/render/request_context.rb +0 -8
  388. data/lib/spontaneous/render.rb +0 -214
  389. data/test/experimental/test_cutaneous.rb +0 -309
  390. data/test/fixtures/application/css/test.less +0 -5
  391. data/test/slow/test_publishing.rb +0 -1006
  392. /data/application/css/{developer.scss → developer.css.scss} +0 -0
  393. /data/application/js/vendor/{jquery-1.7.1.min.js → jquery.js} +0 -0
  394. /data/application/static/{location-arrow.png → location-arrow-c1c1d3ca472481c61a0a5f8cb289d743.png} +0 -0
  395. /data/application/static/{missing.png → missing-911ce6dbd9f4602e0f3fbcd7e78846a2.png} +0 -0
  396. /data/application/static/{orange-down-arrow.png → orange-down-arrow-395ae1929e8662b2ff0977daf12c35bb.png} +0 -0
  397. /data/application/static/{page-browser-next.png → page-browser-next-ce781a242c23b980b99b9db7abc20b05.png} +0 -0
  398. /data/application/static/{plus-box.png → plus-box-dcde74a1e496f68298c9b443caa1c5d5.png} +0 -0
  399. /data/application/static/{select-arrow.png → select-arrow-6e7dd3745b00e934b0d7a3250c46558b.png} +0 -0
  400. /data/application/static/{slot-down-arrow.png → slot-down-arrow-59ad5f5ee5b52a7ebd00bca4b3104194.png} +0 -0
  401. /data/application/static/{splash.png → splash-65b493a714df9b8b3ab170103401b53d.png} +0 -0
  402. /data/application/static/{spot.png → spot-71fab1d2f065034f5fc15e7bea2ad36c.png} +0 -0
  403. /data/application/static/{spot.svg → spot-8505041082d8d3bbe8d34c29dddb3b7d.svg} +0 -0
  404. /data/application/static/{texture.png → texture-03f7627e8264b1d607113ab32c593a58.png} +0 -0
@@ -0,0 +1,546 @@
1
+ # encoding: UTF-8
2
+
3
+ require File.expand_path('../../test_helper', __FILE__)
4
+
5
+
6
+ class RevisionsTest < MiniTest::Spec
7
+
8
+ def setup
9
+ @now = Time.now
10
+ @site = setup_site
11
+ end
12
+
13
+ def teardown
14
+ teardown_site
15
+ end
16
+
17
+ context "Content revisions" do
18
+ setup do
19
+ stub_time(@now)
20
+
21
+ Content.delete
22
+
23
+ class Page < Spontaneous::Page
24
+ field :title, :string, :default => "New Page"
25
+ box :things
26
+ end
27
+ class Piece < Spontaneous::Piece
28
+ box :things
29
+ end
30
+
31
+ @root = Page.create(:uid => "root")
32
+ count = 0
33
+ 2.times do |i|
34
+ c = Page.new(:uid => i)
35
+ @root.things << c
36
+ count += 1
37
+ 2.times do |j|
38
+ d = Piece.new(:uid => "#{i}.#{j}")
39
+ c.things << d
40
+ count += 1
41
+ 2.times do |k|
42
+ d.things << Page.new(:uid => "#{i}.#{j}.#{k}")
43
+ d.save
44
+ count += 1
45
+ end
46
+ end
47
+ c.save
48
+ end
49
+ @root.save
50
+ end
51
+
52
+ teardown do
53
+ RevisionsTest.send(:remove_const, :Page) rescue nil
54
+ RevisionsTest.send(:remove_const, :Piece) rescue nil
55
+ Content.delete
56
+ DB.logger = nil
57
+ end
58
+
59
+ context "data sources" do
60
+
61
+ should "have the right names" do
62
+ Content.revision_table(23).should == '__r00023_content'
63
+ Content.revision_table(nil).should == 'content'
64
+ end
65
+
66
+ should "be recognisable" do
67
+ Content.revision_table?('content').should be_false
68
+ Content.revision_table?('__r00023_content').should be_true
69
+ Content.revision_table?('__r00023_not').should be_false
70
+ Content.revision_table?('subscribers').should be_false
71
+ end
72
+
73
+ should "be switchable within blocks" do
74
+ Content.dataset.should be_content_revision
75
+ Content.with_revision(23) do
76
+ Content.revision.should ==23
77
+ Content.dataset.should be_content_revision(23)
78
+ end
79
+ Content.dataset.should be_content_revision
80
+ Content.revision.should be_nil
81
+ end
82
+
83
+ should "know which revision is active" do
84
+ Content.with_revision(23) do
85
+ Content.revision.should == 23
86
+ end
87
+ end
88
+
89
+ should "understand the with_editable" do
90
+ Content.with_revision(23) do
91
+ Content.dataset.should be_content_revision(23)
92
+ Content.with_editable do
93
+ Content.dataset.should be_content_revision
94
+ end
95
+ Content.dataset.should be_content_revision(23)
96
+ end
97
+ Content.dataset.should be_content_revision
98
+ end
99
+
100
+ should "understand with_published" do
101
+ Site.stubs(:published_revision).returns(99)
102
+ Content.with_published do
103
+ Content.dataset.should be_content_revision(99)
104
+ Content.with_editable do
105
+ Content.dataset.should be_content_revision
106
+ end
107
+ Content.dataset.should be_content_revision(99)
108
+ end
109
+ Content.dataset.should be_content_revision
110
+ end
111
+
112
+ should "be stackable" do
113
+ Content.dataset.should be_content_revision
114
+ Content.with_revision(23) do
115
+ Content.dataset.should be_content_revision(23)
116
+ Content.with_revision(24) do
117
+ Content.dataset.should be_content_revision(24)
118
+ end
119
+ Content.dataset.should be_content_revision(23)
120
+ end
121
+ Content.dataset.should be_content_revision
122
+ end
123
+
124
+ should "reset datasource after an exception" do
125
+ Content.dataset.should be_content_revision
126
+ begin
127
+ Content.with_revision(23) do
128
+ Content.dataset.should be_content_revision(23)
129
+ raise Exception.new
130
+ end
131
+ rescue Exception
132
+ end
133
+ Content.dataset.should be_content_revision
134
+ end
135
+
136
+ should "read revision from the environment if present" do
137
+ ENV["SPOT_REVISION"] = '1001'
138
+ Content.with_published do
139
+ Content.dataset.should be_content_revision(1001)
140
+ end
141
+ ENV.delete("SPOT_REVISION")
142
+ end
143
+
144
+ context "subclasses" do
145
+ setup do
146
+ class ::Subclass < Page; end
147
+ end
148
+
149
+ teardown do
150
+ Object.send(:remove_const, :Subclass)
151
+ end
152
+
153
+ should "set all subclasses to use the same dataset" do
154
+ Content.with_revision(23) do
155
+ Subclass.revision.should ==23
156
+ Subclass.dataset.should be_content_revision(23, Subclass.schema_id)
157
+ # piece wasn't loaded until this point
158
+ Piece.dataset.should be_content_revision(23)
159
+ Piece.revision.should == 23
160
+ end
161
+ Subclass.dataset.should be_content_revision(nil, Subclass.schema_id)
162
+ Piece.dataset.should be_content_revision(nil)
163
+ end
164
+ end
165
+ end
166
+
167
+ context "content revisions" do
168
+ setup do
169
+ @revision = 1
170
+ end
171
+ teardown do
172
+ Content.delete_revision(@revision)
173
+ Content.delete_revision(@revision+1) rescue nil
174
+ end
175
+ should "be testable for existance" do
176
+ Content.revision_exists?(@revision).should be_false
177
+ Content.create_revision(@revision)
178
+ Content.revision_exists?(@revision).should be_true
179
+ end
180
+ should "be deletable en masse" do
181
+ tables = (1..10).map { |i| Content.revision_table(i).to_sym }
182
+ tables.each do |t|
183
+ DB.create_table(t){Integer :id}
184
+ end
185
+ tables.each do |t|
186
+ DB.tables.include?(t).should be_true
187
+ end
188
+ Content.delete_all_revisions!
189
+ tables.each do |t|
190
+ DB.tables.include?(t).should be_false
191
+ end
192
+ end
193
+
194
+ should "be creatable from current content" do
195
+ DB.tables.include?(Content.revision_table(@revision).to_sym).should be_false
196
+ Content.create_revision(@revision)
197
+ DB.tables.include?(Content.revision_table(@revision).to_sym).should be_true
198
+ count = Content.count
199
+ Content.with_revision(@revision) do
200
+ Content.count.should == count
201
+ Content.all.each do |published|
202
+ Content.with_editable do
203
+ e = Content[published.id]
204
+ e.should == published
205
+ end
206
+ end
207
+ end
208
+ end
209
+
210
+ should "be creatable from any revision" do
211
+ revision = 2
212
+ source_revision = @revision
213
+ source_revision_count = nil
214
+
215
+ Content.create_revision(source_revision)
216
+
217
+ Content.with_revision(source_revision) do
218
+ Content.first(:uid => "0").destroy
219
+ source_revision_count = Content.count
220
+ end
221
+
222
+ Content.count.should == source_revision_count + 7
223
+
224
+ Content.create_revision(revision, source_revision)
225
+
226
+ Content.with_revision(revision) do
227
+ Content.count.should == source_revision_count
228
+ Content.all.each do |published|
229
+
230
+ Content.with_revision(source_revision) do
231
+ e = Content.first :id => published.id
232
+ e.should == published
233
+ end
234
+ end
235
+ end
236
+ end
237
+
238
+ should "have the correct indexes" do
239
+ Content.create_revision(@revision)
240
+ content_indexes = DB.indexes(:content)
241
+ published_indexes = DB.indexes(Content.revision_table(@revision))
242
+ # made slightly complex by the fact that the index names depend on the table names
243
+ # (which are different)
244
+ assert_same_elements published_indexes.values, content_indexes.values
245
+ end
246
+
247
+
248
+ context "incremental publishing" do
249
+ setup do
250
+ @initial_revision = 1
251
+ @final_revision = 2
252
+ Content.create_revision(@initial_revision)
253
+ Content.delete_revision(@final_revision) rescue nil
254
+ Content.delete_revision(@final_revision+1) rescue nil
255
+ end
256
+
257
+ teardown do
258
+ begin
259
+ Content.delete_revision(@initial_revision)
260
+ Content.delete_revision(@final_revision)
261
+ Content.delete_revision(@final_revision+1)
262
+ rescue
263
+ end
264
+ DB.logger = nil
265
+ end
266
+
267
+ should "duplicate changes to only a single item" do
268
+ editable1 = Content.first(:uid => '1.0')
269
+ editable1.label.should be_nil
270
+ editable1.label = "published"
271
+ editable1.save
272
+ editable2 = Content.first(:uid => '1.1')
273
+ editable2.label = "unpublished"
274
+ editable2.save
275
+ editable2.reload
276
+ Content.publish(@final_revision, [editable1.id])
277
+ editable1.reload
278
+ Content.with_revision(@final_revision) do
279
+ published = Content.first :id => editable1.id
280
+ unpublished = Content.first :id => editable2.id
281
+ assert_content_equal(published, editable1)
282
+
283
+ unpublished.should_not == editable2
284
+ end
285
+ end
286
+
287
+ should "publish additions to contents of a page" do
288
+ editable1 = Content.first(:uid => '0')
289
+ new_content = Piece.new(:uid => "new")
290
+
291
+ editable1.things << new_content
292
+ editable1.save
293
+ Content.publish(@final_revision, [editable1.id])
294
+ new_content.reload
295
+ editable1.reload
296
+ Content.with_revision(@final_revision) do
297
+ published1 = Content[editable1.id]
298
+ published2 = Content[new_content.id]
299
+ assert_content_equal(published2, new_content)
300
+ assert_content_equal(published1, editable1)
301
+ end
302
+ end
303
+
304
+ should "publish deletions to contents of page" do
305
+ editable1 = Content.first(:uid => '0')
306
+ deleted = editable1.contents.first
307
+ editable1.contents.first.destroy
308
+ Content.publish(@final_revision, [editable1.id])
309
+ editable1.reload
310
+ Content.with_revision(@final_revision) do
311
+ published1 = Content[editable1.id]
312
+ assert_content_equal(published1, editable1)
313
+ Content[deleted.id].should be_nil
314
+ end
315
+ end
316
+
317
+ should "not publish page additions" do
318
+ editable1 = Content.first(:uid => '0')
319
+ new_page = Page.new(:uid => "new")
320
+ editable1.things << new_page
321
+ editable1.save
322
+ new_page.save
323
+ Content.publish(@final_revision, [editable1.id])
324
+ new_page.reload
325
+ editable1.reload
326
+ Content.with_revision(@final_revision) do
327
+ published1 = Content[editable1.id]
328
+ published2 = Content[new_page.id]
329
+ published2.should be_nil
330
+ assert_content_equal(published1, editable1)
331
+ end
332
+ end
333
+
334
+ should "not publish changes to existing pages unless explicitly asked" do
335
+ editable1 = Content.first(:uid => '0')
336
+ editable1.things << Piece.new(:uid => "added")
337
+ editable1.save
338
+ editable2 = Content.first(:uid => '0.0.0')
339
+ new_content = Piece.new(:uid => "new")
340
+ editable2.things << new_content
341
+ editable2.save
342
+ Content.publish(@final_revision, [editable1.id])
343
+ editable1.reload
344
+ editable2.reload
345
+ new_content.reload
346
+ Content.with_revision(@final_revision) do
347
+ published1 = Content.first :id => editable1.id
348
+ Content.first(:uid => "added").should_not be_nil
349
+ published3 = Content.first :id => editable2.id
350
+ assert_content_equal(published1, editable1)
351
+ published3.should_not == editable2
352
+ published3.uid.should_not == "new"
353
+ end
354
+ Content.publish(@final_revision+1, [editable2.id])
355
+ editable1.reload
356
+ editable2.reload
357
+ new_content.reload
358
+ Content.with_revision(@final_revision+1) do
359
+ published1 = Content.first :id => editable1.id
360
+ assert_content_equal(published1, editable1)
361
+ published2 = Content.first :id => editable2.id
362
+ assert_content_equal(published2, editable2)
363
+ published3 = Content.first :id => editable2.contents.first.id
364
+ # published3.should == editable2.contents.first
365
+ assert_content_equal(published3, editable2.contents.first)
366
+ end
367
+ end
368
+
369
+ should "insert an entry value into the parent of a newly added page when that page is published" do
370
+ editable1 = Content.first(:uid => '0')
371
+ new_page = Page.new(:uid => "new")
372
+ editable1.things << new_page
373
+ editable1.save
374
+ new_page.save
375
+ Content.publish(@final_revision, [new_page.id])
376
+ new_page.reload
377
+ editable1.reload
378
+ Content.with_revision(@final_revision) do
379
+ published1 = Content[editable1.id]
380
+ published2 = Content[new_page.id]
381
+ assert_content_equal(published2, new_page)
382
+ editable1.entry_store.should == published1.entry_store
383
+ end
384
+ end
385
+
386
+ should "choose a sensible position for entry into the parent of a newly added page xxx" do
387
+ editable1 = Content.first(:uid => '0')
388
+ new_page1 = Page.new(:uid => "new1")
389
+ new_page2 = Page.new(:uid => "new2")
390
+ editable1.things << new_page1
391
+ editable1.things << new_page2
392
+ editable1.save
393
+ new_page1.save
394
+ new_page2.save
395
+ Content.publish(@final_revision, [new_page2.id])
396
+ new_page1.reload
397
+ new_page2.reload
398
+ editable1.reload
399
+ Content.with_revision(@final_revision) do
400
+ published1 = Content[editable1.id]
401
+ published2 = Content[new_page1.id]
402
+ published3 = Content[new_page2.id]
403
+ published2.should be_nil
404
+ assert_content_equal(published3, new_page2)
405
+ editable1.entry_store.reject { |e| e[0] == new_page1.id }.should == published1.entry_store
406
+ end
407
+ end
408
+
409
+ should "not duplicate entries when publishing pages for the first time" do
410
+ editable1 = Content.first(:uid => '0')
411
+ new_page1 = Page.new(:uid => "new1")
412
+ new_page2 = Page.new(:uid => "new2")
413
+ editable1.things << new_page1
414
+ editable1.things << new_page2
415
+ editable1.save
416
+ new_page1.save
417
+ new_page2.save
418
+ Content.publish(@final_revision, [editable1.id, new_page2.id])
419
+ new_page1.reload
420
+ new_page2.reload
421
+ editable1.reload
422
+ Content.with_revision(@final_revision) do
423
+ published1 = Content[editable1.id]
424
+ published2 = Content[new_page1.id]
425
+ published3 = Content[new_page2.id]
426
+ published2.should be_nil
427
+ assert_content_equal(published3, new_page2)
428
+ assert_content_equal(published1, editable1)
429
+ end
430
+ end
431
+
432
+ should "remove deleted pages from the published content" do
433
+ page = Page.first :uid => "0"
434
+ piece = page.things.first
435
+ child = piece.things.first
436
+ page.things.first.destroy
437
+ Content.publish(@final_revision, [page.id])
438
+
439
+ Content.with_revision(@final_revision) do
440
+ published_parent = Content[page.id]
441
+ published_piece = Content[piece.id]
442
+ published_page = Content[child.id]
443
+ published_parent.should == page.reload
444
+ published_piece.should be_nil
445
+ published_page.should be_nil
446
+ end
447
+ end
448
+ end
449
+ end
450
+
451
+
452
+ context "publication timestamps" do
453
+ setup do
454
+ @revision = 1
455
+ Content.delete_revision(@revision+1)
456
+ end
457
+ teardown do
458
+ Content.delete_revision(@revision)
459
+ Content.delete_revision(@revision+1)
460
+ end
461
+
462
+ should "set correct timestamps on first publish" do
463
+ first = Content.first
464
+ first.reload.first_published_at.should be_nil
465
+ first.reload.last_published_at.should be_nil
466
+ Content.publish(@revision)
467
+ first.reload.first_published_at.to_i.should == @now.to_i
468
+ first.reload.last_published_at.to_i.should == @now.to_i
469
+ first.reload.first_published_revision.should == @revision
470
+ Content.with_editable do
471
+ first.reload.first_published_at.to_i.should == @now.to_i
472
+ first.reload.last_published_at.to_i.should == @now.to_i
473
+ first.reload.first_published_revision.should == @revision
474
+ end
475
+ Content.with_revision(@revision) do
476
+ first.reload.first_published_at.to_i.should == @now.to_i
477
+ first.reload.last_published_at.to_i.should == @now.to_i
478
+ first.reload.first_published_revision.should == @revision
479
+ end
480
+ end
481
+
482
+ should "set correct timestamps on later publishes" do
483
+ first = Content.first
484
+ first.first_published_at.should be_nil
485
+ Content.publish(@revision)
486
+ first.reload.first_published_at.to_i.should == @now.to_i
487
+ c = Content.create
488
+ c.first_published_at.should be_nil
489
+ stub_time(@now + 100)
490
+ Content.publish(@revision+1)
491
+ first.reload.first_published_at.to_i.should == @now.to_i
492
+ first.reload.last_published_at.to_i.should == @now.to_i + 100
493
+ Content.with_editable do
494
+ c = Content.first :id => c.id
495
+ c.first_published_at.to_i.should == @now.to_i + 100
496
+ end
497
+ Content.with_revision(@revision+1) do
498
+ c = Content.first :id => c.id
499
+ c.first_published_at.to_i.should == @now.to_i + 100
500
+ end
501
+ end
502
+
503
+ should "not set publishing date for items not published" do
504
+ Content.publish(@revision)
505
+ page = Content.first
506
+ page.uid = "fish"
507
+ page.save
508
+ added = Content.create
509
+ added.first_published_at.should be_nil
510
+ Content.publish(@revision+1, [page])
511
+ page.first_published_at.to_i.should == @now.to_i
512
+ added.first_published_at.should be_nil
513
+ added.last_published_at.should be_nil
514
+ end
515
+
516
+ should "not set publishing dates if exception raised in passed block" do
517
+ Content.first.first_published_at.should be_nil
518
+ begin
519
+ Content.publish(@revision) do
520
+ raise Exception
521
+ end
522
+ rescue Exception; end
523
+ Content.first.first_published_at.should be_nil
524
+ end
525
+
526
+ should "delete revision tables if exception raised in passed block" do
527
+ Content.revision_exists?(@revision).should be_false
528
+ begin
529
+ Content.publish(@revision) do
530
+ Content.revision_exists?(@revision).should be_true
531
+ Content.revision.should == @revision
532
+ raise Exception
533
+ end
534
+ rescue Exception; end
535
+ Content.revision_exists?(@revision).should be_false
536
+ end
537
+
538
+ should "always publish all if no previous revisions exist" do
539
+ page = Content.first
540
+ Content.filter(:first_published_at => nil).count.should == Content.count
541
+ Content.publish(@revision, [page])
542
+ Content.filter(:first_published_at => nil).count.should == 0
543
+ end
544
+ end
545
+ end
546
+ end
@@ -527,6 +527,88 @@ class SchemaTest < MiniTest::Spec
527
527
  end
528
528
  end
529
529
 
530
+ context "Schema groups" do
531
+ setup do
532
+ class ::A < Spontaneous::Page
533
+ group :a, :b, :c
534
+ box :cgroup do
535
+ allow_group :c
536
+ end
537
+ end
538
+ class ::B < Spontaneous::Piece
539
+ group :b, :c
540
+ style :fish
541
+ style :frog
542
+
543
+ box :agroup do
544
+ allow_groups :a, :c
545
+ end
546
+ end
547
+ class ::C < Spontaneous::Piece
548
+ group :c
549
+
550
+ box :bgroup do
551
+ allow_group :b, :style => "fish"
552
+ end
553
+ box :cgroup do
554
+ allow_group :c, :level => :root
555
+ end
556
+ end
557
+ end
558
+
559
+ teardown do
560
+ Object.send(:remove_const, :A) rescue nil
561
+ Object.send(:remove_const, :B) rescue nil
562
+ Object.send(:remove_const, :C) rescue nil
563
+ end
564
+
565
+ should "let boxes allow a list of content types" do
566
+ A.boxes.cgroup.allowed_types(nil).should == [A, B, C]
567
+ C.boxes.bgroup.allowed_types(nil).should == [A, B]
568
+ C.boxes.cgroup.allowed_types(nil).should == [A, B, C]
569
+ B.boxes.agroup.allowed_types(nil).should == [A, B, C]
570
+ end
571
+
572
+ should "apply the options to all the included classes" do
573
+ user = mock()
574
+ S::Permissions.stubs(:has_level?).with(user, S::Permissions::UserLevel.root).returns(true)
575
+ A.boxes.cgroup.allowed_types(user).should == [A, B, C]
576
+ S::Permissions.stubs(:has_level?).with(user, S::Permissions::UserLevel.root).returns(false)
577
+ A.boxes.cgroup.allowed_types(user).should == []
578
+ end
579
+
580
+ should "allow for configuring styles" do
581
+ c = C.new
582
+ b = B.new
583
+ styles = c.bgroup.available_styles(b)
584
+ styles.length.should == 1
585
+ styles.first.name.should == :fish
586
+ end
587
+
588
+ should "reload correctly" do
589
+ FileUtils.mkdir(@site.root / "config")
590
+ @site.schema.write_schema
591
+ @site.schema.delete(::B)
592
+ Object.send(:remove_const, :B)
593
+
594
+ class ::B < Spontaneous::Piece
595
+ group :b
596
+ style :fish
597
+ style :frog
598
+
599
+ box :agroup do
600
+ allow_groups :a, :c
601
+ end
602
+ end
603
+
604
+ @site.schema.validate!
605
+
606
+ A.boxes.cgroup.allowed_types(nil).should == [A, C]
607
+ C.boxes.bgroup.allowed_types(nil).should == [A, B]
608
+ end
609
+ end
610
+
611
+
530
612
  context "Map writing" do
531
613
  context "Non-existant maps" do
532
614
  setup do
@@ -781,7 +863,7 @@ class SchemaTest < MiniTest::Spec
781
863
  instance.posts << piece2
782
864
  instance.save
783
865
  instance = S::Content[instance.id]
784
- instance.posts.pieces.length.should == 2
866
+ instance.posts.contents.length.should == 2
785
867
  Content.count.should == 3
786
868
  uid = A.boxes[:posts].schema_id.to_s
787
869
  A.stubs(:box_prototypes).returns(S::Collections::PrototypeSet.new)
@@ -451,6 +451,65 @@ class SearchTest < MiniTest::Spec
451
451
  }
452
452
  end
453
453
 
454
+ should "allow for page types to append their own custom indexable values" do
455
+ index = S::Site.index :four do
456
+ include_types PageClass1, PieceClass1
457
+ end
458
+ class ::PageClass1
459
+ def additional_search_values
460
+ { "search_key1" => "value 1",
461
+ "search_key2" => "value 2" }
462
+ end
463
+ end
464
+ index.indexable_content(@page1).should == {
465
+ :id => @page1.id,
466
+ @a.schema_id.to_s => "a value 1",
467
+ @g.schema_id.to_s => "g value 1\ng value 2\ng value 3",
468
+ "search_key1" => "value 1",
469
+ "search_key2" => "value 2"
470
+ }
471
+ end
472
+
473
+ should "deal with arrays of additional search index values" do
474
+ index = S::Site.index :four do
475
+ include_types PageClass1, PieceClass1
476
+ end
477
+ class ::PageClass1
478
+ def additional_search_values
479
+ [ { "search_key1" => "value 1",
480
+ "search_key2" => "value 2" },
481
+ { "search_key1" => "value 3",
482
+ "search_key2" => "value 4" } ]
483
+ end
484
+ end
485
+ index.indexable_content(@page1).should == {
486
+ :id => @page1.id,
487
+ @a.schema_id.to_s => "a value 1",
488
+ @g.schema_id.to_s => "g value 1\ng value 2\ng value 3",
489
+ "search_key1" => "value 1\nvalue 3",
490
+ "search_key2" => "value 2\nvalue 4"
491
+ }
492
+ end
493
+
494
+ should "allow for pieces to append their own custom indexable values" do
495
+ index = S::Site.index :four do
496
+ include_types PageClass1, PieceClass1
497
+ end
498
+ class ::PieceClass1
499
+ def additional_search_values
500
+ { "search_key3" => "value 3",
501
+ "search_key4" => "value 4" }
502
+ end
503
+ end
504
+ index.indexable_content(@page1).should == {
505
+ :id => @page1.id,
506
+ @a.schema_id.to_s => "a value 1",
507
+ @g.schema_id.to_s => "g value 1\ng value 2\ng value 3",
508
+ "search_key3" => "value 3\nvalue 3\nvalue 3",
509
+ "search_key4" => "value 4\nvalue 4\nvalue 4"
510
+ }
511
+ end
512
+
454
513
  should "create database in the right directory" do
455
514
  db_path = @site.revision_dir(@revision) / 'indexes' / 'one'
456
515
  Site.stubs(:published_revision).returns(@revision)