browsercms 3.5.7 → 4.0.0.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (523) hide show
  1. checksums.yaml +7 -0
  2. data/COPYRIGHT.txt +2 -1
  3. data/README.markdown +3 -3
  4. data/app/assets/fonts/icomoon.dev.svg +61 -0
  5. data/app/assets/fonts/icomoon.eot +0 -0
  6. data/app/assets/fonts/icomoon.svg +61 -0
  7. data/app/assets/fonts/icomoon.ttf +0 -0
  8. data/app/assets/fonts/icomoon.woff +0 -0
  9. data/app/assets/images/ckeditor/plugins/delete_content/icons/deletecontent.png +0 -0
  10. data/app/assets/images/ckeditor/plugins/edit_content/icons/editcontent.png +0 -0
  11. data/app/assets/images/ckeditor/plugins/move_content/icons/movecontentdown.png +0 -0
  12. data/app/assets/images/ckeditor/plugins/move_content/icons/movecontentup.png +0 -0
  13. data/app/assets/images/cms/arrow-down.png +0 -0
  14. data/app/assets/images/cms/arrow-up.png +0 -0
  15. data/app/assets/images/cms/cogs.png +0 -0
  16. data/app/assets/images/cms/dashboard/home.png +0 -0
  17. data/app/assets/images/cms/home.png +0 -0
  18. data/app/assets/images/cms/logo.png +0 -0
  19. data/app/assets/images/cms/pencil.png +0 -0
  20. data/app/assets/images/cms/plus.png +0 -0
  21. data/app/assets/images/cms/user.png +0 -0
  22. data/app/assets/javascripts/bcms/ckeditor_inline.js +23 -0
  23. data/app/assets/javascripts/bcms/ckeditor_standard_config.js +1 -1
  24. data/app/assets/javascripts/ckeditor/plugins/delete_content/plugin.js +36 -0
  25. data/app/assets/javascripts/ckeditor/plugins/edit_content/plugin.js +24 -0
  26. data/app/assets/javascripts/ckeditor/plugins/move_content/plugin.js +25 -0
  27. data/app/assets/javascripts/cms/ajax.js +60 -0
  28. data/app/assets/javascripts/cms/application.js +6 -1
  29. data/app/assets/javascripts/cms/attachment_manager.js.erb +3 -10
  30. data/app/assets/javascripts/cms/content_library.js +31 -12
  31. data/app/assets/javascripts/cms/core_library.js.erb +68 -36
  32. data/app/assets/javascripts/cms/form_builder.js +250 -0
  33. data/app/assets/javascripts/cms/namespace.js +2 -0
  34. data/app/assets/javascripts/cms/new_content_button.js +27 -0
  35. data/app/assets/javascripts/cms/page_editor.js +188 -0
  36. data/app/assets/javascripts/cms/page_toolbar.js +13 -0
  37. data/app/assets/javascripts/cms/site.js +2 -0
  38. data/app/assets/javascripts/cms/sitemap.js +219 -0
  39. data/app/assets/javascripts/cms/toolbar.js +17 -1
  40. data/app/assets/javascripts/cms/user.js +40 -0
  41. data/app/assets/javascripts/jquery.exists.js +5 -0
  42. data/app/assets/javascripts/jquery.taglist.js +37 -23
  43. data/app/assets/stylesheets/cms/_assets.css.scss +55 -0
  44. data/app/assets/stylesheets/cms/_base.css.scss +42 -0
  45. data/app/assets/stylesheets/cms/_cms-buttons.css.scss +73 -0
  46. data/app/assets/stylesheets/cms/_cms-forms.css.scss +70 -0
  47. data/app/assets/stylesheets/cms/_colors.css.scss +20 -0
  48. data/app/assets/stylesheets/cms/_dashboard.css.scss +25 -0
  49. data/app/assets/stylesheets/cms/_glyph.css.scss +60 -0
  50. data/app/assets/stylesheets/cms/_main-area.css.scss +62 -0
  51. data/app/assets/stylesheets/cms/_nav.css.scss +197 -0
  52. data/app/assets/stylesheets/cms/_sidebar.css.scss +64 -0
  53. data/app/assets/stylesheets/cms/_sitemap.css.scss +196 -0
  54. data/app/assets/stylesheets/cms/_submenu.css.scss +48 -0
  55. data/app/assets/stylesheets/cms/application.css.scss +49 -0
  56. data/app/assets/stylesheets/cms/core.css.scss +96 -0
  57. data/app/assets/stylesheets/cms/default-forms.css.scss +3 -0
  58. data/app/assets/stylesheets/cms/includes/_animation.css.scss +2 -0
  59. data/app/assets/stylesheets/cms/includes/_rem.css.scss +120 -0
  60. data/app/assets/stylesheets/cms/includes/animation/_animate.css.scss +31 -0
  61. data/app/assets/stylesheets/cms/includes/animation/_core.css.scss +127 -0
  62. data/app/assets/stylesheets/cms/includes/animation/_shared.css.scss +22 -0
  63. data/app/assets/stylesheets/cms/includes/animation/animate/_attention-seekers.css.scss +152 -0
  64. data/app/assets/stylesheets/cms/includes/animation/animate/_bouncing.css.scss +3 -0
  65. data/app/assets/stylesheets/cms/includes/animation/animate/_classes.css.scss +21 -0
  66. data/app/assets/stylesheets/cms/includes/animation/animate/_fading.css.scss +3 -0
  67. data/app/assets/stylesheets/cms/includes/animation/animate/_flippers.css.scss +87 -0
  68. data/app/assets/stylesheets/cms/includes/animation/animate/_lightspeed.css.scss +24 -0
  69. data/app/assets/stylesheets/cms/includes/animation/animate/_rotating.css.scss +3 -0
  70. data/app/assets/stylesheets/cms/includes/animation/animate/_specials.css.scss +42 -0
  71. data/app/assets/stylesheets/cms/includes/animation/animate/bouncing/_bouncing-entrances.css.scss +68 -0
  72. data/app/assets/stylesheets/cms/includes/animation/animate/bouncing/_bouncing-exits.css.scss +60 -0
  73. data/app/assets/stylesheets/cms/includes/animation/animate/fading/_fading-entrances.css.scss +86 -0
  74. data/app/assets/stylesheets/cms/includes/animation/animate/fading/_fading-exits.css.scss +86 -0
  75. data/app/assets/stylesheets/cms/includes/animation/animate/rotating/_rotating-entrances.css.scss +58 -0
  76. data/app/assets/stylesheets/cms/includes/animation/animate/rotating/_rotating-exits.css.scss +58 -0
  77. data/app/assets/stylesheets/cms/page_content_editing.css.scss +4 -0
  78. data/app/assets/stylesheets/cms/page_editor.css.scss +4 -0
  79. data/app/assets/stylesheets/cms/style.css.scss +138 -0
  80. data/app/assets/stylesheets/cms/styles/_alerts.css.scss +150 -0
  81. data/app/assets/stylesheets/cms/styles/_base-grid.css.scss +299 -0
  82. data/app/assets/stylesheets/cms/styles/_buttons.css.scss +247 -0
  83. data/app/assets/stylesheets/cms/styles/_dropdown.css.scss +155 -0
  84. data/app/assets/stylesheets/cms/styles/_forms.css.scss +728 -0
  85. data/app/assets/stylesheets/cms/styles/_glyph.css.scss +86 -0
  86. data/app/assets/stylesheets/cms/styles/_images.css.scss +75 -0
  87. data/app/assets/stylesheets/cms/styles/_lists.css.scss +115 -0
  88. data/app/assets/stylesheets/cms/styles/_modal.css.scss +174 -0
  89. data/app/assets/stylesheets/cms/styles/_progress.css.scss +43 -0
  90. data/app/assets/stylesheets/cms/styles/_tables.css.scss +141 -0
  91. data/app/assets/stylesheets/cms/styles/_text.css.scss +134 -0
  92. data/app/controllers/cms/application_controller.rb +3 -68
  93. data/app/controllers/cms/attachments_controller.rb +5 -5
  94. data/app/controllers/cms/base_controller.rb +20 -13
  95. data/app/controllers/cms/cache_controller.rb +16 -17
  96. data/app/controllers/cms/category_types_controller.rb +6 -1
  97. data/app/controllers/cms/connectors_controller.rb +12 -7
  98. data/app/controllers/cms/content_block_controller.rb +128 -71
  99. data/app/controllers/cms/content_controller.rb +54 -56
  100. data/app/controllers/cms/dashboard_controller.rb +5 -6
  101. data/app/controllers/cms/dynamic_views_controller.rb +12 -9
  102. data/app/controllers/cms/email_messages_controller.rb +18 -13
  103. data/app/controllers/cms/form_entries_controller.rb +119 -0
  104. data/app/controllers/cms/form_fields_controller.rb +74 -0
  105. data/app/controllers/cms/forms_controller.rb +35 -0
  106. data/app/controllers/cms/groups_controller.rb +13 -16
  107. data/app/controllers/cms/html_blocks_controller.rb +2 -2
  108. data/app/controllers/cms/inline_content_controller.rb +48 -0
  109. data/app/controllers/cms/links_controller.rb +58 -46
  110. data/app/controllers/cms/page_components_controller.rb +20 -0
  111. data/app/controllers/cms/page_routes_controller.rb +44 -40
  112. data/app/controllers/cms/pages_controller.rb +111 -97
  113. data/app/controllers/cms/passwords_controller.rb +17 -0
  114. data/app/controllers/cms/portlet_controller.rb +0 -1
  115. data/app/controllers/cms/portlets_controller.rb +20 -27
  116. data/app/controllers/cms/redirects_controller.rb +13 -9
  117. data/app/controllers/cms/resource_controller.rb +15 -4
  118. data/app/controllers/cms/routes_controller.rb +2 -4
  119. data/app/controllers/cms/section_nodes_controller.rb +6 -37
  120. data/app/controllers/cms/sections_controller.rb +13 -8
  121. data/app/controllers/cms/sessions_controller.rb +8 -66
  122. data/app/controllers/cms/sites/passwords_controller.rb +27 -0
  123. data/app/controllers/cms/sites/sessions_controller.rb +20 -0
  124. data/app/controllers/cms/tags_controller.rb +12 -12
  125. data/app/controllers/cms/tasks_controller.rb +45 -46
  126. data/app/controllers/cms/user_controller.rb +8 -0
  127. data/app/controllers/cms/users_controller.rb +91 -68
  128. data/app/helpers/cms/application_helper.rb +58 -52
  129. data/app/helpers/cms/content_block_helper.rb +8 -7
  130. data/app/helpers/cms/form_tag_helper.rb +21 -25
  131. data/app/helpers/cms/menu_helper.rb +1 -3
  132. data/app/helpers/cms/mobile_helper.rb +12 -2
  133. data/app/helpers/cms/nav_menu_helper.rb +23 -0
  134. data/app/helpers/cms/page_helper.rb +72 -30
  135. data/app/helpers/cms/path_helper.rb +46 -70
  136. data/app/helpers/cms/rendering_helper.rb +68 -12
  137. data/app/helpers/cms/section_nodes_helper.rb +92 -31
  138. data/app/helpers/cms/sites/authentication_helper.rb +25 -0
  139. data/app/helpers/cms/sites/devise_shim_helper.rb +31 -0
  140. data/app/helpers/cms/template_support.rb +1 -7
  141. data/app/helpers/cms/ui_elements_helper.rb +147 -6
  142. data/app/helpers/forgot_password_portlet_helper.rb +9 -0
  143. data/app/helpers/login_portlet_helper.rb +10 -0
  144. data/app/inputs/attachments_input.rb +14 -0
  145. data/app/inputs/cms_text_area_input.rb +10 -0
  146. data/app/inputs/cms_text_field_input.rb +29 -0
  147. data/app/inputs/date_picker_input.rb +8 -0
  148. data/app/inputs/file_picker_input.rb +75 -0
  149. data/app/inputs/path_input.rb +18 -0
  150. data/app/inputs/tag_list_input.rb +3 -0
  151. data/app/inputs/template_editor_input.rb +24 -0
  152. data/app/inputs/text_editor_input.rb +19 -0
  153. data/app/models/cms/abstract_file_block.rb +10 -6
  154. data/app/models/cms/attachment.rb +20 -27
  155. data/app/models/cms/category.rb +17 -7
  156. data/app/models/cms/category_type.rb +8 -4
  157. data/app/models/cms/connector.rb +32 -20
  158. data/app/models/cms/content.rb +31 -0
  159. data/app/models/cms/content_type.rb +114 -62
  160. data/app/models/cms/dynamic_view.rb +19 -45
  161. data/app/models/cms/email_message.rb +32 -2
  162. data/app/models/cms/external_user.rb +60 -0
  163. data/app/models/cms/file_block.rb +1 -0
  164. data/app/models/cms/form.rb +47 -0
  165. data/app/models/cms/form_entry.rb +71 -0
  166. data/app/models/cms/form_field.rb +78 -0
  167. data/app/models/cms/group.rb +19 -9
  168. data/app/models/cms/group_permission.rb +1 -1
  169. data/app/models/cms/group_section.rb +1 -1
  170. data/app/models/cms/group_type.rb +5 -5
  171. data/app/models/cms/group_type_permission.rb +1 -1
  172. data/app/models/cms/html_block.rb +14 -19
  173. data/app/models/cms/image_block.rb +1 -0
  174. data/app/models/cms/link.rb +8 -6
  175. data/app/models/cms/page.rb +156 -59
  176. data/app/models/cms/page_component.rb +43 -0
  177. data/app/models/cms/page_partial.rb +16 -8
  178. data/app/models/cms/page_route.rb +1 -1
  179. data/app/models/cms/page_route_condition.rb +1 -1
  180. data/app/models/cms/page_route_option.rb +1 -1
  181. data/app/models/cms/page_route_requirement.rb +1 -1
  182. data/app/models/cms/page_template.rb +14 -9
  183. data/app/models/cms/permission.rb +4 -2
  184. data/app/models/cms/persistent_user.rb +208 -0
  185. data/app/models/cms/portlet.rb +56 -9
  186. data/app/models/cms/redirect.rb +1 -1
  187. data/app/models/cms/search_filter.rb +18 -0
  188. data/app/models/cms/section.rb +39 -28
  189. data/app/models/cms/section_node.rb +32 -5
  190. data/app/models/cms/site.rb +3 -3
  191. data/app/models/cms/tag.rb +14 -12
  192. data/app/models/cms/tagging.rb +2 -2
  193. data/app/models/cms/task.rb +14 -21
  194. data/app/models/cms/templates.rb +1 -2
  195. data/app/models/cms/user.rb +21 -160
  196. data/app/models/cms/user_group_membership.rb +2 -2
  197. data/app/portlets/deprecated_placeholder.rb +12 -0
  198. data/app/portlets/dynamic_portlet.rb +1 -1
  199. data/app/portlets/email_page_portlet.rb +10 -3
  200. data/app/portlets/forgot_password_portlet.rb +9 -28
  201. data/app/portlets/login_portlet.rb +8 -5
  202. data/app/portlets/tag_cloud_portlet.rb +3 -1
  203. data/app/presenters/cms/user_presenter.rb +24 -0
  204. data/app/views/cms/application/_add_content_modal.html.erb +3 -0
  205. data/app/views/cms/application/_buttons.html.erb +7 -0
  206. data/app/views/cms/{shared → application}/_exception.html.erb +0 -0
  207. data/app/views/cms/application/_form_errors.html.erb +7 -0
  208. data/app/views/cms/application/_form_with_buttons.html.erb +10 -0
  209. data/app/views/cms/application/_main_content.html.erb +3 -0
  210. data/app/views/cms/application/_main_with_sidebar.html.erb +8 -0
  211. data/app/views/cms/application/_mobile_toolbar.html.erb +16 -0
  212. data/app/views/cms/application/_page_title.html.erb +5 -0
  213. data/app/views/cms/application/_pagination.html.erb +26 -0
  214. data/app/views/cms/application/_row.html.erb +1 -0
  215. data/app/views/cms/application/_save_buttons.html.erb +7 -0
  216. data/app/views/cms/application/_sidebar_layout.html.erb +3 -0
  217. data/app/views/cms/application/_version.html.erb +23 -0
  218. data/app/views/cms/{shared → application}/_version_conflict_diff.html.erb +0 -0
  219. data/app/views/cms/{shared → application}/_version_conflict_error.html.erb +0 -0
  220. data/app/views/cms/attachments/_attachment_manager.html.erb +22 -0
  221. data/app/views/cms/attachments/_no_attachments_defined.html.erb +1 -0
  222. data/app/views/cms/cache/show.html.erb +5 -10
  223. data/app/views/cms/categories/_form.html.erb +15 -24
  224. data/app/views/cms/category_types/_form.html.erb +1 -1
  225. data/app/views/cms/connectors/new.html.erb +33 -64
  226. data/app/views/cms/content/editing_frame.html.erb +1 -0
  227. data/app/views/cms/content/no_page.html.erb +9 -27
  228. data/app/views/cms/content/show.html.erb +14 -15
  229. data/app/views/cms/content_block/_block_form.html.erb +15 -0
  230. data/app/views/cms/content_block/_buttonbar.html.erb +29 -0
  231. data/app/views/cms/content_block/_buttons.html.erb +13 -0
  232. data/app/views/cms/content_block/_hidden_fields.html.erb +13 -0
  233. data/app/views/cms/content_block/_sidebar.html.erb +35 -0
  234. data/app/views/cms/content_block/edit.html.erb +3 -0
  235. data/app/views/cms/content_block/index.html.erb +87 -0
  236. data/app/views/cms/content_block/new.html.erb +3 -0
  237. data/app/views/cms/content_block/render_block_in_main_container.html.erb +10 -0
  238. data/app/views/cms/content_block/show.html.erb +1 -0
  239. data/app/views/cms/content_block/show_in_isolation.html.erb +15 -0
  240. data/app/views/cms/content_block/versions.html.erb +24 -0
  241. data/app/views/cms/dashboard/_page_drafts.html.erb +12 -22
  242. data/app/views/cms/dashboard/_tasks.html.erb +32 -45
  243. data/app/views/cms/dashboard/index.html.erb +11 -13
  244. data/app/views/cms/dynamic_views/_form.html.erb +8 -10
  245. data/app/views/cms/dynamic_views/edit.html.erb +2 -3
  246. data/app/views/cms/dynamic_views/index.html.erb +22 -44
  247. data/app/views/cms/dynamic_views/new.html.erb +2 -3
  248. data/app/views/cms/email_messages/index.html.erb +31 -34
  249. data/app/views/cms/email_messages/show.html.erb +45 -52
  250. data/app/views/cms/file_blocks/_form.html.erb +2 -4
  251. data/app/views/cms/form_entries/_buttons.html.erb +2 -0
  252. data/app/views/cms/form_entries/_form.html.erb +7 -0
  253. data/app/views/cms/form_entries/_internal_form.html.erb +9 -0
  254. data/app/views/cms/form_entries/edit.html.erb +5 -0
  255. data/app/views/cms/form_entries/error.html.erb +3 -0
  256. data/app/views/cms/form_entries/index.html.erb +4 -0
  257. data/app/views/cms/form_entries/new.html.erb +5 -0
  258. data/app/views/cms/form_entries/show.html.erb +13 -0
  259. data/app/views/cms/form_entries/submit.html.erb +1 -0
  260. data/app/views/cms/form_fields/_form.html.erb +8 -0
  261. data/app/views/cms/form_fields/_select.html.erb +3 -0
  262. data/app/views/cms/form_fields/_text_area.html.erb +3 -0
  263. data/app/views/cms/form_fields/_text_field.html.erb +3 -0
  264. data/app/views/cms/form_fields/edit.html.erb +0 -0
  265. data/app/views/cms/form_fields/new.html.erb +26 -0
  266. data/app/views/cms/form_fields/preview.html.erb +16 -0
  267. data/app/views/cms/forms/_form.html.erb +66 -0
  268. data/app/views/cms/forms/render.html.erb +15 -0
  269. data/app/views/cms/forms/show.html.erb +6 -0
  270. data/app/views/cms/groups/_form.html.erb +32 -38
  271. data/app/views/cms/groups/_permissions.html.erb +11 -34
  272. data/app/views/cms/groups/_sections.html.erb +11 -17
  273. data/app/views/cms/groups/edit.html.erb +1 -3
  274. data/app/views/cms/groups/index.html.erb +10 -32
  275. data/app/views/cms/groups/new.html.erb +2 -4
  276. data/app/views/cms/html_blocks/_form.html.erb +2 -2
  277. data/app/views/cms/html_blocks/render.html.erb +1 -1
  278. data/app/views/cms/image_blocks/_form.html.erb +3 -3
  279. data/app/views/cms/links/_form.html.erb +6 -11
  280. data/app/views/cms/links/edit.html.erb +3 -12
  281. data/app/views/cms/links/new.html.erb +4 -13
  282. data/app/views/cms/page_components/_content.html.erb +18 -0
  283. data/app/views/cms/page_components/new.html.erb +12 -0
  284. data/app/views/cms/page_routes/_form.html.erb +11 -10
  285. data/app/views/cms/page_routes/edit.html.erb +2 -3
  286. data/app/views/cms/page_routes/index.html.erb +25 -48
  287. data/app/views/cms/page_routes/new.html.erb +2 -3
  288. data/app/views/cms/pages/_edit_content.html.erb +28 -0
  289. data/app/views/cms/pages/_form.html.erb +20 -37
  290. data/app/views/cms/pages/_main_form.html.erb +23 -0
  291. data/app/views/cms/pages/_simple_container.html.erb +8 -0
  292. data/app/views/cms/pages/edit.html.erb +2 -23
  293. data/app/views/cms/pages/new.html.erb +2 -16
  294. data/app/views/cms/pages/versions.html.erb +18 -87
  295. data/app/views/cms/redirects/_form.html.erb +6 -14
  296. data/app/views/cms/redirects/edit.html.erb +2 -3
  297. data/app/views/cms/redirects/index.html.erb +24 -50
  298. data/app/views/cms/redirects/new.html.erb +2 -3
  299. data/app/views/cms/routes/index.html.erb +15 -20
  300. data/app/views/cms/section_nodes/_children.html.erb +3 -0
  301. data/app/views/cms/section_nodes/_row_buttons.html.erb +11 -0
  302. data/app/views/cms/section_nodes/_section_node.html.erb +24 -10
  303. data/app/views/cms/section_nodes/_sitemap_buttons.html.erb +47 -0
  304. data/app/views/cms/section_nodes/_status.html.erb +5 -0
  305. data/app/views/cms/section_nodes/show.html.erb +9 -0
  306. data/app/views/cms/sections/_buttons.html.erb +6 -0
  307. data/app/views/cms/sections/_form.html.erb +22 -49
  308. data/app/views/cms/sections/edit.html.erb +3 -8
  309. data/app/views/cms/sections/new.html.erb +4 -20
  310. data/app/views/cms/sessions/new.html.erb +16 -31
  311. data/app/views/cms/shared/access_denied.html.erb +1 -2
  312. data/app/views/cms/shared/error.html.erb +5 -5
  313. data/app/views/cms/sites/_flash.html.erb +8 -0
  314. data/app/views/cms/sites/passwords/new.html.erb +2 -0
  315. data/app/views/cms/sites/sessions/new.html.erb +2 -0
  316. data/app/views/cms/tags/_form.html.erb +1 -1
  317. data/app/views/cms/tags/render.html.erb +0 -1
  318. data/app/views/cms/tasks/new.html.erb +18 -32
  319. data/app/views/cms/toolbar/_new_pages_menu.html.erb +10 -0
  320. data/app/views/cms/users/_form.html.erb +8 -11
  321. data/app/views/cms/users/_password.html.erb +2 -8
  322. data/app/views/cms/users/_user_fields.html.erb +7 -20
  323. data/app/views/cms/users/change_password.html.erb +12 -21
  324. data/app/views/cms/users/edit.html.erb +1 -15
  325. data/app/views/cms/users/index.html.erb +61 -58
  326. data/app/views/cms/users/new.html.erb +1 -12
  327. data/app/views/devise/confirmations/new.html.erb +16 -0
  328. data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  329. data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  330. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  331. data/app/views/devise/passwords/edit.html.erb +19 -0
  332. data/app/views/devise/passwords/new.html.erb +15 -0
  333. data/app/views/devise/registrations/edit.html.erb +28 -0
  334. data/app/views/devise/registrations/new.html.erb +18 -0
  335. data/app/views/devise/shared/_links.erb +25 -0
  336. data/app/views/devise/unlocks/new.html.erb +16 -0
  337. data/app/views/layouts/cms/_content_types.html.erb +13 -0
  338. data/app/views/layouts/cms/_footer.erb +2 -2
  339. data/app/views/layouts/cms/_head.html.erb +8 -18
  340. data/app/views/layouts/cms/_main_menu.html.erb +78 -0
  341. data/app/views/layouts/cms/application.html.erb +19 -24
  342. data/app/views/layouts/cms/content_page.html.erb +5 -0
  343. data/app/views/layouts/cms/page_editor.html.erb +90 -0
  344. data/app/views/portlets/deprecated_placeholders/_form.html.erb +1 -0
  345. data/app/views/portlets/deprecated_placeholders/render.html.erb +8 -0
  346. data/app/views/portlets/dynamic/_form.html.erb +3 -3
  347. data/app/views/portlets/email_page/_form.html.erb +5 -6
  348. data/app/views/portlets/forgot_password/_form.html.erb +2 -3
  349. data/app/views/portlets/forgot_password/render.html.erb +2 -14
  350. data/app/views/portlets/login/_form.html.erb +4 -6
  351. data/app/views/portlets/login/render.html.erb +8 -27
  352. data/app/views/portlets/portlets/_form.html.erb +7 -6
  353. data/app/views/portlets/tag_cloud/_form.html.erb +4 -4
  354. data/app/views/tests/pretend/open_with_layout.html.erb +1 -1
  355. data/bin/bcms +13 -16
  356. data/config/routes.rb +58 -29
  357. data/db/browsercms.seeds.rb +0 -6
  358. data/db/migrate/{20080815014337_browsercms_3_0_0.rb → 20080815014337_browsercms300.rb} +94 -73
  359. data/db/migrate/20130327184912_browsercms400.rb +90 -0
  360. data/db/migrate/20131206214021_devise_create_users.rb +47 -0
  361. data/db/migrate/20131211223908_kill_reset_password.rb +5 -0
  362. data/db/migrate/20131218222005_create_cms_external_users.rb +10 -0
  363. data/doc/features/design_integration.md +45 -0
  364. data/doc/features/external_user.md +7 -0
  365. data/doc/features/form_builder.md +40 -0
  366. data/doc/features/simple_form_refactor.md +60 -0
  367. data/doc/release_notes.md +224 -10
  368. data/lib/acts_as_list.rb +72 -71
  369. data/lib/browsercms.rb +41 -1
  370. data/lib/cms/acts/content_block.rb +12 -2
  371. data/lib/cms/acts/content_page.rb +3 -4
  372. data/lib/cms/admin_tab.rb +15 -0
  373. data/lib/cms/attachments/configuration.rb +1 -1
  374. data/lib/cms/authentication/controller.rb +83 -177
  375. data/lib/cms/authentication/test_password_strategy.rb +19 -0
  376. data/lib/cms/behaviors.rb +1 -0
  377. data/lib/cms/behaviors/archiving.rb +2 -2
  378. data/lib/cms/behaviors/attaching.rb +21 -45
  379. data/lib/cms/behaviors/connecting.rb +14 -4
  380. data/lib/cms/behaviors/dynamic_attributes.rb +3 -3
  381. data/lib/cms/behaviors/hiding.rb +2 -2
  382. data/lib/cms/behaviors/namespacing.rb +6 -36
  383. data/lib/cms/behaviors/publishing.rb +92 -45
  384. data/lib/cms/behaviors/rendering.rb +15 -7
  385. data/lib/cms/behaviors/searching.rb +5 -4
  386. data/lib/cms/behaviors/soft_deleting.rb +13 -16
  387. data/lib/cms/behaviors/taggable.rb +17 -10
  388. data/lib/cms/behaviors/versioning.rb +12 -16
  389. data/lib/cms/commands/to_version400.rb +10 -0
  390. data/lib/cms/concerns.rb +7 -0
  391. data/lib/cms/concerns/can_be_addressable.rb +326 -0
  392. data/lib/cms/concerns/has_content_type.rb +46 -0
  393. data/lib/cms/concerns/ignores_publishing.rb +9 -0
  394. data/lib/cms/configuration.rb +14 -4
  395. data/lib/cms/configuration/configurable_template.rb +24 -0
  396. data/lib/cms/configuration/devise.rb +256 -0
  397. data/lib/cms/configure_simple_form.rb +142 -0
  398. data/lib/cms/configure_simple_form_bootstrap.rb +49 -0
  399. data/lib/cms/content_filter.rb +18 -0
  400. data/lib/cms/content_page.rb +77 -0
  401. data/lib/cms/content_rendering_support.rb +25 -16
  402. data/lib/cms/controllers/admin_controller.rb +78 -0
  403. data/lib/cms/data_loader.rb +30 -11
  404. data/lib/cms/default_accessible.rb +6 -6
  405. data/lib/cms/domain_support.rb +0 -4
  406. data/lib/cms/engine.rb +52 -20
  407. data/lib/cms/engine_helper.rb +41 -51
  408. data/{app/controllers → lib}/cms/error_handling.rb +11 -5
  409. data/lib/cms/extensions.rb +2 -1
  410. data/lib/cms/extensions/active_model/name.rb +13 -0
  411. data/lib/cms/extensions/active_record/connection_adapters/abstract/schema_statements.rb +49 -89
  412. data/lib/cms/extensions/hash.rb +0 -12
  413. data/lib/cms/form_builder/content_block_form_builder.rb +45 -0
  414. data/lib/cms/form_builder/default_input.rb +13 -0
  415. data/lib/cms/form_builder/deprecated_inputs.rb +40 -0
  416. data/lib/cms/form_builder/workflow_buttons.rb +38 -0
  417. data/lib/cms/module.rb +1 -7
  418. data/lib/cms/polymorphic_single_table_inheritance.rb +19 -0
  419. data/lib/cms/publish_workflow.rb +26 -0
  420. data/lib/cms/responders/content_responder.rb +14 -0
  421. data/lib/cms/route_extensions.rb +112 -20
  422. data/lib/cms/version.rb +1 -1
  423. data/lib/generators/browser_cms/demo_site/templates/demo.seeds.rb +0 -2
  424. data/lib/generators/cms/content_block/content_block_generator.rb +19 -46
  425. data/lib/generators/cms/content_block/templates/_form.html.erb +22 -28
  426. data/lib/generators/cms/project/templates/devise.rb.erb +7 -0
  427. metadata +383 -150
  428. data/app/assets/javascripts/cms/sitemap.js.erb +0 -464
  429. data/app/assets/stylesheets/browsercms/application.css +0 -7
  430. data/app/assets/stylesheets/cms/administration.css.erb +0 -91
  431. data/app/assets/stylesheets/cms/application.css.erb +0 -171
  432. data/app/assets/stylesheets/cms/attachment_manager.css.scss +0 -28
  433. data/app/assets/stylesheets/cms/block.css +0 -26
  434. data/app/assets/stylesheets/cms/buttons.css.erb +0 -120
  435. data/app/assets/stylesheets/cms/content_library.css.erb +0 -139
  436. data/app/assets/stylesheets/cms/content_types.css +0 -4
  437. data/app/assets/stylesheets/cms/dashboard.css.erb +0 -118
  438. data/app/assets/stylesheets/cms/data_table.css.erb.erb +0 -156
  439. data/app/assets/stylesheets/cms/date_picker.css.erb +0 -82
  440. data/app/assets/stylesheets/cms/form_layout.css.erb +0 -282
  441. data/app/assets/stylesheets/cms/login.css.erb +0 -78
  442. data/app/assets/stylesheets/cms/menu.css.erb +0 -116
  443. data/app/assets/stylesheets/cms/nav.css.erb +0 -99
  444. data/app/assets/stylesheets/cms/page_toolbar.css.erb +0 -135
  445. data/app/assets/stylesheets/cms/reset.css +0 -46
  446. data/app/assets/stylesheets/cms/selectbox.css.erb +0 -56
  447. data/app/assets/stylesheets/cms/sitemap.css.erb +0 -390
  448. data/app/assets/stylesheets/cms/taglist.css +0 -18
  449. data/app/controllers/application_controller.rb +0 -14
  450. data/app/controllers/cms/content_types_controller.rb +0 -9
  451. data/app/helpers/application_helper.rb +0 -5
  452. data/app/helpers/cms/form_builder.rb +0 -241
  453. data/app/models/cms/content_type_group.rb +0 -15
  454. data/app/models/cms/forgot_password_mailer.rb +0 -14
  455. data/app/portlets/reset_password_portlet.rb +0 -28
  456. data/app/views/cms/blocks/_hidden_fields.html.erb +0 -10
  457. data/app/views/cms/blocks/_toolbar.html.erb +0 -9
  458. data/app/views/cms/blocks/_toolbar_for_collection.html.erb +0 -23
  459. data/app/views/cms/blocks/_toolbar_for_member.html.erb +0 -36
  460. data/app/views/cms/blocks/edit.html.erb +0 -28
  461. data/app/views/cms/blocks/index.html.erb +0 -86
  462. data/app/views/cms/blocks/new.html.erb +0 -19
  463. data/app/views/cms/blocks/show.html.erb +0 -43
  464. data/app/views/cms/blocks/usages.html.erb +0 -44
  465. data/app/views/cms/blocks/versions.html.erb +0 -90
  466. data/app/views/cms/content_types/index.html.erb +0 -14
  467. data/app/views/cms/form_builder/_cms_attachment_manager.html.erb +0 -27
  468. data/app/views/cms/form_builder/_cms_check_box.html.erb +0 -7
  469. data/app/views/cms/form_builder/_cms_date_picker.html.erb +0 -12
  470. data/app/views/cms/form_builder/_cms_datetime_select.html.erb +0 -12
  471. data/app/views/cms/form_builder/_cms_drop_down.html.erb +0 -12
  472. data/app/views/cms/form_builder/_cms_fancy_drop_down.html.erb +0 -9
  473. data/app/views/cms/form_builder/_cms_file_field.html.erb +0 -28
  474. data/app/views/cms/form_builder/_cms_instructions.html.erb +0 -4
  475. data/app/views/cms/form_builder/_cms_tag_list.html.erb +0 -15
  476. data/app/views/cms/form_builder/_cms_template_editor.html.erb +0 -9
  477. data/app/views/cms/form_builder/_cms_text_area.html.erb +0 -10
  478. data/app/views/cms/form_builder/_cms_text_editor.html.erb +0 -19
  479. data/app/views/cms/form_builder/_cms_text_field.html.erb +0 -12
  480. data/app/views/cms/links/destroy.js.rjs +0 -2
  481. data/app/views/cms/page_routes/show.html.erb +0 -10
  482. data/app/views/cms/pages/_edit_connector.html.erb +0 -19
  483. data/app/views/cms/pages/_edit_container.html.erb +0 -11
  484. data/app/views/cms/section_nodes/_link.html.erb +0 -14
  485. data/app/views/cms/section_nodes/_node.html.erb +0 -44
  486. data/app/views/cms/section_nodes/_page.html.erb +0 -20
  487. data/app/views/cms/section_nodes/_section.html.erb +0 -28
  488. data/app/views/cms/section_nodes/index.html.erb +0 -43
  489. data/app/views/cms/sections/_page.html.erb +0 -4
  490. data/app/views/cms/sections/_section.html.erb +0 -8
  491. data/app/views/cms/sections/destroy.js.rjs +0 -2
  492. data/app/views/cms/sections/index.html.erb +0 -23
  493. data/app/views/cms/shared/_admin_sidebar.html.erb +0 -36
  494. data/app/views/cms/shared/_pagination.html.erb +0 -31
  495. data/app/views/cms/toolbar/_mobile_toggle.html.erb +0 -33
  496. data/app/views/cms/toolbar/index.html.erb +0 -1
  497. data/app/views/cms/users/_groups.html.erb +0 -12
  498. data/app/views/cms/users/_toolbar.html.erb +0 -24
  499. data/app/views/cms/users/show.html.erb +0 -50
  500. data/app/views/layouts/_cms_toolbar.html.erb +0 -54
  501. data/app/views/layouts/_page_toolbar.html.erb +0 -119
  502. data/app/views/layouts/cms/administration.html.erb +0 -51
  503. data/app/views/layouts/cms/content_library.html.erb +0 -96
  504. data/app/views/layouts/cms/dashboard.html.erb +0 -16
  505. data/app/views/layouts/cms/login.html.erb +0 -31
  506. data/app/views/layouts/cms/section_nodes.html.erb +0 -20
  507. data/app/views/layouts/cms/toolbar.html.erb +0 -23
  508. data/app/views/portlets/reset_password/_form.html.erb +0 -3
  509. data/app/views/portlets/reset_password/render.html.erb +0 -22
  510. data/bin/bcms-upgrade +0 -332
  511. data/db/migrate/20091109175123_browsercms_3_0_5.rb +0 -9
  512. data/db/migrate/20100117144038_browsercms314.rb +0 -20
  513. data/db/migrate/20100117144039_browsercms315.rb +0 -95
  514. data/db/migrate/20100705083859_browsercms_3_3_0.rb +0 -56
  515. data/db/migrate/20111130221145_browsercms340.rb +0 -56
  516. data/db/migrate/20120329144406_browsercms350.rb +0 -32
  517. data/db/migrate/20120717182827_browsercms353.rb +0 -19
  518. data/db/migrate/20120813180110_browsercms354.rb +0 -9
  519. data/lib/cms/addressable.rb +0 -93
  520. data/lib/cms/authentication/model.rb +0 -116
  521. data/lib/cms/behaviors/pagination.rb +0 -212
  522. data/lib/cms/upgrades/v3_4_0.rb +0 -31
  523. data/lib/cms/upgrades/v3_5_0.rb +0 -227
