locomotivecms 3.0.0.pre.alpha.3 → 3.0.0.pre.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (361) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +15 -8
  3. data/app/api/locomotive/api.rb +1 -0
  4. data/app/api/locomotive/api/entities/content_entry_entity.rb +1 -0
  5. data/app/api/locomotive/api/entities/content_type_entity.rb +2 -1
  6. data/app/api/locomotive/api/entities/site_entity.rb +4 -0
  7. data/app/api/locomotive/api/entities/theme_asset_entity.rb +3 -3
  8. data/app/api/locomotive/api/forms/base_form.rb +0 -6
  9. data/app/api/locomotive/api/forms/content_type_field_form.rb +6 -10
  10. data/app/api/locomotive/api/forms/content_type_form.rb +26 -4
  11. data/app/api/locomotive/api/middlewares/params_decoder_middleware.rb +91 -0
  12. data/app/api/locomotive/api/resources/content_type_resource.rb +7 -2
  13. data/app/api/locomotive/api/resources/current_site_resource.rb +10 -2
  14. data/app/assets/images/locomotive/favicon.png +0 -0
  15. data/app/assets/javascripts/locomotive/not_logged_in.js.coffee +11 -1
  16. data/app/assets/javascripts/locomotive/views/application_view.js.coffee +0 -76
  17. data/app/assets/javascripts/locomotive/views/content_assets/edit_image_view.js.coffee +3 -1
  18. data/app/assets/javascripts/locomotive/views/dashboard/show_view.js.coffee +33 -1
  19. data/app/assets/javascripts/locomotive/views/developers_documentation/show_view.js.coffee +9 -0
  20. data/app/assets/javascripts/locomotive/views/editable_elements/edit_view.js.coffee +3 -1
  21. data/app/assets/javascripts/locomotive/views/editable_elements/index_view.js.coffee +11 -11
  22. data/app/assets/javascripts/locomotive/views/inputs/text_view.js.coffee +16 -0
  23. data/app/assets/javascripts/locomotive/views/pages/_form_view.js.coffee +0 -158
  24. data/app/assets/javascripts/locomotive/views/pages/edit_view.js.coffee +0 -41
  25. data/app/assets/javascripts/locomotive/views/public_submission_accounts/edit_view.js.coffee +7 -0
  26. data/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee +11 -3
  27. data/app/assets/javascripts/locomotive/views/shared/list_view.js.coffee +4 -2
  28. data/app/assets/javascripts/locomotive/views/translations/index_view.js.coffee +5 -0
  29. data/app/assets/stylesheets/locomotive/application.scss +4 -0
  30. data/app/assets/stylesheets/locomotive/base/_fonts.scss +5 -5
  31. data/app/assets/stylesheets/locomotive/base/form/_base.scss +9 -1
  32. data/app/assets/stylesheets/locomotive/components/_activity_feed.scss +66 -0
  33. data/app/assets/stylesheets/locomotive/components/_content_assets.scss +27 -8
  34. data/app/assets/stylesheets/locomotive/components/_developers.scss +34 -0
  35. data/app/assets/stylesheets/locomotive/components/_error.scss +37 -0
  36. data/app/assets/stylesheets/locomotive/components/_list.scss +6 -0
  37. data/app/assets/stylesheets/locomotive/components/_main.scss +4 -0
  38. data/app/assets/stylesheets/locomotive/components/_misc.scss +1 -0
  39. data/app/assets/stylesheets/locomotive/components/_translations.scss +13 -0
  40. data/app/assets/stylesheets/locomotive/components/header/_base.scss +7 -2
  41. data/app/assets/stylesheets/locomotive/components/misc/_modal.scss +13 -0
  42. data/app/assets/stylesheets/locomotive/components/misc/_notify.scss +2 -2
  43. data/app/assets/stylesheets/locomotive/components/not_logged_in/_sign_in_and_up.scss +11 -1
  44. data/app/assets/stylesheets/locomotive/components/sidebar/_pages_tree.scss +2 -2
  45. data/app/assets/stylesheets/locomotive/error.scss +12 -0
  46. data/app/assets/stylesheets/locomotive/globals/_bootstrap.scss +1 -1
  47. data/app/assets/stylesheets/locomotive/globals/_mixins.scss +8 -4
  48. data/app/assets/stylesheets/locomotive/globals/_variables.scss +2 -0
  49. data/app/assets/stylesheets/locomotive/not_logged_in.scss +4 -0
  50. data/app/controllers/locomotive/accounts_controller.rb +6 -1
  51. data/app/controllers/locomotive/base_controller.rb +1 -1
  52. data/app/controllers/locomotive/concerns/exception_controller.rb +2 -1
  53. data/app/controllers/locomotive/concerns/site_dispatcher_controller.rb +2 -1
  54. data/app/controllers/locomotive/content_assets_controller.rb +2 -2
  55. data/app/controllers/locomotive/content_entries_controller.rb +2 -2
  56. data/app/controllers/locomotive/current_site_controller.rb +5 -1
  57. data/app/controllers/locomotive/custom_fields/select_options_controller.rb +1 -1
  58. data/app/controllers/locomotive/dashboard_controller.rb +2 -0
  59. data/app/controllers/locomotive/developers_documentation_controller.rb +11 -0
  60. data/app/controllers/locomotive/editable_elements_controller.rb +11 -10
  61. data/app/controllers/locomotive/errors_controller.rb +15 -0
  62. data/app/controllers/locomotive/pages_controller.rb +3 -3
  63. data/app/controllers/locomotive/public_submission_accounts_controller.rb +42 -0
  64. data/app/controllers/locomotive/translations_controller.rb +9 -23
  65. data/app/helpers/locomotive/base_helper.rb +25 -23
  66. data/app/helpers/locomotive/content_assets_helper.rb +8 -0
  67. data/app/helpers/locomotive/content_entries_helper.rb +13 -19
  68. data/app/helpers/locomotive/content_types_helper.rb +9 -12
  69. data/app/helpers/locomotive/custom_fields_helper.rb +1 -0
  70. data/app/helpers/locomotive/dashboard_helper.rb +91 -0
  71. data/app/helpers/locomotive/developers_documentation_helper.rb +32 -0
  72. data/app/helpers/locomotive/editable_elements_helper.rb +25 -14
  73. data/app/helpers/locomotive/errors_helper.rb +21 -0
  74. data/app/helpers/locomotive/my_account_helper.rb +10 -8
  75. data/app/helpers/locomotive/pages_helper.rb +1 -1
  76. data/app/helpers/locomotive/public_submission_accounts_helper.rb +11 -0
  77. data/app/helpers/locomotive/shared/accounts_helper.rb +2 -2
  78. data/app/helpers/locomotive/sites_helper.rb +15 -11
  79. data/app/helpers/locomotive/translations_helper.rb +21 -13
  80. data/app/inputs/locomotive/api_key_input.rb +2 -0
  81. data/app/inputs/locomotive/array_input.rb +8 -3
  82. data/app/inputs/locomotive/code_input.rb +1 -47
  83. data/app/inputs/locomotive/document_picker_input.rb +1 -0
  84. data/app/inputs/locomotive/rte_input.rb +2 -0
  85. data/app/inputs/locomotive/toggle_input.rb +2 -0
  86. data/app/models/locomotive/activity.rb +32 -0
  87. data/app/models/locomotive/concerns/content_entry/localized.rb +12 -1
  88. data/app/models/locomotive/concerns/content_type/entry_template.rb +52 -0
  89. data/app/models/locomotive/concerns/page/editable_elements.rb +0 -111
  90. data/app/models/locomotive/concerns/page/layout.rb +21 -6
  91. data/app/models/locomotive/concerns/site/access_points.rb +24 -3
  92. data/app/models/locomotive/concerns/site/locales.rb +7 -27
  93. data/app/models/locomotive/content_asset.rb +0 -4
  94. data/app/models/locomotive/content_entry.rb +10 -8
  95. data/app/models/locomotive/content_type.rb +12 -1
  96. data/app/models/locomotive/editable_element.rb +11 -106
  97. data/app/models/locomotive/editable_file.rb +6 -53
  98. data/app/models/locomotive/editable_model.rb +13 -0
  99. data/app/models/locomotive/editable_text.rb +0 -51
  100. data/app/models/locomotive/page.rb +31 -17
  101. data/app/models/locomotive/site.rb +12 -13
  102. data/app/models/locomotive/theme_asset.rb +0 -4
  103. data/app/models/locomotive/translation.rb +50 -35
  104. data/app/policies/locomotive/content_type_policy.rb +4 -0
  105. data/app/policies/locomotive/site_policy.rb +4 -0
  106. data/app/services/locomotive/concerns/activity_service.rb +27 -0
  107. data/app/services/locomotive/content_asset_service.rb +16 -2
  108. data/app/services/locomotive/content_entry_service.rb +77 -8
  109. data/app/services/locomotive/content_type_service.rb +6 -2
  110. data/app/services/locomotive/editable_element_service.rb +11 -4
  111. data/app/services/locomotive/membership_service.rb +20 -4
  112. data/app/services/locomotive/page_parsing_service.rb +94 -23
  113. data/app/services/locomotive/page_service.rb +61 -3
  114. data/app/services/locomotive/site_service.rb +43 -1
  115. data/app/services/locomotive/translation_service.rb +51 -0
  116. data/app/uploaders/locomotive/picture_uploader.rb +5 -1
  117. data/app/views/locomotive/accounts/{new.html.haml → new.html.slim} +0 -0
  118. data/app/views/locomotive/content_assets/{_dropzone.html.haml → _dropzone.html.slim} +4 -3
  119. data/app/views/locomotive/content_assets/{_list.html.haml → _list.html.slim} +11 -9
  120. data/app/views/locomotive/content_assets/{_nav.html.haml → _nav.html.slim} +5 -5
  121. data/app/views/locomotive/content_assets/{_search_form.html.haml → _search_form.html.slim} +1 -1
  122. data/app/views/locomotive/content_assets/edit_in_drawer.html.slim +27 -0
  123. data/app/views/locomotive/content_assets/{index.html.haml → index.html.slim} +4 -4
  124. data/app/views/locomotive/content_assets/{index_in_drawer.html.haml → index_in_drawer.html.slim} +1 -1
  125. data/app/views/locomotive/content_entries/{_entry.html.haml → _entry.html.slim} +3 -3
  126. data/app/views/locomotive/content_entries/{_list.html.haml → _list.html.slim} +9 -8
  127. data/app/views/locomotive/content_entries/{edit.html.haml → edit.html.slim} +5 -0
  128. data/app/views/locomotive/content_entries/form/{_actions.html.haml → _actions.html.slim} +0 -0
  129. data/app/views/locomotive/content_entries/form/{_advanced.html.haml → _advanced.html.slim} +0 -0
  130. data/app/views/locomotive/content_entries/form/{_main.html.haml → _main.html.slim} +0 -0
  131. data/app/views/locomotive/content_entries/form/{_panes.html.haml → _panes.html.slim} +0 -0
  132. data/app/views/locomotive/content_entries/form/{_seo.html.haml → _seo.html.slim} +0 -0
  133. data/app/views/locomotive/content_entries/form/_tabs.html.slim +13 -0
  134. data/app/views/locomotive/content_entries/{index.html.haml → index.html.slim} +22 -9
  135. data/app/views/locomotive/content_entries/{new.html.haml → new.html.slim} +0 -0
  136. data/app/views/locomotive/current_site/{_domain.html.haml → _domain.html.slim} +3 -3
  137. data/app/views/locomotive/current_site/{_locale.html.haml → _locale.html.slim} +4 -4
  138. data/app/views/locomotive/current_site/{_membership.html.haml → _membership.html.slim} +7 -6
  139. data/app/views/locomotive/current_site/{edit.html.haml → edit.html.slim} +1 -1
  140. data/app/views/locomotive/current_site/form/{_access_points.html.haml → _access_points.html.slim} +1 -0
  141. data/app/views/locomotive/current_site/form/{_advanced.html.haml → _advanced.html.slim} +0 -0
  142. data/app/views/locomotive/current_site/form/{_main.html.haml → _main.html.slim} +0 -0
  143. data/app/views/locomotive/current_site/form/{_panes.html.haml → _panes.html.slim} +0 -0
  144. data/app/views/locomotive/current_site/form/{_seo.html.haml → _seo.html.slim} +0 -0
  145. data/app/views/locomotive/current_site/form/_tabs.html.slim +14 -0
  146. data/app/views/locomotive/custom_fields/select_options/{_option.html.haml → _option.html.slim} +7 -7
  147. data/app/views/locomotive/custom_fields/select_options/{edit.html.haml → edit.html.slim} +0 -0
  148. data/app/views/locomotive/dashboard/show.html.slim +28 -0
  149. data/app/views/locomotive/developers_documentation/_api.html.slim +44 -0
  150. data/app/views/locomotive/developers_documentation/_wagon.html.slim +42 -0
  151. data/app/views/locomotive/developers_documentation/show.html.slim +11 -0
  152. data/app/views/locomotive/devise_mailer/reset_password_instructions.html.slim +12 -0
  153. data/app/views/locomotive/editable_elements/_edit.html.slim +52 -0
  154. data/app/views/locomotive/editable_elements/{_form.html.haml → _form.html.slim} +12 -3
  155. data/app/views/locomotive/editable_elements/index.html.slim +8 -0
  156. data/app/views/locomotive/editable_elements/{index_without_preview.html.haml → index_without_preview.html.slim} +5 -4
  157. data/app/views/locomotive/errors/404.html.slim +2 -0
  158. data/app/views/locomotive/errors/500.html.slim +2 -0
  159. data/app/views/locomotive/errors/no_site.html.slim +7 -0
  160. data/app/views/locomotive/layouts/application.html.slim +42 -0
  161. data/app/views/locomotive/layouts/error.html.slim +24 -0
  162. data/app/views/locomotive/layouts/{live_editing.html.haml → live_editing.html.slim} +10 -10
  163. data/app/views/locomotive/layouts/not_logged_in.html.slim +26 -0
  164. data/app/views/locomotive/layouts/{without_site.html.haml → without_site.html.slim} +9 -6
  165. data/app/views/locomotive/memberships/{edit.html.haml → edit.html.slim} +0 -0
  166. data/app/views/locomotive/memberships/{new.html.haml → new.html.slim} +0 -0
  167. data/app/views/locomotive/my_account/{edit.html.haml → edit.html.slim} +1 -1
  168. data/app/views/locomotive/my_account/form/{_actions.html.haml → _actions.html.slim} +0 -0
  169. data/app/views/locomotive/my_account/form/{_api.html.haml → _api.html.slim} +0 -1
  170. data/app/views/locomotive/my_account/form/{_credentials.html.haml → _credentials.html.slim} +0 -0
  171. data/app/views/locomotive/my_account/form/{_main.html.haml → _main.html.slim} +0 -0
  172. data/app/views/locomotive/my_account/form/{_panes.html.haml → _panes.html.slim} +1 -1
  173. data/app/views/locomotive/my_account/form/_tabs.html.slim +7 -0
  174. data/app/views/locomotive/notifications/{new_content_entry.html.haml → new_content_entry.html.slim} +11 -11
  175. data/app/views/locomotive/pages/{edit.html.haml → edit.html.slim} +0 -0
  176. data/app/views/locomotive/pages/form/{_actions.html.haml → _actions.html.slim} +0 -0
  177. data/app/views/locomotive/pages/form/{_main.html.haml → _main.html.slim} +0 -0
  178. data/app/views/locomotive/pages/form/{_panes.html.haml → _panes.html.slim} +0 -0
  179. data/app/views/locomotive/pages/form/{_seo.html.haml → _seo.html.slim} +0 -0
  180. data/app/views/locomotive/pages/form/{_tabs.html.haml → _tabs.html.slim} +1 -1
  181. data/app/views/locomotive/pages/{new.html.haml → new.html.slim} +0 -0
  182. data/app/views/locomotive/pages/show.html.slim +2 -0
  183. data/app/views/locomotive/passwords/{edit.html.haml → edit.html.slim} +6 -6
  184. data/app/views/locomotive/passwords/{new.html.haml → new.html.slim} +6 -6
  185. data/app/views/locomotive/public_submission_accounts/_account.html.slim +19 -0
  186. data/app/views/locomotive/public_submission_accounts/edit.html.slim +16 -0
  187. data/app/views/locomotive/registrations/{new.html.haml → new.html.slim} +2 -4
  188. data/app/views/locomotive/sessions/{new.html.haml → new.html.slim} +2 -4
  189. data/app/views/locomotive/shared/_footer.html.slim +2 -0
  190. data/app/views/locomotive/shared/{_form_actions.html.haml → _form_actions.html.slim} +4 -4
  191. data/app/views/locomotive/shared/_head.html.slim +39 -0
  192. data/app/views/locomotive/shared/{_header.html.haml → _header.html.slim} +10 -10
  193. data/app/views/locomotive/shared/_locale_picker_link.html.slim +11 -0
  194. data/app/views/locomotive/shared/{_main_app_head.html.haml → _main_app_head.html.slim} +0 -0
  195. data/app/views/locomotive/shared/{_main_app_head_before_backbone.html.haml → _main_app_head_before_backbone.html.slim} +0 -0
  196. data/app/views/locomotive/shared/{_main_app_header.html.haml → _main_app_header.html.slim} +0 -0
  197. data/app/views/locomotive/shared/{_sidebar.html.haml → _sidebar.html.slim} +6 -0
  198. data/app/views/locomotive/shared/{_sidebar_without_site.html.haml → _sidebar_without_site.html.slim} +0 -0
  199. data/app/views/locomotive/shared/actions/{_contents.html.haml → _contents.html.slim} +1 -1
  200. data/app/views/locomotive/shared/header/{_account.html.haml → _account.html.slim} +1 -1
  201. data/app/views/locomotive/shared/header/_account_menu.html.slim +5 -0
  202. data/app/views/locomotive/shared/header/_brand.html.slim +5 -0
  203. data/app/views/locomotive/shared/header/{_site.html.haml → _site.html.slim} +2 -2
  204. data/app/views/locomotive/shared/rte/{_image_popover.html.haml → _image_popover.html.slim} +5 -5
  205. data/app/views/locomotive/shared/rte/{_link_popover.html.haml → _link_popover.html.slim} +5 -5
  206. data/app/views/locomotive/shared/rte/_toolbar.html.slim +62 -0
  207. data/app/views/locomotive/shared/sidebar/_content_types.html.slim +16 -0
  208. data/app/views/locomotive/shared/sidebar/_link.html.slim +10 -0
  209. data/app/views/locomotive/shared/sidebar/{_my_account.html.haml → _my_account.html.slim} +2 -2
  210. data/app/views/locomotive/shared/sidebar/_page.html.slim +33 -0
  211. data/app/views/locomotive/shared/sidebar/_pages.html.slim +11 -0
  212. data/app/views/locomotive/sites/{_site.html.haml → _site.html.slim} +3 -3
  213. data/app/views/locomotive/sites/{index.html.haml → index.html.slim} +3 -3
  214. data/app/views/locomotive/sites/{new.html.haml → new.html.slim} +0 -0
  215. data/app/views/locomotive/translations/_form.html.slim +9 -0
  216. data/app/views/locomotive/translations/edit.html.slim +7 -0
  217. data/app/views/locomotive/translations/index.html.slim +41 -0
  218. data/config/initializers/slim.rb +1 -0
  219. data/config/initializers/time_format.rb +15 -0
  220. data/config/locales/admin_ui.en.yml +65 -49
  221. data/config/locales/default.en.yml +3 -0
  222. data/config/locales/default.fr.yml +4 -1
  223. data/config/locales/simple_form.en.yml +14 -8
  224. data/config/routes.rb +6 -0
  225. data/features/support/env.rb +1 -1
  226. data/lib/generators/locomotive/install/install_generator.rb +48 -0
  227. data/lib/generators/locomotive/install/templates/heroku.rb +29 -0
  228. data/lib/generators/locomotive/install/templates/locomotive.rb +5 -2
  229. data/lib/generators/locomotive/install/templates/mongoid.yml +1 -1
  230. data/lib/generators/locomotive/install/templates/mongoid_heroku.yml +78 -0
  231. data/lib/locomotive.rb +0 -1
  232. data/lib/locomotive/configuration.rb +2 -6
  233. data/lib/locomotive/dependencies.rb +1 -2
  234. data/lib/locomotive/dragonfly.rb +4 -5
  235. data/lib/locomotive/engine.rb +10 -13
  236. data/lib/locomotive/middlewares.rb +0 -1
  237. data/lib/locomotive/middlewares/custom_public_exceptions.rb +19 -0
  238. data/lib/locomotive/middlewares/site.rb +49 -16
  239. data/lib/locomotive/simple_form.rb +67 -26
  240. data/lib/locomotive/steam/middlewares/missing_translations.rb +48 -0
  241. data/lib/locomotive/steam/middlewares/page_editing.rb +48 -0
  242. data/lib/locomotive/steam/services/api_entry_submission_service.rb +38 -0
  243. data/lib/locomotive/steam_adaptor.rb +25 -6
  244. data/lib/locomotive/version.rb +1 -1
  245. data/lib/tasks/locomotive.rake +27 -47
  246. data/spec/dummy/app/views/foo/index.html.slim +1 -0
  247. data/spec/dummy/app/views/locomotive/shared/{_main_app_head.html.haml → _main_app_head.html.slim} +0 -0
  248. data/spec/dummy/config.ru +4 -0
  249. data/spec/dummy/config/application.rb +4 -0
  250. data/spec/dummy/config/environments/profile.rb +48 -0
  251. data/spec/dummy/config/mongoid.yml +6 -6
  252. data/spec/lib/locomotive/steam/services/api_entry_submission_service_spec.rb +39 -0
  253. data/spec/models/locomotive/concerns/content_type/entry_template_spec.rb +55 -0
  254. data/spec/models/locomotive/concerns/page/layout_spec.rb +2 -2
  255. data/spec/models/locomotive/concerns/site/access_points_spec.rb +87 -2
  256. data/spec/models/locomotive/concerns/site/locales_spec.rb +2 -3
  257. data/spec/models/locomotive/content_entry_spec.rb +22 -37
  258. data/spec/models/locomotive/page_spec.rb +11 -0
  259. data/spec/models/locomotive/site_spec.rb +0 -36
  260. data/spec/requests/site_spec.rb +28 -0
  261. data/spec/support/capybara.rb +27 -0
  262. data/spec/support/factories.rb +9 -0
  263. data/spec/support/features/session_helpers.rb +21 -0
  264. data/spec/support/locomotive.rb +0 -4
  265. data/spec/support/matchers.rb +0 -25
  266. data/vendor/assets/javascripts/locomotive/highlight.pack.js +1 -0
  267. data/vendor/assets/stylesheets/locomotive/highlightjs/default.css +155 -0
  268. data/vendor/assets/stylesheets/locomotive/highlightjs/github.css +123 -0
  269. metadata +179 -195
  270. data/app/assets/images/locomotive/background/body.png +0 -0
  271. data/app/assets/images/locomotive/form/error-arrow.png +0 -0
  272. data/app/assets/images/locomotive/form/input-sep.png +0 -0
  273. data/app/assets/images/locomotive/icons/start.png +0 -0
  274. data/app/assets/images/locomotive/list/empty.png +0 -0
  275. data/app/assets/images/locomotive/list/item-left.png +0 -0
  276. data/app/assets/images/locomotive/nocoffee.png +0 -0
  277. data/app/assets/images/locomotive/plugins/sites_picker_top_arrow.png +0 -0
  278. data/app/assets/images/locomotive/rails.png +0 -0
  279. data/app/assets/javascripts/locomotive/views/pages/index_view.js.coffee +0 -11
  280. data/app/cells/locomotive/content_locale_picker/show.html.haml +0 -7
  281. data/app/cells/locomotive/content_locale_picker_cell.rb +0 -21
  282. data/app/helpers/locomotive/installation_helper.rb +0 -9
  283. data/app/inputs/locomotive/locale_input.rb +0 -41
  284. data/app/inputs/locomotive/small_code_input.rb +0 -23
  285. data/app/models/locomotive/concerns/content_entry/notifications.rb +0 -33
  286. data/app/models/locomotive/concerns/content_type/item_template.rb +0 -49
  287. data/app/models/locomotive/concerns/page/parse.rb +0 -133
  288. data/app/presenters/locomotive/account_presenter.rb +0 -20
  289. data/app/presenters/locomotive/base_presenter.rb +0 -144
  290. data/app/presenters/locomotive/content_asset_presenter.rb +0 -51
  291. data/app/presenters/locomotive/content_entry_presenter.rb +0 -177
  292. data/app/presenters/locomotive/content_field_presenter.rb +0 -76
  293. data/app/presenters/locomotive/content_type_presenter.rb +0 -82
  294. data/app/presenters/locomotive/editable_control_presenter.rb +0 -19
  295. data/app/presenters/locomotive/editable_element_presenter.rb +0 -46
  296. data/app/presenters/locomotive/editable_file_presenter.rb +0 -36
  297. data/app/presenters/locomotive/editable_text_presenter.rb +0 -40
  298. data/app/presenters/locomotive/membership_presenter.rb +0 -35
  299. data/app/presenters/locomotive/page_presenter.rb +0 -81
  300. data/app/presenters/locomotive/site_presenter.rb +0 -40
  301. data/app/presenters/locomotive/snippet_presenter.rb +0 -22
  302. data/app/presenters/locomotive/theme_asset_presenter.rb +0 -61
  303. data/app/presenters/locomotive/translation_presenter.rb +0 -9
  304. data/app/views/locomotive/content_assets/edit_in_drawer.html.haml +0 -26
  305. data/app/views/locomotive/content_entries/form/_tabs.html.haml +0 -9
  306. data/app/views/locomotive/current_site/form/_tabs.html.haml +0 -14
  307. data/app/views/locomotive/dashboard/show.html.haml +0 -0
  308. data/app/views/locomotive/devise_mailer/reset_password_instructions.html.haml +0 -12
  309. data/app/views/locomotive/editable_elements/_edit.html.haml +0 -49
  310. data/app/views/locomotive/editable_elements/_edit_with_content_entry.html.haml +0 -21
  311. data/app/views/locomotive/editable_elements/index.html.haml +0 -8
  312. data/app/views/locomotive/errors/404.html.haml +0 -7
  313. data/app/views/locomotive/errors/500.html.haml +0 -7
  314. data/app/views/locomotive/errors/no_page.html.haml +0 -1
  315. data/app/views/locomotive/errors/no_site.html.haml +0 -1
  316. data/app/views/locomotive/layouts/application.html.haml +0 -42
  317. data/app/views/locomotive/layouts/error.html.haml +0 -1
  318. data/app/views/locomotive/layouts/not_logged_in.html.haml +0 -18
  319. data/app/views/locomotive/my_account/form/_tabs.html.haml +0 -7
  320. data/app/views/locomotive/pages/_editable_elements.html.haml +0 -64
  321. data/app/views/locomotive/pages/index.html.haml +0 -22
  322. data/app/views/locomotive/pages/show.html.haml +0 -2
  323. data/app/views/locomotive/shared/_footer.html.haml +0 -2
  324. data/app/views/locomotive/shared/_head.html.haml +0 -40
  325. data/app/views/locomotive/shared/_locale_picker_link.html.haml +0 -6
  326. data/app/views/locomotive/shared/header/_account_menu.html.haml +0 -5
  327. data/app/views/locomotive/shared/header/_brand.html.haml +0 -4
  328. data/app/views/locomotive/shared/rte/_toolbar.html.haml +0 -62
  329. data/app/views/locomotive/shared/sidebar/_content_types.html.haml +0 -15
  330. data/app/views/locomotive/shared/sidebar/_link.html.haml +0 -10
  331. data/app/views/locomotive/shared/sidebar/_page.html.haml +0 -33
  332. data/app/views/locomotive/shared/sidebar/_pages.html.haml +0 -11
  333. data/app/views/locomotive/translations/_form.html.haml +0 -12
  334. data/app/views/locomotive/translations/edit.html.haml +0 -15
  335. data/app/views/locomotive/translations/index.html.haml +0 -30
  336. data/app/views/locomotive/translations/new.html.haml +0 -12
  337. data/config/initializers/haml.rb +0 -2
  338. data/config/initializers/locomotive_loaded_first.rb +0 -19
  339. data/config/locales/formtastic.bg.yml +0 -113
  340. data/config/locales/formtastic.cs.yml +0 -125
  341. data/config/locales/formtastic.de.yml +0 -106
  342. data/config/locales/formtastic.es.yml +0 -84
  343. data/config/locales/formtastic.et.yml +0 -103
  344. data/config/locales/formtastic.fr.yml +0 -109
  345. data/config/locales/formtastic.it.yml +0 -99
  346. data/config/locales/formtastic.ja.yml +0 -103
  347. data/config/locales/formtastic.nb.yml +0 -103
  348. data/config/locales/formtastic.nl.yml +0 -85
  349. data/config/locales/formtastic.pl.yml +0 -105
  350. data/config/locales/formtastic.pt-BR.yml +0 -70
  351. data/config/locales/formtastic.pt.yml +0 -70
  352. data/config/locales/formtastic.ru.yml +0 -106
  353. data/config/locales/formtastic.sk.yml +0 -125
  354. data/config/locales/formtastic.sr.yml +0 -112
  355. data/config/locales/formtastic.zh-CN.yml +0 -112
  356. data/lib/locomotive/haml.rb +0 -1
  357. data/lib/locomotive/middlewares/page_editing.rb +0 -41
  358. data/spec/dummy/app/views/foo/index.html.haml +0 -1
  359. data/spec/dummy/config/initializers/haml.rb +0 -2
  360. data/spec/support/asset_host_stubs.rb +0 -17
  361. data/spec/support/controller.rb +0 -32
