locomotivecms_steam 1.4.1 → 1.5.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/Gemfile.lock +31 -25
  4. data/Rakefile +2 -2
  5. data/config/locales/pt-BR.yml +43 -13
  6. data/lib/locomotive/steam.rb +9 -4
  7. data/lib/locomotive/steam/adapters/filesystem.rb +2 -7
  8. data/lib/locomotive/steam/adapters/filesystem/sanitizer.rb +0 -2
  9. data/lib/locomotive/steam/adapters/filesystem/sanitizers/page.rb +11 -0
  10. data/lib/locomotive/steam/adapters/filesystem/sanitizers/section.rb +37 -0
  11. data/lib/locomotive/steam/adapters/filesystem/sanitizers/site.rb +18 -0
  12. data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/content_entry.rb +4 -3
  13. data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/content_type.rb +4 -3
  14. data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/section.rb +40 -0
  15. data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/snippet.rb +0 -1
  16. data/lib/locomotive/steam/adapters/memory.rb +1 -1
  17. data/lib/locomotive/steam/entities/content_entry.rb +15 -3
  18. data/lib/locomotive/steam/entities/content_type.rb +2 -1
  19. data/lib/locomotive/steam/entities/page.rb +21 -19
  20. data/lib/locomotive/steam/entities/section.rb +24 -0
  21. data/lib/locomotive/steam/entities/site.rb +3 -1
  22. data/lib/locomotive/steam/liquid.rb +2 -0
  23. data/lib/locomotive/steam/liquid/drops/page.rb +4 -2
  24. data/lib/locomotive/steam/liquid/drops/params.rb +51 -0
  25. data/lib/locomotive/steam/liquid/drops/section.rb +56 -0
  26. data/lib/locomotive/steam/liquid/drops/section_block.rb +47 -0
  27. data/lib/locomotive/steam/liquid/drops/section_content_proxy.rb +97 -0
  28. data/lib/locomotive/steam/liquid/drops/section_editor_setting_data.rb +65 -0
  29. data/lib/locomotive/steam/liquid/drops/site.rb +2 -1
  30. data/lib/locomotive/steam/liquid/errors.rb +2 -0
  31. data/lib/locomotive/steam/liquid/filters/base.rb +3 -3
  32. data/lib/locomotive/steam/liquid/filters/date.rb +1 -1
  33. data/lib/locomotive/steam/liquid/filters/html.rb +7 -2
  34. data/lib/locomotive/steam/liquid/filters/json.rb +3 -1
  35. data/lib/locomotive/steam/liquid/tags/action.rb +2 -2
  36. data/lib/locomotive/steam/liquid/tags/alt_page_links.rb +63 -0
  37. data/lib/locomotive/steam/liquid/tags/concerns/i18n_page.rb +1 -1
  38. data/lib/locomotive/steam/liquid/tags/concerns/section.rb +117 -0
  39. data/lib/locomotive/steam/liquid/tags/global_section.rb +32 -0
  40. data/lib/locomotive/steam/liquid/tags/model_form.rb +1 -1
  41. data/lib/locomotive/steam/liquid/tags/section.rb +87 -0
  42. data/lib/locomotive/steam/liquid/tags/sections_dropzone.rb +56 -0
  43. data/lib/locomotive/steam/liquid/tags/snippet.rb +3 -2
  44. data/lib/locomotive/steam/liquid/template.rb +0 -5
  45. data/lib/locomotive/steam/middlewares.rb +1 -1
  46. data/lib/locomotive/steam/middlewares/auth.rb +29 -13
  47. data/lib/locomotive/steam/middlewares/concerns/helpers.rb +59 -0
  48. data/lib/locomotive/steam/middlewares/concerns/liquid_context.rb +94 -0
  49. data/lib/locomotive/steam/middlewares/encoded_link_redirection.rb +45 -0
  50. data/lib/locomotive/steam/middlewares/entry_submission.rb +1 -1
  51. data/lib/locomotive/steam/middlewares/favicon.rb +1 -1
  52. data/lib/locomotive/steam/middlewares/locale.rb +63 -15
  53. data/lib/locomotive/steam/middlewares/locale_redirection.rb +18 -6
  54. data/lib/locomotive/steam/middlewares/logging.rb +1 -1
  55. data/lib/locomotive/steam/middlewares/page.rb +35 -6
  56. data/lib/locomotive/steam/middlewares/path.rb +1 -1
  57. data/lib/locomotive/steam/middlewares/private_access.rb +1 -1
  58. data/lib/locomotive/steam/middlewares/redirection.rb +1 -1
  59. data/lib/locomotive/steam/middlewares/renderer.rb +2 -82
  60. data/lib/locomotive/steam/middlewares/robots.rb +1 -1
  61. data/lib/locomotive/steam/middlewares/section.rb +56 -0
  62. data/lib/locomotive/steam/middlewares/site.rb +1 -1
  63. data/lib/locomotive/steam/middlewares/sitemap.rb +58 -45
  64. data/lib/locomotive/steam/middlewares/templatized_page.rb +1 -1
  65. data/lib/locomotive/steam/middlewares/thread_safe.rb +85 -2
  66. data/lib/locomotive/steam/middlewares/timezone.rb +1 -1
  67. data/lib/locomotive/steam/middlewares/url_redirection.rb +1 -1
  68. data/lib/locomotive/steam/models/entity.rb +0 -2
  69. data/lib/locomotive/steam/models/mapper.rb +5 -3
  70. data/lib/locomotive/steam/models/scope.rb +8 -0
  71. data/lib/locomotive/steam/repositories.rb +4 -0
  72. data/lib/locomotive/steam/repositories/content_entry_repository.rb +6 -2
  73. data/lib/locomotive/steam/repositories/page_repository.rb +4 -1
  74. data/lib/locomotive/steam/repositories/section_repository.rb +14 -0
  75. data/lib/locomotive/steam/repositories/site_repository.rb +1 -1
  76. data/lib/locomotive/steam/repositories/snippet_repository.rb +0 -3
  77. data/lib/locomotive/steam/server.rb +3 -1
  78. data/lib/locomotive/steam/services.rb +17 -1
  79. data/lib/locomotive/steam/services/action_service.rb +10 -0
  80. data/lib/locomotive/steam/services/concerns/decorator.rb +0 -2
  81. data/lib/locomotive/steam/services/image_resizer_service.rb +1 -1
  82. data/lib/locomotive/steam/services/page_finder_service.rb +6 -0
  83. data/lib/locomotive/steam/services/section_finder_service.rb +17 -0
  84. data/lib/locomotive/steam/services/url_builder_service.rb +31 -17
  85. data/lib/locomotive/steam/services/url_finder_service.rb +87 -0
  86. data/lib/locomotive/steam/version.rb +2 -2
  87. data/locomotivecms_steam.gemspec +1 -1
  88. data/spec/fixtures/default/app/views/pages/tags/section.liquid.haml +11 -0
  89. data/spec/fixtures/default/app/views/sections/carousel.liquid +20 -0
  90. data/spec/fixtures/default/app/views/sections/footer.liquid +48 -0
  91. data/spec/fixtures/default/app/views/sections/header.liquid +54 -0
  92. data/spec/fixtures/default/config/deploy.yml +1 -1
  93. data/spec/fixtures/errors/section_bad_json_content.liquid +9 -0
  94. data/spec/fixtures/errors/section_bad_json_header.liquid +8 -0
  95. data/spec/fixtures/mongodb/locomotive_accounts.bson +0 -0
  96. data/spec/fixtures/mongodb/locomotive_accounts.metadata.json +1 -1
  97. data/spec/fixtures/mongodb/locomotive_activities.bson +0 -0
  98. data/spec/fixtures/mongodb/locomotive_activities.metadata.json +1 -1
  99. data/spec/fixtures/mongodb/locomotive_content_assets.bson +0 -0
  100. data/spec/fixtures/mongodb/locomotive_content_assets.metadata.json +1 -1
  101. data/spec/fixtures/mongodb/locomotive_content_entries.bson +0 -0
  102. data/spec/fixtures/mongodb/locomotive_content_entries.metadata.json +1 -1
  103. data/spec/fixtures/mongodb/locomotive_content_types.bson +0 -0
  104. data/spec/fixtures/mongodb/locomotive_content_types.metadata.json +1 -1
  105. data/spec/fixtures/mongodb/locomotive_pages.bson +0 -0
  106. data/spec/fixtures/mongodb/locomotive_pages.metadata.json +1 -1
  107. data/spec/fixtures/mongodb/locomotive_sections.bson +0 -0
  108. data/spec/fixtures/mongodb/{sessions.metadata.json → locomotive_sections.metadata.json} +1 -1
  109. data/spec/fixtures/mongodb/locomotive_sites.bson +0 -0
  110. data/spec/fixtures/mongodb/locomotive_sites.metadata.json +1 -1
  111. data/spec/fixtures/mongodb/locomotive_snippets.bson +0 -0
  112. data/spec/fixtures/mongodb/locomotive_snippets.metadata.json +1 -1
  113. data/spec/fixtures/mongodb/locomotive_theme_assets.bson +0 -0
  114. data/spec/fixtures/mongodb/locomotive_theme_assets.metadata.json +1 -1
  115. data/spec/fixtures/mongodb/locomotive_translations.bson +0 -0
  116. data/spec/fixtures/mongodb/locomotive_translations.metadata.json +1 -1
  117. data/spec/integration/repositories/content_entry_repository_spec.rb +1 -1
  118. data/spec/integration/repositories/page_repository_spec.rb +1 -1
  119. data/spec/integration/repositories/theme_asset_repository_spec.rb +1 -1
  120. data/spec/integration/server/auth_spec.rb +0 -4
  121. data/spec/integration/server/basic_spec.rb +8 -0
  122. data/spec/integration/server/contact_form_spec.rb +15 -2
  123. data/spec/integration/server/sitemap_spec.rb +5 -3
  124. data/spec/integration/services/content_entry_service_spec.rb +1 -1
  125. data/spec/support/helpers.rb +3 -3
  126. data/spec/unit/adapters/filesystem/sanitizers/section_spec.rb +65 -0
  127. data/spec/unit/adapters/filesystem/sanitizers/site_spec.rb +28 -2
  128. data/spec/unit/adapters/filesystem/yaml_loaders/content_entry_spec.rb +8 -4
  129. data/spec/unit/adapters/filesystem/yaml_loaders/content_type_spec.rb +2 -2
  130. data/spec/unit/adapters/filesystem/yaml_loaders/page_spec.rb +1 -1
  131. data/spec/unit/adapters/filesystem/yaml_loaders/section_spec.rb +27 -0
  132. data/spec/unit/entities/section_spec.rb +29 -0
  133. data/spec/unit/liquid/drops/params_spec.rb +38 -0
  134. data/spec/unit/liquid/drops/section_content_proxy_spec.rb +88 -0
  135. data/spec/unit/liquid/drops/section_spec.rb +26 -0
  136. data/spec/unit/liquid/filters/html_spec.rb +198 -170
  137. data/spec/unit/liquid/filters/json_spec.rb +7 -0
  138. data/spec/unit/liquid/tags/action_spec.rb +12 -2
  139. data/spec/unit/liquid/tags/alt_page_links_spec.rb +58 -0
  140. data/spec/unit/liquid/tags/global_section_spec.rb +130 -0
  141. data/spec/unit/liquid/tags/link_to_spec.rb +1 -1
  142. data/spec/unit/liquid/tags/locale_switcher_spec.rb +1 -1
  143. data/spec/unit/liquid/tags/model_form_spec.rb +8 -0
  144. data/spec/unit/liquid/tags/path_to_spec.rb +26 -3
  145. data/spec/unit/liquid/tags/section_spec.rb +231 -0
  146. data/spec/unit/liquid/tags/sections_dropzone_spec.rb +107 -0
  147. data/spec/unit/middlewares/auth_spec.rb +9 -2
  148. data/spec/unit/middlewares/encoded_link_redirection_spec.rb +73 -0
  149. data/spec/unit/middlewares/entry_submission_spec.rb +1 -1
  150. data/spec/unit/middlewares/helpers_spec.rb +3 -64
  151. data/spec/unit/middlewares/locale_redirection_spec.rb +13 -2
  152. data/spec/unit/middlewares/locale_spec.rb +52 -10
  153. data/spec/unit/middlewares/page_spec.rb +57 -16
  154. data/spec/unit/middlewares/private_access_spec.rb +1 -1
  155. data/spec/unit/middlewares/redirection_spec.rb +1 -1
  156. data/spec/unit/middlewares/renderer_spec.rb +2 -1
  157. data/spec/unit/middlewares/section_spec.rb +70 -0
  158. data/spec/unit/middlewares/site_spec.rb +1 -1
  159. data/spec/unit/middlewares/sitemap_spec.rb +4 -42
  160. data/spec/unit/middlewares/url_redirection_spec.rb +1 -1
  161. data/spec/unit/repositories/content_entry_repository_spec.rb +13 -13
  162. data/spec/unit/repositories/section_repository_spec.rb +38 -0
  163. data/spec/unit/repositories/snippet_repository_spec.rb +0 -3
  164. data/spec/unit/services/action_service_spec.rb +19 -1
  165. data/spec/unit/services/asset_host_service_spec.rb +8 -0
  166. data/spec/unit/services/parent_finder_service_spec.rb +1 -2
  167. data/spec/unit/services/section_finder_service_spec.rb +28 -0
  168. data/spec/unit/services/url_builder_service_spec.rb +14 -4
  169. data/spec/unit/services/url_finder_service_spec.rb +100 -0
  170. data/spec/unit/services_spec.rb +34 -20
  171. metadata +72 -11
  172. data/lib/locomotive/steam/middlewares/helpers.rb +0 -140
  173. data/spec/fixtures/mongodb/sessions.bson +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be08a6c057a0d05663e1564b6c1ef395d389d7d070a87e1a242a86d0200c1552
