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
@@ -24,19 +24,20 @@ module Locomotive
|
|
24
24
|
|
25
25
|
# map/collect on a given property (support to_f, to_i)
|
26
26
|
def map(input, property)
|
27
|
-
|
27
|
+
::Liquid::StandardFilters::InputIterator.new(input).map do |e|
|
28
28
|
e = e.call if e.is_a?(Proc)
|
29
29
|
|
30
|
-
if property == "to_liquid"
|
30
|
+
if property == "to_liquid".freeze
|
31
31
|
e
|
32
|
-
elsif property ==
|
32
|
+
elsif property == 'to_f'.freeze
|
33
33
|
e.to_f
|
34
|
-
elsif property ==
|
34
|
+
elsif property == 'to_i'.freeze
|
35
35
|
e.to_i
|
36
36
|
elsif e.respond_to?(:[])
|
37
37
|
e[property]
|
38
38
|
end
|
39
39
|
end
|
40
|
+
|
40
41
|
end
|
41
42
|
|
42
43
|
end
|
@@ -46,4 +47,4 @@ module Locomotive
|
|
46
47
|
end
|
47
48
|
end
|
48
49
|
end
|
49
|
-
end
|
50
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Locomotive
|
2
|
+
module Steam
|
3
|
+
module Liquid
|
4
|
+
module Filters
|
5
|
+
module Pagination
|
6
|
+
|
7
|
+
# Render the navigation for a paginated collection
|
8
|
+
def default_pagination(paginate, *args)
|
9
|
+
return '' if paginate['parts'].empty?
|
10
|
+
|
11
|
+
options = args_to_options(args)
|
12
|
+
|
13
|
+
previous_link = default_pagination_next_or_previous_link(:previous, paginate, options, 'prev')
|
14
|
+
next_link = default_pagination_next_or_previous_link(:next, paginate, options, 'next')
|
15
|
+
links = default_pagination_links(paginate)
|
16
|
+
|
17
|
+
%{<div class="pagination #{options[:css]}">
|
18
|
+
#{previous_link}
|
19
|
+
#{links}
|
20
|
+
#{next_link}
|
21
|
+
</div>}
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def default_pagination_links(paginate)
|
27
|
+
paginate['parts'].map do |part|
|
28
|
+
if part['is_link']
|
29
|
+
"<a href=\"#{absolute_url(part['url'])}\">#{part['title']}</a>"
|
30
|
+
elsif part['hellip_break']
|
31
|
+
"<span class=\"gap\">#{part['title']}</span>"
|
32
|
+
else
|
33
|
+
"<span class=\"current\">#{part['title']}</span>"
|
34
|
+
end
|
35
|
+
end.join
|
36
|
+
end
|
37
|
+
|
38
|
+
def default_pagination_next_or_previous_link(type, paginate, options, css)
|
39
|
+
label = options[:"#{type}_label"] || I18n.t("pagination.#{type}")
|
40
|
+
|
41
|
+
if paginate[type.to_s].blank?
|
42
|
+
"<span class=\"disabled #{css}_page\">#{label}</span>"
|
43
|
+
else
|
44
|
+
"<a href=\"#{absolute_url(paginate[type.to_s]['url'])}\" class=\"#{css}_page\">#{label}</a>"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
::Liquid::Template.register_filter(Pagination)
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -5,8 +5,7 @@ module Locomotive
|
|
5
5
|
module Resize
|
6
6
|
|
7
7
|
def resize(input, resize_string)
|
8
|
-
|
9
|
-
dragonfly.resize_url(input, resize_string)
|
8
|
+
@context.registers[:services].image_resizer.resize(input, resize_string) || input
|
10
9
|
end
|
11
10
|
|
12
11
|
end
|
@@ -16,4 +15,4 @@ module Locomotive
|
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
19
|
-
end
|
18
|
+
end
|
@@ -4,16 +4,6 @@ module Locomotive
|
|
4
4
|
module Filters
|
5
5
|
module Text
|
6
6
|
|
7
|
-
# right justify and padd a string
|
8
|
-
def rjust(input, integer, padstr = '')
|
9
|
-
input.to_s.rjust(integer, padstr)
|
10
|
-
end
|
11
|
-
|
12
|
-
# left justify and padd a string
|
13
|
-
def ljust(input, integer, padstr = '')
|
14
|
-
input.to_s.ljust(integer, padstr)
|
15
|
-
end
|
16
|
-
|
17
7
|
def underscore(input)
|
18
8
|
input.to_s.gsub(' ', '_').gsub('/', '_').underscore
|
19
9
|
end
|
@@ -22,6 +12,10 @@ module Locomotive
|
|
22
12
|
input.to_s.gsub(' ', '-').gsub('/', '-').dasherize
|
23
13
|
end
|
24
14
|
|
15
|
+
def encode(input)
|
16
|
+
Rack::Utils.escape(input)
|
17
|
+
end
|
18
|
+
|
25
19
|
# alias newline_to_br
|
26
20
|
def multi_line(input)
|
27
21
|
input.to_s.gsub("\n", '<br/>')
|
@@ -33,16 +27,22 @@ module Locomotive
|
|
33
27
|
result
|
34
28
|
end
|
35
29
|
|
36
|
-
|
37
|
-
|
30
|
+
# right justify and padd a string
|
31
|
+
def rjust(input, integer, padstr = '')
|
32
|
+
input.to_s.rjust(integer, padstr)
|
33
|
+
end
|
34
|
+
|
35
|
+
# left justify and padd a string
|
36
|
+
def ljust(input, integer, padstr = '')
|
37
|
+
input.to_s.ljust(integer, padstr)
|
38
38
|
end
|
39
39
|
|
40
40
|
def textile(input)
|
41
|
-
|
41
|
+
@context.registers[:services].textile.to_html(input)
|
42
42
|
end
|
43
43
|
|
44
44
|
def markdown(input)
|
45
|
-
|
45
|
+
@context.registers[:services].markdown.to_html(input)
|
46
46
|
end
|
47
47
|
|
48
48
|
end
|
@@ -52,4 +52,4 @@ module Locomotive
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
55
|
-
end
|
55
|
+
end
|
@@ -2,22 +2,13 @@ module Locomotive
|
|
2
2
|
module Steam
|
3
3
|
module Liquid
|
4
4
|
module Filters
|
5
|
-
module Translate
|
6
5
|
|
7
|
-
|
8
|
-
locale ||= I18n.locale.to_s
|
9
|
-
if scope.blank?
|
10
|
-
translation = @context.registers[:mounting_point].translations[key.to_s]
|
6
|
+
module Translate
|
11
7
|
|
12
|
-
|
13
|
-
|
14
|
-
else
|
15
|
-
"[unknown translation key: #{key}]"
|
16
|
-
end
|
17
|
-
else
|
18
|
-
I18n.t(key, scope: scope.split('.'), locale: locale)
|
19
|
-
end
|
8
|
+
def translate(input, locale = nil, scope = nil)
|
9
|
+
@context.registers[:services].translator.translate(input, locale, scope) || input
|
20
10
|
end
|
11
|
+
|
21
12
|
end
|
22
13
|
|
23
14
|
::Liquid::Template.register_filter(Translate)
|
@@ -25,4 +16,4 @@ module Locomotive
|
|
25
16
|
end
|
26
17
|
end
|
27
18
|
end
|
28
|
-
end
|
19
|
+
end
|
@@ -1,31 +1,10 @@
|
|
1
1
|
module Liquid
|
2
|
-
|
3
|
-
class Drop
|
4
|
-
|
5
|
-
def site
|
6
|
-
@context.registers[:site]
|
7
|
-
end
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
class Template
|
12
|
-
|
13
|
-
# creates a new <tt>Template</tt> object from liquid source code
|
14
|
-
parse_method = instance_method(:parse)
|
15
|
-
|
16
|
-
define_method :parse do |source, context={}|
|
17
|
-
if RUBY_VERSION =~ /1\.9/
|
18
|
-
source = source.force_encoding('UTF-8') if source.present?
|
19
|
-
end
|
20
|
-
parse_method.bind(self).call(source, context)
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
2
|
module StandardFilters
|
26
3
|
|
27
4
|
private
|
28
5
|
|
6
|
+
# Fixme: Handle DateTime, Date and Time objects, convert them
|
7
|
+
# into seconds (integer)
|
29
8
|
def to_number(obj)
|
30
9
|
case obj
|
31
10
|
when Numeric
|
@@ -38,6 +17,33 @@ module Liquid
|
|
38
17
|
0
|
39
18
|
end
|
40
19
|
end
|
20
|
+
|
41
21
|
end
|
22
|
+
end
|
42
23
|
|
24
|
+
module Liquid
|
25
|
+
module OptionsBuilder
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def parse_options_from_string(string)
|
30
|
+
string.try(:strip!)
|
31
|
+
|
32
|
+
return nil if string.blank?
|
33
|
+
|
34
|
+
string = string.gsub(/^(\s*,)/, '')
|
35
|
+
Solid::Arguments.parse(string)
|
36
|
+
end
|
37
|
+
|
38
|
+
def interpolate_options(options, context)
|
39
|
+
if options
|
40
|
+
options.interpolate(context).first
|
41
|
+
else
|
42
|
+
{}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
43
47
|
end
|
48
|
+
|
49
|
+
Liquid::Tag.send(:include, Liquid::OptionsBuilder)
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Locomotive
|
2
|
+
module Steam
|
3
|
+
module Liquid
|
4
|
+
module Tags
|
5
|
+
module Concerns
|
6
|
+
|
7
|
+
module I18nPage
|
8
|
+
|
9
|
+
def change_page_locale(locale, drop, &block)
|
10
|
+
page = drop.send(:_source)
|
11
|
+
|
12
|
+
page.__with_locale__(locale) do
|
13
|
+
if page.templatized?
|
14
|
+
page.content_entry.__with_locale__(locale) { yield }
|
15
|
+
else
|
16
|
+
yield
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# def build_fullpath(page)
|
22
|
+
# services.url_builder.url_for(page, locale).tap do |fullpath|
|
23
|
+
# if page.templatized?
|
24
|
+
# entry = page.send(:_source).content_entry
|
25
|
+
# fullpath.gsub!('content_type_template', entry._slug)
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
# end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
module Locomotive
|
2
|
+
module Steam
|
3
|
+
module Liquid
|
4
|
+
module Tags
|
5
|
+
module Concerns
|
6
|
+
module Path
|
7
|
+
|
8
|
+
Syntax = /(#{::Liquid::VariableSignature}+)(\s*,.+)?/o
|
9
|
+
|
10
|
+
def initialize(tag_name, markup, options)
|
11
|
+
if markup =~ Syntax
|
12
|
+
@handle, _options = $1, $2
|
13
|
+
|
14
|
+
# FIXME: the with option needs a string with quotes.
|
15
|
+
# this is a hack for sites which don't follow the new syntax.
|
16
|
+
make_options_compatible_with_previous_version(_options)
|
17
|
+
|
18
|
+
@raw_path_options = parse_options_from_string(_options)
|
19
|
+
else
|
20
|
+
self.wrong_syntax!
|
21
|
+
end
|
22
|
+
|
23
|
+
super
|
24
|
+
end
|
25
|
+
|
26
|
+
def render_path(context, &block)
|
27
|
+
set_vars_from_context(context)
|
28
|
+
|
29
|
+
# return a drop or model?
|
30
|
+
if page = self.retrieve_page_drop_from_handle
|
31
|
+
# make sure we've got the page/content entry (if templatized)
|
32
|
+
# in the right locale
|
33
|
+
change_page_locale(locale, page) do
|
34
|
+
path = build_fullpath(page)
|
35
|
+
|
36
|
+
block_given? ? block.call(page, path) : path
|
37
|
+
end
|
38
|
+
else
|
39
|
+
'' # no page found
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
protected
|
44
|
+
|
45
|
+
def services
|
46
|
+
@context.registers[:services]
|
47
|
+
end
|
48
|
+
|
49
|
+
def repository
|
50
|
+
services.repositories.page
|
51
|
+
end
|
52
|
+
|
53
|
+
def retrieve_page_drop_from_handle
|
54
|
+
handle = @context[@handle] || @handle
|
55
|
+
|
56
|
+
case handle
|
57
|
+
when String
|
58
|
+
_retrieve_page_drop_from(handle)
|
59
|
+
when Locomotive::Steam::Liquid::Drops::ContentEntry
|
60
|
+
_retrieve_templatized_page_drop_from(handle)
|
61
|
+
when Locomotive::Steam::Liquid::Drops::Page
|
62
|
+
handle
|
63
|
+
else
|
64
|
+
nil
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def _retrieve_page_drop_from(handle)
|
69
|
+
if page = repository.by_handle(handle)
|
70
|
+
page.to_liquid.tap { |d| d.context = @context }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def _retrieve_templatized_page_drop_from(drop)
|
75
|
+
entry = drop.send(:_source)
|
76
|
+
|
77
|
+
if page = repository.template_for(entry, @path_options[:with])
|
78
|
+
page.to_liquid.tap { |d| d.context = @context }
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def build_fullpath(page)
|
83
|
+
services.url_builder.url_for(page.send(:_source), locale)
|
84
|
+
end
|
85
|
+
|
86
|
+
def locale
|
87
|
+
@path_options[:locale] || @locale
|
88
|
+
end
|
89
|
+
|
90
|
+
def set_vars_from_context(context)
|
91
|
+
@context = context
|
92
|
+
@path_options = evaluate_path_options(context)
|
93
|
+
@site = context.registers[:site]
|
94
|
+
@locale = context.registers[:locale]
|
95
|
+
end
|
96
|
+
|
97
|
+
def evaluate_path_options(context)
|
98
|
+
interpolate_options(@raw_path_options, context)
|
99
|
+
end
|
100
|
+
|
101
|
+
def make_options_compatible_with_previous_version(options)
|
102
|
+
if options
|
103
|
+
%w(with locale).each do |name|
|
104
|
+
options.gsub!(/#{name}: ([\w-]+)/, name + ': "\1"')
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -1,12 +1,13 @@
|
|
1
1
|
module Locomotive
|
2
2
|
module Steam
|
3
3
|
module Liquid
|
4
|
-
|
4
|
+
module Tags
|
5
|
+
|
5
6
|
# Consume web services as easy as pie directly in liquid !
|
6
7
|
#
|
7
8
|
# Usage:
|
8
9
|
#
|
9
|
-
# {% consume blog from 'http://nocoffee.tumblr.com/api/read.json?num=3'
|
10
|
+
# {% consume blog from 'http://nocoffee.tumblr.com/api/read.json?num=3' username: 'john', password: 'easy', format: 'json', expires_in: 3000 %}
|
10
11
|
# {% for post in blog.posts %}
|
11
12
|
# {{ post.title }}
|
12
13
|
# {% endfor %}
|
@@ -14,28 +15,29 @@ module Locomotive
|
|
14
15
|
#
|
15
16
|
class Consume < ::Liquid::Block
|
16
17
|
|
17
|
-
Syntax = /(#{::Liquid::VariableSignature}+)\s*from\s*(#{::Liquid::QuotedString}|#{::Liquid::VariableSignature}+)
|
18
|
+
Syntax = /(#{::Liquid::VariableSignature}+)\s*from\s*(#{::Liquid::QuotedString}|#{::Liquid::VariableSignature}+)(.*)?/o
|
18
19
|
|
19
|
-
def initialize(tag_name, markup,
|
20
|
+
def initialize(tag_name, markup, options)
|
20
21
|
if markup =~ Syntax
|
21
|
-
@
|
22
|
+
@name = $1.to_s
|
22
23
|
|
23
24
|
self.prepare_url($2)
|
24
|
-
|
25
|
+
@api_options = parse_options_from_string($3)
|
25
26
|
else
|
26
|
-
raise ::Liquid::SyntaxError.new(
|
27
|
+
raise ::Liquid::SyntaxError.new("Syntax Error in 'consume' - Valid syntax: consume <var> from \"<url>\" [username: value, password: value]")
|
27
28
|
end
|
28
29
|
|
29
|
-
@local_cache_key = self.hash
|
30
|
-
|
31
30
|
super
|
32
31
|
end
|
33
32
|
|
34
33
|
def render(context)
|
34
|
+
self.set_api_options(context)
|
35
|
+
|
35
36
|
if instance_variable_defined? :@variable_name
|
36
37
|
@url = context[@variable_name]
|
37
38
|
end
|
38
|
-
|
39
|
+
|
40
|
+
render_all_and_cache_it(context)
|
39
41
|
end
|
40
42
|
|
41
43
|
protected
|
@@ -43,60 +45,54 @@ module Locomotive
|
|
43
45
|
def prepare_url(token)
|
44
46
|
if token.match(::Liquid::QuotedString)
|
45
47
|
@url = token.gsub(/['"]/, '')
|
46
|
-
elsif token.match(::Liquid::VariableSignature)
|
47
|
-
@variable_name = token
|
48
48
|
else
|
49
|
-
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def prepare_options(markup)
|
54
|
-
@options = {}
|
55
|
-
markup.scan(::Liquid::TagAttributes) do |key, value|
|
56
|
-
@options[key] = value if key != 'http'
|
49
|
+
@variable_name = token
|
57
50
|
end
|
58
|
-
@options['timeout'] = @options['timeout'].to_f if @options['timeout']
|
59
|
-
@expires_in = (@options.delete('expires_in') || 0).to_i
|
60
51
|
end
|
61
52
|
|
62
|
-
def
|
63
|
-
|
64
|
-
|
53
|
+
def set_api_options(context)
|
54
|
+
@api_options = interpolate_options(@api_options, context)
|
55
|
+
@expires_in = @api_options.delete(:expires_in) || 0
|
65
56
|
end
|
66
57
|
|
67
|
-
def
|
68
|
-
|
69
|
-
|
58
|
+
def render_all_and_cache_it(context)
|
59
|
+
cache_service(context).fetch(page_fragment_cache_key, expires_in: @expires_in, force: @expires_in == 0) do
|
60
|
+
self.render_all_without_cache(context)
|
61
|
+
end
|
70
62
|
end
|
71
63
|
|
72
64
|
def render_all_without_cache(context)
|
73
65
|
context.stack do
|
74
66
|
begin
|
75
|
-
context.scopes.last[@
|
76
|
-
|
77
|
-
self.cached_response = context.scopes.last[@target.to_s]
|
67
|
+
context.scopes.last[@name] = service(context).consume(@url, @api_options)
|
78
68
|
rescue Timeout::Error
|
79
|
-
context.scopes.last[@
|
80
|
-
rescue ::Liquid::Error => e
|
81
|
-
raise e
|
82
|
-
rescue => e
|
83
|
-
liquid_e = ::Liquid::Error.new(e.message, line)
|
84
|
-
liquid_e.set_backtrace(e.backtrace)
|
85
|
-
raise liquid_e
|
69
|
+
context.scopes.last[@name] = last_response(context)
|
86
70
|
end
|
87
71
|
|
88
|
-
|
72
|
+
@body.render(context)
|
89
73
|
end
|
90
74
|
end
|
91
75
|
|
92
|
-
def
|
93
|
-
context.registers[:services]
|
76
|
+
def service(context)
|
77
|
+
context.registers[:services].external_api
|
78
|
+
end
|
79
|
+
|
80
|
+
def cache_service(context)
|
81
|
+
context.registers[:services].cache
|
82
|
+
end
|
83
|
+
|
84
|
+
def last_response(context)
|
85
|
+
cache_service(context).read(page_fragment_cache_key)
|
86
|
+
end
|
87
|
+
|
88
|
+
def page_fragment_cache_key
|
89
|
+
Digest::SHA1.hexdigest(@name + @url)
|
94
90
|
end
|
95
91
|
|
96
92
|
end
|
97
93
|
|
98
|
-
::Liquid::Template.register_tag('consume', Consume)
|
94
|
+
::Liquid::Template.register_tag('consume'.freeze, Consume)
|
99
95
|
end
|
100
96
|
end
|
101
97
|
end
|
102
|
-
end
|
98
|
+
end
|