data/config/routes.rb CHANGED
@@ -28,6 +28,8 @@ Locomotive::Engine.routes.draw do
28
28
  get '/', to: 'dashboard#show'
29
29
  get 'dashboard', to: 'dashboard#show', as: :dashboard
30
30
 
31
+ get 'developers', to: 'developers_documentation#show', as: :developers_documentation
32
+
31
33
  resources :pages do
32
34
  put :sort, on: :member
33
35
  get :get_path, on: :collection
@@ -47,6 +49,10 @@ Locomotive::Engine.routes.draw do
47
49
  post :bulk_create, on: :collection
48
50
  end
49
51
 
52
+ resource :public_submission_accounts, only: [:edit, :update], path: 'content_types/:slug/public_submission_accounts' do
53
+ get :new_account
54
+ end
55
+
50
56
  resources :content_entries, path: 'content_types/:slug/entries' do
51
57
  get :show_in_form, on: :collection
52
58
  put :sort, on: :collection
@@ -79,4 +79,4 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec/support/locomotiv
79
79
 
80
80
  World(Locomotive::Engine.routes.url_helpers) # Load engine routes
81
81
 
82
- Locomotive.configure_for_test(true)
82
+ Locomotive.configure_for_test(true)
@@ -3,6 +3,8 @@ module Locomotive
3
3
 