4
- data.tar.gz: 69000665df92a36611e86e5b9187a4e61bfc28f8d115f61db9cdb4f815dddb28
3
+ metadata.gz: a416940aeda3a368c649ab613068cb52eca1cab73eb55539c96d7b8669683789
4
+ data.tar.gz: 4d82964327f6732779fffc0bc0d58761409b0beeb1dcab05c996a7f9f7191aae
5
5
  SHA512:
6
- metadata.gz: 93b8824303d4a8b3aff815393c24a7acd206c0725dfea17653204371b05024e7613fadec33d93fb54ee20069fc918fd8bf513a1b30e6631680a7666e2d444f0a
7
- data.tar.gz: '018d6823e5f6aeb95fda7e37e79a4cd798c2446816289d43d94c5aa9cf0a711eaaffcaf2c811d5273201d16b164a047d7d848e69d7db7018e92f4317f9cbb933'
6
+ metadata.gz: b705994d68051d9abc826b1fae9968bcf48c3c52d3f74487c56ba704755744115a0081f8c65315ce0f3b5ced476472223474aa6a19a9f79814cc28f56ac65263
7
+ data.tar.gz: c7946edfacbaa652feca82ebba5c41a9f674f1b20a7e5b2f7b7b61d4e1c336ae76fcf4a0ac2028b50d1904d11784fd64ac8c903ee2c722aadf3a1185e293c01c
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  group :development do
6
- # gem 'locomotivecms_common', github: 'locomotivecms/common', ref: '257047b'
6
+ gem 'locomotivecms_common', github: 'locomotivecms/common', ref: '4d1bd56'
7
7
  # gem 'locomotivecms_common', path: '../common'