@@ -0,0 +1,31 @@
1
+ module Cms
2
+ # An API for interacting with the Content API of BrowserCMS.
3
+ module Content
4
+
5
+ # Find a single content item.
6
+ # example:
7
+ # Cms::Content.find("html_block", 12) # Finds a Cms::HtmlBlock with an id of 12.
8
+ #
9
+ # @param [String] content_name The name of the content type to find.
10
+ # @param [Integer] id The id of the content.
11
+ # @return [ContentBlock] A single content block or page
12
+ def self.find(content_type, id)
13
+ if content_type == "page"
14
+ return Cms::Page.find(id)
15
+ end
16
+ type = ContentType.find_by_key(content_type)
17
+ type.model_class.find(id)
18
+ end
19
+
20
+ # Find the latest draft for a single content item.
21
+ # example:
22
+ # Cms::Content.find("html_block", 12) # Finds a Cms::HtmlBlock with an id of 12.
23
+ #
24
+ # @param [String] content_name The name of the content type to find.
25
+ # @param [Integer] id The id of the content.
26
+ # @return [ContentBlock] A single content block or page
27
+ def self.find_draft(content_type, id)
28
+ find(content_type, id).as_of_draft_version
29
+ end
30
+ end
31
+ end
@@ -1,22 +1,87 @@
1
1
  module Cms