4
4
  source_root File.expand_path('../../../../../', __FILE__)
5
5
 
6
+ class_option :heroku, type: :boolean, default: false, description: 'if the Engine runs on Heroku'
7
+
6
8
  def copy_initializers
7
9
  @source_paths = nil # reset it for the find_in_source_paths method
8
10
 
@@ -31,10 +33,56 @@ module Locomotive
31
33
  mount Locomotive::Steam::Server.to_app => '/', anchor: false)
32
34
  end
33
35
 
36
+ def enable_heroku
37
+ if options.heroku?
38
+ inject_into_file 'Gemfile', after: "source 'https://rubygems.org'\n" do <<-'RUBY'
39
+
40
+ if ENV['HEROKU_APP_NAME']
41
+ ruby '2.2.2'
42
+ end
43
+ RUBY
44
+ end
45
+
46
+ template 'heroku.rb', 'config/initializers/heroku.rb'
47
+ template 'mongoid_heroku.yml', 'config/mongoid.yml', force: true
48
+
49
+ inject_into_file 'config/environments/production.rb', after: " # config.action_mailer.raise_delivery_errors = false\n" do <<-'RUBY'
50
+ config.action_mailer.raise_delivery_errors = true
51
+ config.action_mailer.delivery_method = :smtp
52
+ config.action_mailer.smtp_settings = {
53
+ :address => 'smtp.sendgrid.net',
54
+ :port => 25,
55
+ :authentication => :plain,
56
+ :user_name => ENV['SENDGRID_USERNAME'],
57
+ :password => ENV['SENDGRID_PASSWORD'],
58
+ :domain => ENV['SENDGRID_DOMAIN']
59
+ }
60
+ RUBY
61
+ end
62
+
63
+ inject_into_file 'config/initializers/carrierwave.rb', after: " config.fog_directory = ENV['S3_BUCKET']\n" do <<-'RUBY'
64
+
65
+ # Put your CDN host below instead
66
+ config.asset_host = ENV['S3_BUCKET_REGION'].present? ? "s3-#{ENV['S3_BUCKET_REGION']}.amazonaws.com" : 's3.amazonaws.com'
67
+ RUBY
68
+ end
69
+
70
+ gem 'platform-api', '~> 0.3.0'
71
+ end
72
+ end
73
+
34
74
  def remove_index_html
