locomotivecms_steam 0.1.2.pre.beta → 1.0.0.pre.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.travis.yml +8 -1
- data/Gemfile +17 -8
- data/Gemfile.lock +160 -113
- data/LICENSE +1 -1
- data/README.md +36 -15
- data/Rakefile +27 -1
- data/bin/steam.rb +97 -0
- data/config/locales/en.yml +2 -1
- data/config/locales/fr.yml +2 -1
- data/lib/locomotive/steam.rb +28 -19
- data/lib/locomotive/steam/adapters/concerns/key.rb +15 -0
- data/lib/locomotive/steam/adapters/filesystem.rb +124 -0
- data/lib/locomotive/steam/adapters/filesystem/sanitizer.rb +54 -0
- data/lib/locomotive/steam/adapters/filesystem/sanitizers/content_entry.rb +86 -0
- data/lib/locomotive/steam/adapters/filesystem/sanitizers/content_type.rb +21 -0
- data/lib/locomotive/steam/adapters/filesystem/sanitizers/page.rb +160 -0
- data/lib/locomotive/steam/adapters/filesystem/sanitizers/simple.rb +15 -0
- data/lib/locomotive/steam/adapters/filesystem/sanitizers/snippet.rb +33 -0
- data/lib/locomotive/steam/adapters/filesystem/simple_cache_store.rb +38 -0
- data/lib/locomotive/steam/adapters/filesystem/yaml_loader.rb +47 -0
- data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/content_entry.rb +87 -0
- data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/content_type.rb +96 -0
- data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/page.rb +145 -0
- data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/site.rb +25 -0
- data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/snippet.rb +66 -0
- data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/theme_asset.rb +21 -0
- data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/translation.rb +72 -0
- data/lib/locomotive/steam/adapters/memory.rb +55 -0
- data/lib/locomotive/steam/adapters/memory/condition.rb +103 -0
- data/lib/locomotive/steam/adapters/memory/dataset.rb +77 -0
- data/lib/locomotive/steam/adapters/memory/order.rb +60 -0
- data/lib/locomotive/steam/adapters/memory/query.rb +116 -0
- data/lib/locomotive/steam/adapters/mongodb.rb +83 -0
- data/lib/locomotive/steam/adapters/mongodb/dataset.rb +20 -0
- data/lib/locomotive/steam/adapters/mongodb/origin.rb +3 -0
- data/lib/locomotive/steam/adapters/mongodb/query.rb +82 -0
- data/lib/locomotive/steam/configuration.rb +106 -2
- data/lib/locomotive/steam/core_ext.rb +2 -1
- data/lib/locomotive/steam/core_ext/hash.rb +31 -19
- data/lib/locomotive/steam/core_ext/kernel.rb +14 -0
- data/lib/locomotive/steam/core_ext/string.rb +35 -6
- data/lib/locomotive/steam/decorators/i18n_decorator.rb +99 -0
- data/lib/locomotive/steam/decorators/template_decorator.rb +37 -0
- data/lib/locomotive/steam/entities/content_entry.rb +151 -0
- data/lib/locomotive/steam/entities/content_type.rb +44 -6
- data/lib/locomotive/steam/entities/content_type_field.rb +71 -0
- data/lib/locomotive/steam/entities/editable_element.rb +21 -0
- data/lib/locomotive/steam/entities/page.rb +48 -127
- data/lib/locomotive/steam/entities/site.rb +36 -27
- data/lib/locomotive/steam/entities/snippet.rb +20 -0
- data/lib/locomotive/steam/entities/theme_asset.rb +9 -0
- data/lib/locomotive/steam/entities/translation.rb +15 -0
- data/lib/locomotive/steam/initializers.rb +0 -4
- data/lib/locomotive/steam/initializers/dragonfly.rb +51 -11
- data/lib/locomotive/steam/initializers/i18n.rb +6 -3
- data/lib/locomotive/steam/initializers/sprockets.rb +4 -1
- data/lib/locomotive/steam/liquid.rb +4 -7
- data/lib/locomotive/steam/liquid/drops/base.rb +0 -1
- data/lib/locomotive/steam/liquid/drops/content_entry.rb +37 -16
- data/lib/locomotive/steam/liquid/drops/content_entry_collection.rb +77 -0
- data/lib/locomotive/steam/liquid/drops/content_types.rb +5 -102
- data/lib/locomotive/steam/liquid/drops/current_user.rb +23 -0
- data/lib/locomotive/steam/liquid/drops/i18n_base.rb +39 -0
- data/lib/locomotive/steam/liquid/drops/page.rb +77 -11
- data/lib/locomotive/steam/liquid/drops/session_proxy.rb +1 -1
- data/lib/locomotive/steam/liquid/drops/site.rb +14 -8
- data/lib/locomotive/steam/liquid/drops/upload_file.rb +23 -0
- data/lib/locomotive/steam/liquid/errors.rb +3 -9
- data/lib/locomotive/steam/liquid/filters/base.rb +62 -0
- data/lib/locomotive/steam/liquid/filters/date.rb +85 -61
- data/lib/locomotive/steam/liquid/filters/html.rb +30 -115
- data/lib/locomotive/steam/liquid/filters/misc.rb +6 -5
- data/lib/locomotive/steam/liquid/filters/pagination.rb +55 -0
- data/lib/locomotive/steam/liquid/filters/resize.rb +2 -3
- data/lib/locomotive/steam/liquid/filters/text.rb +15 -15
- data/lib/locomotive/steam/liquid/filters/translate.rb +5 -14
- data/lib/locomotive/steam/liquid/patches.rb +29 -23
- data/lib/locomotive/steam/liquid/tags/concerns/i18n_page.rb +36 -0
- data/lib/locomotive/steam/liquid/tags/concerns/path.rb +114 -0
- data/lib/locomotive/steam/liquid/tags/consume.rb +39 -43
- data/lib/locomotive/steam/liquid/tags/csrf.rb +21 -12
- data/lib/locomotive/steam/liquid/tags/editable.rb +1 -3
- data/lib/locomotive/steam/liquid/tags/editable/base.rb +54 -15
- data/lib/locomotive/steam/liquid/tags/editable/control.rb +17 -4
- data/lib/locomotive/steam/liquid/tags/editable/file.rb +34 -2
- data/lib/locomotive/steam/liquid/tags/editable/text.rb +54 -2
- data/lib/locomotive/steam/liquid/tags/extends.rb +45 -8
- data/lib/locomotive/steam/liquid/tags/fetch_page.rb +38 -0
- data/lib/locomotive/steam/liquid/tags/google_analytics.rb +25 -12
- data/lib/locomotive/steam/liquid/tags/hybrid.rb +24 -12
- data/lib/locomotive/steam/liquid/tags/inherited_block.rb +39 -0
- data/lib/locomotive/steam/liquid/tags/inline_editor.rb +14 -4
- data/lib/locomotive/steam/liquid/tags/link_to.rb +16 -27
- data/lib/locomotive/steam/liquid/tags/locale_switcher.rb +45 -56
- data/lib/locomotive/steam/liquid/tags/model_form.rb +72 -0
- data/lib/locomotive/steam/liquid/tags/nav.rb +65 -57
- data/lib/locomotive/steam/liquid/tags/paginate.rb +79 -47
- data/lib/locomotive/steam/liquid/tags/path_to.rb +8 -20
- data/lib/locomotive/steam/liquid/tags/seo.rb +8 -8
- data/lib/locomotive/steam/liquid/tags/session_assign.rb +6 -8
- data/lib/locomotive/steam/liquid/tags/snippet.rb +26 -42
- data/lib/locomotive/steam/liquid/tags/with_scope.rb +44 -26
- data/lib/locomotive/steam/middlewares.rb +7 -13
- data/lib/locomotive/steam/middlewares/default_env.rb +25 -0
- data/lib/locomotive/steam/middlewares/dynamic_assets.rb +34 -17
- data/lib/locomotive/steam/middlewares/entry_submission.rb +117 -79
- data/lib/locomotive/steam/middlewares/favicon.rb +5 -2
- data/lib/locomotive/steam/middlewares/helpers.rb +44 -0
- data/lib/locomotive/steam/middlewares/locale.rb +25 -17
- data/lib/locomotive/steam/middlewares/locale_redirection.rb +62 -0
- data/lib/locomotive/steam/middlewares/logging.rb +7 -3
- data/lib/locomotive/steam/middlewares/page.rb +17 -48
- data/lib/locomotive/steam/middlewares/path.rb +5 -8
- data/lib/locomotive/steam/middlewares/renderer.rb +65 -106
- data/lib/locomotive/steam/middlewares/robots.rb +20 -0
- data/lib/locomotive/steam/middlewares/site.rb +42 -0
- data/lib/locomotive/steam/middlewares/sitemap.rb +94 -0
- data/lib/locomotive/steam/middlewares/stack_proxy.rb +46 -0
- data/lib/locomotive/steam/middlewares/templatized_page.rb +40 -14
- data/lib/locomotive/steam/middlewares/threadsafe.rb +65 -0
- data/lib/locomotive/steam/middlewares/timezone.rb +10 -6
- data/lib/locomotive/steam/models.rb +12 -0
- data/lib/locomotive/steam/models/associations/belongs_to.rb +18 -0
- data/lib/locomotive/steam/models/associations/embedded.rb +43 -0
- data/lib/locomotive/steam/models/associations/has_many.rb +22 -0
- data/lib/locomotive/steam/models/associations/many_to_many.rb +22 -0
- data/lib/locomotive/steam/models/associations/referenced.rb +48 -0
- data/lib/locomotive/steam/models/concerns/validation.rb +58 -0
- data/lib/locomotive/steam/models/entity.rb +40 -0
- data/lib/locomotive/steam/models/i18n_field.rb +42 -0
- data/lib/locomotive/steam/models/mapper.rb +119 -0
- data/lib/locomotive/steam/models/pager.rb +53 -0
- data/lib/locomotive/steam/models/repository.rb +101 -0
- data/lib/locomotive/steam/models/scope.rb +31 -0
- data/lib/locomotive/steam/repositories.rb +51 -0
- data/lib/locomotive/steam/repositories/content_entry_repository.rb +183 -0
- data/lib/locomotive/steam/repositories/content_type_field_repository.rb +50 -0
- data/lib/locomotive/steam/repositories/content_type_field_select_option_repository.rb +23 -0
- data/lib/locomotive/steam/repositories/content_type_repository.rb +38 -0
- data/lib/locomotive/steam/repositories/editable_element_repository.rb +20 -0
- data/lib/locomotive/steam/repositories/page_repository.rb +86 -0
- data/lib/locomotive/steam/repositories/site_repository.rb +29 -0
- data/lib/locomotive/steam/repositories/snippet_repository.rb +19 -0
- data/lib/locomotive/steam/repositories/theme_asset_repository.rb +24 -0
- data/lib/locomotive/steam/repositories/translation_repository.rb +17 -0
- data/lib/locomotive/steam/server.rb +61 -40
- data/lib/locomotive/steam/services.rb +120 -1
- data/lib/locomotive/steam/services/asset_host_service.rb +51 -0
- data/lib/locomotive/steam/services/concerns/decorator.rb +35 -0
- data/lib/locomotive/steam/services/csrf_protection_service.rb +13 -0
- data/lib/locomotive/steam/services/editable_element_service.rb +19 -0
- data/lib/locomotive/steam/services/entry_submission_service.rb +91 -0
- data/lib/locomotive/steam/services/external_api_service.rb +55 -0
- data/lib/locomotive/steam/services/image_resizer_service.rb +49 -0
- data/lib/locomotive/steam/services/liquid_parser_service.rb +23 -0
- data/lib/locomotive/steam/services/markdown_service.rb +17 -0
- data/lib/locomotive/steam/services/no_cache_service.rb +17 -0
- data/lib/locomotive/steam/services/page_finder_service.rb +44 -0
- data/lib/locomotive/steam/services/parent_finder_service.rb +23 -0
- data/lib/locomotive/steam/services/site_finder_service.rb +13 -0
- data/lib/locomotive/steam/services/snippet_finder_service.rb +17 -0
- data/lib/locomotive/steam/services/textile_service.rb +17 -0
- data/lib/locomotive/steam/services/theme_asset_url_service.rb +43 -0
- data/lib/locomotive/steam/services/translator_service.rb +34 -0
- data/lib/locomotive/steam/services/url_builder_service.rb +40 -0
- data/lib/locomotive/steam/version.rb +1 -1
- data/locomotivecms_steam.gemspec +34 -28
- data/script/ci/before_build.sh +4 -0
- data/spec/fixtures/default/app/content_types/bands.yml +3 -1
- data/spec/fixtures/default/app/content_types/events.yml +2 -2
- data/spec/fixtures/default/app/views/pages/about_us.liquid.haml +2 -1
- data/spec/fixtures/default/app/views/pages/archives.liquid.haml +6 -0
- data/spec/fixtures/default/app/views/pages/basic.liquid.haml +1 -0
- data/spec/fixtures/default/app/views/pages/contest.liquid.haml +2 -1
- data/spec/fixtures/default/app/views/pages/events.fr.liquid +4 -0
- data/spec/fixtures/default/app/views/pages/events.liquid.haml +23 -1
- data/spec/fixtures/default/app/views/pages/filtered.liquid.haml +16 -5
- data/spec/fixtures/default/app/views/pages/grunge_bands.liquid.haml +2 -1
- data/spec/fixtures/default/app/views/pages/index.liquid.haml +12 -11
- data/spec/fixtures/default/app/views/pages/music.liquid.haml +1 -1
- data/spec/fixtures/default/app/views/pages/songs.liquid +6 -0
- data/spec/fixtures/default/app/views/pages/songs/song-number-1.liquid.haml +5 -0
- data/spec/fixtures/default/app/views/pages/store.liquid +2 -1
- data/spec/fixtures/default/app/views/pages/tags.liquid +6 -0
- data/spec/fixtures/default/app/views/pages/unlisted_pages.liquid.haml +2 -1
- data/spec/fixtures/default/app/views/snippets/song.fr.liquid.haml +1 -1
- data/spec/fixtures/default/config/deploy.yml +2 -2
- data/spec/fixtures/default/config/site.yml +7 -1
- data/spec/fixtures/default/data/bands.yml +3 -0
- data/spec/fixtures/mongodb/locomotive_accounts.bson +0 -0
- data/spec/fixtures/mongodb/locomotive_accounts.metadata.json +1 -0
- data/spec/fixtures/mongodb/locomotive_content_assets.bson +0 -0
- data/spec/fixtures/mongodb/locomotive_content_assets.metadata.json +1 -0
- data/spec/fixtures/mongodb/locomotive_content_entries.bson +0 -0
- data/spec/fixtures/mongodb/locomotive_content_entries.metadata.json +1 -0
- data/spec/fixtures/mongodb/locomotive_content_types.bson +0 -0
- data/spec/fixtures/mongodb/locomotive_content_types.metadata.json +1 -0
- data/spec/fixtures/mongodb/locomotive_pages.bson +0 -0
- data/spec/fixtures/mongodb/locomotive_pages.metadata.json +1 -0
- data/spec/fixtures/mongodb/locomotive_sites.bson +0 -0
- data/spec/fixtures/mongodb/locomotive_sites.metadata.json +1 -0
- data/spec/fixtures/mongodb/locomotive_snippets.bson +0 -0
- data/spec/fixtures/mongodb/locomotive_snippets.metadata.json +1 -0
- data/spec/fixtures/mongodb/locomotive_theme_assets.bson +0 -0
- data/spec/fixtures/mongodb/locomotive_theme_assets.metadata.json +1 -0
- data/spec/fixtures/mongodb/locomotive_translations.bson +0 -0
- data/spec/fixtures/mongodb/locomotive_translations.metadata.json +1 -0
- data/spec/fixtures/mongodb/sessions.bson +0 -0
- data/spec/fixtures/mongodb/sessions.metadata.json +1 -0
- data/spec/fixtures/mongodb/system.indexes.bson +0 -0
- data/spec/integration/integration_helper.rb +2 -2
- data/spec/integration/liquid/tags/paginate_spec.rb +79 -0
- data/spec/integration/repositories/content_entry_repository_spec.rb +94 -0
- data/spec/integration/repositories/content_type_repository_spec.rb +69 -0
- data/spec/integration/repositories/page_repository_spec.rb +105 -0
- data/spec/integration/repositories/site_repository_spec.rb +45 -0
- data/spec/integration/repositories/snippet_repository_spec.rb +50 -0
- data/spec/integration/repositories/theme_asset_repository_spec.rb +48 -0
- data/spec/integration/repositories/translation_repository_spec.rb +50 -0
- data/spec/integration/server/assets_spec.rb +60 -0
- data/spec/integration/server/basic_spec.rb +100 -100
- data/spec/integration/server/contact_form_spec.rb +96 -25
- data/spec/integration/server/liquid_spec.rb +19 -41
- data/spec/integration/server/nav_spec.rb +49 -0
- data/spec/integration/server/session_spec.rb +33 -0
- data/spec/integration/server/sitemap_spec.rb +34 -0
- data/spec/integration/server/with_scope_spec.rb +28 -2
- data/spec/integration/services/external_api_service_spec.rb +20 -0
- data/spec/locales/locales_spec.rb +7 -7
- data/spec/spec_helper.rb +27 -13
- data/spec/support.rb +5 -1
- data/spec/support/cache_store.rb +3 -0
- data/spec/support/helpers.rb +20 -23
- data/spec/support/liquid.rb +29 -0
- data/spec/support/pry.rb +4 -0
- data/spec/support/time.rb +3 -0
- data/spec/unit/adapters/filesystem/yaml_loaders/content_entry_spec.rb +50 -0
- data/spec/unit/adapters/filesystem/yaml_loaders/content_type_spec.rb +25 -0
- data/spec/unit/adapters/filesystem/yaml_loaders/page_spec.rb +25 -0
- data/spec/unit/adapters/filesystem/yaml_loaders/site_spec.rb +19 -0
- data/spec/unit/adapters/filesystem/yaml_loaders/snippet_spec.rb +26 -0
- data/spec/unit/adapters/filesystem/yaml_loaders/translation_spec.rb +25 -0
- data/spec/unit/adapters/filesystem_adapter_spec.rb +53 -0
- data/spec/unit/adapters/memory/condition_spec.rb +125 -0
- data/spec/unit/adapters/memory/dataset_spec.rb +73 -0
- data/spec/unit/adapters/memory/order_spec.rb +67 -0
- data/spec/unit/adapters/memory/query_spec.rb +85 -0
- data/spec/unit/adapters/memory_adapter_spec.rb +36 -0
- data/spec/unit/adapters/mongodb/query_spec.rb +68 -0
- data/spec/unit/adapters/mongodb_adapter_spec.rb +17 -0
- data/spec/unit/configuration_spec.rb +29 -0
- data/spec/unit/core_ext/string_spec.rb +44 -0
- data/spec/unit/decorators/i18n_decorator_spec.rb +80 -0
- data/spec/unit/entities/content_entry_spec.rb +159 -0
- data/spec/unit/entities/content_type_field_spec.rb +67 -0
- data/spec/unit/entities/content_type_spec.rb +59 -0
- data/spec/unit/entities/page_spec.rb +40 -34
- data/spec/unit/entities/site_spec.rb +56 -5
- data/spec/unit/initializers/dragonfly_spec.rb +31 -0
- data/spec/unit/liquid/drops/content_entry_collection_spec.rb +81 -0
- data/spec/unit/liquid/drops/content_entry_spec.rb +99 -0
- data/spec/unit/liquid/drops/content_types_spec.rb +25 -0
- data/spec/unit/liquid/drops/current_user_spec.rb +45 -0
- data/spec/unit/liquid/drops/page_spec.rb +134 -0
- data/spec/unit/liquid/drops/session_proxy_spec.rb +13 -0
- data/spec/unit/liquid/drops/site_spec.rb +49 -0
- data/spec/unit/liquid/filters/date_spec.rb +160 -0
- data/spec/unit/liquid/filters/html_spec.rb +263 -0
- data/spec/unit/liquid/filters/misc_spec.rb +108 -0
- data/spec/unit/liquid/filters/pagination_spec.rb +42 -0
- data/spec/unit/liquid/filters/resize_spec.rb +36 -0
- data/spec/unit/liquid/filters/text_spec.rb +56 -0
- data/spec/unit/liquid/filters/translate_spec.rb +33 -0
- data/spec/unit/liquid/patches_spec.rb +50 -0
- data/spec/unit/liquid/tags/consume_spec.rb +87 -0
- data/spec/unit/liquid/tags/csrf_spec.rb +47 -0
- data/spec/unit/liquid/tags/editable/control_spec.rb +109 -0
- data/spec/unit/liquid/tags/editable/file_spec.rb +116 -0
- data/spec/unit/liquid/tags/editable/text_spec.rb +139 -0
- data/spec/unit/liquid/tags/extends_spec.rb +38 -0
- data/spec/unit/liquid/tags/fetch_page_spec.rb +39 -0
- data/spec/unit/liquid/tags/google_analytics_spec.rb +16 -0
- data/spec/unit/liquid/tags/inherited_block_spec.rb +33 -0
- data/spec/unit/liquid/tags/link_to_spec.rb +112 -0
- data/spec/unit/liquid/tags/locale_switcher_spec.rb +58 -0
- data/spec/unit/liquid/tags/model_form_spec.rb +35 -0
- data/spec/unit/liquid/tags/nav_spec.rb +184 -111
- data/spec/unit/liquid/tags/paginate_spec.rb +131 -0
- data/spec/unit/liquid/tags/path_to_spec.rb +100 -0
- data/spec/unit/liquid/tags/seo_spec.rb +85 -0
- data/spec/unit/liquid/tags/session_assign_spec.rb +51 -0
- data/spec/unit/liquid/tags/snippet_spec.rb +42 -0
- data/spec/unit/liquid/tags/with_scope_spec.rb +66 -0
- data/spec/unit/middlewares/dynamic_assets_spec.rb +25 -0
- data/spec/unit/middlewares/locale_redirection_spec.rb +105 -0
- data/spec/unit/middlewares/renderer_spec.rb +29 -0
- data/spec/unit/middlewares/stack_proxy_spec.rb +67 -0
- data/spec/unit/models/mapper_spec.rb +75 -0
- data/spec/unit/models/pager_spec.rb +82 -0
- data/spec/unit/models/repository_spec.rb +46 -0
- data/spec/unit/models/scope_spec.rb +27 -0
- data/spec/unit/repositories/content_entry_repository_spec.rb +347 -0
- data/spec/unit/repositories/content_type_repository_spec.rb +126 -0
- data/spec/unit/repositories/page_repository_spec.rb +365 -0
- data/spec/unit/repositories/site_repository_spec.rb +41 -0
- data/spec/unit/repositories/snippet_repository_spec.rb +37 -0
- data/spec/unit/repositories/theme_asset_repository_spec.rb +35 -0
- data/spec/unit/repositories/translation_repository_spec.rb +34 -0
- data/spec/unit/services/asset_host_service_spec.rb +79 -0
- data/spec/unit/services/entry_submission_service_spec.rb +143 -0
- data/spec/unit/services/external_api_service_spec.rb +80 -0
- data/spec/unit/services/image_resizer_service_spec.rb +75 -0
- data/spec/unit/services/markdown_service_spec.rb +36 -0
- data/spec/unit/services/parent_finder_service_spec.rb +41 -0
- data/spec/unit/services/textile_service_spec.rb +34 -0
- data/spec/unit/services/translator_service_spec.rb +65 -0
- data/spec/unit/services/url_builder_service_spec.rb +48 -0
- data/spec/unit/services_spec.rb +25 -0
- metadata +462 -119
- data/example/server.rb +0 -31
- data/lib/locomotive/steam/decorators.rb +0 -1
- data/lib/locomotive/steam/decorators/page_decorator.rb +0 -50
- data/lib/locomotive/steam/exceptions.rb +0 -62
- data/lib/locomotive/steam/liquid/scopeable.rb +0 -149
- data/lib/locomotive/steam/liquid/tags/editable/long_text.rb +0 -15
- data/lib/locomotive/steam/liquid/tags/editable/short_text.rb +0 -20
- data/lib/locomotive/steam/liquid/tags/path_helper.rb +0 -98
- data/lib/locomotive/steam/loaders/yml/pages_loader.rb +0 -193
- data/lib/locomotive/steam/loaders/yml/site_loader.rb +0 -49
- data/lib/locomotive/steam/loaders/yml/utils/localized_tree.rb +0 -33
- data/lib/locomotive/steam/loaders/yml/utils/yaml_front_matters_template.rb +0 -66
- data/lib/locomotive/steam/loaders/yml_loader.rb +0 -33
- data/lib/locomotive/steam/mapper.rb +0 -86
- data/lib/locomotive/steam/middlewares/base.rb +0 -65
- data/lib/locomotive/steam/middlewares/stack.rb +0 -66
- data/lib/locomotive/steam/middlewares/static_assets.rb +0 -25
- data/lib/locomotive/steam/monkey_patches.rb +0 -3
- data/lib/locomotive/steam/monkey_patches/haml.rb +0 -17
- data/lib/locomotive/steam/repositories/content_types_repository.rb +0 -14
- data/lib/locomotive/steam/repositories/pages_repository.rb +0 -23
- data/lib/locomotive/steam/repositories/sites_repository.rb +0 -16
- data/lib/locomotive/steam/services/dragonfly.rb +0 -49
- data/lib/locomotive/steam/services/external_api.rb +0 -47
- data/lib/locomotive/steam/services/markdown.rb +0 -20
- data/lib/locomotive/steam/standalone_server.rb +0 -30
- data/spec/unit/decorators/page_decorator_spec.rb +0 -55
- data/spec/unit/loaders/pages_loader_spec.rb +0 -42
- data/spec/unit/loaders/site_loader_spec.rb +0 -21
- data/spec/unit/loaders/utils/localized_tree_spec.rb +0 -33
- data/spec/unit/loaders/utils/yaml_front_matters_template_spec.rb +0 -39
- data/spec/unit/middlewares/base_spec.rb +0 -20
- data/spec/unit/middlewares/page_spec.rb +0 -51
- data/spec/unit/repositories/pages_spec.rb +0 -11
@@ -0,0 +1,134 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Locomotive::Steam::Liquid::Drops::Page do
|
4
|
+
|
5
|
+
let(:assigns) { {} }
|
6
|
+
let(:services) { Locomotive::Steam::Services.build_instance }
|
7
|
+
let(:site) { instance_double('Site', default_locale: 'en') }
|
8
|
+
let(:context) { ::Liquid::Context.new(assigns, {}, { locale: 'en', services: services, site: site }) }
|
9
|
+
let(:page) { instance_double('Page', id: 42, localized_attributes: [], title: 'Index', slug: 'index', fullpath: 'index', content_type: nil, depth: 1, templatized?: false, listed?: true, published?: true, is_layout?: true, redirect?: false, seo_title: 'seo title', redirect_url: '/', handle: 'index', meta_keywords: 'keywords', meta_description: 'description') }
|
10
|
+
let(:drop) { described_class.new(page).tap { |d| d.context = context } }
|
11
|
+
|
12
|
+
subject { drop }
|
13
|
+
|
14
|
+
it 'gives access to general attributes' do
|
15
|
+
expect(subject.id).to eq 42
|
16
|
+
expect(subject.title).to eq 'Index'
|
17
|
+
expect(subject.original_title).to eq 'Index'
|
18
|
+
expect(subject.slug).to eq 'index'
|
19
|
+
expect(subject.original_slug).to eq 'index'
|
20
|
+
expect(subject.fullpath).to eq 'index'
|
21
|
+
expect(subject.content_type).to eq nil
|
22
|
+
expect(subject.depth).to eq 1
|
23
|
+
expect(subject.redirect_url).to eq '/'
|
24
|
+
expect(subject.handle).to eq 'index'
|
25
|
+
expect(subject.seo_title).to eq 'seo title'
|
26
|
+
expect(subject.meta_keywords).to eq 'keywords'
|
27
|
+
expect(subject.meta_description).to eq 'description'
|
28
|
+
expect(subject.listed?).to eq true
|
29
|
+
expect(subject.redirect?).to eq false
|
30
|
+
expect(subject.is_layout?).to eq true
|
31
|
+
expect(subject.published?).to eq true
|
32
|
+
expect(subject.templatized?).to eq false
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#parent' do
|
36
|
+
|
37
|
+
let(:parent) { instance_double('ParentPage', to_liquid: { 'title' => 'Parent' }) }
|
38
|
+
|
39
|
+
before do
|
40
|
+
allow(services.repositories.page).to receive(:parent_of).with(page).and_return(parent)
|
41
|
+
end
|
42
|
+
|
43
|
+
it { expect(subject.parent).to eq({ 'title' => 'Parent' }) }
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#breadcrumbs' do
|
48
|
+
|
49
|
+
let(:ancestors) { [instance_double('ParentPage', to_liquid: { 'title' => 'Parent' })] }
|
50
|
+
|
51
|
+
before do
|
52
|
+
allow(services.repositories.page).to receive(:ancestors_of).with(page).and_return(ancestors)
|
53
|
+
end
|
54
|
+
|
55
|
+
it { expect(subject.breadcrumbs).to eq([{ 'title' => 'Parent' }]) }
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#children' do
|
60
|
+
|
61
|
+
let(:children) { [instance_double('ChildPage', to_liquid: { 'title' => 'Child' })] }
|
62
|
+
|
63
|
+
before do
|
64
|
+
allow(services.repositories.page).to receive(:children_of).with(page).and_return(children)
|
65
|
+
end
|
66
|
+
|
67
|
+
it { expect(subject.children).to eq([{ 'title' => 'Child' }]) }
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#editable_elements' do
|
72
|
+
|
73
|
+
let(:elements) { [instance_double('EditableElement', block: 'top/left', slug: 'banner', content: 'Hello world')] }
|
74
|
+
|
75
|
+
before do
|
76
|
+
allow(services.repositories.page).to receive(:editable_elements_of).with(page).and_return(elements)
|
77
|
+
end
|
78
|
+
|
79
|
+
it { expect(subject.editable_elements).to eq({ 'top' => { 'left' => { 'banner' => 'Hello world' } } }) }
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'templatized page' do
|
84
|
+
|
85
|
+
let(:entry) { liquid_instance_double('ContentEntry', _label: 'First Article', _slug: 'first-article') }
|
86
|
+
let(:assigns) { { 'entry' => entry } }
|
87
|
+
let(:page) { instance_double('Page', id: 42, title: 'Index', slug: 'index', localized_attributes: [], templatized?: true, content_type_id: 42) }
|
88
|
+
|
89
|
+
it { expect(subject.title).to eq 'First Article' }
|
90
|
+
it { expect(subject.slug).to eq 'first-article' }
|
91
|
+
|
92
|
+
describe '#content_type' do
|
93
|
+
|
94
|
+
before do
|
95
|
+
allow(services.repositories.content_type).to receive(:find).with(42).and_return('Articles')
|
96
|
+
end
|
97
|
+
|
98
|
+
it { expect(subject.content_type).not_to eq nil }
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
describe 'i18n' do
|
105
|
+
|
106
|
+
let(:page) { instance_double('Page', title: { en: 'About us', fr: 'A notre sujet' }, templatized?: false, localized_attributes: { title: true }) }
|
107
|
+
let(:drop) { described_class.new(page).tap { |d| d.context = context } }
|
108
|
+
|
109
|
+
it { expect(subject.title).to eq 'About us' }
|
110
|
+
|
111
|
+
context 'change the current locale of the context' do
|
112
|
+
|
113
|
+
let(:context) { ::Liquid::Context.new(assigns, {}, { locale: 'fr', site: site }) }
|
114
|
+
it { expect(subject.title).to eq 'A notre sujet' }
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
context 'change the locale down the road' do
|
119
|
+
|
120
|
+
before { subject.send(:_change_locale, 'fr') }
|
121
|
+
it { expect(subject.title).to eq 'A notre sujet' }
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'prevents further modifications of the locale' do
|
126
|
+
subject.send(:_change_locale!, 'fr')
|
127
|
+
expect(subject.title).to eq 'A notre sujet'
|
128
|
+
subject.send(:_change_locale, 'en')
|
129
|
+
expect(subject.title).to eq 'A notre sujet'
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Locomotive::Steam::Liquid::Drops::SessionProxy do
|
4
|
+
|
5
|
+
let(:request) { instance_double('Request', session: { answer: 42 }) }
|
6
|
+
let(:context) { ::Liquid::Context.new({}, {}, { request: request }) }
|
7
|
+
let(:drop) { described_class.new.tap { |d| d.context = context } }
|
8
|
+
|
9
|
+
subject { drop['answer'] }
|
10
|
+
|
11
|
+
it { is_expected.to eq 42 }
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Locomotive::Steam::Liquid::Drops::Site do
|
4
|
+
|
5
|
+
let(:services) { Locomotive::Steam::Services.build_instance }
|
6
|
+
let(:context) { ::Liquid::Context.new({}, {}, { services: services }) }
|
7
|
+
let(:site) { instance_double('Site', name: 'Locomotive', domains: ['acme.org'], seo_title: 'seo title', meta_keywords: 'keywords', meta_description: 'description', localized_attributes: {}) }
|
8
|
+
let(:drop) { described_class.new(site).tap { |d| d.context = context } }
|
9
|
+
|
10
|
+
subject { drop }
|
11
|
+
|
12
|
+
it 'gives access to general attributes' do
|
13
|
+
expect(subject.name).to eq 'Locomotive'
|
14
|
+
expect(subject.seo_title).to eq 'seo title'
|
15
|
+
expect(subject.meta_keywords).to eq 'keywords'
|
16
|
+
expect(subject.meta_description).to eq 'description'
|
17
|
+
expect(subject.domains).to eq ['acme.org']
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#index' do
|
21
|
+
|
22
|
+
let(:index) { instance_double('IndexPage', to_liquid: { 'title' => 'Home page' }) }
|
23
|
+
|
24
|
+
before do
|
25
|
+
allow(services.repositories.page).to receive(:root).and_return(index)
|
26
|
+
end
|
27
|
+
|
28
|
+
it { expect(subject.index).to eq({ 'title' => 'Home page' }) }
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#pages' do
|
33
|
+
|
34
|
+
let(:pages) do
|
35
|
+
[
|
36
|
+
instance_double('AboutUsPage', to_liquid: { 'title' => 'About us' }),
|
37
|
+
instance_double('ContactPage', to_liquid: { 'title' => 'Contact' })
|
38
|
+
]
|
39
|
+
end
|
40
|
+
|
41
|
+
before do
|
42
|
+
allow(services.repositories.page).to receive(:all).and_return(pages)
|
43
|
+
end
|
44
|
+
|
45
|
+
it { expect(subject.pages).to eq([{ 'title' => 'About us' }, { 'title' => 'Contact' }]) }
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,160 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Locomotive::Steam::Liquid::Filters::Date do
|
4
|
+
|
5
|
+
include Locomotive::Steam::Liquid::Filters::Date
|
6
|
+
|
7
|
+
let(:timezone) { 'Paris' }
|
8
|
+
let(:date) { Date.parse('2007/06/29') }
|
9
|
+
let(:date_time) { Time.zone.parse('2007-06-29 21:35:00') }
|
10
|
+
|
11
|
+
let(:registers) { { site: instance_double('Site', timezone: timezone) } }
|
12
|
+
let(:assigns) { { 'today' => date } }
|
13
|
+
let(:context) { instance_double('Context', assigns: assigns, registers: registers) }
|
14
|
+
|
15
|
+
before(:each) { Time.zone = timezone; @context = context }
|
16
|
+
|
17
|
+
describe '#parse_date' do
|
18
|
+
|
19
|
+
let(:format) { nil }
|
20
|
+
let(:input) { '2007-06-29' }
|
21
|
+
|
22
|
+
subject { parse_date(input, format) }
|
23
|
+
|
24
|
+
it { is_expected.to eq date }
|
25
|
+
|
26
|
+
describe 'with a specified format' do
|
27
|
+
|
28
|
+
let(:format) { '%m/%d/%Y' }
|
29
|
+
let(:input) { '06/29/2007' }
|
30
|
+
|
31
|
+
it { is_expected.to eq date }
|
32
|
+
|
33
|
+
describe 'but incorrect' do
|
34
|
+
|
35
|
+
let(:format) { '%Y-%d-%m' }
|
36
|
+
|
37
|
+
it { is_expected.to eq '' }
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#parse_date_time' do
|
46
|
+
|
47
|
+
let(:format) { nil }
|
48
|
+
let(:input) { '2007-06-29 21:35:00' }
|
49
|
+
|
50
|
+
subject { parse_date_time(input, format) }
|
51
|
+
|
52
|
+
it { is_expected.to eq date_time }
|
53
|
+
|
54
|
+
describe 'with a specified format' do
|
55
|
+
|
56
|
+
let(:format) { '%m/%d/%Y %H:%M' }
|
57
|
+
let(:input) { '06/29/2007 21:35' }
|
58
|
+
|
59
|
+
it { is_expected.to eq date_time }
|
60
|
+
|
61
|
+
describe 'but incorrect' do
|
62
|
+
|
63
|
+
let(:format) { '%Y-%d-%m %H:%M' }
|
64
|
+
|
65
|
+
it { is_expected.to eq '' }
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '#distance_of_time_in_words' do
|
74
|
+
|
75
|
+
before(:each) do
|
76
|
+
datetime = Time.zone.parse('2012/11/25 00:00:00')
|
77
|
+
allow(Time.zone).to receive(:now) { datetime }
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'prints the distance of time in words from a string' do
|
81
|
+
expect(distance_of_time_in_words('2007/06/29 00:00:00')).to eq('over 5 years')
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'prints the distance of time in words from a date' do
|
85
|
+
expect(distance_of_time_in_words(date)).to eq('over 5 years')
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'prints the distance of time in words from a time' do
|
89
|
+
expect(distance_of_time_in_words('2007/06/29 00:00:00', '2007/06/29 00:00:01', true)).to eq('less than 5 seconds')
|
90
|
+
expect(distance_of_time_in_words('2007/06/29 00:00:00', '2007/06/29 00:00:05', true)).to eq('less than 10 seconds')
|
91
|
+
expect(distance_of_time_in_words('2007/06/29 00:00:00', '2007/06/29 00:00:10', true)).to eq('less than 20 seconds')
|
92
|
+
expect(distance_of_time_in_words('2007/06/29 00:00:00', '2007/06/29 00:00:20', true)).to eq('half a minute')
|
93
|
+
expect(distance_of_time_in_words('2007/06/29 00:00:00', '2007/06/29 00:00:30', true)).to eq('half a minute')
|
94
|
+
expect(distance_of_time_in_words('2007/06/29 00:00:00', '2007/06/29 00:00:40', true)).to eq('less than a minute')
|
95
|
+
expect(distance_of_time_in_words('2007/06/29 00:00:00', '2007/06/29 00:01:00', true)).to eq('1 minute')
|
96
|
+
expect(distance_of_time_in_words('2007/06/29 00:00:00', '2007/06/29 00:00:01')).to eq('less than a minute')
|
97
|
+
expect(distance_of_time_in_words('2007/06/29 00:00:00', '2007/06/29 00:02:00')).to eq('2 minutes')
|
98
|
+
expect(distance_of_time_in_words('2007/06/29 00:00:00', '2007/06/29 00:45:00')).to eq('about 1 hour')
|
99
|
+
expect(distance_of_time_in_words('2007/06/29 00:00:00', '2007/06/29 01:32:00')).to eq('about 2 hours')
|
100
|
+
expect(distance_of_time_in_words('2007/06/29 00:00:00', '2007/06/30 00:00:00')).to eq('1 day')
|
101
|
+
expect(distance_of_time_in_words('2007/06/29 00:00:00', '2007/07/01 00:00:00')).to eq('2 days')
|
102
|
+
expect(distance_of_time_in_words('2007/06/29 00:00:00', '2007/08/01 00:00:00')).to eq('about 1 month')
|
103
|
+
expect(distance_of_time_in_words('2007/06/29 00:00:00', '2007/10/01 00:00:00')).to eq('3 months')
|
104
|
+
expect(distance_of_time_in_words('2007/06/29 00:00:00', '2008/06/29 00:00:00')).to eq('about 1 year')
|
105
|
+
expect(distance_of_time_in_words('2007/06/29 00:00:00', '2008/09/29 00:00:00')).to eq('over 1 year')
|
106
|
+
expect(distance_of_time_in_words('2007/06/29 00:00:00', '2009/03/29 00:00:00')).to eq('almost 2 years')
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'prints the distance of time in words with a different from_time variable' do
|
110
|
+
expect(distance_of_time_in_words(date, '2010/11/25 00:00:00')).to eq('over 3 years')
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
describe '#localized_date' do
|
116
|
+
|
117
|
+
it 'prints an empty string it is nil or empty' do
|
118
|
+
expect(localized_date(nil)).to eq('')
|
119
|
+
expect(localized_date('')).to eq('')
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'prints a date from a string' do
|
123
|
+
expect(localized_date('2007-06-29')).to eq('2007-06-29')
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'prints a date from a not-formated string' do
|
127
|
+
expect(localized_date('29/06/2007')).to eq('2007-06-29')
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'prints a date' do
|
131
|
+
expect(localized_date(date)).to eq('2007-06-29')
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'prints a date with a custom format' do
|
135
|
+
expect(localized_date(date, '%d/%m/%Y')).to eq('29/06/2007')
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'prints a date depending on the locale' do
|
139
|
+
I18n.locale = 'fr'
|
140
|
+
expect(localized_date(date)).to eq('29/06/2007')
|
141
|
+
I18n.locale = 'en'
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'prints a date when forcing the locale' do
|
145
|
+
expect(localized_date(date, '%A %d %B %Y', 'fr')).to eq('vendredi 29 juin 2007')
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'has an alias for the localized_date filter: format_date' do
|
149
|
+
expect(format_date(date)).to eq('2007-06-29')
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'prints a date within a template (from the documentation)' do
|
153
|
+
template = ::Liquid::Template.parse("{{ today | localized_date: '%d %B', 'fr' }}")
|
154
|
+
context = ::Liquid::Context.new({}, assigns, registers)
|
155
|
+
expect(template.render(context)).to eq('29 juin')
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
end
|
@@ -0,0 +1,263 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Locomotive::Steam::Liquid::Filters::Html do
|
4
|
+
|
5
|
+
include Locomotive::Steam::Liquid::Filters::Base
|
6
|
+
include Locomotive::Steam::Liquid::Filters::Html
|
7
|
+
|
8
|
+
let(:site) { instance_double('Site', _id: 42)}
|
9
|
+
let(:services) { Locomotive::Steam::Services.build_instance.tap { |s| s.repositories.current_site = site } }
|
10
|
+
let(:context) { instance_double('Context', registers: { services: services }) }
|
11
|
+
|
12
|
+
let(:theme_asset_url) { services.theme_asset_url }
|
13
|
+
let(:theme_asset_repository) { services.repositories.theme_asset }
|
14
|
+
|
15
|
+
before { services.repositories.theme_asset = EngineThemeAsset.new(nil, site) }
|
16
|
+
|
17
|
+
before { @context = context }
|
18
|
+
|
19
|
+
it 'writes the tag to display a rss/atom feed' do
|
20
|
+
expect(auto_discovery_link_tag('/foo/bar')).to eq %(
|
21
|
+
<link rel="alternate" type="application/rss+xml" title="RSS" href="/foo/bar" />
|
22
|
+
).strip
|
23
|
+
|
24
|
+
expect(auto_discovery_link_tag('/foo/bar', 'rel:alternate2', 'type:atom', 'title:Hello world')).to eq %(
|
25
|
+
<link rel="alternate2" type="atom" title="Hello world" href="/foo/bar" />
|
26
|
+
).strip
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'returns an url for a stylesheet file' do
|
30
|
+
result = "/sites/42/theme/stylesheets/main.css"
|
31
|
+
expect(stylesheet_url('main.css')).to eq(result)
|
32
|
+
expect(stylesheet_url('main')).to eq(result)
|
33
|
+
expect(stylesheet_url(nil)).to eq('')
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'with checksum' do
|
37
|
+
|
38
|
+
before do
|
39
|
+
Locomotive::Steam.configure { |c| c.theme_assets_checksum = true }
|
40
|
+
allow(theme_asset_repository).to receive(:checksums).and_return('stylesheets/main.css' => 42)
|
41
|
+
end
|
42
|
+
|
43
|
+
after do
|
44
|
+
Locomotive::Steam.reset
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'returns an url with the checksum' do
|
48
|
+
result = "/sites/42/theme/stylesheets/main.css?42"
|
49
|
+
expect(stylesheet_url('main.css')).to eq(result)
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'returns an url for a stylesheet file with folder' do
|
55
|
+
result = "/sites/42/theme/stylesheets/trash/main.css"
|
56
|
+
expect(stylesheet_url('trash/main.css')).to eq(result)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'returns an url for a stylesheet file without touching the url that starts with "/"' do
|
60
|
+
result = "/trash/main.css"
|
61
|
+
expect(stylesheet_url('/trash/main.css')).to eq(result)
|
62
|
+
expect(stylesheet_url('/trash/main')).to eq(result)
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'returns an url for a stylesheet file without touching the url that starts with "http:"' do
|
66
|
+
result = "http://cdn.example.com/trash/main.css"
|
67
|
+
expect(stylesheet_url('http://cdn.example.com/trash/main.css')).to eq(result)
|
68
|
+
expect(stylesheet_url('http://cdn.example.com/trash/main')).to eq(result)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'returns an url for a stylesheet file without touching the url that starts with "https:"' do
|
72
|
+
result = "https://cdn.example.com/trash/main.css"
|
73
|
+
expect(stylesheet_url('https://cdn.example.com/trash/main.css')).to eq(result)
|
74
|
+
expect(stylesheet_url('https://cdn.example.com/trash/main')).to eq(result)
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'returns an url for a stylesheet file with respect to URL-parameters' do
|
78
|
+
result = "/sites/42/theme/stylesheets/main.css?v=42"
|
79
|
+
expect(stylesheet_url('main.css?v=42')).to eq(result)
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'returns a link tag for a stylesheet file' do
|
83
|
+
result = "<link href=\"/sites/42/theme/stylesheets/main.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />"
|
84
|
+
expect(stylesheet_tag('main.css')).to eq(result)
|
85
|
+
expect(stylesheet_tag('main')).to eq(result)
|
86
|
+
expect(stylesheet_tag(nil)).to eq('')
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'returns a link tag for a stylesheet file with folder' do
|
90
|
+
result = "<link href=\"/sites/42/theme/stylesheets/trash/main.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />"
|
91
|
+
expect(stylesheet_tag('trash/main.css')).to eq(result)
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'returns a link tag for a stylesheet file without touching the url that starts with "/"' do
|
95
|
+
result = "<link href=\"/trash/main.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />"
|
96
|
+
expect(stylesheet_tag('/trash/main.css')).to eq(result)
|
97
|
+
expect(stylesheet_tag('/trash/main')).to eq(result)
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'returns a link tag for a stylesheet file without touching the url that starts with "http:"' do
|
101
|
+
result = "<link href=\"http://cdn.example.com/trash/main.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />"
|
102
|
+
expect(stylesheet_tag('http://cdn.example.com/trash/main.css')).to eq(result)
|
103
|
+
expect(stylesheet_tag('http://cdn.example.com/trash/main')).to eq(result)
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'returns a link tag for a stylesheet file without touching the url that starts with "https:"' do
|
107
|
+
result = "<link href=\"https://cdn.example.com/trash/main.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />"
|
108
|
+
expect(stylesheet_tag('https://cdn.example.com/trash/main.css')).to eq(result)
|
109
|
+
expect(stylesheet_tag('https://cdn.example.com/trash/main')).to eq(result)
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'returns a link tag for a stylesheet stored in Amazon S3' do
|
113
|
+
url = 'https://com.citrrus.locomotive.s3.amazonaws.com/sites/42/theme/stylesheets/bootstrap2.css'
|
114
|
+
allow(theme_asset_url).to receive(:build).and_return(url)
|
115
|
+
result = "<link href=\"#{url}\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />"
|
116
|
+
expect(stylesheet_tag('bootstrap2.css')).to eq(result)
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'returns a link tag for a stylesheet file and media attribute set to print' do
|
120
|
+
result = "<link href=\"/sites/42/theme/stylesheets/main.css\" media=\"print\" rel=\"stylesheet\" type=\"text/css\" />"
|
121
|
+
expect(stylesheet_tag('main.css','print')).to eq(result)
|
122
|
+
expect(stylesheet_tag('main','print')).to eq(result)
|
123
|
+
expect(stylesheet_tag(nil)).to eq('')
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'returns a link tag for a stylesheet file with folder and media attribute set to print' do
|
127
|
+
result = "<link href=\"/sites/42/theme/stylesheets/trash/main.css\" media=\"print\" rel=\"stylesheet\" type=\"text/css\" />"
|
128
|
+
expect(stylesheet_tag('trash/main.css','print')).to eq(result)
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'returns a link tag for a stylesheet file without touching the url that starts with "/" and media attribute set to print' do
|
132
|
+
result = "<link href=\"/trash/main.css\" media=\"print\" rel=\"stylesheet\" type=\"text/css\" />"
|
133
|
+
expect(stylesheet_tag('/trash/main.css','print')).to eq(result)
|
134
|
+
expect(stylesheet_tag('/trash/main','print')).to eq(result)
|
135
|
+
end
|
136
|
+
|
137
|
+
it 'returns a link tag for a stylesheet file without touching the url that starts with "http:" and media attribute set to print' do
|
138
|
+
result = "<link href=\"http://cdn.example.com/trash/main.css\" media=\"print\" rel=\"stylesheet\" type=\"text/css\" />"
|
139
|
+
expect(stylesheet_tag('http://cdn.example.com/trash/main.css','print')).to eq(result)
|
140
|
+
expect(stylesheet_tag('http://cdn.example.com/trash/main','print')).to eq(result)
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'returns a link tag for a stylesheet file without touching the url that starts with "https:" and media attribute set to print' do
|
144
|
+
result = "<link href=\"https://cdn.example.com/trash/main.css\" media=\"print\" rel=\"stylesheet\" type=\"text/css\" />"
|
145
|
+
expect(stylesheet_tag('https://cdn.example.com/trash/main.css','print')).to eq(result)
|
146
|
+
expect(stylesheet_tag('https://cdn.example.com/trash/main','print')).to eq(result)
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'returns an url for a javascript file' do
|
150
|
+
result = "/sites/42/theme/javascripts/main.js"
|
151
|
+
expect(javascript_url('main.js')).to eq(result)
|
152
|
+
expect(javascript_url('main')).to eq(result)
|
153
|
+
expect(javascript_url(nil)).to eq('')
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'returns an url for a javascript file with folder' do
|
157
|
+
result = "/sites/42/theme/javascripts/trash/main.js"
|
158
|
+
expect(javascript_url('trash/main.js')).to eq(result)
|
159
|
+
expect(javascript_url('trash/main')).to eq(result)
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'returns an url for a javascript file without touching the url that starts with "/"' do
|
163
|
+
result = "/trash/main.js"
|
164
|
+
expect(javascript_url('/trash/main.js')).to eq(result)
|
165
|
+
expect(javascript_url('/trash/main')).to eq(result)
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'returns an url for a javascript file without touching the url that starts with "http:"' do
|
169
|
+
result = "http://cdn.example.com/trash/main.js"
|
170
|
+
expect(javascript_url('http://cdn.example.com/trash/main.js')).to eq(result)
|
171
|
+
expect(javascript_url('http://cdn.example.com/trash/main')).to eq(result)
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'returns an url for a javascript file without touching the url that starts with "https:"' do
|
175
|
+
result = "https://cdn.example.com/trash/main.js"
|
176
|
+
expect(javascript_url('https://cdn.example.com/trash/main.js')).to eq(result)
|
177
|
+
expect(javascript_url('https://cdn.example.com/trash/main')).to eq(result)
|
178
|
+
end
|
179
|
+
|
180
|
+
it 'returns an url for a javascript file with respect to URL-parameters' do
|
181
|
+
result = "/sites/42/theme/javascripts/main.js?v=42"
|
182
|
+
expect(javascript_url('main.js?v=42')).to eq(result)
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'returns a script tag for a javascript file' do
|
186
|
+
result = %{<script src="/sites/42/theme/javascripts/main.js" type="text/javascript" ></script>}
|
187
|
+
expect(javascript_tag('main.js')).to eq(result)
|
188
|
+
expect(javascript_tag('main')).to eq(result)
|
189
|
+
expect(javascript_tag(nil)).to eq('')
|
190
|
+
end
|
191
|
+
|
192
|
+
it 'returns a script tag for a javascript file with folder' do
|
193
|
+
result = %{<script src="/sites/42/theme/javascripts/trash/main.js" type="text/javascript" ></script>}
|
194
|
+
expect(javascript_tag('trash/main.js')).to eq(result)
|
195
|
+
expect(javascript_tag('trash/main')).to eq(result)
|
196
|
+
end
|
197
|
+
|
198
|
+
it 'returns a script tag for a javascript file without touching the url that starts with "/"' do
|
199
|
+
result = %{<script src="/trash/main.js" type="text/javascript" ></script>}
|
200
|
+
expect(javascript_tag('/trash/main.js')).to eq(result)
|
201
|
+
expect(javascript_tag('/trash/main')).to eq(result)
|
202
|
+
end
|
203
|
+
|
204
|
+
it 'returns a script tag for a javascript file without touching the url that starts with "http:"' do
|
205
|
+
result = %{<script src="http://cdn.example.com/trash/main.js" type="text/javascript" ></script>}
|
206
|
+
expect(javascript_tag('http://cdn.example.com/trash/main.js')).to eq(result)
|
207
|
+
expect(javascript_tag('http://cdn.example.com/trash/main')).to eq(result)
|
208
|
+
end
|
209
|
+
|
210
|
+
it 'returns a script tag for a javascript file without touching the url that starts with "https:"' do
|
211
|
+
result = %{<script src="https://cdn.example.com/trash/main.js" type="text/javascript" ></script>}
|
212
|
+
expect(javascript_tag('https://cdn.example.com/trash/main.js')).to eq(result)
|
213
|
+
expect(javascript_tag('https://cdn.example.com/trash/main')).to eq(result)
|
214
|
+
end
|
215
|
+
|
216
|
+
it 'returns a script tag for a javascript file with "defer" option' do
|
217
|
+
result = %{<script src="https://cdn.example.com/trash/main.js" type="text/javascript" defer="defer" ></script>}
|
218
|
+
expect(javascript_tag('https://cdn.example.com/trash/main.js', ['defer:defer'])).to eq(result)
|
219
|
+
end
|
220
|
+
|
221
|
+
it 'returns an image tag for a given theme file without parameters' do
|
222
|
+
expect(theme_image_tag('foo.jpg')).to eq("<img src=\"/sites/42/theme/images/foo.jpg\" >")
|
223
|
+
end
|
224
|
+
|
225
|
+
it 'returns an image tag for a given theme file with size' do
|
226
|
+
expect(theme_image_tag('foo.jpg', 'width:100', 'height:100')).to eq("<img src=\"/sites/42/theme/images/foo.jpg\" height=\"100\" width=\"100\" >")
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'returns an image tag without parameters' do
|
230
|
+
expect(image_tag('foo.jpg')).to eq("<img src=\"foo.jpg\" >")
|
231
|
+
end
|
232
|
+
|
233
|
+
it 'returns an image tag with size' do
|
234
|
+
expect(image_tag('foo.jpg', 'width:100', 'height:50')).to eq("<img src=\"foo.jpg\" height=\"50\" width=\"100\" >")
|
235
|
+
end
|
236
|
+
|
237
|
+
it 'returns a flash tag without parameters' do
|
238
|
+
expect(flash_tag('foo.flv')).to eq(%{
|
239
|
+
<object>
|
240
|
+
<param name="movie" value="foo.flv">
|
241
|
+
<embed src="foo.flv">
|
242
|
+
</embed>
|
243
|
+
</object>
|
244
|
+
}.strip)
|
245
|
+
end
|
246
|
+
|
247
|
+
it 'returns a flash tag with size' do
|
248
|
+
expect(flash_tag('foo.flv', 'width:100', 'height:50')).to eq(%{
|
249
|
+
<object height=\"50\" width=\"100\">
|
250
|
+
<param name="movie" value="foo.flv">
|
251
|
+
<embed src="foo.flv" height=\"50\" width=\"100\">
|
252
|
+
</embed>
|
253
|
+
</object>
|
254
|
+
}.strip)
|
255
|
+
end
|
256
|
+
|
257
|
+
class EngineThemeAsset < Locomotive::Steam::ThemeAssetRepository
|
258
|
+
def url_for(path)
|
259
|
+
['', 'sites', site._id.to_s, 'theme', path].join('/')
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
end
|