locomotivecms 3.0.0.pre.beta.1 → 3.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -3
- data/app/api/locomotive/api.rb +1 -0
- data/app/api/locomotive/api/entities/page_entity.rb +1 -1
- data/app/api/locomotive/api/entities/site_entity.rb +9 -1
- data/app/api/locomotive/api/exception_rescuers.rb +3 -5
- data/app/api/locomotive/api/forms/page_form.rb +1 -1
- data/app/api/locomotive/api/forms/site_form.rb +1 -2
- data/app/api/locomotive/api/helpers/authentication_helper.rb +6 -1
- data/app/api/locomotive/api/helpers/locales_helper.rb +15 -0
- data/app/api/locomotive/api/helpers/params_helper.rb +13 -0
- data/app/api/locomotive/api/middlewares/locale_middleware.rb +6 -1
- data/app/api/locomotive/api/resources/content_entry_resource.rb +2 -0
- data/app/api/locomotive/api/resources/content_type_resource.rb +2 -2
- data/app/api/locomotive/api/resources/current_site_resource.rb +2 -1
- data/app/api/locomotive/api/resources/membership_resource.rb +0 -4
- data/app/api/locomotive/api/resources/page_resource.rb +6 -1
- data/app/api/locomotive/api/resources/site_resource.rb +4 -2
- data/app/assets/javascripts/locomotive.js +1 -0
- data/app/assets/javascripts/locomotive/utils/nprogress.js.coffee +3 -1
- data/app/assets/javascripts/locomotive/views/editable_elements/index_view.js.coffee +10 -3
- data/app/assets/javascripts/locomotive/views/inputs/markdown_view.js.coffee +82 -0
- data/app/assets/javascripts/locomotive/views/inputs/rte/file_view.js.coffee +1 -1
- data/app/assets/javascripts/locomotive/views/inputs/rte/link_view.js.coffee +1 -1
- data/app/assets/javascripts/locomotive/views/inputs/rte_view.js.coffee.erb +1 -1
- data/app/assets/javascripts/locomotive/views/inputs/text_view.js.coffee +4 -1
- data/app/assets/javascripts/locomotive/views/pages/list_view.js.coffee +3 -0
- data/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee +22 -1
- data/app/assets/javascripts/locomotive/views/shared/header_view.js.coffee +2 -2
- data/app/assets/stylesheets/locomotive/application.scss +2 -0
- data/app/assets/stylesheets/locomotive/base/_form.scss +2 -0
- data/app/assets/stylesheets/locomotive/base/form/_api_key.scss +0 -1
- data/app/assets/stylesheets/locomotive/base/form/_array_input.scss +2 -0
- data/app/assets/stylesheets/locomotive/base/form/_base.scss +13 -2
- data/app/assets/stylesheets/locomotive/base/form/_color_input.scss +12 -0
- data/app/assets/stylesheets/locomotive/base/form/_markdown.scss +292 -0
- data/app/assets/stylesheets/locomotive/base/form/_popover.scss +22 -0
- data/app/assets/stylesheets/locomotive/base/form/_rte.scss +2 -1
- data/app/assets/stylesheets/locomotive/components/_activity_feed.scss +1 -0
- data/app/assets/stylesheets/locomotive/components/_dashboard.scss +29 -0
- data/app/assets/stylesheets/locomotive/components/_live_editing.scss +13 -1
- data/app/assets/stylesheets/locomotive/components/_main.scss +1 -1
- data/app/assets/stylesheets/locomotive/components/_transitions.scss +24 -3
- data/app/assets/stylesheets/locomotive/components/sidebar/_base.scss +1 -0
- data/app/assets/stylesheets/locomotive/globals/_bootstrap.scss +2 -2
- data/app/assets/stylesheets/locomotive/globals/_variables.scss +4 -3
- data/app/assets/stylesheets/locomotive/layouts/_live_editing.scss +4 -0
- data/app/controllers/locomotive/concerns/locale_helpers_controller.rb +1 -0
- data/app/controllers/locomotive/content_entries_controller.rb +10 -2
- data/app/controllers/locomotive/pages_controller.rb +2 -1
- data/app/controllers/locomotive/passwords_controller.rb +17 -1
- data/app/helpers/locomotive/base_helper.rb +19 -0
- data/app/helpers/locomotive/content_types_helper.rb +2 -1
- data/app/helpers/locomotive/custom_fields_helper.rb +14 -1
- data/app/helpers/locomotive/dashboard_helper.rb +12 -0
- data/app/helpers/locomotive/editable_elements_helper.rb +9 -4
- data/app/helpers/locomotive/pages_helper.rb +1 -14
- data/app/helpers/locomotive/shared/pages_helper.rb +17 -0
- data/app/helpers/locomotive/translations_helper.rb +0 -14
- data/app/inputs/locomotive/color_input.rb +18 -0
- data/app/inputs/locomotive/markdown_input.rb +19 -0
- data/app/models/locomotive/account.rb +2 -1
- data/app/models/locomotive/concerns/content_entry/file_size.rb +27 -0
- data/app/models/locomotive/concerns/content_type/group_by.rb +3 -1
- data/app/models/locomotive/concerns/page/layout.rb +63 -19
- data/app/models/locomotive/concerns/shared/site_scope.rb +37 -0
- data/app/models/locomotive/concerns/site/cache.rb +32 -0
- data/app/models/locomotive/concerns/theme_asset/plain_text.rb +85 -0
- data/app/models/locomotive/content_entry.rb +7 -7
- data/app/models/locomotive/content_type.rb +12 -6
- data/app/models/locomotive/page.rb +12 -14
- data/app/models/locomotive/site.rb +9 -3
- data/app/models/locomotive/snippet.rb +6 -4
- data/app/models/locomotive/theme_asset.rb +8 -73
- data/app/models/locomotive/translation.rb +6 -5
- data/app/policies/locomotive/site_policy.rb +2 -2
- data/app/services/locomotive/content_entry_service.rb +7 -6
- data/app/services/locomotive/site_service.rb +1 -0
- data/app/views/locomotive/content_entries/_entry.html.slim +1 -0
- data/app/views/locomotive/content_entries/edit.html.slim +1 -1
- data/app/views/locomotive/content_entries/new.html.slim +1 -1
- data/app/views/locomotive/current_site/_membership.html.slim +1 -0
- data/app/views/locomotive/current_site/edit.html.slim +1 -1
- data/app/views/locomotive/current_site/form/_access_points.html.slim +1 -1
- data/app/views/locomotive/current_site/form/_advanced.html.slim +2 -0
- data/app/views/locomotive/dashboard/_activity.html.slim +26 -0
- data/app/views/locomotive/dashboard/_url.html.slim +9 -0
- data/app/views/locomotive/dashboard/show.html.slim +3 -21
- data/app/views/locomotive/devise_mailer/reset_password_instructions.html.slim +1 -1
- data/app/views/locomotive/editable_elements/_edit.html.slim +8 -1
- data/app/views/locomotive/editable_elements/_form.html.slim +1 -1
- data/app/views/locomotive/editable_elements/index_without_preview.html.slim +24 -17
- data/app/views/locomotive/layouts/application.html.slim +6 -4
- data/app/views/locomotive/layouts/live_editing.html.slim +9 -0
- data/app/views/locomotive/layouts/not_logged_in.html.slim +1 -1
- data/app/views/locomotive/layouts/without_site.html.slim +2 -0
- data/app/views/locomotive/memberships/edit.html.slim +1 -1
- data/app/views/locomotive/memberships/new.html.slim +1 -1
- data/app/views/locomotive/my_account/edit.html.slim +7 -5
- data/app/views/locomotive/pages/_header.html.slim +7 -0
- data/app/views/locomotive/pages/edit.html.slim +2 -4
- data/app/views/locomotive/pages/form/_main.html.slim +4 -1
- data/app/views/locomotive/pages/form/_tabs.html.slim +4 -3
- data/app/views/locomotive/public_submission_accounts/_account.html.slim +1 -1
- data/app/views/locomotive/public_submission_accounts/edit.html.slim +1 -1
- data/app/views/locomotive/shared/_header.html.slim +25 -22
- data/app/views/locomotive/shared/_locale_picker_link.html.slim +3 -0
- data/app/views/locomotive/shared/_main_app_header.html.slim +1 -1
- data/app/views/locomotive/shared/_sidebar.html.slim +15 -11
- data/app/views/locomotive/shared/rte/_markdown_toolbar.html.slim +42 -0
- data/config/locales/admin_ui.en.yml +9 -4
- data/config/locales/default.en.yml +4 -0
- data/config/locales/devise.en.yml +1 -0
- data/config/locales/simple_form.en.yml +6 -2
- data/lib/locomotive/action_controller/responder.rb +5 -0
- data/lib/locomotive/engine.rb +5 -0
- data/lib/locomotive/middlewares/site.rb +39 -21
- data/lib/locomotive/simple_form.rb +3 -31
- data/lib/locomotive/steam/middlewares/cache.rb +62 -0
- data/lib/locomotive/steam/middlewares/page_editing.rb +9 -3
- data/lib/locomotive/steam/services/api_entry_submission_service.rb +6 -3
- data/lib/locomotive/steam/services/liquid_parser_with_cache_service.rb +74 -0
- data/lib/locomotive/steam_adaptor.rb +7 -1
- data/lib/locomotive/version.rb +1 -1
- data/lib/tasks/development.rake +4 -0
- data/lib/tasks/locomotive.rake +14 -0
- data/spec/lib/locomotive/steam/services/api_entry_submission_service_spec.rb +10 -1
- data/spec/lib/locomotive/steam/services/liquid_parser_with_cache_service_spec.rb +53 -0
- data/spec/models/locomotive/concerns/content_entry/file_size_spec.rb +40 -0
- data/spec/models/locomotive/concerns/page/layout_spec.rb +122 -17
- data/spec/models/locomotive/concerns/site/cache_spec.rb +60 -0
- data/spec/models/locomotive/content_entry_spec.rb +7 -0
- data/spec/models/locomotive/content_type_spec.rb +18 -11
- data/spec/models/locomotive/page_spec.rb +32 -8
- data/spec/models/locomotive/snippet_spec.rb +13 -4
- data/spec/models/locomotive/theme_asset_spec.rb +10 -3
- data/spec/models/locomotive/translation_spec.rb +28 -0
- data/spec/requests/locomotive/steam/cache_spec.rb +83 -0
- data/spec/requests/site_spec.rb +24 -0
- data/spec/support/capybara.rb +5 -13
- data/spec/support/factories.rb +9 -0
- data/spec/support/features/session_helpers.rb +19 -3
- data/spec/support/features/site_helpers.rb +27 -0
- data/spec/support/shared_examples/site_scope_examples.rb +27 -0
- data/vendor/assets/images/locomotive/bootstrap-colorpicker/alpha-horizontal.png +0 -0
- data/vendor/assets/images/locomotive/bootstrap-colorpicker/alpha.png +0 -0
- data/vendor/assets/images/locomotive/bootstrap-colorpicker/hue-horizontal.png +0 -0
- data/vendor/assets/images/locomotive/bootstrap-colorpicker/hue.png +0 -0
- data/vendor/assets/images/locomotive/bootstrap-colorpicker/saturation.png +0 -0
- data/vendor/assets/javascripts/locomotive/bootstrap-colorpicker.js +1 -0
- data/vendor/assets/javascripts/locomotive/datepicker_i18n.js.erb +6 -6
- data/vendor/assets/javascripts/locomotive/kramed.min.js +11 -0
- data/vendor/assets/stylesheets/locomotive/bootstrap-colorpicker.scss +9 -0
- metadata +59 -44
- data/app/controllers/locomotive/api/accounts_controller.rb +0 -60
- data/app/controllers/locomotive/api/base_controller.rb +0 -35
- data/app/controllers/locomotive/api/content_assets_controller.rb +0 -51
- data/app/controllers/locomotive/api/content_entries_controller.rb +0 -71
- data/app/controllers/locomotive/api/content_types_controller.rb +0 -52
- data/app/controllers/locomotive/api/current_site_controller.rb +0 -34
- data/app/controllers/locomotive/api/memberships_controller.rb +0 -52
- data/app/controllers/locomotive/api/my_account_controller.rb +0 -46
- data/app/controllers/locomotive/api/pages_controller.rb +0 -53
- data/app/controllers/locomotive/api/sites_controller.rb +0 -58
- data/app/controllers/locomotive/api/snippets_controller.rb +0 -52
- data/app/controllers/locomotive/api/theme_assets_controller.rb +0 -51
- data/app/controllers/locomotive/api/tokens_controller.rb +0 -36
- data/app/controllers/locomotive/api/translations_controller.rb +0 -51
- data/app/controllers/locomotive/api/version_controller.rb +0 -11
- data/spec/models/locomotive/editable_control_spec.rb +0 -79
- data/spec/models/locomotive/editable_file_spec.rb +0 -94
- data/spec/models/locomotive/editable_text_spec.rb +0 -219
- data/vendor/assets/images/select2-spinner.gif +0 -0
- data/vendor/assets/images/select2.png +0 -0
- data/vendor/assets/images/select2x2.png +0 -0
@@ -1,58 +0,0 @@
|
|
1
|
-
# module Locomotive
|
2
|
-
# module Api
|
3
|
-
# class SitesController < Api::BaseController
|
4
|
-
|
5
|
-
# account_required
|
6
|
-
|
7
|
-
# before_filter :load_site, only: [:show, :update, :destroy]
|
8
|
-
# before_filter :load_sites, only: [:index]
|
9
|
-
|
10
|
-
# def index
|
11
|
-
# authorize Locomotive::Site
|
12
|
-
# respond_with @sites
|
13
|
-
# end
|
14
|
-
|
15
|
-
# def show
|
16
|
-
# authorize @site
|
17
|
-
# respond_with @site
|
18
|
-
# end
|
19
|
-
|
20
|
-
# def create
|
21
|
-
# authorize Locomotive::Site
|
22
|
-
# @site = Site.from_presenter(params[:site])
|
23
|
-
# @site.memberships.build account: self.current_locomotive_account, role: 'admin'
|
24
|
-
# @site.save
|
25
|
-
# respond_with @site, location: -> { main_app.locomotive_api_site_url(@site) }
|
26
|
-
# end
|
27
|
-
|
28
|
-
# def update
|
29
|
-
# authorize @site
|
30
|
-
# @site.from_presenter(params[:site]).save
|
31
|
-
# respond_with @site, location: main_app.locomotive_api_site_url(@site)
|
32
|
-
# end
|
33
|
-
|
34
|
-
# def destroy
|
35
|
-
# authorize @site
|
36
|
-
# @site.destroy
|
37
|
-
# respond_with @site, location: main_app.locomotive_api_sites_url
|
38
|
-
# end
|
39
|
-
|
40
|
-
# private
|
41
|
-
|
42
|
-
# def load_site
|
43
|
-
# @site = policy_scope(Locomotive::Site).find(params[:id])
|
44
|
-
# end
|
45
|
-
|
46
|
-
# def load_sites
|
47
|
-
# @sites = policy_scope(Locomotive::Site)
|
48
|
-
# end
|
49
|
-
|
50
|
-
# def current_membership
|
51
|
-
# membership = @site ? @site.membership_for(current_locomotive_account) : nil
|
52
|
-
# membership || Locomotive::Membership.new(account: current_locomotive_account)
|
53
|
-
# end
|
54
|
-
|
55
|
-
# end
|
56
|
-
|
57
|
-
# end
|
58
|
-
# end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
# module Locomotive
|
2
|
-
# module Api
|
3
|
-
# class SnippetsController < Api::BaseController
|
4
|
-
|
5
|
-
# account_required & within_site
|
6
|
-
|
7
|
-
# before_filter :load_snippet, only: [:show, :update, :destroy]
|
8
|
-
# before_filter :load_snippets, only: [:index]
|
9
|
-
|
10
|
-
# def index
|
11
|
-
# authorize Locomotive::Snippet
|
12
|
-
# @snippets = @snippets.order_by(:name.asc)
|
13
|
-
# respond_with @snippets
|
14
|
-
# end
|
15
|
-
|
16
|
-
# def show
|
17
|
-
# authorize @snippet
|
18
|
-
# respond_with @snippet
|
19
|
-
# end
|
20
|
-
|
21
|
-
# def create
|
22
|
-
# authorize Locomotive::Snippet
|
23
|
-
# @snippet = current_site.snippets.build
|
24
|
-
# @snippet.from_presenter(params[:snippet]).save
|
25
|
-
# respond_with @snippet, location: -> { main_app.locomotive_api_snippet_url(@snippet) }
|
26
|
-
# end
|
27
|
-
|
28
|
-
# def update
|
29
|
-
# authorize @snippet
|
30
|
-
# @snippet.from_presenter(params[:snippet]).save
|
31
|
-
# respond_with @snippet, location: main_app.locomotive_api_snippet_url(@snippet)
|
32
|
-
# end
|
33
|
-
|
34
|
-
# def destroy
|
35
|
-
# authorize Locomotive::Snippet
|
36
|
-
# @snippet.destroy
|
37
|
-
# respond_with @snippet, location: main_app.locomotive_api_snippets_url
|
38
|
-
# end
|
39
|
-
|
40
|
-
# private
|
41
|
-
|
42
|
-
# def load_snippet
|
43
|
-
# @snippet = current_site.snippets.find(params[:id])
|
44
|
-
# end
|
45
|
-
|
46
|
-
# def load_snippets
|
47
|
-
# @snippets = current_site.snippets
|
48
|
-
# end
|
49
|
-
|
50
|
-
# end
|
51
|
-
# end
|
52
|
-
# end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# module Locomotive
|
2
|
-
# module Api
|
3
|
-
# class ThemeAssetsController < Api::BaseController
|
4
|
-
|
5
|
-
# account_required & within_site
|
6
|
-
|
7
|
-
# before_filter :load_theme_asset, only: [:show, :update, :destroy]
|
8
|
-
# before_filter :load_theme_assets, only: [:index]
|
9
|
-
|
10
|
-
# def index
|
11
|
-
# authorize Locomotive::ThemeAsset
|
12
|
-
# respond_with @theme_assets.sort_by(&:local_path)
|
13
|
-
# end
|
14
|
-
|
15
|
-
# def show
|
16
|
-
# authorize @theme_asset
|
17
|
-
# respond_with @theme_asset
|
18
|
-
# end
|
19
|
-
|
20
|
-
# def create
|
21
|
-
# authorize Locomotive::ThemeAsset
|
22
|
-
# @theme_asset = current_site.theme_assets.build
|
23
|
-
# @theme_asset.from_presenter(params[:theme_asset]).save
|
24
|
-
# respond_with @theme_asset, location: -> { main_app.locomotive_api_theme_asset_url(@theme_asset) }
|
25
|
-
# end
|
26
|
-
|
27
|
-
# def update
|
28
|
-
# authorize @theme_asset
|
29
|
-
# @theme_asset.from_presenter(params[:theme_asset]).save
|
30
|
-
# respond_with @theme_asset, location: main_app.locomotive_api_theme_asset_url(@theme_asset)
|
31
|
-
# end
|
32
|
-
|
33
|
-
# def destroy
|
34
|
-
# authorize @theme_asset
|
35
|
-
# @theme_asset.destroy
|
36
|
-
# respond_with @theme_asset, location: main_app.locomotive_api_theme_assets_url
|
37
|
-
# end
|
38
|
-
|
39
|
-
# private
|
40
|
-
|
41
|
-
# def load_theme_asset
|
42
|
-
# @theme_asset = current_site.theme_assets.find(params[:id])
|
43
|
-
# end
|
44
|
-
|
45
|
-
# def load_theme_assets
|
46
|
-
# @theme_assets = current_site.theme_assets
|
47
|
-
# end
|
48
|
-
|
49
|
-
# end
|
50
|
-
# end
|
51
|
-
# end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# module Locomotive
|
2
|
-
# module Api
|
3
|
-
# class TokensController < Api::BaseController
|
4
|
-
|
5
|
-
# def create
|
6
|
-
# begin
|
7
|
-
# token = Account.create_api_token(params[:email], params[:password], params[:api_key])
|
8
|
-
# respond_with({ token: token }, location: location_after_request)
|
9
|
-
# rescue Exception => e
|
10
|
-
# logger.error "Unable to create a token, reason: #{e.message}"
|
11
|
-
# respond_with({ message: e.message }, status: 401, location: location_after_request)
|
12
|
-
# end
|
13
|
-
# end
|
14
|
-
|
15
|
-
# def destroy
|
16
|
-
# begin
|
17
|
-
# token = Account.invalidate_api_token(params[:id])
|
18
|
-
# respond_with({ token: token }, location: location_after_request)
|
19
|
-
# rescue Exception => e
|
20
|
-
# respond_with({ message: e.message }, status: 404, location: location_after_request)
|
21
|
-
# end
|
22
|
-
# end
|
23
|
-
|
24
|
-
# private
|
25
|
-
|
26
|
-
# def set_locale
|
27
|
-
# I18n.locale = Locomotive.config.locales.first
|
28
|
-
# end
|
29
|
-
|
30
|
-
# def location_after_request
|
31
|
-
# main_app.locomotive_api_my_account_url(format: :json)
|
32
|
-
# end
|
33
|
-
|
34
|
-
# end
|
35
|
-
# end
|
36
|
-
# end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# module Locomotive
|
2
|
-
# module Api
|
3
|
-
# class TranslationsController < Api::BaseController
|
4
|
-
|
5
|
-
# account_required & within_site
|
6
|
-
|
7
|
-
# before_filter :load_translation, only: [:show, :update, :destroy]
|
8
|
-
# before_filter :load_translations, only: [:index]
|
9
|
-
|
10
|
-
# def index
|
11
|
-
# authorize Translation
|
12
|
-
# respond_with @translations
|
13
|
-
# end
|
14
|
-
|
15
|
-
# def show
|
16
|
-
# authorize @translation
|
17
|
-
# respond_with @translation
|
18
|
-
# end
|
19
|
-
|
20
|
-
# def create
|
21
|
-
# authorize Translation
|
22
|
-
# @translation = self.current_site.translations.build
|
23
|
-
# @translation.from_presenter(params[:translation]).save
|
24
|
-
# respond_with @translation, location: -> { main_app.locomotive_api_translation_url(@translation) }
|
25
|
-
# end
|
26
|
-
|
27
|
-
# def update
|
28
|
-
# authorize @translation
|
29
|
-
# @translation.from_presenter(params[:translation]).save
|
30
|
-
# respond_with @translation, location: main_app.locomotive_api_translation_url(@translation)
|
31
|
-
# end
|
32
|
-
|
33
|
-
# def destroy
|
34
|
-
# authorize @translation
|
35
|
-
# @translation.destroy
|
36
|
-
# respond_with @translation, location: main_app.locomotive_api_translations_url
|
37
|
-
# end
|
38
|
-
|
39
|
-
# private
|
40
|
-
|
41
|
-
# def load_translation
|
42
|
-
# @translation = self.current_site.translations.find params[:id]
|
43
|
-
# end
|
44
|
-
|
45
|
-
# def load_translations
|
46
|
-
# @translations = self.current_site.translations
|
47
|
-
# end
|
48
|
-
|
49
|
-
# end
|
50
|
-
# end
|
51
|
-
# end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
# require 'spec_helper'
|
2
|
-
|
3
|
-
# describe Locomotive::EditableControl do
|
4
|
-
|
5
|
-
# before(:each) do
|
6
|
-
# @site = FactoryGirl.create(:site)
|
7
|
-
# @home = @site.pages.root.first
|
8
|
-
# end
|
9
|
-
|
10
|
-
# describe '#simple' do
|
11
|
-
|
12
|
-
# before(:each) do
|
13
|
-
# @home.update_attributes raw_template: %({% block body %}{% editable_control 'menu', options: "true=Yes,false=No" %}false{% endeditable_control %}{% endblock %}%)
|
14
|
-
|
15
|
-
# @sub_page_1 = FactoryGirl.create(:page, slug: 'sub_page_1', parent: @home, raw_template: "{% extends 'parent' %}")
|
16
|
-
# end
|
17
|
-
|
18
|
-
# it 'exists' do
|
19
|
-
# expect(@sub_page_1.editable_elements.size).to eq(1)
|
20
|
-
# end
|
21
|
-
|
22
|
-
# it 'has a non-nil slug' do
|
23
|
-
# expect(@sub_page_1.editable_elements.first.slug).to eq('menu')
|
24
|
-
# end
|
25
|
-
|
26
|
-
# it 'has a default value' do
|
27
|
-
# expect(@sub_page_1.editable_elements.first.content).to eq('false')
|
28
|
-
# end
|
29
|
-
|
30
|
-
# it 'has a list of options' do
|
31
|
-
# expect(@sub_page_1.editable_elements.first.options).to eq([{ 'value' => 'true', 'text' => 'Yes' }, { 'value' => 'false', 'text' => 'No' }])
|
32
|
-
# end
|
33
|
-
|
34
|
-
# it 'removes leading and trailling characters' do
|
35
|
-
# @home.update_attributes raw_template: %({% block body %}
|
36
|
-
# {% editable_control 'menu', options: 'true=Yes,false=No' %}
|
37
|
-
# true
|
38
|
-
# {% endeditable_control %}
|
39
|
-
# {% endblock %})
|
40
|
-
# expect(@home.editable_elements.first.content).to eq('true')
|
41
|
-
# end
|
42
|
-
|
43
|
-
# end
|
44
|
-
|
45
|
-
# describe '"sticky" elements' do
|
46
|
-
|
47
|
-
# before(:each) do
|
48
|
-
# @home.update_attributes raw_template: "{% block body %}{% editable_control 'menu', options: 'true=Yes,false=No', fixed: true %}false{% endeditable_control %}{% endblock %}"
|
49
|
-
# @home_el = @home.editable_elements.first
|
50
|
-
|
51
|
-
# @sub_page_1 = FactoryGirl.create(:page, slug: 'sub_page_1', parent: @home, raw_template: "{% extends 'parent' %}")
|
52
|
-
# @sub_page_2 = FactoryGirl.create(:page, slug: 'sub_page_2', parent: @home, raw_template: "{% extends 'parent' %}")
|
53
|
-
|
54
|
-
# @sub_page_1_el = @sub_page_1.editable_elements.first
|
55
|
-
# @sub_page_2_el = @sub_page_2.editable_elements.first
|
56
|
-
# end
|
57
|
-
|
58
|
-
# it 'exists in sub pages' do
|
59
|
-
# expect(@sub_page_1.editable_elements.size).to eq(1)
|
60
|
-
# expect(@sub_page_2.editable_elements.size).to eq(1)
|
61
|
-
# end
|
62
|
-
|
63
|
-
# it 'is marked as fixed' do
|
64
|
-
# expect(@sub_page_1_el.fixed?).to eq(true)
|
65
|
-
# expect(@sub_page_2_el.fixed?).to eq(true)
|
66
|
-
# end
|
67
|
-
|
68
|
-
# it 'gets also updated when updating the very first element' do
|
69
|
-
# @home_el.content = 'true'
|
70
|
-
# @home.save
|
71
|
-
# @sub_page_1.reload; @sub_page_1_el = @sub_page_1.editable_elements.first
|
72
|
-
# @sub_page_2.reload; @sub_page_2_el = @sub_page_2.editable_elements.first
|
73
|
-
# expect(@sub_page_1_el.content).to eq('true')
|
74
|
-
# expect(@sub_page_2_el.content).to eq('true')
|
75
|
-
# end
|
76
|
-
|
77
|
-
# end
|
78
|
-
|
79
|
-
# end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
# require 'spec_helper'
|
2
|
-
|
3
|
-
# describe Locomotive::EditableFile do
|
4
|
-
|
5
|
-
# before(:each) do
|
6
|
-
# @site = FactoryGirl.create(:site)
|
7
|
-
# @home = @site.pages.root.first
|
8
|
-
|
9
|
-
# @home.update_attributes raw_template: "{% block body %}{% editable_file 'image' %}Lorem ipsum{% endeditable_file %}{% endblock %}"
|
10
|
-
|
11
|
-
# @home = @site.pages.root.first
|
12
|
-
# end
|
13
|
-
|
14
|
-
# it 'has one editable file element' do
|
15
|
-
# expect(@home.editable_elements.size).to eq(1)
|
16
|
-
# expect(@home.editable_elements.first.slug).to eq('image')
|
17
|
-
# end
|
18
|
-
|
19
|
-
# it 'disables the default content flag if the remove_source method is called' do
|
20
|
-
# @home.editable_elements.first.remove_source = true
|
21
|
-
# @home.save; @home.reload
|
22
|
-
# expect(@home.editable_elements.first.default_content?).to be(false)
|
23
|
-
# end
|
24
|
-
|
25
|
-
# it 'disables the default content when a new file is uploaded' do
|
26
|
-
# @home.editable_elements.first.source = FixturedAsset.open('5k.png')
|
27
|
-
# @home.save
|
28
|
-
# expect(@home.editable_elements.first.default_content?).to be(false)
|
29
|
-
# end
|
30
|
-
|
31
|
-
# it 'does not have 2 image fields' do
|
32
|
-
# editable_file = @home.editable_elements.first
|
33
|
-
# fields = editable_file.class.fields.keys
|
34
|
-
# expect(fields.include?('source') && fields.include?(:source)).to be(false)
|
35
|
-
# end
|
36
|
-
|
37
|
-
# describe 'with an attached file' do
|
38
|
-
|
39
|
-
# before(:each) do
|
40
|
-
# @editable_file = @home.editable_elements.first
|
41
|
-
# @editable_file.source = FixturedAsset.open('5k.png')
|
42
|
-
# @home.save
|
43
|
-
# @home.reload
|
44
|
-
# end
|
45
|
-
|
46
|
-
# it 'has a valid source' do
|
47
|
-
# expect(@editable_file.source?).to be(true)
|
48
|
-
# end
|
49
|
-
|
50
|
-
# it 'returns the right path even if the page has been retrieved with the minimum_attributes scope' do
|
51
|
-
# @home = @site.pages.root.first
|
52
|
-
# expect(@home.editable_elements.first.source?).to be(true)
|
53
|
-
# end
|
54
|
-
|
55
|
-
# end
|
56
|
-
|
57
|
-
# describe '"sticky" files' do
|
58
|
-
|
59
|
-
# before(:each) do
|
60
|
-
# @home.update_attributes raw_template: "{% block body %}{% editable_file 'image', fixed: true %}/foo.png{% endeditable_file %}{% endblock %}"
|
61
|
-
|
62
|
-
# @sub_page_1 = FactoryGirl.create(:page, slug: 'sub_page_1', parent: @home, raw_template: "{% extends 'index' %}")
|
63
|
-
# @sub_page_2 = FactoryGirl.create(:page, slug: 'sub_page_2', parent: @home, raw_template: "{% extends 'index' %}")
|
64
|
-
|
65
|
-
# @sub_page_1_el = @sub_page_1.editable_elements.first
|
66
|
-
# @sub_page_2_el = @sub_page_2.editable_elements.first
|
67
|
-
# end
|
68
|
-
|
69
|
-
# it 'exists in sub pages' do
|
70
|
-
# expect(@sub_page_1.editable_elements.size).to eq(1)
|
71
|
-
# expect(@sub_page_2.editable_elements.size).to eq(1)
|
72
|
-
# end
|
73
|
-
|
74
|
-
# it 'is marked as fixed' do
|
75
|
-
# expect(@sub_page_1_el.fixed?).to be(true)
|
76
|
-
# expect(@sub_page_2_el.fixed?).to be(true)
|
77
|
-
# end
|
78
|
-
|
79
|
-
# it 'enables the default content when it just got created' do
|
80
|
-
# expect(@sub_page_1_el.source?).to be(false)
|
81
|
-
# expect(@sub_page_1_el.default_source_url).to eq('/foo.png')
|
82
|
-
# expect(@sub_page_1_el.default_content?).to be(true)
|
83
|
-
# end
|
84
|
-
|
85
|
-
# it 'gets also updated when updating the very first element' do
|
86
|
-
# @home.editable_elements.first.source = FixturedAsset.open('5k.png')
|
87
|
-
# @home.save; @sub_page_1.reload; @sub_page_2.reload
|
88
|
-
# expect(@sub_page_1.editable_elements.first.default_source_url).to match(/files\/5k.png$/)
|
89
|
-
# expect(@sub_page_2.editable_elements.first.default_source_url).to match(/files\/5k.png$/)
|
90
|
-
# end
|
91
|
-
|
92
|
-
# end
|
93
|
-
|
94
|
-
# end
|
@@ -1,219 +0,0 @@
|
|
1
|
-
# require 'spec_helper'
|
2
|
-
|
3
|
-
# describe Locomotive::EditableText do
|
4
|
-
|
5
|
-
# describe 'a simple case' do
|
6
|
-
|
7
|
-
# before(:each) do
|
8
|
-
# @site = FactoryGirl.create(:site)
|
9
|
-
# @home = @site.pages.root.first
|
10
|
-
|
11
|
-
# @home.update_attributes raw_template: "{% block body %}{% editable_text 'body' %}Lorem ipsum{% endeditable_text %}{% endblock %}"
|
12
|
-
|
13
|
-
# @sub_page_1 = FactoryGirl.create(:page, title: '1', slug: 'sub_page_1', parent: @home, raw_template: "{% extends 'parent' %}")
|
14
|
-
# @sub_page_2 = FactoryGirl.create(:page, title: '2', slug: 'sub_page_2', parent: @home, raw_template: "{% extends 'parent' %}")
|
15
|
-
|
16
|
-
# @sub_page_1_el = @sub_page_1.editable_elements.first
|
17
|
-
|
18
|
-
# @sub_page_1_1 = FactoryGirl.create(:page, title: '1_1', slug: 'sub_page_1_1', parent: @sub_page_1, raw_template: "{% extends 'parent' %}")
|
19
|
-
# end
|
20
|
-
|
21
|
-
# describe 'properties' do
|
22
|
-
|
23
|
-
# it 'exists' do
|
24
|
-
# expect(@sub_page_1.editable_elements.size).to eq(1)
|
25
|
-
# end
|
26
|
-
|
27
|
-
# it 'has a non-nil slug' do
|
28
|
-
# expect(@sub_page_1.editable_elements.first.slug).to eq('body')
|
29
|
-
# end
|
30
|
-
|
31
|
-
# it 'has a default content at first' do
|
32
|
-
# expect(@sub_page_1.editable_elements.first.default_content).to eq(true)
|
33
|
-
# expect(@sub_page_1.editable_elements.first.content).to eq('Lorem ipsum')
|
34
|
-
# end
|
35
|
-
|
36
|
-
# it 'is still default when it gets modified by the exact same value' do
|
37
|
-
# @sub_page_1.editable_elements.first.content = 'Lorem ipsum'
|
38
|
-
# expect(@sub_page_1.editable_elements.first.default_content).to eq(true)
|
39
|
-
# end
|
40
|
-
|
41
|
-
# it 'strips the content' do
|
42
|
-
# @sub_page_1.editable_elements.first.update_attribute :content, " Lorem ipsum\n\n "
|
43
|
-
# expect(@sub_page_1.editable_elements.first.content).to eq('Lorem ipsum')
|
44
|
-
# end
|
45
|
-
|
46
|
-
# end
|
47
|
-
|
48
|
-
# describe 'locales' do
|
49
|
-
|
50
|
-
# it 'assigns the default locale' do
|
51
|
-
# expect(@sub_page_1_el.locales).to eq(['en'])
|
52
|
-
# end
|
53
|
-
|
54
|
-
# it 'adds new locale' do
|
55
|
-
# ::Mongoid::Fields::I18n.with_locale 'fr' do
|
56
|
-
# page = Locomotive::Page.find(@home._id)
|
57
|
-
# page.editable_elements.first.content = 'Lorem ipsum (FR)'
|
58
|
-
# page.save
|
59
|
-
# expect(page.editable_elements.first.locales).to eq(%w(en fr))
|
60
|
-
# end
|
61
|
-
# end
|
62
|
-
|
63
|
-
# it 'adds new locale within sub page elements' do
|
64
|
-
# ::Mongoid::Fields::I18n.with_locale 'fr' do
|
65
|
-
# @home.update_attributes title: 'Accueil', raw_template: "{% block body %}{% editable_text 'body' %}Lorem ipsum{% endeditable_text %}{% endblock %}"
|
66
|
-
# page = Locomotive::Page.find(@sub_page_1._id)
|
67
|
-
# page.editable_elements.first.content = 'Lorem ipsum (FR)'
|
68
|
-
# page.save
|
69
|
-
# expect(page.editable_elements.first.locales).to eq(%w(en fr))
|
70
|
-
# end
|
71
|
-
# end
|
72
|
-
|
73
|
-
# end
|
74
|
-
|
75
|
-
# describe 'when modifying the raw template' do
|
76
|
-
|
77
|
-
# it 'can update its content from the raw template if the user has not modified it' do
|
78
|
-
# @home.update_attributes raw_template: "{% block body %}{% editable_text 'body' %}Lorem ipsum v2{% endeditable_text %}{% endblock %}"
|
79
|
-
# expect(@home.editable_elements.first.default_content).to eq(true)
|
80
|
-
# expect(@home.editable_elements.first.content).to eq('Lorem ipsum v2')
|
81
|
-
# end
|
82
|
-
|
83
|
-
# it 'does not touch the content if the user has modified it before' do
|
84
|
-
# @home.editable_elements.first.content = 'Hello world'
|
85
|
-
# @home.raw_template = "{% block body %}{% editable_text 'body' %}Lorem ipsum v2{% endeditable_text %}{% endblock %}"
|
86
|
-
# @home.save
|
87
|
-
# expect(@home.editable_elements.first.default_content).to eq(false)
|
88
|
-
# expect(@home.editable_elements.first.content).to eq('Hello world')
|
89
|
-
# end
|
90
|
-
|
91
|
-
# end
|
92
|
-
|
93
|
-
# describe '.editable?' do
|
94
|
-
|
95
|
-
# it 'is editable' do
|
96
|
-
# expect(@sub_page_1_el.editable?).to eq(true)
|
97
|
-
# end
|
98
|
-
|
99
|
-
# it 'is not editable if the element is disabled' do
|
100
|
-
# @sub_page_1_el.disabled = true
|
101
|
-
# expect(@sub_page_1_el.editable?).to eq(false)
|
102
|
-
# end
|
103
|
-
|
104
|
-
# it 'is not editable if it is a fixed one' do
|
105
|
-
# @sub_page_1_el.fixed = true
|
106
|
-
# expect(@sub_page_1_el.editable?).to eq(false)
|
107
|
-
# end
|
108
|
-
|
109
|
-
# it 'is not editable if it does exist for the current locale' do
|
110
|
-
# ::Mongoid::Fields::I18n.with_locale 'fr' do
|
111
|
-
# expect(@sub_page_1_el.editable?).to eq(false)
|
112
|
-
# end
|
113
|
-
# end
|
114
|
-
|
115
|
-
# it 'is among the editable elements of the page' do
|
116
|
-
# expect(@sub_page_1.enabled_editable_elements.map(&:slug)).to eq(%w(body))
|
117
|
-
# end
|
118
|
-
|
119
|
-
# it 'is not among the editable elements of the page if disabled' do
|
120
|
-
# @sub_page_1_el.disabled = true
|
121
|
-
# expect(@sub_page_1.enabled_editable_elements.map(&:slug)).to eq([])
|
122
|
-
# end
|
123
|
-
|
124
|
-
# end
|
125
|
-
|
126
|
-
# describe 'in sub pages level #1' do
|
127
|
-
|
128
|
-
# before(:each) do
|
129
|
-
# @sub_page_1.reload
|
130
|
-
# @sub_page_2.reload
|
131
|
-
# end
|
132
|
-
|
133
|
-
# it 'exists' do
|
134
|
-
# expect(@sub_page_1.editable_elements.size).to eq(1)
|
135
|
-
# expect(@sub_page_2.editable_elements.size).to eq(1)
|
136
|
-
# end
|
137
|
-
|
138
|
-
# it 'has a non-nil slug' do
|
139
|
-
# expect(@sub_page_1.editable_elements.first.slug).to eq('body')
|
140
|
-
# end
|
141
|
-
|
142
|
-
# it 'does not have a content at first' do
|
143
|
-
# expect(@sub_page_1_el.default_content).to eq(true)
|
144
|
-
# expect(@sub_page_1_el.content).to eq('Lorem ipsum')
|
145
|
-
# end
|
146
|
-
|
147
|
-
# end
|
148
|
-
|
149
|
-
# describe 'in sub pages level #2' do
|
150
|
-
|
151
|
-
# before(:each) do
|
152
|
-
# @sub_page_1_1.reload
|
153
|
-
# end
|
154
|
-
|
155
|
-
# it 'exists' do
|
156
|
-
# expect(@sub_page_1_1.editable_elements.size).to eq(1)
|
157
|
-
# end
|
158
|
-
|
159
|
-
# it 'has a non-nil slug' do
|
160
|
-
# expect(@sub_page_1_1.editable_elements.first.slug).to eq('body')
|
161
|
-
# end
|
162
|
-
|
163
|
-
# it 'removes editable elements' do
|
164
|
-
# @sub_page_1_1.editable_elements.destroy_all
|
165
|
-
# @sub_page_1_1.reload
|
166
|
-
# expect(@sub_page_1_1.editable_elements.size).to eq(0)
|
167
|
-
# end
|
168
|
-
|
169
|
-
# end
|
170
|
-
|
171
|
-
# end
|
172
|
-
|
173
|
-
# describe '"sticky" elements' do
|
174
|
-
|
175
|
-
# before(:each) do
|
176
|
-
# @site = FactoryGirl.create(:site)
|
177
|
-
# @home = @site.pages.root.first
|
178
|
-
|
179
|
-
# @home.update_attributes raw_template: "{% block body %}{% editable_text 'body', fixed: true %}Lorem ipsum{% endeditable_text %}{% endblock %}"
|
180
|
-
# @home_el = @home.editable_elements.first
|
181
|
-
|
182
|
-
# @sub_page_1 = FactoryGirl.create(:page, slug: 'sub_page_1', parent: @home, raw_template: "{% extends 'parent' %}")
|
183
|
-
# @sub_page_2 = FactoryGirl.create(:page, slug: 'sub_page_2', parent: @home, raw_template: "{% extends 'parent' %}")
|
184
|
-
|
185
|
-
# @sub_page_1_el = @sub_page_1.editable_elements.first
|
186
|
-
# @sub_page_2_el = @sub_page_2.editable_elements.first
|
187
|
-
# end
|
188
|
-
|
189
|
-
# it 'exists in sub pages' do
|
190
|
-
# expect(@sub_page_1.editable_elements.size).to eq(1)
|
191
|
-
# expect(@sub_page_2.editable_elements.size).to eq(1)
|
192
|
-
# end
|
193
|
-
|
194
|
-
# it 'is marked as fixed' do
|
195
|
-
# expect(@sub_page_1_el.fixed?).to eq(true)
|
196
|
-
# expect(@sub_page_2_el.fixed?).to eq(true)
|
197
|
-
# end
|
198
|
-
|
199
|
-
# it 'enables the default content when it just got created' do
|
200
|
-
# expect(@sub_page_1_el.default_content?).to eq(true)
|
201
|
-
# end
|
202
|
-
|
203
|
-
# it 'disables the default content if the content changed' do
|
204
|
-
# @sub_page_1_el.content = 'Bla bla'
|
205
|
-
# expect(@sub_page_1_el.default_content?).to eq(false)
|
206
|
-
# end
|
207
|
-
|
208
|
-
# it 'gets also updated when updating the very first element' do
|
209
|
-
# @home_el.content = 'Hello world'
|
210
|
-
# @home.save
|
211
|
-
# @sub_page_1.reload; @sub_page_1_el = @sub_page_1.editable_elements.first
|
212
|
-
# @sub_page_2.reload; @sub_page_2_el = @sub_page_2.editable_elements.first
|
213
|
-
# expect(@sub_page_1_el.content).to eq('Hello world')
|
214
|
-
# expect(@sub_page_2_el.content).to eq('Hello world')
|
215
|
-
# end
|
216
|
-
|
217
|
-
# end
|
218
|
-
|
219
|
-
# end
|