8
8
  # gem 'locomotivecms_models', '~> 0.0.1', path: '../models'
9
9
  # gem 'locomotivecms_models', '0.0.1.pre.alpha'
@@ -1,7 +1,18 @@
1
+ GIT
2
+ remote: git://github.com/locomotivecms/common.git
3
+ revision: 4d1bd565246262ab4b1b824e21c7847846f4cc5c
4
+ ref: 4d1bd56
5
+ specs:
6
+ locomotivecms_common (0.3.1)
7
+ activesupport (>= 5.1.5, < 6.0)
8
+ attr_extras (~> 5.2.0)
9
+ colorize
10
+ stringex (~> 2.8.2)
11
+
1
12
  PATH
2
13
  remote: .
3
14
  specs:
4
- locomotivecms_steam (1.4.1)
15
+ locomotivecms_steam (1.5.0.beta1)
5
16
  RedCloth (~> 4.3.2)
6
17
  autoprefixer-rails (~> 8.0.0)
7
18
  bcrypt (~> 3.1.11)
@@ -13,7 +24,7 @@ PATH
13
24
  httparty (~> 0.16.0)
14
25
  kramdown (~> 1.16.2)
15
26
  locomotivecms-solid (~> 4.0.1)
16
- locomotivecms_common (~> 0.3.0)
27
+ locomotivecms_common (~> 0.3.1)
17
28
  mime-types (~> 3.1.0)
