locomotivecms_steam 1.5.0.rc0 → 1.5.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/Gemfile +3 -6
- data/Gemfile.lock +39 -39
- data/README.md +2 -2
- data/lib/locomotive/steam/adapters/filesystem/sanitizers/section.rb +62 -16
- data/lib/locomotive/steam/adapters/filesystem/sanitizers/site.rb +15 -1
- data/lib/locomotive/steam/adapters/filesystem/yaml_loader.rb +30 -9
- data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/content_entry.rb +1 -1
- data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/page.rb +1 -1
- data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/section.rb +14 -2
- data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/site.rb +1 -1
- data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/translation.rb +1 -1
- data/lib/locomotive/steam/adapters/mongodb.rb +1 -1
- data/lib/locomotive/steam/entities/content_entry.rb +0 -1
- data/lib/locomotive/steam/entities/site.rb +4 -0
- data/lib/locomotive/steam/errors.rb +54 -18
- data/lib/locomotive/steam/liquid/drops/content_entry.rb +1 -1
- data/lib/locomotive/steam/liquid/drops/content_entry_collection.rb +1 -1
- data/lib/locomotive/steam/liquid/drops/content_types.rb +1 -1
- data/lib/locomotive/steam/liquid/drops/inherited_block.rb +28 -0
- data/lib/locomotive/steam/liquid/drops/metafields.rb +2 -2
- data/lib/locomotive/steam/liquid/drops/params.rb +1 -1
- data/lib/locomotive/steam/liquid/drops/section.rb +10 -2
- data/lib/locomotive/steam/liquid/drops/section_content_proxy.rb +13 -2
- data/lib/locomotive/steam/liquid/drops/section_editor_setting_data.rb +1 -1
- data/lib/locomotive/steam/liquid/drops/session_proxy.rb +1 -1
- data/lib/locomotive/steam/liquid/file_system.rb +46 -0
- data/lib/locomotive/steam/liquid/filters/array.rb +61 -0
- data/lib/locomotive/steam/liquid/filters/misc.rb +12 -2
- data/lib/locomotive/steam/liquid/filters/number.rb +13 -12
- data/lib/locomotive/steam/liquid/filters/text.rb +4 -0
- data/lib/locomotive/steam/liquid/patches.rb +58 -19
- data/lib/locomotive/steam/liquid/tags/alt_page_links.rb +9 -5
- data/lib/locomotive/steam/liquid/tags/concerns/attributes.rb +47 -0
- data/lib/locomotive/steam/liquid/tags/concerns/path.rb +18 -31
- data/lib/locomotive/steam/liquid/tags/concerns/section.rb +22 -11
- data/lib/locomotive/steam/liquid/tags/consume.rb +26 -33
- data/lib/locomotive/steam/liquid/tags/csrf.rb +2 -2
- data/lib/locomotive/steam/liquid/tags/editable/base.rb +30 -20
- data/lib/locomotive/steam/liquid/tags/editable/control.rb +2 -2
- data/lib/locomotive/steam/liquid/tags/editable/file.rb +11 -11
- data/lib/locomotive/steam/liquid/tags/editable/text.rb +5 -5
- data/lib/locomotive/steam/liquid/tags/extends.rb +56 -8
- data/lib/locomotive/steam/liquid/tags/global_section.rb +6 -6
- data/lib/locomotive/steam/liquid/tags/google_analytics.rb +16 -6
- data/lib/locomotive/steam/liquid/tags/hybrid.rb +8 -4
- data/lib/locomotive/steam/liquid/tags/inherited_block.rb +90 -13
- data/lib/locomotive/steam/liquid/tags/inline_editor.rb +4 -4
- data/lib/locomotive/steam/liquid/tags/link_to.rb +2 -1
- data/lib/locomotive/steam/liquid/tags/locale_switcher.rb +25 -21
- data/lib/locomotive/steam/liquid/tags/model_form.rb +38 -17
- data/lib/locomotive/steam/liquid/tags/nav.rb +4 -4
- data/lib/locomotive/steam/liquid/tags/page_not_found.rb +19 -0
- data/lib/locomotive/steam/liquid/tags/paginate.rb +13 -7
- data/lib/locomotive/steam/liquid/tags/path_to.rb +1 -0
- data/lib/locomotive/steam/liquid/tags/redirect_to.rb +34 -0
- data/lib/locomotive/steam/liquid/tags/section.rb +34 -33
- data/lib/locomotive/steam/liquid/tags/sections_dropzone.rb +1 -1
- data/lib/locomotive/steam/liquid/tags/seo.rb +2 -4
- data/lib/locomotive/steam/liquid/tags/session_assign.rb +1 -0
- data/lib/locomotive/steam/liquid/tags/snippet.rb +21 -29
- data/lib/locomotive/steam/liquid/tags/with_scope.rb +61 -27
- data/lib/locomotive/steam/liquid.rb +3 -1
- data/lib/locomotive/steam/middlewares/cache.rb +117 -0
- data/lib/locomotive/steam/middlewares/concerns/helpers.rb +22 -8
- data/lib/locomotive/steam/middlewares/concerns/liquid_context.rb +5 -1
- data/lib/locomotive/steam/middlewares/concerns/rendering.rb +53 -0
- data/lib/locomotive/steam/middlewares/impersonated_entry.rb +4 -0
- data/lib/locomotive/steam/middlewares/locale.rb +2 -2
- data/lib/locomotive/steam/middlewares/locale_redirection.rb +1 -1
- data/lib/locomotive/steam/middlewares/logging.rb +1 -0
- data/lib/locomotive/steam/middlewares/page_not_found.rb +37 -0
- data/lib/locomotive/steam/middlewares/redirection.rb +1 -1
- data/lib/locomotive/steam/middlewares/renderer.rb +4 -26
- data/lib/locomotive/steam/middlewares/thread_safe.rb +0 -4
- data/lib/locomotive/steam/models/pager.rb +1 -0
- data/lib/locomotive/steam/server.rb +3 -1
- data/lib/locomotive/steam/services/action_service.rb +5 -0
- data/lib/locomotive/steam/services/auth_service.rb +9 -9
- data/lib/locomotive/steam/services/cookie_service.rb +1 -0
- data/lib/locomotive/steam/services/external_api_service.rb +5 -0
- data/lib/locomotive/steam/services/liquid_parser_service.rb +4 -2
- data/lib/locomotive/steam/services/page_finder_service.rb +1 -1
- data/lib/locomotive/steam/services/recaptcha_service.rb +4 -2
- data/lib/locomotive/steam/version.rb +1 -1
- data/lib/locomotive/steam.rb +5 -1
- data/locomotivecms_steam.gemspec +4 -4
- data/spec/fixtures/default/app/views/pages/basic.liquid.haml +1 -0
- data/spec/fixtures/default/app/views/pages/music.liquid.haml +6 -0
- data/spec/fixtures/default/app/views/sections/carousel.liquid +15 -16
- data/spec/fixtures/default/app/views/sections/footer.liquid +37 -3
- data/spec/fixtures/default/app/views/sections/header.liquid +47 -10
- data/spec/fixtures/default/app/views/sections/misc/hero.liquid +28 -0
- data/spec/fixtures/default/config/metafields_schema.yml +3 -0
- data/spec/integration/liquid/tags/section_spec.rb +82 -0
- data/spec/integration/repositories/content_entry_repository_spec.rb +9 -0
- data/spec/integration/server/basic_spec.rb +2 -2
- data/spec/integration/server/metafields_spec.rb +1 -0
- data/spec/integration/services/content_entry_service_spec.rb +12 -0
- data/spec/support/helpers.rb +1 -0
- data/spec/support/liquid.rb +32 -2
- data/spec/support/mongo.rb +1 -0
- data/spec/unit/adapters/filesystem/sanitizers/section_spec.rb +66 -40
- data/spec/unit/adapters/filesystem/yaml_loaders/section_spec.rb +25 -0
- data/spec/unit/errors_spec.rb +1 -1
- data/spec/unit/liquid/drops/content_entry_collection_spec.rb +3 -3
- data/spec/unit/liquid/drops/content_entry_spec.rb +4 -4
- data/spec/unit/liquid/drops/content_types_spec.rb +2 -2
- data/spec/unit/liquid/drops/metafields_spec.rb +8 -8
- data/spec/unit/liquid/drops/params_spec.rb +5 -5
- data/spec/unit/liquid/drops/section_content_proxy_spec.rb +69 -18
- data/spec/unit/liquid/drops/section_spec.rb +1 -1
- data/spec/unit/liquid/file_system_spec.rb +25 -0
- data/spec/unit/liquid/filters/array_spec.rb +140 -0
- data/spec/unit/liquid/filters/misc_spec.rb +21 -3
- data/spec/unit/liquid/filters/number_spec.rb +4 -4
- data/spec/unit/liquid/filters/text_spec.rb +4 -0
- data/spec/unit/liquid/tags/alt_page_links_spec.rb +19 -2
- data/spec/unit/liquid/tags/authorize_spec.rb +1 -1
- data/spec/unit/liquid/tags/editable/text_spec.rb +32 -4
- data/spec/unit/liquid/tags/extends_spec.rb +115 -28
- data/spec/unit/liquid/tags/global_section_spec.rb +4 -3
- data/spec/unit/liquid/tags/google_analytics_spec.rb +21 -2
- data/spec/unit/liquid/tags/inherited_block_spec.rb +18 -4
- data/spec/unit/liquid/tags/inline_editor_spec.rb +11 -0
- data/spec/unit/liquid/tags/link_to_spec.rb +1 -1
- data/spec/unit/liquid/tags/model_form_spec.rb +7 -0
- data/spec/unit/liquid/tags/page_not_found_spec.rb +14 -0
- data/spec/unit/liquid/tags/redirect_to_spec.rb +171 -0
- data/spec/unit/liquid/tags/section_spec.rb +43 -3
- data/spec/unit/liquid/tags/sections_dropzone_spec.rb +0 -1
- data/spec/unit/liquid/tags/snippet_spec.rb +9 -8
- data/spec/unit/liquid/tags/with_scope_spec.rb +80 -60
- data/spec/unit/middlewares/cache_spec.rb +186 -0
- data/spec/unit/middlewares/impersonated_entry_spec.rb +7 -0
- data/spec/unit/middlewares/locale_redirection_spec.rb +7 -0
- data/spec/unit/middlewares/locale_spec.rb +8 -1
- data/spec/unit/middlewares/page_not_found_spec.rb +46 -0
- data/spec/unit/middlewares/redirection_spec.rb +8 -0
- data/spec/unit/middlewares/renderer_spec.rb +64 -6
- data/spec/unit/middlewares/section_spec.rb +1 -0
- data/spec/unit/models/pager_spec.rb +11 -1
- data/spec/unit/repositories/section_repository_spec.rb +1 -1
- data/spec/unit/services/action_service_spec.rb +23 -3
- data/spec/unit/services/page_redirection_service_spec.rb +2 -2
- data/spec/unit/services/recaptcha_service_spec.rb +1 -1
- metadata +50 -24
@@ -96,6 +96,15 @@ module Locomotive
|
|
96
96
|
:invalid_token
|
97
97
|
end
|
98
98
|
|
99
|
+
def notify(action, entry, request)
|
100
|
+
ActiveSupport::Notifications.instrument("steam.auth.#{action}",
|
101
|
+
site: site,
|
102
|
+
entry: entry,
|
103
|
+
locale: entries.locale,
|
104
|
+
request: request
|
105
|
+
)
|
106
|
+
end
|
107
|
+
|
99
108
|
private
|
100
109
|
|
101
110
|
def send_welcome_email(options, context)
|
@@ -138,15 +147,6 @@ EMAIL
|
|
138
147
|
res == 0
|
139
148
|
end
|
140
149
|
|
141
|
-
def notify(action, entry, request)
|
142
|
-
ActiveSupport::Notifications.instrument("steam.auth.#{action}",
|
143
|
-
site: site,
|
144
|
-
entry: entry,
|
145
|
-
locale: entries.locale,
|
146
|
-
request: request
|
147
|
-
)
|
148
|
-
end
|
149
|
-
|
150
150
|
# Module inject to the content entry to enable
|
151
151
|
# related authentication methods.
|
152
152
|
#
|
@@ -21,11 +21,13 @@ module Locomotive
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def _parse(object, options = {})
|
24
|
-
# Note: the template must not be parsed here
|
25
24
|
begin
|
26
25
|
Locomotive::Steam::Liquid::Template.parse(object.liquid_source, options)
|
26
|
+
rescue Locomotive::Steam::TemplateError => e
|
27
|
+
# we don't want to hide an exception occured during parsing a section or a snippet
|
28
|
+
raise e
|
27
29
|
rescue ::Liquid::Error => e
|
28
|
-
raise Locomotive::Steam::
|
30
|
+
raise Locomotive::Steam::LiquidError.new(e, object.template_path, object.liquid_source)
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
@@ -20,7 +20,7 @@ module Locomotive
|
|
20
20
|
# normal pages have priority over the templatized ones if they're not in the same "folder"
|
21
21
|
same_folder?(page_1, page_2) ?
|
22
22
|
page_1.position <=> page_2.position :
|
23
|
-
(page_2.fullpath.include?(WILDCARD) ? 0 : 1) <=> (page_1
|
23
|
+
(page_2.fullpath.include?(WILDCARD) ? 0 : 1) <=> (page_1.fullpath.include?(WILDCARD) ? 0 : 1)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -9,8 +9,10 @@ module Locomotive
|
|
9
9
|
GOOGLE_API_URL = 'https://www.google.com/recaptcha/api/siteverify'.freeze
|
10
10
|
|
11
11
|
def initialize(site, request)
|
12
|
-
|
13
|
-
|
12
|
+
attributes = site.metafields.values.reduce({}, :merge).with_indifferent_access
|
13
|
+
|
14
|
+
@api = attributes[:recaptcha_api_url] || GOOGLE_API_URL
|
15
|
+
@secret = attributes[:recaptcha_secret]
|
14
16
|
@ip = request.ip
|
15
17
|
end
|
16
18
|
|
data/lib/locomotive/steam.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'locomotive/common'
|
2
2
|
|
3
|
+
require_relative 'steam/version'
|
3
4
|
require_relative 'steam/configuration'
|
4
5
|
require_relative_all 'steam/decorators'
|
5
6
|
require_relative 'steam/liquid'
|
@@ -14,7 +15,8 @@ module Locomotive
|
|
14
15
|
module Steam
|
15
16
|
|
16
17
|
FRONTMATTER_REGEXP = /^(?<yaml>(---\s*\n.*?\n?)^(---\s*$\n?))?(?<template>.*)/mo.freeze
|
17
|
-
|
18
|
+
YAML_FRONTMATTER_REGEXP = /^---\s*\n(?<yaml>(.*?\n?))?^(---\s*$\n?)(?<template>.*)/mo.freeze
|
19
|
+
JSON_FRONTMATTER_REGEXP = /^---\s*\n(?<json>\s*\{(.*?\n?))?^(---\s*$\n?)(?<template>.*)/mo.freeze
|
18
20
|
|
19
21
|
WILDCARD = 'content_type_template'.freeze
|
20
22
|
|
@@ -24,6 +26,8 @@ module Locomotive
|
|
24
26
|
SECTIONS_BLOCK_FORLOOP_REGEXP = /(?<name>.+)-section\.blocks$/o.freeze
|
25
27
|
SECTIONS_LINK_TARGET_REGEXP = /[^\"]+\/_locomotive-link\/(?<link>[^\"]+)/mo.freeze
|
26
28
|
|
29
|
+
ASSET_URL_REGEXP = /("|')(https:\/\/[^\/]+)?\/(sites|steam)\/(\S+)("|')/.freeze
|
30
|
+
|
27
31
|
IsHTTP = /\Ahttps?:\/\//o.freeze
|
28
32
|
|
29
33
|
IsLAYOUT = /\Alayouts(\/|\z)/o.freeze
|
data/locomotivecms_steam.gemspec
CHANGED
@@ -17,16 +17,17 @@ Gem::Specification.new do |spec|
|
|
17
17
|
|
18
18
|
spec.add_development_dependency 'rake', '~> 12.3.0'
|
19
19
|
|
20
|
-
spec.add_development_dependency 'mongo', '~> 2.
|
20
|
+
spec.add_development_dependency 'mongo', '~> 2.8.0'
|
21
21
|
spec.add_development_dependency 'origin', '~> 2.3.1'
|
22
22
|
|
23
|
-
spec.add_dependency 'nokogiri', '~> 1.
|
23
|
+
spec.add_dependency 'nokogiri', '~> 1.10.4'
|
24
24
|
spec.add_dependency 'sanitize', '~> 4.6.4'
|
25
25
|
spec.add_dependency 'morphine', '~> 0.1.1'
|
26
26
|
spec.add_dependency 'httparty', '~> 0.16.0'
|
27
27
|
spec.add_dependency 'chronic', '~> 0.10.2'
|
28
28
|
spec.add_dependency 'bcrypt', '~> 3.1.11'
|
29
29
|
spec.add_dependency 'multi_json', '~> 1.13.1'
|
30
|
+
spec.add_dependency 'liquid', '~> 4.0.3'
|
30
31
|
|
31
32
|
spec.add_dependency 'rack-rewrite', '~> 1.5.1'
|
32
33
|
spec.add_dependency 'rack-cache', '~> 1.7.0'
|
@@ -45,10 +46,9 @@ Gem::Specification.new do |spec|
|
|
45
46
|
spec.add_dependency 'RedCloth', '~> 4.3.2'
|
46
47
|
spec.add_dependency 'mimetype-fu', '~> 0.1.2'
|
47
48
|
spec.add_dependency 'mime-types', '~> 3.1.0'
|
48
|
-
spec.add_dependency 'duktape', '~>
|
49
|
+
spec.add_dependency 'duktape', '~> 2.0.1.1'
|
49
50
|
spec.add_dependency 'pony', '~> 1.12'
|
50
51
|
|
51
|
-
spec.add_dependency 'locomotivecms-solid', '~> 4.0.1'
|
52
52
|
spec.add_dependency 'locomotivecms_common', '~> 0.3.1'
|
53
53
|
|
54
54
|
spec.required_ruby_version = '>= 2.0'
|
@@ -14,6 +14,7 @@ position: 6
|
|
14
14
|
This is a basic page
|
15
15
|
|
16
16
|
%ul
|
17
|
+
%li Font={{ site.metafields.theme.font }}
|
17
18
|
%li Color scheme={{ site.metafields.theme.color_scheme }}
|
18
19
|
%li Facebook ID={{ site.metafields.social.facebook_id }}
|
19
20
|
%li Google ID={{ site.metafields.social.google_id }}
|
@@ -2,11 +2,17 @@
|
|
2
2
|
listed: true
|
3
3
|
handle: our-music
|
4
4
|
position: 2
|
5
|
+
sections_content:
|
6
|
+
carousel:
|
7
|
+
settings:
|
8
|
+
brand: "My brand"
|
5
9
|
---
|
6
10
|
{% extends parent %}
|
7
11
|
|
8
12
|
{% block content %}
|
9
13
|
|
14
|
+
{% section 'carousel' %}
|
15
|
+
|
10
16
|
{% editable_long_text 'introduction' %}
|
11
17
|
|
12
18
|
%p
|
@@ -1,20 +1,19 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
2
|
+
name: carousel
|
3
|
+
category: carousel
|
4
|
+
class: section-carousel
|
5
|
+
settings:
|
6
|
+
- id: brand
|
7
|
+
type: text
|
8
|
+
label: Text to display in the carousel
|
9
|
+
default: Header
|
10
|
+
dropzone_presets:
|
11
|
+
- name: Carousel
|
12
|
+
category: Content
|
13
|
+
settings:
|
14
|
+
brand: Acme
|
15
|
+
blocks: []
|
16
16
|
---
|
17
|
-
|
18
17
|
<h2>
|
19
|
-
|
18
|
+
CAROUSEL
|
20
19
|
</h2>
|
@@ -10,9 +10,40 @@
|
|
10
10
|
"type": "text",
|
11
11
|
"label": "Text to display in the footer",
|
12
12
|
"default": "Header"
|
13
|
+
},
|
14
|
+
{
|
15
|
+
"id": "copyright",
|
16
|
+
"type": "text",
|
17
|
+
"label": "Copyright",
|
18
|
+
"default": "(c) NoCoffee"
|
19
|
+
}
|
20
|
+
],
|
21
|
+
"blocks": [
|
22
|
+
{
|
23
|
+
"type": "link",
|
24
|
+
"settings": [
|
25
|
+
{
|
26
|
+
"id": "label",
|
27
|
+
"type": "text",
|
28
|
+
"label": "Label",
|
29
|
+
"default": "Link"
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"id": "url",
|
33
|
+
"type": "url",
|
34
|
+
"label": "Url",
|
35
|
+
"default": "https://www.locomotivecms.com"
|
36
|
+
},
|
37
|
+
{
|
38
|
+
"id": "new_tab",
|
39
|
+
"type": "checkbox",
|
40
|
+
"label": "Open in a new tab?",
|
41
|
+
"default": true
|
42
|
+
}
|
43
|
+
]
|
13
44
|
}
|
14
45
|
],
|
15
|
-
"
|
46
|
+
"global_content":
|
16
47
|
{
|
17
48
|
"settings":
|
18
49
|
{
|
@@ -26,7 +57,7 @@
|
|
26
57
|
{
|
27
58
|
"label": "Link #1",
|
28
59
|
"url": "https://www.nocoffee.fr",
|
29
|
-
"new_tab":
|
60
|
+
"new_tab": true
|
30
61
|
}
|
31
62
|
},
|
32
63
|
{
|
@@ -35,8 +66,11 @@
|
|
35
66
|
{
|
36
67
|
"label": "Link #2",
|
37
68
|
"url": "https://www.nocoffee.fr",
|
38
|
-
"new_tab":
|
69
|
+
"new_tab": true
|
39
70
|
}
|
71
|
+
},
|
72
|
+
{
|
73
|
+
"type": "link"
|
40
74
|
}
|
41
75
|
]
|
42
76
|
}
|
@@ -3,30 +3,57 @@
|
|
3
3
|
"name": "header",
|
4
4
|
"category": "header",
|
5
5
|
"class": "section-header",
|
6
|
-
"settings":
|
7
|
-
[
|
6
|
+
"settings": [
|
8
7
|
{
|
9
8
|
"id": "brand",
|
10
9
|
"type": "text",
|
11
10
|
"label": "Text to display in the header",
|
12
11
|
"default": "Header"
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"id": "logo",
|
15
|
+
"type": "image_picker",
|
16
|
+
"label": "Logo",
|
17
|
+
"default": "/images/logo.png"
|
13
18
|
}
|
14
19
|
],
|
15
|
-
"
|
16
|
-
{
|
17
|
-
"settings":
|
20
|
+
"blocks": [
|
18
21
|
{
|
22
|
+
"type": "link",
|
23
|
+
"settings": [
|
24
|
+
{
|
25
|
+
"id": "label",
|
26
|
+
"type": "text",
|
27
|
+
"label": "Label",
|
28
|
+
"default": "Link"
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"id": "url",
|
32
|
+
"type": "url",
|
33
|
+
"label": "Url",
|
34
|
+
"default": "https://www.locomotivecms.com"
|
35
|
+
},
|
36
|
+
{
|
37
|
+
"id": "new_tab",
|
38
|
+
"type": "checkbox",
|
39
|
+
"label": "Open in a new tab?",
|
40
|
+
"default": true
|
41
|
+
}
|
42
|
+
]
|
43
|
+
}
|
44
|
+
],
|
45
|
+
"default": {
|
46
|
+
"settings": {
|
19
47
|
"brand": "MY COMPANY"
|
20
48
|
},
|
21
|
-
"blocks":
|
22
|
-
[
|
49
|
+
"blocks": [
|
23
50
|
{
|
24
51
|
"type": "link",
|
25
52
|
"settings":
|
26
53
|
{
|
27
54
|
"label": "Link #1",
|
28
55
|
"url": "https://www.nocoffee.fr",
|
29
|
-
"new_tab":
|
56
|
+
"new_tab": true
|
30
57
|
}
|
31
58
|
},
|
32
59
|
{
|
@@ -35,11 +62,21 @@
|
|
35
62
|
{
|
36
63
|
"label": "Link #2",
|
37
64
|
"url": "https://www.nocoffee.fr",
|
38
|
-
"new_tab":
|
65
|
+
"new_tab": true
|
39
66
|
}
|
67
|
+
},
|
68
|
+
{
|
69
|
+
"type": "link"
|
40
70
|
}
|
41
71
|
]
|
42
|
-
}
|
72
|
+
},
|
73
|
+
"dropzone_presets": [
|
74
|
+
{
|
75
|
+
"name": "Default header",
|
76
|
+
"category": "Header",
|
77
|
+
"use_default": true
|
78
|
+
}
|
79
|
+
]
|
43
80
|
}
|
44
81
|
---
|
45
82
|
<h1> {{ section.settings.brand }} </h1>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
---
|
2
|
+
{
|
3
|
+
"name": "Hero",
|
4
|
+
"class": "section-hero",
|
5
|
+
"settings":
|
6
|
+
[
|
7
|
+
{
|
8
|
+
"id": "title",
|
9
|
+
"type": "text",
|
10
|
+
"label": "Title",
|
11
|
+
"default": "Title goes here"
|
12
|
+
}
|
13
|
+
],
|
14
|
+
"dropzone_presets": [
|
15
|
+
{
|
16
|
+
"name": "Simple Hero",
|
17
|
+
"category": "Content",
|
18
|
+
"settings": {
|
19
|
+
"title": "Hello world!"
|
20
|
+
},
|
21
|
+
"blocks": []
|
22
|
+
}
|
23
|
+
]
|
24
|
+
}
|
25
|
+
---
|
26
|
+
<h2>
|
27
|
+
HERO
|
28
|
+
</h2>
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Locomotive::Steam::Liquid::Tags::Section do
|
4
|
+
|
5
|
+
let(:assigns) { {} }
|
6
|
+
let(:context) { ::Liquid::Context.new(assigns, {}, {}) }
|
7
|
+
|
8
|
+
subject { render_template(source, context).strip }
|
9
|
+
|
10
|
+
describe 'image_picker field' do
|
11
|
+
|
12
|
+
let(:source) { <<-EOF
|
13
|
+
{% if image is present %}
|
14
|
+
We've got an image!
|
15
|
+
{% else %}
|
16
|
+
Nope
|
17
|
+
{% endif %}
|
18
|
+
EOF
|
19
|
+
}
|
20
|
+
|
21
|
+
let(:assigns) { { 'image' => Locomotive::Steam::Liquid::Drops::SectionImagePickerField.new(image) } }
|
22
|
+
|
23
|
+
context 'the image is nil' do
|
24
|
+
|
25
|
+
let(:image) { nil }
|
26
|
+
it { is_expected.to eq 'Nope' }
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'the image is an empty string' do
|
31
|
+
|
32
|
+
let(:image) { '' }
|
33
|
+
it { is_expected.to eq 'Nope' }
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'the image is an url' do
|
38
|
+
|
39
|
+
let(:image) { 'https://cdn.somewhere.net/images/banner.png' }
|
40
|
+
it { is_expected.to eq "We've got an image!" }
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
describe 'link field' do
|
47
|
+
|
48
|
+
let(:source) { <<-EOF
|
49
|
+
{% if link is present %}
|
50
|
+
We've got a link!
|
51
|
+
{% else %}
|
52
|
+
Nope
|
53
|
+
{% endif %}
|
54
|
+
EOF
|
55
|
+
}
|
56
|
+
|
57
|
+
let(:assigns) { { 'link' => Locomotive::Steam::Liquid::Drops::SectionUrlField.new(url) } }
|
58
|
+
|
59
|
+
context 'the link is nil' do
|
60
|
+
|
61
|
+
let(:url) { nil }
|
62
|
+
it { is_expected.to eq 'Nope' }
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'the link is an empty string' do
|
67
|
+
|
68
|
+
let(:url) { '' }
|
69
|
+
it { is_expected.to eq 'Nope' }
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'the link is an url' do
|
74
|
+
|
75
|
+
let(:url) { 'https://www.locomotivecms.com' }
|
76
|
+
it { is_expected.to eq "We've got a link!" }
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
@@ -142,6 +142,15 @@ describe Locomotive::Steam::ContentEntryRepository do
|
|
142
142
|
let(:adapter) { Locomotive::Steam::MongoDBAdapter.new(database: mongodb_database, hosts: ['127.0.0.1:27017']) }
|
143
143
|
let(:entry_id) { BSON::ObjectId.from_string('5baf7d38a953300567956448') }
|
144
144
|
|
145
|
+
describe 'filter by a date field' do
|
146
|
+
|
147
|
+
let(:type) { type_repository.by_slug('events') }
|
148
|
+
|
149
|
+
subject { repository.all(:date.lte => Time.now.to_date, order_by: 'date desc') }
|
150
|
+
it { expect(subject.map { |entry| entry[:place] }.slice(0, 2)).to eq(["Avogadro's Number", "Quixote's True Blue"]) }
|
151
|
+
|
152
|
+
end
|
153
|
+
|
145
154
|
end
|
146
155
|
|
147
156
|
end
|
@@ -178,14 +178,14 @@ describe Locomotive::Steam::Server do
|
|
178
178
|
context 'liquid parsing error' do
|
179
179
|
|
180
180
|
subject { get '/about-us/john-doe'; last_response.body }
|
181
|
-
it { expect { subject }.to raise_error(Locomotive::Steam::
|
181
|
+
it { expect { subject }.to raise_error(Locomotive::Steam::LiquidError, "Liquid syntax error (line 1): Syntax Error in 'for loop' - Valid syntax: for [item] in [collection]") }
|
182
182
|
|
183
183
|
end
|
184
184
|
|
185
185
|
context 'rendering error' do
|
186
186
|
|
187
187
|
subject { get '/fr/a-notre-sujet/jean-personne'; last_response.body }
|
188
|
-
it { expect { subject }.to raise_error(Locomotive::Steam::ActionError, "identifier 'foo' undefined") }
|
188
|
+
it { expect { subject }.to raise_error(Locomotive::Steam::ActionError, "Action error - identifier 'foo' undefined") }
|
189
189
|
|
190
190
|
end
|
191
191
|
|
@@ -10,6 +10,7 @@ describe 'Site metafields' do
|
|
10
10
|
|
11
11
|
it 'returns all the values of the site metafields' do
|
12
12
|
get '/basic'
|
13
|
+
expect(last_response.body).to include 'Font=OpenSans'
|
13
14
|
expect(last_response.body).to include 'Color scheme=white'
|
14
15
|
expect(last_response.body).to include 'Facebook ID=FB42'
|
15
16
|
expect(last_response.body).to include 'Google ID=G42'
|
@@ -105,6 +105,18 @@ describe Locomotive::Steam::ContentEntryService do
|
|
105
105
|
it { expect(subject['errors']).to eq({ 'name' => ["can't be blank"], 'email' => ["can't be blank"], 'message' => ["can't be blank"] }) }
|
106
106
|
|
107
107
|
end
|
108
|
+
|
109
|
+
context 'with a belongs_to relationship' do
|
110
|
+
|
111
|
+
let(:attributes) { { title: 'Do the evolution', band_id: 'pearl-jam' } }
|
112
|
+
|
113
|
+
subject { service.create('songs', attributes, false) }
|
114
|
+
|
115
|
+
it { expect { subject }.to change { service.all('songs').size } }
|
116
|
+
it { expect(subject.band.name).to eq 'Pearl Jam' }
|
117
|
+
|
118
|
+
end
|
119
|
+
|
108
120
|
end
|
109
121
|
|
110
122
|
describe '#update' do
|
data/spec/support/helpers.rb
CHANGED
@@ -22,6 +22,7 @@ module Spec
|
|
22
22
|
def setup_common(logger_output = nil)
|
23
23
|
Locomotive::Common.reset
|
24
24
|
Locomotive::Common.configure do |config|
|
25
|
+
logger_output ||= File.join(default_fixture_site_path, 'log/steam.log')
|
25
26
|
config.notifier = Locomotive::Common::Logger.setup(logger_output)
|
26
27
|
end
|
27
28
|
end
|
data/spec/support/liquid.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
def render_template(source, context = nil, options = {})
|
2
2
|
context ||= ::Liquid::Context.new
|
3
|
-
context.
|
3
|
+
context.exception_renderer = ->(e) do
|
4
|
+
# puts e.message # UN-COMMENT IT FOR DEBUGGING
|
5
|
+
raise e
|
6
|
+
end
|
4
7
|
Locomotive::Steam::Liquid::Template.parse(source, options).render(context)
|
5
8
|
end
|
6
9
|
|
@@ -15,7 +18,7 @@ module Liquid
|
|
15
18
|
@_source = source.with_indifferent_access
|
16
19
|
end
|
17
20
|
|
18
|
-
def
|
21
|
+
def liquid_method_missing(meth)
|
19
22
|
@_source[meth.to_sym]
|
20
23
|
end
|
21
24
|
|
@@ -40,6 +43,33 @@ module Liquid
|
|
40
43
|
@stack || []
|
41
44
|
end
|
42
45
|
end
|
46
|
+
|
47
|
+
class LayoutFileSystem
|
48
|
+
def read_template_file(template_path, _)
|
49
|
+
case template_path
|
50
|
+
when "base"
|
51
|
+
"<body>base</body>"
|
52
|
+
|
53
|
+
when "inherited"
|
54
|
+
"{% extends base %}"
|
55
|
+
|
56
|
+
when "page_with_title"
|
57
|
+
"<body><h1>{% block title %}Hello{% endblock %}</h1><p>Lorem ipsum</p></body>"
|
58
|
+
|
59
|
+
when "product"
|
60
|
+
"<body><h1>Our product: {{ name }}</h1>{% block info %}{% endblock %}</body>"
|
61
|
+
|
62
|
+
when "product_with_warranty"
|
63
|
+
"{% extends product %}{% block info %}<p>mandatory warranty</p>{% endblock %}"
|
64
|
+
|
65
|
+
when "product_with_static_price"
|
66
|
+
"{% extends product %}{% block info %}<h2>Some info</h2>{% block price %}<p>$42.00</p>{% endblock %}{% endblock %}"
|
67
|
+
|
68
|
+
else
|
69
|
+
template_path
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
43
73
|
end
|
44
74
|
|
45
75
|
def liquid_instance_double(doubled_class, stubs)
|