35
75
  remove_file 'public/index.html'
36
76
  end
37
77
 
78
+ def use_puma_as_app_server
79
+ inject_into_file 'Gemfile', after: "# gem 'unicorn'\n" do <<-'RUBY'
80
+ # Use Puma as the app server
81
+ gem 'puma'
82
+ RUBY
83
+ end
84
+ end
85
+
38
86
  def show_readme
39
87
  readme 'README'
40
88
  end
@@ -0,0 +1,29 @@
1
+ # Custom code if Locomotive is running on the Heroku platform
2
+
3
+ if Rails.env.production? && (api_key = ENV['HEROKU_API_KEY']) && (app_name = ENV['HEROKU_APP_NAME'])
4
+ Rails.logger.info "[Locomotive] Heroku app detected"
5
+
6
+ require 'platform-api'
7
+
8
+ heroku = PlatformAPI.connect(api_key)
9
+
10
+ ActiveSupport::Notifications.subscribe('locomotive.site.domain_sync') do |name, start, finish, id, payload|
11
+ (payload[:added] || []).each do |domain|
12
+ next if Locomotive.config.host == domain
13
+ begin
14
+ heroku.domain.create(app_name, hostname: domain)
15
+ rescue Exception => e
16
+ Rails.logger.error "Unable to add '#{domain}' as a new domain in Heroku, error #{e.message}"
17
+ end
18
+ end
19
+
20
+ (payload[:removed] || []).each do |domain|
21
+ next if Locomotive.config.host == domain
22
+ begin
23
+ heroku.domain.delete(app_name, domain)
24
+ rescue Exception => e
25
+ Rails.logger.error "Unable to remove '#{domain}' from the list of domains in Heroku, error #{e.message}"
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,11 +1,14 @@
1
1
  Locomotive.configure do |config|