18
29
  mimetype-fu (~> 0.1.2)
19
30
  moneta (~> 1.0.0)
@@ -32,7 +43,7 @@ GEM
32
43
  remote: https://rubygems.org/
33
44
  specs:
34
45
  RedCloth (4.3.2)
35
- activesupport (5.1.6)
46
+ activesupport (5.2.1)
36
47
  concurrent-ruby (~> 1.0, >= 1.0.2)
37
48
  i18n (>= 0.7, < 2)
38
49
  minitest (~> 5.1)
@@ -66,15 +77,15 @@ GEM
66
77
  compass-import-once (1.0.5)
67
78
  sass (>= 3.2, < 3.5)
68
79
  concurrent-ruby (1.0.5)
69
- coveralls (0.8.21)
80
+ coveralls (0.8.22)
70
81
  json (>= 1.8, < 3)
71
- simplecov (~> 0.14.1)
82
+ simplecov (~> 0.16.1)
72
83
  term-ansicolor (~> 1.3)
73
84
  thor (~> 0.19.4)
74
85
  tins (~> 1.6)
75
86
  crass (1.0.4)
76
87
  diff-lcs (1.3)
77
- docile (1.1.5)
88
+ docile (1.3.1)
78
89
  dragonfly (1.1.5)
79
90
  addressable (~> 2.3)