2
- class ContentType < ActiveRecord::Base
2
+ class ContentType
3
3
 
4
- attr_accessible :name, :group_name, :content_type_group
4
+ attr_accessor :name
5
5
 
6
- attr_accessor :group_name
7
- belongs_to :content_type_group, :class_name => 'Cms::ContentTypeGroup'
8
- validates_presence_of :content_type_group
9
- before_validation :set_content_type_group
6
+ def initialize(options)
7
+ self.name = options[:name]
8
+ @path_builder = EngineAwarePathBuilder.new(model_class)
9
+ end
10
+
11
+ attr_accessor :path_builder
12
+ delegate :main_app_model?, :engine_name, :engine_class, to: :path_builder
13
+
14
+ DEFAULT_CONTENT_TYPE_NAME = 'Cms::HtmlBlock'
15
+
16
+ class << self
17
+ def named(name)
18
+ [Cms::ContentType.new(name: name)]
19
+ end
10
20
 
11
- scope :named, lambda { |name| {:conditions => ["#{ContentType.table_name}.name = ?", name]} }
21
+ def connectable
22
+ available.select { |content_type| content_type.connectable? }
23
+ end
24
+
25
+ # Return all content types, grouped by module.
26
+ #
27
+ # @return [Hash<Symbol, Cms::ContentType]
28
+ def available_by_module
29
+ modules = {}
30
+ available.each do |content_type|
31
+
32
+ modules[content_type.module_name] = [] unless modules[content_type.module_name]
33
+ modules[content_type.module_name] << content_type
34
+ end
35
+ modules
36
+ end
37
+
38
+ # Returns a list of all ContentTypes in the system. Content Types can opt out of this list by specifying:
39
+ #
40
+ # class MyWidget < ActiveRecord::Base
41
+ # acts_as_content content_module: false
42
+ # end
43
+ #
44
+ # Ignores the database to just look at classes, then returns a 'new' ContentType to match.
45
+ #
46
+ # @return [Array<Cms::ContentType] An alphabetical list of content types.
47
+ def available
48
+ subclasses = ObjectSpace.each_object(::Class).select do |klass|
49
+ klass < Cms::Concerns::HasContentType::InstanceMethods
50
+ end
51
+ subclasses << Cms::Portlet
52
+ subclasses.uniq! { |k| k.name } # filter duplicate classes
53
+ subclasses.map do |klass|
54
+ unless klass < Cms::Portlet
55
+ Cms::ContentType.new(name: klass.name)
56
+ end
57
+ end.compact.sort { |a, b| a.name <=> b.name }
58
+ end
59
+
60
+ def list
61
+ available
62
+ end
63
+
64
+ # Returns all content types besides the default.
65
+ #
66
+ # @return [Array<Cms::ContentType]
67
+ def other_connectables()
68
+ available.select { |content_type| content_type.name != DEFAULT_CONTENT_TYPE_NAME }
69
+ end
70
+
71
+ # Returns the default content type that is most frequently added to pages.
72
+ def default()
73
+ Cms::ContentType.new(name: DEFAULT_CONTENT_TYPE_NAME)
74
+ end
12
75
 