2
2
 
3
+ # enable it if you want Locomotive to render the site of the Rails application embedding the engine
4
+ # config.host = 'mylocomotiveapp.com'
5
+
3
6
  # list of forbidden handles for a site because there are in conflicts with internal resources.
4
7
  # config.reserved_site_handles = %w(sites my_account password sign_in sign_out)
5
8
 
6
- # configure how many items we display in sub menu in the "Contents" section.
9
+ # configure how many items we display in sub menu in the "Models" section.
7
10
  config.ui = {
8
- per_page: 10
11
+ per_page: 10
9
12
  }
10
13
 
11
14
  # default locale (for now, only en, de, fr, pl, pt, pt-BR, it, nl, nb, ja, cs, bg and sk are supported)
@@ -78,4 +78,4 @@ production:
78
78
  options:
79
79
  # consistency: :strong
80
80
  # identity_map_enabled: true
81
- # uri: <%%= ENV['MONGOHQ_URL'] %>
81
+ # uri: <%%= ENV['MONGOLAB_URI'] || ENV['MONGOHQ_URL'] %>
@@ -0,0 +1,78 @@
1
+ development:
2
+ # Configure available database sessions. (required)
3
+ sessions:
4
+ # Defines the default session. (required)
5
+ default:
6
+ # Defines the name of the default database that Mongoid can connect to.
7
+ # (required).
8
+ database: <%= Rails.application.class.parent.to_s.underscore.downcase %>_dev
9
+ # Provides the hosts the default session can connect to. Must be an array
10
+ # of host:port pairs. (required)
11
+ hosts:
12
+ - localhost:27017
13
+ options:
14
+ # Change whether the session persists in safe mode by default.
15
+ # (default: false)
16
+ # safe: false
17
+
18
+ # Change the default consistency model to :eventual or :strong.
19
+ # :eventual will send reads to secondaries, :strong sends everything
20
+ # to master. (default: :eventual)
21
+ # consistency: :strong
22
+ # Configure Mongoid specific options. (optional)
23
+ options:
24
+ # Configuration for whether or not to allow access to fields that do
25
+ # not have a field definition on the model. (default: true)
26
+ # allow_dynamic_fields: true
27
+
28
+ # Enable the identity map, needed for eager loading. (default: false)
29
+ # identity_map_enabled: true
30
+
31
+ # Includes the root model name in json serialization. (default: false)
32
+ # include_root_in_json: false
33
+
34
+ # Include the _type field in serializaion. (default: false)
35
+ # include_type_for_serialization: false
36
+
37
+ # Preload all models in development, needed when models use
38
+ # inheritance. (default: false)
39
+ # preload_models: false
40
+
41
+ # Protect id and type from mass assignment. (default: true)
42
+ # protect_sensitive_fields: true
43
+
44
+ # Raise an error when performing a #find and the document is not found.
45
+ # (default: true)
46
+ # raise_not_found_error: true
47
+
48
+ # Raise an error when defining a scope with the same name as an
49
+ # existing method. (default: false)
50
+ # scope_overwrite_exception: false
51
+
52
+ # Skip the database version check, used when connecting to a db without
53
+ # admin access. (default: false)
54
+ # skip_version_check: false
55
+
56
+ # User Active Support's time zone in conversions. (default: true)
57
+ # use_activesupport_time_zone: true
58
+
59
+ # Ensure all times are UTC in the app side. (default: false)
60
+ # use_utc: false
61
+
62
+ test:
63
+ sessions:
64
+ default:
65
+ database: <%= Rails.application.class.parent.to_s.underscore.downcase %>_test
66
+ hosts:
67
+ - localhost:27017
68
+ options:
69
+ # consistency: :strong
70
+ # identity_map_enabled: true
71
+
72
+ production:
73
+ sessions:
74
+ default:
75
+ uri: <%%= ENV['MONGOLAB_URI'] || ENV['MONGOHQ_URL'] %>
76
+ options:
77
+ # consistency: :strong
78
+ # identity_map_enabled: true
data/lib/locomotive.rb CHANGED
@@ -4,7 +4,6 @@ require 'locomotive/configuration'
4
4
  require 'locomotive/devise'