80
91
  multi_json (~> 1.0)
@@ -86,10 +97,9 @@ GEM
86
97
  haml (5.0.4)
87
98
  temple (>= 0.8.0)
88
99
  tilt
89
- httparty (0.16.3)
90
- mime-types (~> 3.0)
100
+ httparty (0.16.2)
91
101
  multi_xml (>= 0.5.2)
92
- i18n (0.9.5)
102
+ i18n (1.1.0)
93
103
  concurrent-ruby (~> 1.0)
94
104
  i18n-spec (0.6.0)
95
105
  iso
@@ -103,14 +113,9 @@ GEM
103
113
  locomotivecms-liquid (4.0.0)
104
114
  locomotivecms-solid (4.0.1)
105
115
  locomotivecms-liquid (~> 4.0.0)
106
- locomotivecms_common (0.3.0)
107
- activesupport (~> 5.1.5)
108
- attr_extras (~> 5.2.0)
109
- colorize
110
- stringex (~> 2.8.2)
111
- mail (2.7.1)
116
+ mail (2.7.0)
112
117
  mini_mime (>= 0.1.1)
113
- memory_profiler (0.9.10)
118
+ memory_profiler (0.9.11)
114
119
  mime-types (3.1)
115
120
  mime-types-data (~> 3.2015)
116
121
  mime-types-data (3.2018.0812)
@@ -119,12 +124,12 @@ GEM
119
124
  mini_portile2 (2.3.0)
120
125
  minitest (5.11.3)
121
126
  moneta (1.0.0)
122
- mongo (2.5.1)
127
+ mongo (2.5.3)
123
128
  bson (>= 4.3.0, < 5.0.0)
124
129
  morphine (0.1.1)
125
130
  multi_json (1.13.1)
126
131
  multi_xml (0.6.0)
127
- nokogiri (1.8.5)
132
+ nokogiri (1.8.4)
128
133
  mini_portile2 (~> 2.3.0)
129
134
  nokogumbo (1.5.0)
130
135
  nokogiri
@@ -132,8 +137,8 @@ GEM
132
137
  pony (1.12)
133
138
  mail (>= 2.0)
134
139
  public_suffix (3.0.3)
135
- puma (3.11.3)
136
- rack (2.0.4)
140
+ puma (3.12.0)
141
+ rack (2.0.5)
137
142
  rack-cache (1.7.2)
138
143
  rack (>= 0.4)