13
- scope :connectable,
14
- :include => :content_type_group,
15
- :conditions => ["#{ContentTypeGroup.table_name}.name != ?", 'Categorization'],
16
- :order => "#{ContentType.table_name}.priority, #{ContentType.table_name}.name"
76
+ # Returns only user generated Content Blocks
77
+ def user_generated_connectables()
78
+ available.select { |content_type| !content_type.name.starts_with?("Cms::") }
79
+ end
17
80
 
18
- def self.list
19
- all.map { |f| f.name.underscore.to_sym }
81
+ # Return content types that can be accessed as pages.
82
+ def addressable()
83
+ available.select { |content_type| content_type.model_class.addressable? }
84
+ end
20
85
  end
21
86
 
22
87
 
@@ -24,38 +89,44 @@ module Cms
24
89
  # Raises exception if nothing was found.
25
90
  def self.find_by_key(key)
26
91
  class_name = key.tableize.classify
27
- content_type = find(:first, :conditions => ["name like ?", "%#{class_name}"])
28
- if content_type.nil?
29
- if class_name.constantize.ancestors.include?(Cms::Portlet)
30
- content_type = Cms::ContentType.new(:name => class_name)
31
- content_type.content_type_group = Cms::ContentTypeGroup.find_by_name('Core')
32
- content_type.freeze
33
- content_type
34
- else
35
- raise "Not a Portlet"
92
+ klass = nil
93
+ prefix = "Cms::"
94
+ if !class_name.starts_with? prefix
95
+ klass = "Cms::#{class_name}".safe_constantize
96
+ end
97
+ unless klass
98
+ klass = class_name.safe_constantize
99
+ end
100
+ unless klass
101
+ if class_name.starts_with?(prefix)
102
+ klass = class_name[prefix.length, class_name.length].safe_constantize
36
103
  end