5
5
  require 'locomotive/simple_token_authentication'
6
6
  require 'locomotive/logger'
7
- require 'locomotive/haml'
8
7
  require 'locomotive/simple_form'
9
8
  require 'locomotive/dragonfly'
10
9
  require 'locomotive/kaminari'
@@ -5,6 +5,7 @@ module Locomotive
5
5
 
6
6
  @@defaults = {
7
7
  name: 'Locomotive',
8
+ host: nil,
8
9
  # forbidden_paths: %w{layouts snippets stylesheets javascripts assets admin system api},
9
10
  reserved_site_handles: %w(sites my_account password sign_in sign_out),
10
11
  reserved_slugs: %w{stylesheets javascripts assets admin locomotive images api pages edit},
@@ -25,12 +26,7 @@ module Locomotive
25
26
  metastore: URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/meta"), # URI encoded in case of spaces
26
27
  entitystore: URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/body")
27
28
  },
28
- devise_modules: [:registerable, :rememberable, :database_authenticatable, :recoverable, :trackable, :validatable, :encryptable, { encryptor: :sha1 }],
29
- context_assign_extensions: { },
30
- models_for_templatization: [],
31
- csrf_protection: false,
32
- theme_assets_checksum: false,
33
- asset_host: nil
29
+ devise_modules: [:registerable, :rememberable, :database_authenticatable, :recoverable, :trackable, :validatable, :encryptable, { encryptor: :sha1 }]
34
30
  }
