spontaneous 0.2.0.alpha2 → 0.2.0.alpha3

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -64,10 +64,7 @@ Spontaneous.Location = (function($, S) {
64
64
  var Location = new JS.Singleton({
65
65
  include: Spontaneous.Properties,
66
66
  init: function(callback) {
67
- var complete = function() {
68
- callback();
69
- this.location_loaded();
70
- }.bind(this);
67
+ this.locationCache = {};
71
68
  callback();
72
69
  State.restore();
73
70
  // $(window).bind('hashchange', State.restore);
@@ -86,12 +83,10 @@ Spontaneous.Location = (function($, S) {
86
83
  },
87
84
  load_map: function() {
88
85
  },
89
- location_loaded: function(location, status, xhr) {
90
- if (status !== 'success') {
91
- if (xhr.status === 406) { // Code returned if site is missing a root page
92
- var d = new Spontaneous.AddHomeDialogue(Spontaneous.Types.get('types'));
93
- d.open();
94
- }
86
+ location_loaded: function(location, xhr) {
87
+ if (xhr.status === 406) { // Code returned if site is missing a root page
88
+ var d = new Spontaneous.AddHomeDialogue(Spontaneous.Types.get('types'));
89
+ d.open();
95
90
  } else {
96
91
  this.set('location', location);
97
92
  // HACK: see preview.js (Preview.display)
@@ -132,13 +127,13 @@ Spontaneous.Location = (function($, S) {
132
127
  if (this.location() && path === this.location().path) {
133
128
  return this.location();
134
129
  }
135
- ajax.get('/location'+path, this.location_loaded.bind(this));
130
+ this.retrieve('/location'+path, this.location_loaded.bind(this));
136
131
  },
137
132
  find_id: function(id) {
138
133
  if (this.location() && id === this.location().id) {
139
134
  return this.location();
140
135
  }
141
- ajax.get('/map/'+id, this.location_loaded.bind(this));
136
+ this.retrieve('/map/'+id, this.location_loaded.bind(this));
142
137
  },
143
138
  path_from_url: function(url) {
144
139
  var map = this.get('map'),
@@ -159,10 +154,43 @@ Spontaneous.Location = (function($, S) {
159
154
  position += 1;
160
155
  }
161
156
  return path;
157
+ },
158
+ // easier to create my own 304 sensitive ajax request
159
+ // than peg on a content cache to jQuery's
160
+ retrieve: function(url, callback) {
161
+ var self = this
162
+ , req = new XMLHttpRequest()
163
+ , data;
164
+ req.open("GET", ajax.request_url(url, true), true)
165
+ req.setRequestHeader('If-Modified-Since', self.lastModified(url));
166
+ req.onreadystatechange = function(event) {
167
+ if (req.readyState === XMLHttpRequest.DONE) {
168
+ if (req.status === 200) {
169
+ data = jQuery.parseJSON(req.responseText);
170
+ self.setLocationCache(url, req.getResponseHeader("Last-Modified"), data)
171
+ }
172
+ if (req.status === 304) {
173
+ data = self.getLocationCache(url)
174
+ }
175
+ if (req.status === 401) {
176
+ S.Ajax.unauthorized();
177
+ }
178
+ callback(data, req);
179
+ }
180
+ };
181
+ req.send(null);
182
+ },
183
+ lastModified: function(path) {
184
+ return (this.locationCache[path] || {}).lastModified;
185
+ },
186
+ setLocationCache: function(path, lastModified, location) {
187
+ this.locationCache[path] = { lastModified: lastModified, location: location };
188
+ },
189
+ getLocationCache: function(path) {
190
+ return this.locationCache[path].location;
162
191
  }
163
192
  });
164
193
  // $(window).bind('popstate', State.popstate);
165
194
  return Location;
166
195
  })(jQuery, Spontaneous);
167
196
 
168
-
@@ -1,3 +1,6 @@
1
+ //= require compatibility
2
+ //= require authentication
3
+
1
4
  (function($) {
2
5
  $(function() {
3
6
  $('#login-form input.text').focus(function() {
@@ -0,0 +1,543 @@
1
+ Spontaneous.MetaView.UserAdmin = (function($, S){
2
+ var dom = S.Dom, ajax = S.Ajax;
3
+
4
+ var Level = new JS.Class({
5
+ initialize: function(attributes) {
6
+ this.attributes = attributes;
7
+ },
8
+ levelName: function() { return this.attributes.level; },
9
+ title: function() {
10
+ var level = this.attributes.level;
11
+ return level.charAt(0).toUpperCase() + level.substr(1);
12
+ },
13
+ canPublish: function() {
14
+ return this.attributes.can_publish;
15
+ },
16
+ isAdmin: function() {
17
+ return this.attributes.is_admin;
18
+ }
19
+ });
20
+
21
+ Level.get = function(level) {
22
+ return this.levels.filter(function(l) {
23
+ return l.levelName() === level;
24
+ })[0];
25
+ };
26
+ Level.defaultLevel = function() {
27
+ var levels = this.levels;
28
+ var nonePosition = function() {
29
+ for (var i = 0, ii = levels.length; i < ii; i++) {
30
+ if (levels[i].levelName() === "none") {
31
+ return i;
32
+ }
33
+ };
34
+ }();
35
+ return levels[nonePosition + 1];
36
+ };
37
+
38
+ var LevelSelect = new JS.Class({
39
+ initialize: function(name, user) {
40
+ this.name = name;
41
+ this.user = user;
42
+ },
43
+ element: function(cancelCallback) {
44
+ var self = this;
45
+ var levels = Level.levels;
46
+ var currentLevel = Level.get(this.user.get("level")) || Level.defaultLevel();
47
+ var outer = dom.div(".level-select");
48
+ var input = dom.input({type: "hidden", name: Input.inputName(this.name), value: currentLevel.levelName()});
49
+ var select = dom.div(".select").hide();
50
+ var value = dom.div(".level-value").text(currentLevel.title());
51
+ levels.forEach(function(level) {
52
+ var row = dom.div(".level").addClass("level-" + level.levelName());
53
+ row.append(dom.span(".level-name").text(level.title()));
54
+ row.append(dom.span(".level-publish").text("Publish").addClass(""+level.canPublish()));
55
+ row.append(dom.span(".level-admin").text("Admin").addClass(""+level.isAdmin()));
56
+ row.data("level", level);
57
+ row.click(function() {
58
+ self.choose(level);
59
+ return false;
60
+ });
61
+ select.append(row);
62
+ });
63
+ value.click(function() {
64
+ self.open();
65
+ return false;
66
+ });
67
+ outer.append(select, input, value);
68
+ this.input = input;
69
+ this.pulldown = select;
70
+ this.level = currentLevel;
71
+ this.value = value;
72
+ return outer;
73
+ },
74
+ open: function() {
75
+ var pulldown = this.pulldown;
76
+ pulldown.fadeIn(100);
77
+ var level = this.currentLevel();
78
+ var options = pulldown.find(".level");
79
+ var levelDiv = options.filter(function(div) {
80
+ return $(this).data("level").levelName() == level.levelName();
81
+ })[0];
82
+ var pos = $(levelDiv).position();
83
+ pulldown.css("top", dom.px(-pos.top));
84
+ },
85
+
86
+ choose: function(level) {
87
+ this.input.val(level.levelName());
88
+ this.value.text(level.title());
89
+
90
+ this.close();
91
+ },
92
+ close: function( ) {
93
+ this.pulldown.fadeOut(100);
94
+ },
95
+ activate: function() {
96
+ this.select();
97
+ },
98
+ currentLevel: function() {
99
+ return Level.get(this.input.val());
100
+ },
101
+ select: function() {
102
+ var level = this.currentLevel();
103
+ this.value.text(level.title());
104
+
105
+ },
106
+ showError: function(errors) { },
107
+ hideError: function() { }
108
+ });
109
+
110
+ var Input = new JS.Class({
111
+ initialize: function(name, value) {
112
+ this.name = name;
113
+ this.value = value;
114
+ },
115
+ element: function(cancelCallback) {
116
+ var type = (this.name === "email" ? "email" : "text");
117
+ var input = dom.input({
118
+ name: this.inputName(),
119
+ value: this.value,
120
+ type: type
121
+ }).focus(function() {
122
+ $(this).parents("p").addClass("focus");
123
+ }).blur(function() {
124
+ $(this).parents("p").removeClass("focus");
125
+ }).keydown(function(event) {
126
+ if (event.keyCode === 27) { cancelCallback(); }
127
+ });
128
+ // TODO: catch RETURN and ESCAPE
129
+ return input;
130
+ }.cache("input"),
131
+ inputName: function() { return Input.inputName(this.name); },
132
+ isModified: function() {
133
+ // TODO: compare current value of input against original value
134
+ },
135
+ activate: function() {},
136
+ showError: function(errors) {
137
+ var error = errors[0]
138
+ , element = this.element()
139
+ , errorWrap = dom.div(".error").append(dom.span().text(error)).hide();
140
+ element.after(errorWrap);
141
+ errorWrap.fadeIn(300);
142
+ },
143
+ hideError: function() {
144
+ var error = this.element().next(".error");
145
+ error.fadeOut(100, function() {
146
+ error.remove();
147
+ });
148
+ }
149
+ });
150
+
151
+ Input.inputName = function(name) {
152
+ return "user[" + name + "]";
153
+ };
154
+
155
+ var responseCallback = function(complete, successCallback, failCallback) {
156
+ var isFunction = function(f) { return (typeof f === "function"); }
157
+ return function(result, status) {
158
+ if (status === "success") {
159
+ if (isFunction(complete)) { complete(result); }
160
+ if (isFunction(successCallback)) { successCallback(result); }
161
+ } else {
162
+ if (isFunction(failCallback)) { failCallback(result); }
163
+ }
164
+ }
165
+ };
166
+
167
+ var UserController = {
168
+ save: function(user, params, successCallback, failCallback) {
169
+ var url = ["/users", user.get("id")].join("/");
170
+ ajax.put(url, params, responseCallback(function(result) {
171
+ user.update(result);
172
+ }, successCallback, failCallback));
173
+ },
174
+ create: function(user, params, successCallback, failCallback) {
175
+ var url = "/users";
176
+ ajax.post(url, params, responseCallback(function(result) {
177
+ user.update(result);
178
+ }, successCallback, failCallback));
179
+ },
180
+ delete: function(user, successCallback, failCallback) {
181
+ var url = ["/users", user.get("id")].join("/");
182
+ ajax.del(url, {}, responseCallback(function(result) {
183
+
184
+ }, successCallback, failCallback));
185
+ },
186
+ enable: function(user, enabled, successCallback, failCallback) {
187
+ var action = (enabled ? "enable" : "disable")
188
+ , url = ["/users", action, user.get("id")].join("/");
189
+ ajax.put(url, {}, responseCallback(function(result) {
190
+ user.set("disabled", !enabled);
191
+ }, successCallback, failCallback));
192
+ },
193
+ logout: function(user, successCallback, failCallback) {
194
+ var url = ["/users", "keys", user.get("id")].join("/");
195
+ ajax.del(url, {}, responseCallback(function(result) {
196
+
197
+ },successCallback, failCallback));
198
+ },
199
+ };
200
+
201
+ var EditUserView = new JS.Class({
202
+ initialize: function(parent, user) {
203
+ this.parent = parent;
204
+ this.user = user;
205
+ },
206
+ titleText: function() {
207
+ return "Editing User “" + this.user.get("name") + "”";
208
+ },
209
+ view: function() {
210
+ var self = this;
211
+ var user = this.user;
212
+ var wrap = dom.div();
213
+ var form = dom.form({method: "post", action: ajax.request_url("/users/"+ user.get("id"))})
214
+ var inputs = {};
215
+ var p, label, input, value;
216
+ var titleBar = dom.div(".title").append(dom.span().text(this.titleText()));
217
+
218
+ form.append(self.aboveUserAttributes());
219
+
220
+ var cancel = function() {
221
+ self.parent.closeUser();
222
+ };
223
+ self.editableAttributes().forEach(function(name) {
224
+ p = dom.p()
225
+ label = dom.label().text(name);
226
+ input = self.inputForAttribute(name);
227
+ value = dom.div(".value").append(input.element(cancel));
228
+ p.append(label, value);
229
+ form.append(p);
230
+ inputs[name] = input;
231
+ });
232
+ p = dom.div('.save');
233
+ var saveComplete = function() {
234
+ self.parent.closeUser();
235
+ };
236
+ var saveFail = function(errors) {
237
+ self.verificationErrors(errors);
238
+ };
239
+ var performSave = function() {
240
+ self.beforeSave();
241
+ self.save(form, saveComplete, saveFail);
242
+ return false;
243
+ };
244
+ var cancelBtn = dom.a(".button.cancel").text("Cancel").click(cancel);
245
+ var saveBtn = dom.button(".button", {type: "submit"}).text(self.saveButtonText()).click(performSave);
246
+ p.append(cancelBtn, dom.div(".gap"), saveBtn);
247
+ form.append(p);
248
+ form.submit(performSave);
249
+ this.inputs = inputs;
250
+ form.find('input[type="text"]:first').focus().select();
251
+ wrap.append(titleBar, form)
252
+ return wrap;
253
+ },
254
+ verificationErrors: function(errors) {
255
+ var self = this;
256
+ $.each(errors, function(name, error) {
257
+ self.inputs[name].showError(error);
258
+ });
259
+ },
260
+ saveButtonText: function() {
261
+ return "Save";
262
+ },
263
+ inputForAttribute: function(name) {
264
+ if (name === "level") {
265
+ return new LevelSelect(name, this.user);
266
+ }
267
+ return new Input(name, this.user.get(name));
268
+ },
269
+ editableAttributes: function() {
270
+ return ["login", "name", "email", "level"];
271
+ },
272
+ aboveUserAttributes: function() {
273
+ var self = this;
274
+ var user = this.user
275
+ var admin = dom.div(".admin");
276
+ p = dom.p(".enabled");
277
+ label = dom.label().text("Enabled");
278
+ var checkbox = dom.input({type:"checkbox", checked: (!user.get("disabled"))}).click(function() {
279
+ var enabled = $(this).attr("checked") === "checked";
280
+ UserController.enable(user, enabled);
281
+ return false;
282
+ });
283
+ user.watch("disabled", function(disabled) {
284
+ checkbox.attr("checked", !disabled);
285
+ });
286
+ label.append(checkbox);
287
+ p.append(label);
288
+ admin.append(p);
289
+
290
+ admin.append(dom.p(".gap"));
291
+ p = dom.p(".log-off");
292
+ var btn = dom.a(".button.log-out").text("Log "+user.get("login")+" Out").click(function() {
293
+ var $this = $(this);
294
+ $this.addClass("pending");
295
+ UserController.logout(user, function() {
296
+ $this.removeClass("pending").addClass("complete").text("Logged Out");
297
+ });
298
+ });
299
+ p.append(btn);
300
+ admin.append(p);
301
+ return admin;
302
+ },
303
+ activate: function() {
304
+ $.each(this.inputs, function(name, input) {
305
+ input.activate();
306
+ });
307
+ },
308
+ belowUserAttributes: function() {
309
+
310
+ },
311
+ serialiseForm: function(form) {
312
+ var valueArray = form.serializeArray()
313
+ , params = {};
314
+ valueArray.forEach(function(input) {
315
+ params[input.name] = input.value;
316
+ });
317
+ return params;
318
+ },
319
+ beforeSave: function() {
320
+ var self = this;
321
+ self.editableAttributes().forEach(function(name) {
322
+ self.inputs[name].hideError();
323
+ });
324
+ },
325
+ save: function(form, successCallback, failCallback) {
326
+ var self = this
327
+ , params = self.serialiseForm(form)
328
+ UserController.save(self.user, params, successCallback, failCallback);
329
+ }
330
+ });
331
+
332
+ var CreateUserView = new JS.Class(EditUserView, {
333
+ titleText: function() {
334
+ return "Create User";
335
+ },
336
+ aboveUserAttributes: function() {
337
+ return "";
338
+ },
339
+ belowUserAttributes: function() {
340
+ return "";
341
+ },
342
+ editableAttributes: function() {
343
+ return ["login", "name", "email", "password", "level"];
344
+ },
345
+ saveButtonText: function() {
346
+ return "Create";
347
+ },
348
+ save: function(form, successCallback, failCallback) {
349
+ var self = this
350
+ , params = self.serialiseForm(form)
351
+ , callback = function(params) {
352
+ if (typeof successCallback === "function") {
353
+ successCallback(params);
354
+ }
355
+ self.parent.addUser(self.user);
356
+ };
357
+
358
+ UserController.create(self.user, params, callback, failCallback);
359
+ }
360
+ });
361
+ var User = new JS.Class({
362
+ include: S.Properties,
363
+ initialize: function(dialogue, attributes) {
364
+ var self = this;
365
+ self.dialogue = dialogue;
366
+ self.attributes = attributes;
367
+ self.update(attributes);
368
+ },
369
+ update: function(attributes) {
370
+ var self = this;
371
+ $.each(attributes, function(key, val) {
372
+ self.set(key, val);
373
+ });
374
+ },
375
+ });
376
+
377
+ var UserAdmin = new JS.Class({
378
+ initialize: function() {
379
+ },
380
+ show: function(container) {
381
+ // we use this as a single shared instance so that the state is maintanined
382
+ // between visits
383
+ if (this.outer) {
384
+ container.append(this.outer);
385
+ return;
386
+ }
387
+ var self = this;
388
+ var outer = dom.div("#user-admin-container");
389
+ var title = dom.div(".title.main").append(dom.span().text("CMS Users"));
390
+ var contents = dom.div(".contents");
391
+ var edit = dom.div(".edit").hide();
392
+ var done = dom.a(".button.done").text("Done").click(function() {
393
+ self.close();
394
+ });
395
+ var addWrapper = dom.div(".add-user")
396
+ var addButton = dom.a(".button.add").text("Create User").click(function() {
397
+ self.createUser();
398
+ });
399
+ addWrapper.append(addButton);
400
+ title.append(done);
401
+ outer.append(title, contents, addWrapper, edit);
402
+
403
+ this.outer = outer;
404
+ this.titleContainer = title;
405
+ this.contentsContainer = contents;
406
+ this.editContainer = edit;
407
+ container.append(outer)
408
+ ajax.get("/users", this.ready.bind(this));
409
+ },
410
+ createUser: function() {
411
+ var user = new User(this, {});
412
+ this.openView(new CreateUserView(this, user));
413
+ },
414
+ addUser: function(user) {
415
+ this.addUserEntry(user);
416
+ },
417
+ ready: function(userData) {
418
+ var self = this;
419
+
420
+ Level.levels = userData.levels.map(function(data) { return new Level(data); });
421
+ self.users = userData.users.map(function(data) { return new User(self, data); });
422
+
423
+ self.users.forEach(function(user) {
424
+ self.addUserEntry(user);
425
+ });
426
+ },
427
+ addUserEntry: function(user) {
428
+ var entry = this.listEntry(user);
429
+ user.listEntry = entry;
430
+ this.contentsContainer.append(entry);
431
+ },
432
+ detach: function() {
433
+ this.outer = this.outer.detach();
434
+ },
435
+ listEntry: function(user) {
436
+ var self = this;
437
+ var row = dom.div(".user");
438
+ row.attr("id", "user-admin-" + user.get("id"));
439
+ var cells = ["name", "level"].map(function(attr) {
440
+ var div = dom.div().addClass(attr).text(user.get(attr)).click(function() {
441
+ self.editUser(user)
442
+ return false;
443
+ });
444
+ user.watch(attr, function(newValue) {
445
+ div.text(newValue);
446
+ });
447
+ return div;
448
+ });
449
+ var disabledState = function(disabled) {
450
+ if (disabled) {
451
+ row.addClass("disabled");
452
+ } else {
453
+ row.removeClass("disabled");
454
+ }
455
+ };
456
+ user.watch("disabled", disabledState);
457
+ disabledState(user.get("disabled"));
458
+ var del = dom.div(".delete").click(function() {
459
+ self.confirmDeleteUser(user);
460
+ return false;
461
+ });
462
+ cells.push(del);
463
+ row.append.apply(row, cells)
464
+ return row;
465
+ },
466
+ animationDuration: 300,
467
+ editUser: function(user) {
468
+ this.openView(new EditUserView(this, user));
469
+ },
470
+ openView: function(viewInstance) {
471
+ var self = this;
472
+ var animationDuration = self.animationDuration;
473
+ var edit = this.editContainer.empty();
474
+ var list = this.contentsContainer;
475
+ var back = dom.div(".back");
476
+ edit.append(back, viewInstance.view());
477
+ edit.css({ left: "100%", opacity: 0 }).show();
478
+ list.animate({ opacity: 0.2 }, animationDuration);
479
+ edit.animate({ left: "48px", opacity: 1 }, animationDuration, "swing")
480
+ viewInstance.activate();
481
+ },
482
+ closeUser: function() {
483
+ var animationDuration = this.animationDuration;
484
+ var edit = this.editContainer.empty();
485
+ var list = this.contentsContainer;
486
+ list.animate({ opacity: 1 }, animationDuration);
487
+ edit.animate({ left: "100%", opacity: 0 }, animationDuration, function() {
488
+ edit.empty().hide();
489
+ });
490
+ },
491
+ confirmDeleteUser: function(user) {
492
+ var dialogue = Spontaneous.Popover.open(event, new ConfirmDeletePopup(this, user));
493
+ },
494
+ deleteUser: function(user) {
495
+ var url = ["/users", user.get("id")].join("/");
496
+ ajax.del(url, {}, function(result, status) {
497
+ if (status === "success") {
498
+ user.listEntry.disappear();
499
+ }
500
+ });
501
+ },
502
+ close: function() {
503
+ S.ContentArea.exitMeta();
504
+ }
505
+ });
506
+
507
+ var ConfirmDeletePopup = new JS.Class(Spontaneous.Views.PieceView.ConfirmDeletePopup, {
508
+ initialize: function(list, user) {
509
+ this.list = list;
510
+ this.user = user;
511
+ },
512
+ // width: function() {
513
+ // return 208;
514
+ // },
515
+ title: function() {
516
+ return "Delete user “" + (this.user.get("login")) + "”";
517
+ },
518
+ position_from_event: function(event) {
519
+ var pos = this.position_from_element(event);
520
+ pos.left += 40;
521
+ return pos;
522
+ },
523
+ view: function() {
524
+ var self = this, __entry = this.list;
525
+ var w = dom.div('#popover-delete').click(function() {
526
+ self.close();
527
+ return false;
528
+ });
529
+
530
+ var ok = dom.a('.ok').text("Delete").click(function() {
531
+ self.close();
532
+ __entry.deleteUser(self.user);
533
+ return false;
534
+ });
535
+ var cancel = dom.a('.cancel').text("Cancel");
536
+ w.append(cancel, ok)
537
+ return w;
538
+ }
539
+ });
540
+
541
+ return UserAdmin;
542
+
543
+ }(jQuery, Spontaneous));
@@ -0,0 +1 @@
1
+ Spontaneous.MetaView = {};
@@ -0,0 +1,20 @@
1
+ // console.log('Loading Metadata...')
2
+
3
+ Spontaneous.Metadata = (function($, S) {
4
+ var ajax = S.Ajax;
5
+ var loaded = function(callback) {
6
+ return function(metadata) {
7
+ S.Types.loaded(metadata.types);
8
+ S.User.loaded(metadata.user);
9
+ S.Services.loaded(metadata.services);
10
+ if (callback) { callback.call(); };
11
+ };
12
+ };
13
+ return {
14
+ load: function(onComplete) {
15
+ ajax.get('/metadata', loaded(onComplete));
16
+ }
17
+ };
18
+ }(jQuery, Spontaneous));
19
+
20
+
@@ -15,6 +15,9 @@ Spontaneous.Page = (function($, S) {
15
15
  this.set('path', values.path);
16
16
  },
17
17
 
18
+ is_root: function() {
19
+ return (this.get('path') === "/");
20
+ },
18
21
  depth: function() {
19
22
  // depth in this case refers to content depth which is always 0 for pages
20
23
  return 0;
@@ -27,12 +30,15 @@ Spontaneous.Page = (function($, S) {
27
30
  }
28
31
  return _entries;
29
32
  },
33
+ // annoyingly duplicating the version coming from the server, which is
34
+ // a hash of box_name => [box_entries]
30
35
  children: function() {
31
- var _children = [];
36
+ var _children = {};
32
37
  for (var i = 0, entries = this.entries(), ii = entries.length; i < ii; i++) {
33
- var e = entries[i];
38
+ var e = entries[i], container = e.container, container_name = container.name();
34
39
  if (e.is_page()) {
35
- _children.push(e);
40
+ _children[container_name] = (_children[container_name] || []);
41
+ _children[container_name].push(e);
36
42
  }
37
43
  }
38
44
  return _children;
@@ -42,3 +48,11 @@ Spontaneous.Page = (function($, S) {
42
48
 
43
49
  return Page;
44
50
  }(jQuery, Spontaneous));
51
+
52
+ Spontaneous.page = function() {
53
+ return Spontaneous.Editing.get('page');
54
+ };
55
+
56
+ Spontaneous.set_browser_title = function(page_title) {
57
+ document.title = Spontaneous.site_domain + " | Editing: '"+page_title+"'";
58
+ };