37
- else
38
- content_type
39
104
  end
40
- rescue Exception
41
- if class_name.starts_with? "Cms::"
42
- return self.find_by_key(class_name.gsub(/Cms::/, ""))
105
+ unless klass
106
+ raise "Couldn't find ContentType for '#{key}'. Checked for classes Cms::#{class_name} and #{class_name}."
43
107
  end
44
- raise "Couldn't find ContentType of class '#{class_name}'"
108
+ klass.content_type
45
109
  end
46
110
 
47
- # Returns URL friendly 'key' which is used to identify this
48
- def key
49
- model_class_form_name
111
+ # @deprecated
112
+ def save!
113
+ ActiveSupport::Deprecation.warn "Cms::ContentType#save! should no longer be called. Content Types do not need to be registered in the database."
114
+ end
115
+
116
+ def self.create!
117
+ ActiveSupport::Deprecation.warn "Cms::ContentType.create! should no longer be called. Content Types do not need to be registered in the database."
118
+ end
119
+
120
+ # Return the name of the module this content type should be grouped in. In most cases, content blocks will be
121
+ # configured to specify this.
122
+ # @return [Symbol]
123
+ def module_name
124
+ model_class.content_module
50
125
  end
51
126
 
52
127
  # Returns the partial used to render the form fields for a given block.