35
31
 
36
32
  cattr_accessor :settings
@@ -13,14 +13,13 @@ require 'bootstrap-kaminari-views'
13
13
  require 'bootstrap-sass'
14
14
  require 'font-awesome-sass'
15
15
  require 'autoprefixer-rails'
16
- require 'haml'
16
+ require 'slim'
17
17
  require 'simple_form'
18
18
  require 'responders'
19
19
  require 'carrierwave'
20
20
  require 'custom_fields'
21
21
  require 'mimetype_fu'
22
22
  require 'actionmailer_with_request'
23
- require 'httparty'
24
23
  require 'select2-rails'
25
24
  require 'dragonfly'
26
25
  require 'pundit'
@@ -22,7 +22,7 @@ module Locomotive
22
22
  def self.fetch_file(source)
23
23
  file = nil
24
24
 
25
- if source.is_a?(String) || source.is_a?(Hash) # simple string or theme asset
25
+ if source.is_a?(String) || source.is_a?(Hash) # simple string or drop
26
26
  source = source['url'] if source.is_a?(Hash)
27
27
 
28
28
  clean_source!(source)
@@ -34,12 +34,11 @@ module Locomotive
34
34
  end
35
35
 
36
36
  elsif source.respond_to?(:url) # carrierwave uploader
37
- if source.file.respond_to?(:url)
38
- file = self.app.fetch_url(source.url) # amazon s3, cloud files, ...etc
39
- else
37
+ if source.path.first == '/'
40
38
  file = self.app.fetch_file(source.path)
39
+ else
40
+ file = self.app.fetch_url(source.url)
41
41
  end
42
-
43
42
  end
44
43
 
45
44
  file
@@ -10,19 +10,15 @@ module Locomotive
10
10
 
11
11
  paths['mongodb/migrate'] = 'mongodb/migrate'
12
12
 