139
144
  rack-mini-profiler (0.10.7)
@@ -143,7 +148,7 @@ GEM
143
148
  rack (>= 1.0, < 3)
144
149
  rack_csrf (2.6.0)
145
150
  rack (>= 1.1.0)
146
- rake (12.3.0)
151
+ rake (12.3.1)
147
152
  rb-fsevent (0.10.3)
148
153
  rb-inotify (0.9.10)
149
154
  ffi (>= 0.5.0, < 2)
@@ -165,16 +170,16 @@ GEM
165
170
  nokogiri (>= 1.4.4)
166
171
  nokogumbo (~> 1.4)
167
172
  sass (3.4.25)
168
- simplecov (0.14.1)
169
- docile (~> 1.1.0)
173
+ simplecov (0.16.1)
174
+ docile (~> 1.1)
170
175
  json (>= 1.8, < 3)
171
176
  simplecov-html (~> 0.10.0)
172
177
  simplecov-html (0.10.2)
173
178
  sprockets (3.7.2)
174
179
  concurrent-ruby (~> 1.0)
175
180
  rack (> 1, < 3)
176
- stackprof (0.2.11)
177
- stringex (2.8.5)
181
+ stackprof (0.2.12)
182
+ stringex (2.8.4)
178
183
  temple (0.8.0)
179
184
  term-ansicolor (1.6.0)
180
185
  tins (~> 1.0)
@@ -199,6 +204,7 @@ DEPENDENCIES
199
204
  haml (~> 5.0.4)
200
205
  i18n-spec (~> 0.6.0)
201
206
  json_spec (~> 1.1.5)
207
+ locomotivecms_common!
202
208
  locomotivecms_steam!
203
209
  memory_profiler
204
210
  mongo (~> 2.5.1)
data/Rakefile CHANGED
@@ -22,8 +22,8 @@ namespace :mongodb do
22
22
  `mv #{dump_path} #{db_path}`
23
23
  end
24
24
 
25
- `mongo steam_test_1_4_x --eval "db.dropDatabase()"`
26
- `mongorestore -d steam_test_1_4_x #{db_path}`
25
+ `mongo steam_test_1_5_x --eval "db.dropDatabase()"`
26
+ `mongorestore -d steam_test_1_5_x #{db_path}`
27
27
 
28
28
  puts "Done! Update now the spec/support/helpers.rb file by setting the new id of the site returned by the mongodb_site_id method"
29
29
  end
@@ -23,14 +23,18 @@ pt-BR:
23
23
  one: 'é muito curto (mínimo: 1 caracter)'
24
24
  other: 'é muito curto (mínimo: %{count} caracteres)'
25
25
 
26
- date:
27
- formats:
28
- default: "%d/%m/%Y"
29
-
30
26
  pagination:
31
27
  previous: "&laquo; Anterior"
32
28
  next: "Próximo &raquo;"
33
29
 
30
+ date:
31
+ formats:
32
+ default: "%d/%m/%Y"
33
+ short: "%e %b"
34
+ long: "%e %B %Y"
35
+ long_ordinal: "%e %B %Y"
36
+ only_day: "%e"
37
+
34
38
  date:
35
39
  formats:
36
40
  default: "%d/%m/%Y"
@@ -115,26 +119,52 @@ pt-BR:
115
119
 
116
120
 
117
121
  number:
118
- format:
119
- precision: 3
120
- separator: ','
121
- delimiter: '. '
122
122
  currency:
123
123
  format:
124
- unit: 'R$'
124
+ delimiter: ! '.'
125
+ format: ! '%u %n'
125
126
  precision: 2
126
- format: '%n %u'
127
+ separator: ','
128
+ significant: false
129
+ strip_insignificant_zeros: false
130
+ unit: 'R$'
131
+ format:
132
+ delimiter: ! '.'
133
+ precision: 3
134
+ separator: ','
135
+ significant: false
136
+ strip_insignificant_zeros: false
127
137
  human:
138
+ decimal_units:
139
+ format: ! '%n %u'
140
+ units:
141
+ billion: Bilhão
142
+ million: Milhão
143
+ quadrillion: Quadrilhão
144
+ thousand: Mil
145
+ trillion: Trilhão
146
+ unit: ''
128
147
  format:
