locomotive_cms 2.0.3 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/Gemfile +3 -3
- data/README.textile +7 -7
- data/app/assets/images/locomotive/icons/flags/ja.png +0 -0
- data/app/assets/javascripts/locomotive/aloha.js.coffee +3 -0
- data/app/assets/javascripts/locomotive/models/page.js.coffee +1 -1
- data/app/assets/javascripts/locomotive/models/site.js.coffee +16 -6
- data/app/assets/javascripts/locomotive/utils/aloha_settings.js.coffee +1 -1
- data/app/assets/javascripts/locomotive/views/content_entries/_form_view.js.coffee +5 -0
- data/app/assets/javascripts/locomotive/views/my_account/edit_view.js.coffee +14 -0
- data/app/assets/javascripts/locomotive/views/pages/_form_view.js.coffee +1 -1
- data/app/assets/javascripts/locomotive/views/pages/edit_view.js.coffee +2 -1
- data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/de.js +1 -0
- data/app/assets/stylesheets/locomotive.css +1 -0
- data/app/assets/stylesheets/locomotive/backoffice/formtastic_changes.css.scss +18 -3
- data/app/assets/stylesheets/locomotive/backoffice/layout.css.scss +1 -1
- data/app/assets/stylesheets/locomotive/backoffice/menu/main.css.scss +7 -3
- data/app/assets/stylesheets/locomotive/backoffice/pagination.css.scss +37 -0
- data/app/assets/stylesheets/locomotive/backoffice/tagit_changes.css.scss +49 -0
- data/app/cells/locomotive/content_locale_picker/show.html.haml +1 -1
- data/app/cells/locomotive/global_actions_cell.rb +8 -8
- data/app/cells/locomotive/main_menu/show.html.haml +2 -2
- data/app/cells/locomotive/main_menu_cell.rb +2 -2
- data/app/cells/locomotive/menu_cell.rb +6 -6
- data/app/cells/locomotive/partials_cell.rb +21 -0
- data/app/cells/locomotive/settings_menu_cell.rb +4 -4
- data/app/cells/locomotive/sub_menu/show.html.haml +2 -2
- data/app/cells/locomotive/sub_menu_cell.rb +1 -1
- data/app/controllers/locomotive/accounts_controller.rb +4 -4
- data/app/controllers/locomotive/api/accounts_controller.rb +1 -0
- data/app/controllers/locomotive/api/content_assets_controller.rb +1 -1
- data/app/controllers/locomotive/api/content_entries_controller.rb +1 -1
- data/app/controllers/locomotive/api/content_types_controller.rb +2 -2
- data/app/controllers/locomotive/api/pages_controller.rb +1 -1
- data/app/controllers/locomotive/api/snippets_controller.rb +1 -1
- data/app/controllers/locomotive/api/theme_assets_controller.rb +47 -0
- data/app/controllers/locomotive/api/tokens_controller.rb +2 -2
- data/app/controllers/locomotive/base_controller.rb +5 -2
- data/app/controllers/locomotive/content_assets_controller.rb +1 -1
- data/app/controllers/locomotive/content_entries_controller.rb +22 -9
- data/app/controllers/locomotive/content_types_controller.rb +6 -6
- data/app/controllers/locomotive/current_site_controller.rb +6 -6
- data/app/controllers/locomotive/installation_controller.rb +11 -3
- data/app/controllers/locomotive/memberships_controller.rb +6 -6
- data/app/controllers/locomotive/my_account_controller.rb +9 -3
- data/app/controllers/locomotive/pages_controller.rb +10 -6
- data/app/controllers/locomotive/passwords_controller.rb +1 -1
- data/app/controllers/locomotive/public/content_entries_controller.rb +1 -1
- data/app/controllers/locomotive/public/pages_controller.rb +5 -5
- data/app/controllers/locomotive/public/robots_controller.rb +1 -1
- data/app/controllers/locomotive/public/sitemaps_controller.rb +1 -1
- data/app/controllers/locomotive/sessions_controller.rb +1 -1
- data/app/controllers/locomotive/sites_controller.rb +5 -5
- data/app/controllers/locomotive/snippets_controller.rb +6 -6
- data/app/controllers/locomotive/theme_assets_controller.rb +6 -6
- data/app/controllers/locomotive/translations_controller.rb +1 -1
- data/app/helpers/locomotive/accounts_helper.rb +1 -1
- data/app/helpers/locomotive/base_helper.rb +13 -21
- data/app/helpers/locomotive/content_types_helper.rb +3 -3
- data/app/helpers/locomotive/custom_fields_helper.rb +5 -5
- data/app/helpers/locomotive/installation_helper.rb +1 -1
- data/app/helpers/locomotive/pages_helper.rb +5 -5
- data/app/helpers/locomotive/snippets_helper.rb +1 -1
- data/app/helpers/locomotive/theme_assets_helper.rb +1 -1
- data/app/helpers/locomotive/translations_helper.rb +2 -2
- data/app/inputs/locomotive/api_key_input.rb +40 -0
- data/app/inputs/locomotive/code_input.rb +5 -5
- data/app/inputs/locomotive/file_input.rb +6 -6
- data/app/inputs/locomotive/locale_input.rb +5 -5
- data/app/inputs/locomotive/locales_input.rb +4 -4
- data/app/inputs/locomotive/rte_input.rb +1 -1
- data/app/inputs/locomotive/small_code_input.rb +1 -1
- data/app/inputs/locomotive/subdomain_input.rb +1 -1
- data/app/mailers/locomotive/devise_mailer.rb +1 -1
- data/app/mailers/locomotive/notifications.rb +3 -3
- data/app/models/locomotive/ability.rb +10 -11
- data/app/models/locomotive/account.rb +61 -26
- data/app/models/locomotive/content_asset.rb +8 -8
- data/app/models/locomotive/content_entry.rb +8 -7
- data/app/models/locomotive/content_type.rb +12 -7
- data/app/models/locomotive/editable_control.rb +2 -2
- data/app/models/locomotive/editable_element.rb +13 -8
- data/app/models/locomotive/editable_file.rb +5 -3
- data/app/models/locomotive/editable_short_text.rb +3 -3
- data/app/models/locomotive/extensions/asset/types.rb +2 -2
- data/app/models/locomotive/extensions/content_entry/csv.rb +78 -0
- data/app/models/locomotive/extensions/content_type/item_template.rb +3 -3
- data/app/models/locomotive/extensions/content_type/sync.rb +4 -4
- data/app/models/locomotive/extensions/page/editable_elements.rb +1 -1
- data/app/models/locomotive/extensions/page/parse.rb +2 -2
- data/app/models/locomotive/extensions/page/render.rb +7 -1
- data/app/models/locomotive/extensions/page/templatized.rb +20 -15
- data/app/models/locomotive/extensions/page/tree.rb +4 -4
- data/app/models/locomotive/extensions/shared/seo.rb +3 -3
- data/app/models/locomotive/extensions/site/first_installation.rb +5 -2
- data/app/models/locomotive/extensions/site/locales.rb +9 -6
- data/app/models/locomotive/extensions/site/subdomain_domains.rb +8 -8
- data/app/models/locomotive/membership.rb +6 -6
- data/app/models/locomotive/page.rb +30 -23
- data/app/models/locomotive/site.rb +19 -15
- data/app/models/locomotive/snippet.rb +5 -5
- data/app/models/locomotive/theme_asset.rb +17 -6
- data/app/models/locomotive/translation.rb +21 -16
- data/app/presenters/locomotive/account_presenter.rb +1 -1
- data/app/presenters/locomotive/content_entry_presenter.rb +2 -2
- data/app/presenters/locomotive/content_field_presenter.rb +2 -2
- data/app/presenters/locomotive/content_type_presenter.rb +6 -1
- data/app/presenters/locomotive/theme_asset_presenter.rb +2 -2
- data/app/uploaders/locomotive/editable_file_uploader.rb +1 -1
- data/app/uploaders/locomotive/theme_asset_uploader.rb +1 -1
- data/app/views/locomotive/accounts/new.html.haml +6 -6
- data/app/views/locomotive/content_assets/_asset.html.haml +3 -3
- data/app/views/locomotive/content_assets/_picker.html.haml +12 -12
- data/app/views/locomotive/content_entries/_form.html.haml +9 -8
- data/app/views/locomotive/content_entries/_list.html.haml +8 -5
- data/app/views/locomotive/content_entries/edit.html.haml +6 -6
- data/app/views/locomotive/content_entries/index.html.haml +8 -6
- data/app/views/locomotive/content_entries/new.html.haml +5 -5
- data/app/views/locomotive/content_types/_form.html.haml +16 -16
- data/app/views/locomotive/content_types/edit.html.haml +5 -5
- data/app/views/locomotive/content_types/new.html.haml +3 -3
- data/app/views/locomotive/current_site/_form.html.haml +12 -12
- data/app/views/locomotive/current_site/edit.html.haml +5 -5
- data/app/views/locomotive/custom_fields/_form.html.haml +23 -19
- data/app/views/locomotive/custom_fields/_select_templates.html.haml +5 -5
- data/app/views/locomotive/custom_fields/types/_belongs_to.html.haml +4 -4
- data/app/views/locomotive/custom_fields/types/_boolean.html.haml +3 -3
- data/app/views/locomotive/custom_fields/types/_date.html.haml +4 -4
- data/app/views/locomotive/custom_fields/types/_email.html.haml +4 -0
- data/app/views/locomotive/custom_fields/types/_file.html.haml +3 -3
- data/app/views/locomotive/custom_fields/types/_float.html.haml +6 -0
- data/app/views/locomotive/custom_fields/types/_has_many.html.haml +10 -10
- data/app/views/locomotive/custom_fields/types/_integer.html.haml +5 -0
- data/app/views/locomotive/custom_fields/types/_many_to_many.html.haml +10 -10
- data/app/views/locomotive/custom_fields/types/_select.html.haml +10 -10
- data/app/views/locomotive/custom_fields/types/_string.html.haml +3 -3
- data/app/views/locomotive/custom_fields/types/_tags.html.haml +4 -0
- data/app/views/locomotive/custom_fields/types/_text.html.haml +4 -4
- data/app/views/locomotive/devise_mailer/reset_password_instructions.html.haml +1 -1
- data/app/views/locomotive/installation/step_1.html.haml +5 -5
- data/app/views/locomotive/installation/step_2.html.haml +6 -6
- data/app/views/locomotive/kaminari/_first_page.html.haml +2 -0
- data/app/views/locomotive/kaminari/_gap.html.haml +2 -0
- data/app/views/locomotive/kaminari/_last_page.html.haml +2 -0
- data/app/views/locomotive/kaminari/_next_page.html.haml +2 -0
- data/app/views/locomotive/kaminari/_page.html.haml +2 -0
- data/app/views/locomotive/kaminari/_paginator.html.haml +11 -0
- data/app/views/locomotive/kaminari/_prev_page.html.haml +2 -0
- data/app/views/locomotive/layouts/application.html.haml +2 -2
- data/app/views/locomotive/layouts/not_logged_in.html.haml +3 -3
- data/app/views/locomotive/memberships/new.html.haml +4 -4
- data/app/views/locomotive/my_account/edit.html.haml +14 -13
- data/app/views/locomotive/notifications/new_content_entry.html.haml +2 -2
- data/app/views/locomotive/pages/_editable_elements.html.haml +20 -20
- data/app/views/locomotive/pages/_form.html.haml +23 -27
- data/app/views/locomotive/pages/_page.html.haml +6 -6
- data/app/views/locomotive/pages/edit.html.haml +5 -5
- data/app/views/locomotive/pages/index.html.haml +2 -2
- data/app/views/locomotive/pages/new.html.haml +4 -4
- data/app/views/locomotive/passwords/edit.html.haml +3 -3
- data/app/views/locomotive/passwords/new.html.haml +2 -2
- data/app/views/locomotive/public/pages/show_toolbar.html.haml +15 -15
- data/app/views/locomotive/sessions/new.html.haml +4 -4
- data/app/views/locomotive/shared/_footer.html.haml +1 -1
- data/app/views/locomotive/shared/_head.html.haml +7 -7
- data/app/views/locomotive/shared/_header.html.haml +2 -2
- data/app/views/locomotive/shared/_locale_picker_link.html.haml +1 -1
- data/app/views/locomotive/shared/_site_picker.html.haml +2 -2
- data/app/views/locomotive/shared/actions/_contents.html.haml +1 -1
- data/app/views/locomotive/shared/menu/_contents.html.haml +5 -5
- data/app/views/locomotive/sites/_domains.html.haml +7 -7
- data/app/views/locomotive/sites/_form.html.haml +6 -1
- data/app/views/locomotive/sites/_memberships.html.haml +3 -3
- data/app/views/locomotive/sites/new.html.haml +3 -3
- data/app/views/locomotive/snippets/_form.html.haml +6 -6
- data/app/views/locomotive/snippets/_snippet.html.haml +2 -2
- data/app/views/locomotive/snippets/edit.html.haml +5 -5
- data/app/views/locomotive/snippets/new.html.haml +3 -3
- data/app/views/locomotive/theme_assets/_asset.html.haml +2 -2
- data/app/views/locomotive/theme_assets/_form.html.haml +10 -10
- data/app/views/locomotive/theme_assets/_list.html.haml +3 -3
- data/app/views/locomotive/theme_assets/_picker.html.haml +8 -8
- data/app/views/locomotive/theme_assets/edit.html.haml +7 -7
- data/app/views/locomotive/theme_assets/index.html.haml +6 -6
- data/app/views/locomotive/theme_assets/new.html.haml +3 -3
- data/app/views/locomotive/translations/_form.html.haml +3 -3
- data/app/views/locomotive/translations/edit.html.haml +6 -6
- data/app/views/locomotive/translations/index.html.haml +2 -0
- data/app/views/locomotive/translations/new.html.haml +2 -2
- data/config/initializers/csv_renderer.rb +10 -0
- data/config/locales/admin_ui.de.yml +1 -0
- data/config/locales/admin_ui.en.yml +12 -0
- data/config/locales/admin_ui.es.yml +1 -0
- data/config/locales/admin_ui.et.yml +1 -0
- data/config/locales/admin_ui.fr.yml +12 -0
- data/config/locales/admin_ui.it.yml +1 -0
- data/config/locales/admin_ui.ja.yml +335 -0
- data/config/locales/admin_ui.nb.yml +1 -0
- data/config/locales/admin_ui.nl.yml +1 -0
- data/config/locales/admin_ui.pl.yml +1 -0
- data/config/locales/admin_ui.pt-BR.yml +8 -0
- data/config/locales/admin_ui.ru.yml +1 -0
- data/config/locales/carrierwave.ja.yml +4 -0
- data/config/locales/default.de.yml +1 -1
- data/config/locales/default.en.yml +1 -1
- data/config/locales/default.es.yml +3 -0
- data/config/locales/default.et.yml +2 -2
- data/config/locales/default.fr.yml +1 -1
- data/config/locales/default.it.yml +3 -0
- data/config/locales/default.ja.yml +94 -0
- data/config/locales/default.nb.yml +1 -1
- data/config/locales/default.nl.yml +5 -0
- data/config/locales/default.pl.yml +2 -2
- data/config/locales/default.pt-BR.yml +3 -2
- data/config/locales/default.ru.yml +19 -16
- data/config/locales/devise.ja.yml +63 -0
- data/config/locales/flash.ja.yml +115 -0
- data/config/locales/formtastic.en.yml +7 -0
- data/config/locales/formtastic.fr.yml +9 -0
- data/config/locales/formtastic.ja.yml +103 -0
- data/config/locales/formtastic.pt-BR.yml +1 -1
- data/config/routes.rb +5 -2
- data/features/api/authentication.feature +24 -2
- data/features/api/authorization/pages.feature +3 -1
- data/features/api/entries_custom_fields.feature +2 -2
- data/features/backoffice/authorization/pages.feature +7 -7
- data/features/backoffice/content_types/email.feature +26 -0
- data/features/backoffice/content_types/has_many.feature +20 -0
- data/features/backoffice/content_types/integer.feature +26 -0
- data/features/backoffice/content_types/many_to_many.feature +29 -1
- data/features/backoffice/content_types/tags.feature +22 -0
- data/features/backoffice/content_types/uniqueness.feature +29 -0
- data/features/backoffice/contents.feature +16 -0
- data/features/backoffice/installation.feature +33 -0
- data/features/backoffice/my_account.feature +21 -0
- data/features/backoffice/pages.feature +21 -1
- data/features/backoffice/site.feature +59 -40
- data/features/backoffice/snippets.feature +1 -1
- data/features/backoffice/translations.feature +7 -1
- data/features/public/basic.feature +1 -1
- data/features/public/pages.feature +92 -0
- data/features/public/session.feature +40 -0
- data/features/public/tags.feature +45 -0
- data/features/step_definitions/backoffice_steps.rb +4 -0
- data/features/step_definitions/content_types_steps.rb +16 -3
- data/features/step_definitions/more_web_steps.rb +35 -4
- data/features/step_definitions/page_steps.rb +52 -35
- data/features/step_definitions/pagination_steps.rb +4 -4
- data/features/step_definitions/site_steps.rb +22 -10
- data/features/step_definitions/snippet_steps.rb +1 -1
- data/features/step_definitions/theme_asset_steps.rb +2 -2
- data/features/step_definitions/translation_steps.rb +1 -1
- data/features/step_definitions/web_steps.rb +1 -1
- data/features/support/http.rb +1 -1
- data/features/support/locales.rb +5 -0
- data/lib/generators/locomotive/install/install_generator.rb +1 -6
- data/lib/generators/locomotive/install/templates/carrierwave.rb +4 -4
- data/lib/generators/locomotive/install/templates/locomotive.rb +12 -7
- data/lib/locomotive.rb +4 -4
- data/lib/locomotive/action_controller.rb +1 -0
- data/lib/locomotive/action_controller/responder.rb +9 -10
- data/lib/locomotive/action_controller/section_helpers.rb +1 -1
- data/lib/locomotive/action_controller/ssl.rb +11 -0
- data/lib/locomotive/action_controller/url_helpers.rb +9 -5
- data/lib/locomotive/carrierwave/asset.rb +6 -6
- data/lib/locomotive/configuration.rb +28 -26
- data/lib/locomotive/core_ext.rb +1 -2
- data/lib/locomotive/custom_fields.rb +12 -6
- data/lib/locomotive/dependencies.rb +1 -0
- data/lib/locomotive/dragonfly.rb +1 -1
- data/lib/locomotive/engine.rb +3 -3
- data/lib/locomotive/formtastic.rb +1 -1
- data/lib/locomotive/httparty/webservice.rb +1 -1
- data/lib/locomotive/kaminari.rb +28 -13
- data/lib/locomotive/liquid.rb +1 -0
- data/lib/locomotive/liquid/drops/content_entry.rb +1 -1
- data/lib/locomotive/liquid/drops/content_types.rb +27 -2
- data/lib/locomotive/liquid/drops/page.rb +14 -2
- data/lib/locomotive/liquid/drops/proxy_collection.rb +4 -0
- data/lib/locomotive/liquid/drops/session_proxy.rb +16 -0
- data/lib/locomotive/liquid/drops/site.rb +11 -3
- data/lib/locomotive/liquid/drops/uploader.rb +1 -1
- data/lib/locomotive/liquid/filters/base.rb +1 -1
- data/lib/locomotive/liquid/filters/date.rb +2 -2
- data/lib/locomotive/liquid/filters/html.rb +12 -12
- data/lib/locomotive/liquid/filters/translate.rb +21 -3
- data/lib/locomotive/liquid/tags/consume.rb +50 -19
- data/lib/locomotive/liquid/tags/editable/base.rb +9 -9
- data/lib/locomotive/liquid/tags/editable/control.rb +1 -1
- data/lib/locomotive/liquid/tags/editable/file.rb +1 -1
- data/lib/locomotive/liquid/tags/editable/short_text.rb +1 -1
- data/lib/locomotive/liquid/tags/fetch_page.rb +28 -0
- data/lib/locomotive/liquid/tags/hybrid.rb +25 -0
- data/lib/locomotive/liquid/tags/inherited_block.rb +2 -2
- data/lib/locomotive/liquid/tags/inline_editor.rb +4 -4
- data/lib/locomotive/liquid/tags/javascript.rb +16 -0
- data/lib/locomotive/liquid/tags/link_to.rb +42 -0
- data/lib/locomotive/liquid/tags/locale_switcher.rb +1 -1
- data/lib/locomotive/liquid/tags/nav.rb +2 -2
- data/lib/locomotive/liquid/tags/paginate.rb +2 -2
- data/lib/locomotive/liquid/tags/session_assign.rb +39 -0
- data/lib/locomotive/liquid/tags/snippet.rb +1 -1
- data/lib/locomotive/liquid/tags/with_scope.rb +6 -2
- data/lib/locomotive/logger.rb +1 -1
- data/lib/locomotive/middlewares/cache.rb +1 -1
- data/lib/locomotive/middlewares/fonts.rb +1 -1
- data/lib/locomotive/middlewares/inline_editor.rb +1 -1
- data/lib/locomotive/middlewares/permalink.rb +1 -1
- data/lib/locomotive/middlewares/seo_trailing_slash.rb +1 -1
- data/lib/locomotive/mongoid/patches.rb +21 -21
- data/lib/locomotive/rails/action_view.rb +20 -4
- data/lib/locomotive/regexps.rb +1 -1
- data/lib/locomotive/render.rb +4 -2
- data/lib/locomotive/routing/default_constraint.rb +1 -1
- data/lib/locomotive/routing/site_dispatcher.rb +1 -1
- data/lib/locomotive/session_store.rb +7 -7
- data/lib/locomotive/version.rb +1 -1
- data/lib/tasks/development.rake +11 -9
- data/lib/tasks/locomotive.rake +11 -11
- data/mongodb/migrate/20130204072721_make_editable_elements_consistent.rb +3 -1
- data/mongodb/migrate/20130326201349_rename_entry_to_content_entry.rb +6 -6
- data/mongodb/migrate/20130511121956_generate_checksum_for_theme_assets.rb +14 -0
- data/mongodb/migrate/20130530162559_api_key_for_all_accounts.rb +10 -0
- data/spec/cells/locomotive/global_actions_spec.rb +11 -11
- data/spec/cells/locomotive/main_menu_cell_spec.rb +9 -9
- data/spec/cells/locomotive/settings_menu_cell_spec.rb +11 -11
- data/spec/dummy/config/environments/development.rb +1 -1
- data/spec/dummy/config/initializers/locomotive.rb +16 -11
- data/spec/dummy/config/mongoid.yml +99 -18
- data/spec/lib/action_view_spec.rb +19 -0
- data/spec/lib/core_ext_spec.rb +2 -2
- data/spec/lib/locomotive/configuration_spec.rb +1 -1
- data/spec/lib/locomotive/httparty/webservice_spec.rb +6 -6
- data/spec/lib/locomotive/liquid/drops/content_entry_spec.rb +1 -1
- data/spec/lib/locomotive/liquid/drops/current_user.rb +3 -3
- data/spec/lib/locomotive/liquid/drops/page_spec.rb +63 -14
- data/spec/lib/locomotive/liquid/drops/site_spec.rb +3 -3
- data/spec/lib/locomotive/liquid/filters/html_spec.rb +22 -7
- data/spec/lib/locomotive/liquid/filters/resize_spec.rb +3 -3
- data/spec/lib/locomotive/liquid/filters/translate_spec.rb +26 -12
- data/spec/lib/locomotive/liquid/tags/consume_spec.rb +26 -2
- data/spec/lib/locomotive/liquid/tags/csrf_spec.rb +3 -3
- data/spec/lib/locomotive/liquid/tags/editable/short_text_spec.rb +1 -1
- data/spec/lib/locomotive/liquid/tags/extends_spec.rb +5 -5
- data/spec/lib/locomotive/liquid/tags/javascript_spec.rb +18 -0
- data/spec/lib/locomotive/liquid/tags/locale_switcher_spec.rb +23 -13
- data/spec/lib/locomotive/liquid/tags/nav_spec.rb +11 -11
- data/spec/lib/locomotive/liquid/tags/paginate_spec.rb +13 -13
- data/spec/lib/locomotive/liquid/tags/seo_spec.rb +8 -8
- data/spec/lib/locomotive/liquid/tags/with_scope_spec.rb +8 -2
- data/spec/lib/locomotive/presentable_spec.rb +10 -10
- data/spec/lib/locomotive/render_spec.rb +14 -14
- data/spec/mailers/locomotive/notifications_spec.rb +3 -3
- data/spec/models/locomotive/ability_spec.rb +23 -9
- data/spec/models/locomotive/account_spec.rb +30 -8
- data/spec/models/locomotive/content_asset_spec.rb +1 -1
- data/spec/models/locomotive/content_entry_spec.rb +57 -2
- data/spec/models/locomotive/content_type_spec.rb +42 -41
- data/spec/models/locomotive/editable_control_spec.rb +5 -5
- data/spec/models/locomotive/editable_file_spec.rb +21 -5
- data/spec/models/locomotive/editable_long_text_spec.rb +3 -3
- data/spec/models/locomotive/editable_short_text_spec.rb +8 -8
- data/spec/models/locomotive/extensions/page/editable_elements_spec.rb +9 -9
- data/spec/models/locomotive/extensions/page/redirect_spec.rb +1 -1
- data/spec/models/locomotive/extensions/page/render_spec.rb +4 -8
- data/spec/models/locomotive/extensions/site/locales_spec.rb +2 -2
- data/spec/models/locomotive/membership_spec.rb +5 -5
- data/spec/models/locomotive/page_spec.rb +10 -1
- data/spec/models/locomotive/site_spec.rb +19 -19
- data/spec/models/locomotive/snippet_spec.rb +9 -9
- data/spec/models/locomotive/theme_asset_spec.rb +91 -57
- data/spec/requests/admin_ssl_spec.rb +25 -0
- data/spec/support/factories.rb +32 -27
- data/spec/support/locomotive.rb +2 -0
- data/vendor/assets/javascripts/locomotive/backbone.sync.js +1 -1
- data/vendor/assets/javascripts/locomotive/tag-it.min.js +16 -0
- data/vendor/assets/stylesheets/locomotive/jquery.tagit.css +67 -0
- metadata +108 -138
@@ -23,12 +23,24 @@ module Locomotive
|
|
23
23
|
after_save :propagate_templatized
|
24
24
|
|
25
25
|
## scopes ##
|
26
|
-
scope :templatized, where
|
26
|
+
scope :templatized, where(templatized: true)
|
27
27
|
|
28
28
|
## virtual attributes ##
|
29
29
|
attr_accessor :content_entry
|
30
30
|
end
|
31
31
|
|
32
|
+
# Return the content type specified by the target_klass_name property.
|
33
|
+
#
|
34
|
+
# @return [ Object ] The content type or nil if not found
|
35
|
+
#
|
36
|
+
def content_type
|
37
|
+
if self.target_klass_name =~ /^Locomotive::ContentEntry([a-z0-9]+)$/
|
38
|
+
@content_type ||= self.site.content_types.find($1)
|
39
|
+
else
|
40
|
+
nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
32
44
|
# Return the class specified by the target_klass_name property
|
33
45
|
#
|
34
46
|
# @example
|
@@ -45,15 +57,10 @@ module Locomotive
|
|
45
57
|
# Return the slug related to the target_klass.
|
46
58
|
# In other words, it returns the slug of the target content type.
|
47
59
|
#
|
48
|
-
# @return [ String ] The slug of the target class / content type. Nil if no target klass
|
60
|
+
# @return [ String ] The slug of the target class / content type. Nil if no target klass matching a content type
|
49
61
|
#
|
50
62
|
def target_klass_slug
|
51
|
-
|
52
|
-
@content_type ||= self.site.content_types.find($1)
|
53
|
-
@content_type.slug
|
54
|
-
else
|
55
|
-
nil
|
56
|
-
end
|
63
|
+
self.content_type.try(:slug)
|
57
64
|
end
|
58
65
|
|
59
66
|
# Set the target klass from the slug of a content type
|
@@ -84,9 +91,8 @@ module Locomotive
|
|
84
91
|
# @return [ String ] The name in lowercase and underscored
|
85
92
|
#
|
86
93
|
def target_entry_name
|
87
|
-
if self.
|
88
|
-
|
89
|
-
@content_type.slug.singularize
|
94
|
+
if self.content_type
|
95
|
+
self.content_type.slug.singularize
|
90
96
|
else
|
91
97
|
self.target_klass_name.underscore
|
92
98
|
end
|
@@ -110,9 +116,8 @@ module Locomotive
|
|
110
116
|
# @return [ Object ] The documents
|
111
117
|
#
|
112
118
|
def fetch_target_entries(conditions = {})
|
113
|
-
if self.
|
114
|
-
|
115
|
-
@content_type.ordered_entries(conditions)
|
119
|
+
if self.content_type
|
120
|
+
self.content_type.ordered_entries(conditions)
|
116
121
|
else
|
117
122
|
[]
|
118
123
|
end
|
@@ -170,7 +175,7 @@ module Locomotive
|
|
170
175
|
}
|
171
176
|
}
|
172
177
|
|
173
|
-
self.collection.update
|
178
|
+
self.collection.find(selector).update(operations, multi: true)
|
174
179
|
end
|
175
180
|
|
176
181
|
end
|
@@ -18,8 +18,8 @@ module Locomotive
|
|
18
18
|
before_destroy :delete_descendants
|
19
19
|
|
20
20
|
## indexes ##
|
21
|
-
index :
|
22
|
-
index
|
21
|
+
index position: 1
|
22
|
+
index depth: 1, position: 1
|
23
23
|
|
24
24
|
alias_method_chain :rearrange, :identity_map
|
25
25
|
alias_method_chain :rearrange_children, :identity_map
|
@@ -49,7 +49,7 @@ module Locomotive
|
|
49
49
|
# @return [ Array ] The first array of pages (depth = 0)
|
50
50
|
#
|
51
51
|
def quick_tree(site, minimal_attributes = true)
|
52
|
-
pages = (minimal_attributes ? site.pages.unscoped.minimal_attributes : site.pages.unscoped).order_by(
|
52
|
+
pages = (minimal_attributes ? site.pages.unscoped.minimal_attributes : site.pages.unscoped).order_by(:depth.asc, :position.asc).to_a
|
53
53
|
|
54
54
|
tmp = []
|
55
55
|
|
@@ -105,7 +105,7 @@ module Locomotive
|
|
105
105
|
def sort_children!(ids)
|
106
106
|
cached_children = self.children.to_a
|
107
107
|
ids.each_with_index do |id, position|
|
108
|
-
child = cached_children.detect { |p| p._id == BSON::ObjectId(id) }
|
108
|
+
child = cached_children.detect { |p| p._id == Moped::BSON::ObjectId(id) }
|
109
109
|
child.position = position
|
110
110
|
child.save
|
111
111
|
end
|
@@ -5,9 +5,9 @@ module Locomotive
|
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
7
|
included do
|
8
|
-
field :seo_title, :
|
9
|
-
field :meta_keywords, :
|
10
|
-
field :meta_description, :
|
8
|
+
field :seo_title, type: String, localize: true
|
9
|
+
field :meta_keywords, type: String, localize: true
|
10
|
+
field :meta_description, type: String, localize: true
|
11
11
|
end
|
12
12
|
|
13
13
|
end # Seo
|
@@ -6,11 +6,14 @@ module Locomotive
|
|
6
6
|
# only called during the installation workflow, just after the admin account has been created
|
7
7
|
def create_first_one(attributes)
|
8
8
|
site = self.new(attributes)
|
9
|
-
|
10
|
-
site.memberships.build :account
|
9
|
+
account = Account.first
|
10
|
+
site.memberships.build account: account, role: 'admin'
|
11
11
|
|
12
12
|
site.save
|
13
13
|
|
14
|
+
account.locale = site.default_locale
|
15
|
+
account.save
|
16
|
+
|
14
17
|
site
|
15
18
|
end
|
16
19
|
|
@@ -8,7 +8,7 @@ module Locomotive
|
|
8
8
|
included do
|
9
9
|
|
10
10
|
## fields ##
|
11
|
-
field :locales, :
|
11
|
+
field :locales, type: ::RawArray, default: []
|
12
12
|
|
13
13
|
## validations ##
|
14
14
|
validate :can_not_remove_default_locale
|
@@ -67,7 +67,7 @@ module Locomotive
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def default_locale_was
|
70
|
-
self.locales_was.first || Locomotive.config.site_locales.first
|
70
|
+
self.locales_was.try(:first) || Locomotive.config.site_locales.first
|
71
71
|
end
|
72
72
|
|
73
73
|
def locale_fallbacks(locale)
|
@@ -82,25 +82,28 @@ module Locomotive
|
|
82
82
|
|
83
83
|
def can_not_remove_default_locale
|
84
84
|
if self.persisted? && !self.locales.include?(self.default_locale_was)
|
85
|
-
self.errors.add :locales, I18n.t(:default_locale_removed, :
|
85
|
+
self.errors.add :locales, I18n.t(:default_locale_removed, scope: [:errors, :messages, :site])
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
+
# Verify if the index and 404 pages in ALL the locales of the site
|
90
|
+
# have a non empty slug, fullpath and title. If not, it sets them.
|
91
|
+
#
|
89
92
|
def verify_localized_default_pages_integrity
|
90
93
|
if self.persisted? && self.locales_changed?
|
91
|
-
self.pages.where(:"slug.#{self.default_locale_was}".in => %w(index 404), :
|
94
|
+
self.pages.where(:"slug.#{self.default_locale_was}".in => %w(index 404), depth: 0).each do |page|
|
92
95
|
modifications = { 'title' => {}, 'slug' => {}, 'fullpath' => {}, 'locales' => self.locales }
|
93
96
|
|
94
97
|
self.locales.each do |locale|
|
95
98
|
slug = page.attributes['slug'][self.default_locale_was]
|
96
|
-
title = page.attributes['title'][locale] || ::I18n.t("attributes.defaults.pages.#{slug}.title", :
|
99
|
+
title = page.attributes['title'][locale] || ::I18n.t("attributes.defaults.pages.#{slug}.title", locale: locale)
|
97
100
|
|
98
101
|
modifications['slug'][locale] = slug
|
99
102
|
modifications['fullpath'][locale] = slug
|
100
103
|
modifications['title'][locale] = title
|
101
104
|
end
|
102
105
|
|
103
|
-
page.collection.
|
106
|
+
page.collection.find(_id: page._id).update('$set' => modifications)
|
104
107
|
end
|
105
108
|
end
|
106
109
|
end
|
@@ -10,16 +10,16 @@ module Locomotive
|
|
10
10
|
|
11
11
|
## fields ##
|
12
12
|
field :subdomain
|
13
|
-
field :domains, :
|
13
|
+
field :domains, type: Array, default: []
|
14
14
|
|
15
15
|
## indexes
|
16
|
-
index :
|
16
|
+
index domains: 1
|
17
17
|
|
18
18
|
## validations ##
|
19
19
|
validates_presence_of :subdomain
|
20
20
|
validates_uniqueness_of :subdomain
|
21
|
-
validates_exclusion_of :subdomain, :
|
22
|
-
validates_format_of :subdomain, :
|
21
|
+
validates_exclusion_of :subdomain, in: Locomotive.config.reserved_subdomains
|
22
|
+
validates_format_of :subdomain, with: Locomotive::Regexps::SUBDOMAIN, allow_blank: true
|
23
23
|
validate :domains_must_be_valid_and_unique
|
24
24
|
|
25
25
|
## callbacks ##
|
@@ -27,9 +27,9 @@ module Locomotive
|
|
27
27
|
after_destroy :clear_cache_for_all_domains
|
28
28
|
|
29
29
|
## named scopes ##
|
30
|
-
scope :match_domain, lambda { |domain| { :
|
30
|
+
scope :match_domain, lambda { |domain| { any_in: { domains: [*domain] } } }
|
31
31
|
scope :match_domain_with_exclusion_of, lambda { |domain, site|
|
32
|
-
{ :
|
32
|
+
{ any_in: { domains: [*domain] }, where: { :_id.ne => site.id } }
|
33
33
|
}
|
34
34
|
|
35
35
|
send :include, InstanceMethods
|
@@ -75,11 +75,11 @@ module Locomotive
|
|
75
75
|
|
76
76
|
self.domains_without_subdomain.each do |domain|
|
77
77
|
if self.class.match_domain_with_exclusion_of(domain, self).any?
|
78
|
-
self.errors.add(:domains, :domain_taken, :
|
78
|
+
self.errors.add(:domains, :domain_taken, value: domain)
|
79
79
|
end
|
80
80
|
|
81
81
|
if not domain =~ Locomotive::Regexps::DOMAIN
|
82
|
-
self.errors.add(:domains, :invalid_domain, :
|
82
|
+
self.errors.add(:domains, :invalid_domain, value: domain)
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
@@ -4,15 +4,15 @@ module Locomotive
|
|
4
4
|
include Locomotive::Mongoid::Document
|
5
5
|
|
6
6
|
## fields ##
|
7
|
-
field :role, :
|
7
|
+
field :role, default: 'author'
|
8
8
|
|
9
9
|
## associations ##
|
10
|
-
|
11
|
-
embedded_in
|
10
|
+
belongs_to :account, class_name: 'Locomotive::Account', validate: false
|
11
|
+
embedded_in :site, class_name: 'Locomotive::Site', inverse_of: :memberships
|
12
12
|
|
13
13
|
## validations ##
|
14
14
|
validates_presence_of :account
|
15
|
-
validate :can_change_role, :
|
15
|
+
validate :can_change_role, if: :role_changed?
|
16
16
|
|
17
17
|
## callbacks ##
|
18
18
|
before_save :define_role
|
@@ -29,7 +29,7 @@ module Locomotive
|
|
29
29
|
|
30
30
|
def email=(email)
|
31
31
|
@email = email
|
32
|
-
self.account = Locomotive::Account.where(:
|
32
|
+
self.account = Locomotive::Account.where(email: email).first
|
33
33
|
end
|
34
34
|
|
35
35
|
def process!
|
@@ -62,7 +62,7 @@ module Locomotive
|
|
62
62
|
# be an administrator
|
63
63
|
def can_change_role
|
64
64
|
current_site = Thread.current[:site]
|
65
|
-
current_membership = current_site.memberships.where(:
|
65
|
+
current_membership = current_site.memberships.where(account_id: Thread.current[:account].id).first if current_site.present?
|
66
66
|
|
67
67
|
if current_membership.present?
|
68
68
|
# The role cannot be set higher than the current one (we use the index in
|
@@ -3,6 +3,8 @@ module Locomotive
|
|
3
3
|
|
4
4
|
include Locomotive::Mongoid::Document
|
5
5
|
|
6
|
+
MINIMAL_ATTRIBUTES = %w(_id title slug fullpath position depth published templatized redirect listed response_type parent_id parent_ids site_id created_at updated_at)
|
7
|
+
|
6
8
|
## Extensions ##
|
7
9
|
include Extensions::Page::Tree
|
8
10
|
include Extensions::Page::EditableElements
|
@@ -14,23 +16,23 @@ module Locomotive
|
|
14
16
|
include Extensions::Shared::Seo
|
15
17
|
|
16
18
|
## fields ##
|
17
|
-
field :title, :
|
18
|
-
field :slug, :
|
19
|
-
field :fullpath, :
|
19
|
+
field :title, localize: true
|
20
|
+
field :slug, localize: true
|
21
|
+
field :fullpath, localize: true
|
20
22
|
field :handle
|
21
|
-
field :raw_template, :
|
22
|
-
field :locales, :
|
23
|
-
field :published, :
|
24
|
-
field :cache_strategy, :
|
25
|
-
field :response_type, :
|
23
|
+
field :raw_template, localize: true
|
24
|
+
field :locales, type: Array
|
25
|
+
field :published, type: Boolean, default: false
|
26
|
+
field :cache_strategy, default: 'none'
|
27
|
+
field :response_type, default: 'text/html'
|
26
28
|
|
27
29
|
## associations ##
|
28
|
-
belongs_to :site, :
|
30
|
+
belongs_to :site, class_name: 'Locomotive::Site', autosave: false
|
29
31
|
|
30
32
|
## indexes ##
|
31
|
-
index :
|
32
|
-
index :
|
33
|
-
index
|
33
|
+
index site_id: 1
|
34
|
+
index parent_id: 1
|
35
|
+
index fullpath: 1, site_id: 1
|
34
36
|
|
35
37
|
## callbacks ##
|
36
38
|
after_initialize :set_default_raw_template
|
@@ -38,22 +40,23 @@ module Locomotive
|
|
38
40
|
before_save :build_fullpath
|
39
41
|
before_save :record_current_locale
|
40
42
|
before_destroy :do_not_remove_index_and_404_pages
|
43
|
+
after_save :update_children
|
41
44
|
|
42
45
|
## validations ##
|
43
46
|
validates_presence_of :site, :title, :slug
|
44
|
-
validates_uniqueness_of :slug, :
|
45
|
-
validates_uniqueness_of :handle, :
|
46
|
-
validates_exclusion_of :slug, :
|
47
|
+
validates_uniqueness_of :slug, scope: [:site_id, :parent_id], allow_blank: true
|
48
|
+
validates_uniqueness_of :handle, scope: :site_id, allow_blank: true
|
49
|
+
validates_exclusion_of :slug, in: Locomotive.config.reserved_slugs, if: Proc.new { |p| p.depth <= 1 }
|
47
50
|
|
48
51
|
## named scopes ##
|
49
|
-
scope :latest_updated,
|
50
|
-
scope :root,
|
51
|
-
scope :not_found,
|
52
|
-
scope :published,
|
53
|
-
scope :fullpath,
|
54
|
-
scope :handle,
|
55
|
-
scope :minimal_attributes,
|
56
|
-
scope :dependent_from,
|
52
|
+
scope :latest_updated, order_by(updated_at: :desc).limit(Locomotive.config.ui[:latest_entries_nb])
|
53
|
+
scope :root, where(slug: 'index', depth: 0)
|
54
|
+
scope :not_found, where(slug: '404', depth: 0)
|
55
|
+
scope :published, where(published: true)
|
56
|
+
scope :fullpath, ->(fullpath){ where(fullpath: fullpath) }
|
57
|
+
scope :handle, ->(handle){ where(handle: handle) }
|
58
|
+
scope :minimal_attributes, ->(attrs = []) { without(self.fields.keys - MINIMAL_ATTRIBUTES) }
|
59
|
+
scope :dependent_from, ->(id) { where(:template_dependencies.in => [id]) }
|
57
60
|
|
58
61
|
## methods ##
|
59
62
|
|
@@ -120,6 +123,10 @@ module Locomotive
|
|
120
123
|
end
|
121
124
|
end
|
122
125
|
|
126
|
+
def update_children
|
127
|
+
self.children.map(&:save) if self.slug_changed? or self.fullpath_changed?
|
128
|
+
end
|
129
|
+
|
123
130
|
def record_current_locale
|
124
131
|
self.locales ||= []
|
125
132
|
self.locales << ::Mongoid::Fields::I18n.locale
|
@@ -14,13 +14,13 @@ module Locomotive
|
|
14
14
|
field :robots_txt
|
15
15
|
|
16
16
|
## associations ##
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
embeds_many
|
17
|
+
has_many :pages, class_name: 'Locomotive::Page', validate: false
|
18
|
+
has_many :snippets, class_name: 'Locomotive::Snippet', dependent: :destroy, validate: false
|
19
|
+
has_many :theme_assets, class_name: 'Locomotive::ThemeAsset', dependent: :destroy, validate: false
|
20
|
+
has_many :content_assets, class_name: 'Locomotive::ContentAsset', dependent: :destroy, validate: false
|
21
|
+
has_many :content_types, class_name: 'Locomotive::ContentType', dependent: :destroy, validate: false
|
22
|
+
has_many :translations, class_name: 'Locomotive::Translation', dependent: :destroy, validate: false
|
23
|
+
embeds_many :memberships, class_name: 'Locomotive::Membership'
|
24
24
|
|
25
25
|
## validations ##
|
26
26
|
validates_presence_of :name
|
@@ -62,16 +62,20 @@ module Locomotive
|
|
62
62
|
# namespaced ::I18n should be changed to just I18n when the t()
|
63
63
|
# method is available
|
64
64
|
def create_default_pages!
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
65
|
+
%w{index 404}.each do |slug|
|
66
|
+
page = self.pages.build(published: true)
|
67
|
+
self.locales.each do |locale|
|
68
|
+
::Mongoid::Fields::I18n.with_locale(locale) do
|
69
|
+
page.attributes = {
|
70
|
+
slug: slug,
|
71
|
+
title: ::I18n.t("attributes.defaults.pages.#{slug}.title", locale: locale),
|
72
|
+
raw_template: ::I18n.t("attributes.defaults.pages.#{slug}.body", locale: locale)
|
73
|
+
}
|
74
|
+
end
|
73
75
|
end
|
76
|
+
page.save
|
74
77
|
end
|
78
|
+
|
75
79
|
end
|
76
80
|
|
77
81
|
def destroy_pages
|
@@ -6,10 +6,10 @@ module Locomotive
|
|
6
6
|
## fields ##
|
7
7
|
field :name
|
8
8
|
field :slug
|
9
|
-
field :template, :
|
9
|
+
field :template, localize: true
|
10
10
|
|
11
11
|
## associations ##
|
12
|
-
|
12
|
+
belongs_to :site, class_name: 'Locomotive::Site'
|
13
13
|
|
14
14
|
## callbacks ##
|
15
15
|
before_validation :normalize_slug
|
@@ -18,7 +18,7 @@ module Locomotive
|
|
18
18
|
|
19
19
|
## validations ##
|
20
20
|
validates_presence_of :site, :name, :slug, :template
|
21
|
-
validates_uniqueness_of :slug, :
|
21
|
+
validates_uniqueness_of :slug, scope: :site_id
|
22
22
|
|
23
23
|
## behaviours ##
|
24
24
|
attr_protected :id
|
@@ -37,7 +37,7 @@ module Locomotive
|
|
37
37
|
return unless (self.site rescue false) # not run if the site is being destroyed
|
38
38
|
|
39
39
|
pages = ::I18n.with_locale(::Mongoid::Fields::I18n.locale) do
|
40
|
-
pages = self.site.pages.any_in(:
|
40
|
+
pages = self.site.pages.any_in(snippet_dependencies: [self.slug]).to_a
|
41
41
|
end
|
42
42
|
|
43
43
|
pages.each do |page|
|
@@ -46,7 +46,7 @@ module Locomotive
|
|
46
46
|
page.send(:_serialize_template)
|
47
47
|
|
48
48
|
Page.without_callback(:save, :after, :update_template_descendants) do
|
49
|
-
page.save(:
|
49
|
+
page.save(validate: false)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|