53
128
  def form
54
- f = model_class.respond_to?(:form) ? model_class.form : "#{name.underscore.pluralize}/form"
55
- if main_app_model?
56
- f = "cms/#{f}"
57
- end
58
- f
129
+ model_class.respond_to?(:form) ? model_class.form : "#{name.underscore.pluralize}/form"
59
130
  end
60
131
 
61
132
  def display_name
@@ -70,28 +141,15 @@ module Cms
70
141
  name.constantize
71
142
  end
72
143
 
73
- # @deprecated Should be removed eventually
74
- def route_name
75
- if model_class.name.starts_with?("Cms")
76
- model_class_form_name
77
- else
78
- "main_app.cms_#{model_class_form_name}"
79
- end
80
- end
81
-
82
- include EngineHelper
83
- def target_class
84
- model_class
85
- end
86
-
87
- def path_subject
88
- model_class
144
+ # Determines if the content can be connected to other pages.
145
+ def connectable?
146
+ model_class.connectable?
89
147
  end
90
148
 
91
149
  # Cms::HtmlBlock -> html_block
92
150
  # ThingBlock -> thing_block
93
- def model_class_form_name
94
- model_class.model_name.element
151
+ def param_key
152
+ model_class.model_name.param_key
95
153
  end
96
154
 