129
- precision: 2
148
+ delimiter: ''
149
+ precision: 3
150
+ significant: true
151
+ strip_insignificant_zeros: true
130
152
  storage_units:
131
- format: '%n %u'
153
+ format: ! '%n %u'
132
154
  units:
133
- byte: 'Byte'
155
+ byte:
156
+ one: Byte
157
+ other: Bytes
134
158
  kb: 'Kb'
135
159
  mb: 'Mb'
136
160
  gb: 'Gb'
137
161
  tb: 'Tb'
162
+ percentage:
163
+ format:
164
+ delimiter: ''
165
+ precision:
166
+ format:
167
+ delimiter: ''
138
168
 
139
169
  support:
140
170
  array:
@@ -13,15 +13,20 @@ require_relative 'steam/services'
13
13
  module Locomotive
14
14
  module Steam
15
15
 
16
- FRONTMATTER_REGEXP = /^(?<yaml>(---\s*\n.*?\n?)^(---\s*$\n?))?(?<template>.*)/mo.freeze
16
+ FRONTMATTER_REGEXP = /^(?<yaml>(---\s*\n.*?\n?)^(---\s*$\n?))?(?<template>.*)/mo.freeze
17
+ JSON_FRONTMATTER_REGEXP = /^---\s*\n(?<json>(.*?\n?))?^(---\s*$\n?)(?<template>.*)/mo.freeze
17
18
 
18
19
  WILDCARD = 'content_type_template'.freeze
19
20
 
20
- CONTENT_ENTRY_ENGINE_CLASS_NAME = /^Locomotive::ContentEntry(.*)$/o.freeze
21
+ CONTENT_ENTRY_ENGINE_CLASS_NAME = /^Locomotive::ContentEntry(.*)$/o.freeze
21
22
 