13
- initializer "locomotive.params.filter" do |app|
14
- # Do not log remote_<field>_url params because they can contain huge base64 string
15
- app.config.filter_parameters += [/\Aremote_.+_url\Z/]
13
+ config.to_prepare do
14
+ Dir.glob(Rails.root + 'app/decorators/**/*_decorator*.rb').each do |c|
15
+ require_dependency(c)
16
+ end
16
17
  end
17
18
 
18
- initializer 'locomotive.content_types' do |app|
19
- # Load all the dynamic classes (custom fields)
20
- begin
21
- ContentType.all.collect { |content_type| content_type.klass_with_custom_fields(:entries) }
22
- rescue Exception => e
23
- # let assume it's because of the first install (meaning no config.yml file)
24
- Locomotive.log :warn, "WARNING: unable to load the content types, #{e.message}"
25
- end
19
+ initializer 'locomotive.params.filter' do |app|
20
+ # Do not log remote_<field>_url params because they can contain huge base64 string
21
+ app.config.filter_parameters += [/\Aremote_.+_url\Z/]
26
22
  end
27
23
 
28
24
  initializer 'locomotive.action_controller' do |app|
@@ -33,14 +29,15 @@ module Locomotive
33
29
  ::DeviseController.respond_to :html, :json
34
30
  end
35
31
 
36
- initializer "locomotive.precompile.hook", group: :all do |app|
32
+ initializer 'locomotive.precompile.hook', group: :all do |app|
37
33
  app.config.assets.precompile += %w(
38
34
  locomotive/wysihtml5_reset.css
39
35
  locomotive/wysihtml5_editor.css
40
36
  locomotive.js
41
37
  locomotive.css
42
38
  locomotive/not_logged_in.js
43
- locomotive/not_logged_in.css)
39
+ locomotive/not_logged_in.css
40
+ locomotive/error.css)
44
41
 
45
42
  # Uncomment the lines below to view the names of assets as they are
46
43
  # precompiled for the rails asset pipeline
@@ -1,2 +1 @@
1
1
  require 'locomotive/middlewares/site'
2
- require 'locomotive/middlewares/page_editing'
@@ -0,0 +1,19 @@
1
+ module Locomotive
2
+ module Middlewares
3
+
4
+ class CustomPublicExceptions < ActionDispatch::PublicExceptions
5
+
6
+ def call(env)
7
+ status = env['PATH_INFO'][1..-1]
8
+
9
+ if status == '404' || status == '500'
10
+ Locomotive::ErrorsController.action(:"error_#{status}").call(env)
11
+ else
12
+ super
13
+ end
14
+ end
15
+
16
+ end
17
+
18
+ end
19
+ end
@@ -8,9 +8,16 @@ module Locomotive
8
8
 
9
9
  def call(env)
10
10
  env['locomotive.site'] = env['steam.site'] = fetch_site(env)
11
- @app.call(env)
11
+ begin
12
+ @app.call(env)
13
+ rescue ::Locomotive::Steam::NoSiteException => exception
14
+ # no_site!
15
+ Locomotive::ErrorsController.action(:no_site).call(env)
16
+ end
12
17
  end
13
18
 
19
+ private
20
+
14
21
  def fetch_site(env)
15
22
  request = Rack::Request.new(env)
16
23
  handle = site_handle(request)
@@ -20,25 +27,41 @@ module Locomotive
20
27
  Locomotive.log "[fetch site] host = #{request.host} / site_handle = #{handle.inspect}"
21
28
 
22
29
  if handle
23
- # The site is not rendered from a domain but from the back-office
24
- # we need to get:
25
- # - the path of "mouting point" (basically: locomotive/:handle/preview)
26
- # - the real path of the page
27
- #
28
- # FIXME: move that in a different middleware
29
- mounted_on = "#{Locomotive.mounted_on}/#{handle}/preview"
30
+ fetch_from_handle(handle, env, request)
31
+ elsif !request_for_the_back_office_and_default_host?(request)
32
+ fetch_from_host(env, request)
33
+ else
34
+ nil
35
+ end
36
+ end
30
37
 
31
- env['locomotive.mounted_on'] = env['steam.mounted_on'] = mounted_on
32
- env['locomotive.path'] = request.path_info.gsub(mounted_on, '')
38
+ # def no_site!(env)
39
+ # Locomotive::ErrorsController.action(:no_site).call(env)
40
+ # # [200, { 'Content-Type' => 'text/html' }, ['Hello world']]
41
+ # end
33
42
 
34
- env['steam.live_editing'] = true
43
+ # The site is not rendered from a domain but from the back-office
44
+ # we need to get:
45
+ # - the path of "mouting point" (basically: locomotive/:handle/preview)
46
+ # - the real path of the page
47
+ #
48
+ # FIXME: move that in a different middleware
49
+ def fetch_from_handle(handle, env, request)
50
+ mounted_on = "#{Locomotive.mounted_on}/#{handle}/preview"
35
51
 
36
- Locomotive::Site.where(handle: handle).first
37
- else
38
- env['locomotive.path'] = request.path_info
52
+ env['locomotive.mounted_on'] = env['steam.mounted_on'] = mounted_on
53
+ env['locomotive.path'] = request.path_info.gsub(mounted_on, '')
39
54
 
40
- Locomotive::Site.match_domain(request.host).first
41
- end
55
+ env['steam.live_editing'] = true
56
+
57
+ Locomotive::Site.where(handle: handle).first
58
+ end
59
+
60
+ # The request is for one of the domains registered in Locomotive.
61
+ # Find the related site.
62
+ def fetch_from_host(env, request)
63
+ env['locomotive.path'] = request.path_info
64
+ Locomotive::Site.match_domain(request.host).first
42
65
  end
43
66
 
44
67
  def site_handle(request)
@@ -55,6 +78,16 @@ module Locomotive
55
78
  @regexp ||= /#{Locomotive.mounted_on}\/([^\/]+)/o
56
79
  end
57
80
 
81
+ # Is it a request for the back-office AND the domain used to also
82
+ # render the site of the Rails application?
83
+ def request_for_the_back_office_and_default_host?(request)
84
+ default_host && request.host == default_host && request.path_info =~ /#{Locomotive.mounted_on}\//
85
+ end
86
+
87
+ def default_host
88
+ Locomotive.config.host
89
+ end
90
+
58
91
  end
59
92
  end
60
93
  end