97
155
  # Allows models to show additional columns when being shown in a list.
@@ -108,7 +166,8 @@ module Cms
108
166
 
109
167
  # Used in ERB for pathing
110
168
  def content_block_type
111
- name.demodulize.pluralize.underscore
169
+ n = name.starts_with?("Cms::") ? name.demodulize : name
170
+ n.pluralize.underscore
112
171
  end
113
172
 
114
173
  # This is used for situations where you want different to use a type for the list page
@@ -122,12 +181,5 @@ module Cms
122
181
  end
123
182
  end
124
183
 
125
- def set_content_type_group
126
- if group_name
127
- group = Cms::ContentTypeGroup.first(:conditions => {:name => group_name})
128
- self.content_type_group = group || build_content_type_group(:name => group_name)
129
- end
130
- end
131
-
132
184
  end
133
185
  end
@@ -1,22 +1,18 @@
1
1
  module Cms
2
2
  class DynamicView < ActiveRecord::Base
3
+ store_templates
3
4
 
4
- after_save :write_file_to_disk
5
- after_destroy :remove_file_from_disk
5
+ extend DefaultAccessible
6
6
 
7
- include DefaultAccessible
8
- # Need to explicitly define these, since during new project creation, these files aren't discoverable.
9
- attr_accessible :name, :body, :format, :handler
10
-
11
- scope :with_file_name, lambda { |file_name|
7
+ def self.with_file_name(file_name)
12
8
  conditions = {:name => nil, :format => nil, :handler => nil}
13
9
  if file_name && (parts = file_name.split(".")).size == 3
14
10
  conditions[:name] = parts[0]
15
11
  conditions[:format] = parts[1]
16
12
  conditions[:handler] = parts[2]
17
13
  end
18
- {:conditions => conditions}
19
- }
14
+ where(conditions)
15
+ end
20
16
 
21
17
  def self.inherited(subclass)
22
18
  super if defined? super
@@ -29,16 +25,22 @@ module Cms
29
25
  is_versioned
30
26
 
31
27
  before_validation :set_publish_on_save
28
+ before_validation :set_defaults, :set_path
32
29
 
33
- validates_presence_of :name, :format, :handler
30
+ validates_presence_of :name, :format, :handler, :path, :locale
34
31
  validates_uniqueness_of :name, :scope => [:format, :handler],
35
32
  :message => "Must have a unique combination of name, format and handler"
36
33
 
37
34
  end
38
35
  end
39
36
 
37
+ # Returns the title of this class
38
+ def self.title
39
+ self.name.demodulize.titleize
40
+ end
41
+
40
42
  def self.new_with_defaults(options={})