22
- IsHTTP = /\Ahttps?:\/\//o.freeze
23
+ SECTIONS_SETTINGS_VARIABLE_REGEXP = /^\s*([a-z]+\.)?settings\.(?<id>.*)\s*$/o.freeze
24
+ SECTIONS_BLOCK_FORLOOP_REGEXP = /(?<name>.+)-section\.blocks$/o.freeze
25
+ SECTIONS_LINK_TARGET_REGEXP = /[^\"]+\/_locomotive-link\/(?<link>[^\"]+)/mo.freeze
23
26
 
24
- IsLAYOUT = /\Alayouts(\/|\z)/o.freeze
27
+ IsHTTP = /\Ahttps?:\/\//o.freeze
28
+
29
+ IsLAYOUT = /\Alayouts(\/|\z)/o.freeze
25
30
 
26
31
  class << self
27
32
  attr_writer :configuration
@@ -9,7 +9,6 @@ require_relative 'filesystem/sanitizer'
9
9
  require_relative_all 'filesystem/sanitizers'
10
10
 
11
11
  module Locomotive::Steam
12
-
13
12
  class FilesystemAdapter
14
13
 
15
14
  include Morphine
@@ -116,7 +115,7 @@ module Locomotive::Steam
116
115
  end
117
116
 
118
117
  def build_yaml_loaders
119
- %i(sites pages content_types content_entries snippets translations theme_assets).inject({}) do |memo, name|
118
+ %i(sites pages content_types content_entries snippets sections translations theme_assets).inject({}) do |memo, name|
120
119
  memo[name] = build_klass('YAMLLoaders', name).new(site_path)
121
120
  memo
122
121
  end
@@ -124,7 +123,7 @@ module Locomotive::Steam
124
123
 
125
124
  def build_sanitizers
126
125
  hash = Hash.new { build_klass('Sanitizers', :simple).new }
127
- %i(sites pages content_types content_entries snippets).inject(hash) do |memo, name|
126
+ %i(sites pages content_types content_entries snippets sections).inject(hash) do |memo, name|
128
127
  memo[name] = build_klass('Sanitizers', name).new
129
128
  memo
130
129
  end
@@ -138,9 +137,5 @@ module Locomotive::Steam
138
137
  def site_path
139
138
  options.respond_to?(:has_key?) ? options[:path] : options
140
139
  end
141
-
142
140
  end
143
-
144
141
  end
145
-
146
-
@@ -1,9 +1,7 @@
1
1
  module Locomotive::Steam
2
2
  module Adapters
3
3
  module Filesystem
4
-
5
4
  module Sanitizer
6
-
7
5
  extend Forwardable
8
6
 
9
7
  def_delegators :@scope, :site, :locale, :locales, :default_locale
@@ -37,6 +37,8 @@ module Locomotive::Steam
37
37
  set_fullpath_for(page, locale)
38
38
 
39
39
  use_default_locale_template_path(page, locale)
40
+
41
+ transform_sections_content(page, locale)
40
42
  end
41
43
  end
42
44
  end
@@ -137,6 +139,15 @@ module Locomotive::Steam
137
139
  page[:target_klass_name] = "Locomotive::ContentEntry#{content_type}"
138
140
  end
139
141
 
142
+ def transform_sections_content(page, locale)
143
+ [:sections_dropzone_content, :sections_content].each do |name|
144
+ if content = page[name][locale]
145
+ return unless content.is_a?(String)
146
+ page[name][locale] = JSON.parse(content)
147
+ end
148
+ end
149
+ end
150
+
140
151
  def modify_if_parent_templatized(page, locale)
141
152
  parent_templatized = @templatized_ids[page.parent_id]
142
153
 
@@ -0,0 +1,37 @@
1
+ module Locomotive::Steam
2
+ module Adapters
3
+ module Filesystem
4
+ module Sanitizers
5
+ class Section
6
+
7
+ include Adapters::Filesystem::Sanitizer
8
+
9
+ def apply_to_entity(entity)
10
+ super
11
+ parse_json(entity)
12
+ end
13
+
14
+ private
15
+
16
+ def parse_json(entity)
17
+ content = File.read(entity.template_path)
18
+ match = content.match(JSON_FRONTMATTER_REGEXP)
19
+
20
+ raise_parsing_error(entity, content) if match.nil?
21
+
22
+ json, template = match[:json], match[:template]
23
+
24
+ entity.definition = JSON.parse(json)
25
+ entity.template = template
26
+ end
27
+
28
+ def raise_parsing_error(entity, content)
29
+ message = 'Your section requires a valid JSON header'
30
+ raise Locomotive::Steam::ParsingRenderingError.new(message, entity.template_path, content, 0, nil)
31
+ end
32
+
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -9,6 +9,7 @@ module Locomotive::Steam
9
9
 
10
10
  def apply_to_entity(entity)
11
11
  entity.metafields_schema = clean_metafields_schema(entity.metafields_schema)
12
+ entity.routes = build_routes(entity.routes)
12
13
  end
13
14
 
14
15
  private
@@ -47,6 +48,23 @@ module Locomotive::Steam
47
48
  end
48
49
  end
49
50
 
51
+ def build_routes(definitions)
52
+ return [] if definitions.blank?
53
+
54
+ definitions.map do |definition|
55
+ if definition.size == 1
56
+ # format: { '/posts/:year/:month' => 'blog' }
57
+ {
58
+ 'route' => definition.keys.first,
59
+ 'page_handle' => definition.values.first
60
+ }
61
+ else
62
+ # format: { 'route' => '/posts/:year/:month', 'page_handle' => 'blog' }
63
+ definition.stringify_keys
64
+ end
65
+ end
66
+ end
67
+
50
68
  end
51
69
  end
52
70
  end
@@ -34,12 +34,13 @@ module Locomotive
34
34
  content_type.select_fields.each do |field|
35
35
  if (option = attributes.delete(field.name.to_sym)).is_a?(Hash)
36
36
  attributes[:"#{field.name}_id"] = option.inject({}) do |memo, (locale, name)|
37
- field.select_options.scope.locale = locale
38
- memo[locale] = field.select_options.by_name(name).try(:_id)
37
+ field.select_options.scope.with_locale(locale) do
38
+ memo[locale] = field.select_options.by_name(name).try(:_id)
39
+ end
39
40
  memo
40
41
  end
41
42
  else
42
- attributes[:"#{field.name}_id"] = option
43
+ attributes[:"#{field.name}_id"] = field.select_options.by_name(option).try(:_id)
43
44
  end
44
45
  end
45
46
  end