41
- new({:format => "html", :handler => "erb", :body => default_body}.merge(options))
43
+ new({:format => "html", :handler => "erb", :body => default_body, :locale => I18n.locale}.merge(options))
42
44
  end
43
45
 
44
46
  def self.find_by_file_name(file_name)
@@ -49,10 +51,6 @@ module Cms
49
51
  File.join(Rails.root, "tmp", "views")
50
52
  end
51
53
 
52
- def self.form_name
53
- ActiveModel::Naming.singular(self)
54
- end
55
-
56
54
  def file_name
57
55
  "#{name}.#{format}.#{handler}"
58
56
  end
@@ -61,23 +59,6 @@ module Cms
61
59
  self.class.display_name(file_name)
62
60
  end
63
61
 
64
- def write_file_to_disk
65
- if respond_to?(:file_path) && !file_path.blank?
66
- FileUtils.mkpath(File.dirname(file_path))
67
- open(file_path, 'w') { |f| f << body }
68
- end
69
- end
70
-
71
- def self.write_all_to_disk!
72
- all(:conditions => {:deleted => false}).each { |v| v.write_file_to_disk }
73
- end
74
-
75
- def remove_file_from_disk
76
- if respond_to?(:file_path) && File.exists?(file_path)
77
- File.delete(file_path)
78
- end
79
- end
80
-
81
62
  def self.default_body
82
63
  ""
83
64
  end
@@ -86,21 +67,14 @@ module Cms
86
67
  self.publish_on_save = true
87
68
  end
88
69
 
89
- # Get the plural symbol for a particular resource.
90
- # i.e. Cms::PageTemplate -> :page_templates
91
- def self.resource_name
92
- resource_collection_name.pluralize
93
- end
94
-
95
- # Default implementation
96
- def self.resource_collection_name
97
- model_name.underscore
70
+ def set_path
71
+ self.path = self.class.relative_path + '/' + name
98
72
  end
99
73
 
100
- # So that route lookup works for these resources.
101
- # See PathHelper#cms_index_path_for
102
- def self.engine
103
- "cms"
74
+ def set_defaults
75
+ self.locale = I18n.locale.to_s unless locale
76
+ self.partial = partial?
77
+ true
104
78
  end
105
79
  end
106
80
  end
@@ -1,9 +1,10 @@
1
1
  module Cms
2
2
  class EmailMessage < ActiveRecord::Base
3
3
 
4
- include DefaultAccessible
4
+ extend DefaultAccessible
5
+ extend Cms::DomainSupport
5
6
 
6
- scope :undelivered, :conditions => "delivered_at is null"
7
+ scope :undelivered, -> { where("delivered_at is null") }
7
8
  validates_presence_of :recipients
8
9
  after_create :deliver_now
9
10
 
@@ -18,6 +19,34 @@ module Cms
18
19
  end
19
20
  end
20
21
 
22
+ # Returns a clean (non-www prefixed) domain name
23
+ def self.normalize_domain(domain)
24
+ normalized = domain =~ /^www/ ? domain.sub(/^www\./, "") : domain
25
+ # Strip the port
26
+ URI.parse("http://#{normalized}").host
27
+ end
28
+
29
+ # Converts a relative path to a path in the CMS. Used for creating a links to internal pages in the body of emails.
30
+ #
31
+ # @param [String] path A relative path (i.e. /cms/your-page)
32
+ # @return [String] (i.e http://cms.example.com/cms/your-page)
33
+ def self.absolute_cms_url(path)
34
+ host = normalize_domain(Rails.configuration.cms.site_domain)
35
+ "http://#{cms_domain_prefix}.#{host}#{path}"
36
+ end
37
+
38
+ # Returns a default address that mail will be sent from. (i.e. mailbot@example.com)
39
+ def self.mailbot_address
40
+ address = Rails.configuration.cms.mailbot
41
+ if address == :default
42
+ host = normalize_domain(Rails.configuration.cms.site_domain)
43
+ "mailbot@#{host}"
44
+ else
45
+ address
46
+ end
47
+
48
+ end
49
+
21
50
  #TODO: Take this out when we have an email queue processor
22
51
  def deliver_now
23
52
  deliver!
@@ -25,6 +54,7 @@ module Cms
25
54
 
26
55
  def deliver!
27
56
  return false if delivered?
57
+ self.sender = self.class.mailbot_address if self.sender.blank?
28
58
  Cms::EmailMessageMailer.email_message(self).deliver
29
59
  update_attributes(:delivered_at => Time.now)
30
60
  end
@@ -0,0 +1,60 @@
1
+ module Cms
2
+
3
+ # Represents a user that has been authenticated from an external data source. Typical use case might be:
4
+ #
5
+ # ```
6
+ # # Assumes there is an external Crm tool that we look up username/passwords from.
7
+ # if(SouthparkCrm::Client.authenticate(params[:login], params[:password]))
8
+ # user = Cms::ExternalUser.authenticate('stan.marsh', 'southpark-crm')
9
+ # user.authorize('cms-admin')
10
+ # end
11
+ # ```
12
+ class ExternalUser < Cms::PersistentUser
13
+
14
+ # Allows extra data to be cached from external sources without needing to alter table columns of the :cms_users table.
15
+ # This could be anything from security group information to shoe size.
16
+ store :external_data, coder: JSON
17
+
18
+ class << self
19
+
20
+ # Returns an authenticated external user. If this is the first time this account has been logged in, this will create
21
+ # a new User row as a side effect. Otherwise, it returns the existing user account.
22
+ #
23
+ # @param [String] login
24
+ # @param [String] source Used for documentation purposes to determine where User accounts were granted permission from.
25
+ # @param [Hash] info (Optional) Additional user attributes to assign to user. Can be core user fields (:first_name) or :external_data.
26
+ # @return [Cms::ExternalUser] An ExternalUser record which has been persisted in the database.
27
+ def authenticate(login, source, info={})
28
+ info = work_around_rails_4_serialization_bug(info)
29
+ criteria = {login: login, source: source}
30
+ existing = Cms::ExternalUser.where(criteria).first
31
+ if existing
32
+ existing.update(info)
33
+ return existing
34
+ end
35
+ criteria.merge!(info)
36
+ new_user = Cms::ExternalUser.create!(criteria)
37
+ new_user.groups << Cms::Group.guest if Cms::Group.guest
38
+ new_user
39
+ end
40
+
41
+ # Rails 4.0.2 bug: If some value (even {}) for external_data is not specified, then a serialization error occurs.
42
+ def work_around_rails_4_serialization_bug(info)
43
+ {external_data: {}}.merge(info)
44
+ end
45
+ end
46
+
47
+ # Determines if this User can have their password changed.
48
+ def password_changeable?
49
+ false
50
+ end
51
+
52
+ # Authorize this particular user to be part of one or more groups.
53
+ # This will overwrite any previous group membership. Typically this would be called after authenticating a user.
54
+ # @param [Array<String>] group_codes One or more group codes
55
+ def authorize(*group_codes)
56
+ new_groups = group_codes.collect { |code| Cms::Group.with_code(code).first }
57
+ self.groups = new_groups
58
+ end
59
+ end
60
+ end