locomotivecms_steam 1.5.3 → 1.6.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +1 -3
  4. data/Gemfile +2 -3
  5. data/Gemfile.lock +57 -54
  6. data/README.md +17 -8
  7. data/bin/steam.rb +3 -13
  8. data/lib/locomotive/steam/adapters/filesystem/sanitizers/content_entry.rb +1 -1
  9. data/lib/locomotive/steam/adapters/mongodb.rb +3 -2
  10. data/lib/locomotive/steam/entities/theme_asset.rb +0 -1
  11. data/lib/locomotive/steam/liquid/drops/section.rb +31 -2
  12. data/lib/locomotive/steam/liquid/drops/section_block.rb +13 -0
  13. data/lib/locomotive/steam/liquid/drops/section_content_proxy.rb +44 -5
  14. data/lib/locomotive/steam/liquid/drops/section_editor_setting_data.rb +1 -1
  15. data/lib/locomotive/steam/liquid/tags/concerns/path.rb +1 -1
  16. data/lib/locomotive/steam/liquid/tags/concerns/section.rb +1 -1
  17. data/lib/locomotive/steam/liquid/tags/section.rb +6 -1
  18. data/lib/locomotive/steam/middlewares/logging.rb +4 -1
  19. data/lib/locomotive/steam/middlewares/site.rb +1 -1
  20. data/lib/locomotive/steam/repositories/content_entry_repository.rb +3 -3
  21. data/lib/locomotive/steam/repositories/content_type_field_select_option_repository.rb +8 -1
  22. data/lib/locomotive/steam/services/asset_host_service.rb +1 -1
  23. data/lib/locomotive/steam/services/url_finder_service.rb +2 -0
  24. data/lib/locomotive/steam/version.rb +1 -1
  25. data/lib/locomotive/steam.rb +2 -2
  26. data/locomotivecms_steam.gemspec +8 -8
  27. data/script/ci/before_build.sh +1 -0
  28. data/spec/fixtures/default/public/fonts/chunkfive-webfont.eot +0 -0
  29. data/spec/fixtures/default/public/fonts/chunkfive-webfont.svg +0 -0
  30. data/spec/fixtures/default/public/fonts/chunkfive-webfont.ttf +0 -0
  31. data/spec/fixtures/default/public/fonts/chunkfive-webfont.woff +0 -0
  32. data/spec/fixtures/default/public/fonts/chunkfive.css +0 -0
  33. data/spec/fixtures/default/public/fonts/chunkfive.otf +0 -0
  34. data/spec/integration/adapters/mongodb_spec.rb +5 -5
  35. data/spec/integration/liquid/drops/content_types_spec.rb +62 -0
  36. data/spec/integration/repositories/content_entry_repository_spec.rb +5 -0
  37. data/spec/unit/liquid/drops/section_block_spec.rb +26 -0
  38. data/spec/unit/liquid/drops/section_content_proxy_spec.rb +61 -2
  39. data/spec/unit/liquid/drops/section_spec.rb +31 -4
  40. data/spec/unit/liquid/tags/section_spec.rb +8 -9
  41. data/spec/unit/middlewares/cache_spec.rb +4 -4
  42. data/spec/unit/middlewares/section_spec.rb +3 -3
  43. data/spec/unit/middlewares/site_spec.rb +11 -1
  44. data/spec/unit/services/url_finder_service_spec.rb +25 -11
  45. metadata +35 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f5fcd89084fca2167fb869e5819dce44029256761bbed64ceaec4274b4d24bfc
4
- data.tar.gz: fc263ea755d1e716e2f288a2a8b88ed87419b47916a8a1945f4b13679a380744
3
+ metadata.gz: 0d35b741fa9c5e6b037bbd68927bc8649fc84f8af37d2f78a985cfa69152dfcd
4
+ data.tar.gz: c49d4e7241cd13cbe04d243efb260563b6f3dd9a4fd5e3c28a5ce45b5843ebbe
5
5
  SHA512:
6
- metadata.gz: f8d908e44d028406732eae11fc5fdc73b774a684afef6b4cf40a55c0b27342dc86bd3ed512ffb77917fcedae0c4791ba4bc6d25418ef284587f0c191d18a9e3f
7
- data.tar.gz: 46357b80f3a669cb0306045ecd5dbb961aed2d2c9124836aaebd2583752d757df4b43c8be8c34a1df15894362d3c85640899c38264df4a848e82b2a9e64b7e75
6
+ metadata.gz: bcac97ad438cce9af46f52444acbcc27c6124a8c73cc05d186778b1db3c527ecbfefffaa0ee19cab1dd8936cbb1f8c28ae8fa9964c04ec9599c748ca94add9f3
7
+ data.tar.gz: 457eae026dfbcbff8eefd1720dc659fea6f79e97259a9106988c5c5ccab77b5653d0c594bdb4a747d3ec3a8334ce3e6162a47f36dce165f6162471a1bde06ab2
data/.gitignore CHANGED
@@ -13,6 +13,7 @@ test/tmp
13
13
  test/version_tmp
14
14
  tmp
15
15
  benchmark.rb
16
+ .DS_Store
16
17
 
17
18
  # YARD artifacts
18
19
  .yardoc
data/.travis.yml CHANGED
@@ -2,10 +2,8 @@ language: ruby
2
2
  services: mongodb
3
3
  before_script: ./script/ci/before_build.sh
4
4
  rvm:
5
- - 2.6.1
6
5
  - 2.6.5
7
- env:
8
- - CODECLIMATE_REPO_TOKEN=3fa74f2ade25037fccd7261090acbdeae232639c3a83aafb80ee428ec16b8cf9
6
+ - 2.7.2
9
7
  addons:
10
8
  code_climate:
11
9
  repo_token: 3fa74f2ade25037fccd7261090acbdeae232639c3a83aafb80ee428ec16b8cf9
data/Gemfile CHANGED
@@ -9,8 +9,8 @@ group :development do
9
9
  # gem 'duktape', github: 'judofyr/duktape.rb', ref: '20ef6a5'
10
10
  # gem 'duktape', github: 'did/duktape.rb', branch: 'any-fixnum'
11
11
 
12
- gem 'puma', '~> 4.3.1'
13
- gem 'haml', '~> 5.0.4'
12
+ gem 'puma', '~> 5.3.1'
13
+ gem 'haml', '~> 5.2.0'
14
14
 
15
15
  gem 'rack-mini-profiler', '~> 0.10.1'
16
16
  gem 'flamegraph'
@@ -29,6 +29,5 @@ group :test do
29
29
 
30
30
  gem 'rack-test', '~> 0.8.2'
31
31
 
32
- gem 'codeclimate-test-reporter', '~> 0.4.7', require: false
33
32
  gem 'coveralls', '~> 0.8.1', require: false
34
33
  end
data/Gemfile.lock CHANGED
@@ -1,30 +1,30 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- locomotivecms_steam (1.5.3)
4
+ locomotivecms_steam (1.6.0.beta1)
5
5
  RedCloth (~> 4.3.2)
6
6
  autoprefixer-rails (~> 8.0.0)
7
7
  bcrypt (~> 3.1.11)
8
8
  chronic (~> 0.10.2)
9
9
  coffee-script (~> 2.4.1)
10
10
  compass (~> 1.0.3)
11
- dragonfly (~> 1.2.0)
11
+ dragonfly (>= 1.2, < 1.5)
12
12
  duktape (~> 2.0.1.1)
13
13
  httparty (~> 0.16.0)
14
- kramdown (~> 1.16.2)
14
+ kramdown (~> 2.3.0)
15
15
  liquid (~> 4.0.3)
16
16
  locomotivecms_common (~> 0.4.0)
17
- mime-types (~> 3.1.0)
17
+ mime-types (~> 3.3.0)
18
18
  mimetype-fu (~> 0.1.2)
19
19
  moneta (~> 1.0.0)
20
20
  morphine (~> 0.1.1)
21
- multi_json (~> 1.13.1)
22
- nokogiri (~> 1.10.8)
21
+ multi_json (~> 1.15.0)
22
+ nokogiri (~> 1.11.0)
23
23
  pony (~> 1.12)
24
24
  rack-cache (~> 1.7.0)
25
25
  rack-rewrite (~> 1.5.1)
26
26
  rack_csrf (~> 2.6.0)
27
- sanitize (~> 4.6.4)
27
+ sanitize (~> 5.2.1)
28
28
  sass (~> 3.4.25)
29
29
  sprockets (~> 3.7.1)
30
30
  uglifier (~> 4.1.3)
@@ -33,22 +33,20 @@ GEM
33
33
  remote: https://rubygems.org/
34
34
  specs:
35
35
  RedCloth (4.3.2)
36
- activesupport (5.2.4.1)
36
+ activesupport (5.2.6)
37
37
  concurrent-ruby (~> 1.0, >= 1.0.2)
38
38
  i18n (>= 0.7, < 2)
39
39
  minitest (~> 5.1)
40
40
  tzinfo (~> 1.1)
41
- addressable (2.7.0)
41
+ addressable (2.8.0)
42
42
  public_suffix (>= 2.0.2, < 5.0)
43
43
  attr_extras (5.2.0)
44
44
  autoprefixer-rails (8.0.0)
45
45
  execjs
46
- bcrypt (3.1.13)
47
- bson (4.6.0)
46
+ bcrypt (3.1.16)
47
+ bson (4.11.1)
48
48
  chronic (0.10.2)
49
- chunky_png (1.3.11)
50
- codeclimate-test-reporter (0.4.8)
51
- simplecov (>= 0.7.1, < 1.0.0)
49
+ chunky_png (1.4.0)
52
50
  coffee-script (2.4.1)
53
51
  coffee-script-source
54
52
  execjs
@@ -66,7 +64,7 @@ GEM
66
64
  sass (>= 3.3.0, < 3.5)
67
65
  compass-import-once (1.0.5)
68
66
  sass (>= 3.2, < 3.5)
69
- concurrent-ruby (1.1.5)
67
+ concurrent-ruby (1.1.7)
70
68
  coveralls (0.8.23)
71
69
  json (>= 1.8, < 3)
72
70
  simplecov (~> 0.16.1)
@@ -74,33 +72,34 @@ GEM
74
72
  thor (>= 0.19.4, < 2.0)
75
73
  tins (~> 1.6)
76
74
  crass (1.0.6)
77
- diff-lcs (1.3)
75
+ diff-lcs (1.4.4)
78
76
  docile (1.3.2)
79
- dragonfly (1.2.0)
77
+ dragonfly (1.4.0)
80
78
  addressable (~> 2.3)
81
79
  multi_json (~> 1.0)
82
80
  rack (>= 1.3)
83
81
  duktape (2.0.1.1)
84
- execjs (2.7.0)
85
- ffi (1.12.2)
82
+ execjs (2.8.1)
83
+ ffi (1.15.4)
86
84
  flamegraph (0.9.5)
87
- haml (5.0.4)
85
+ haml (5.2.0)
88
86
  temple (>= 0.8.0)
89
87
  tilt
90
88
  httparty (0.16.4)
91
89
  mime-types (~> 3.0)
92
90
  multi_xml (>= 0.5.2)
93
- i18n (1.7.0)
91
+ i18n (1.8.5)
94
92
  concurrent-ruby (~> 1.0)
95
93
  i18n-spec (0.6.0)
96
94
  iso
97
- iso (0.2.2)
95
+ iso (0.3.0)
98
96
  i18n
99
- json (2.2.0)
97
+ json (2.3.1)
100
98
  json_spec (1.1.5)
101
99
  multi_json (~> 1.0)
102
100
  rspec (>= 2.0, < 4.0)
103
- kramdown (1.16.2)
101
+ kramdown (2.3.1)
102
+ rexml
104
103
  liquid (4.0.3)
105
104
  locomotivecms_common (0.4.0)
106
105
  activesupport (>= 5.1.5, < 6.0)
@@ -110,31 +109,33 @@ GEM
110
109
  mail (2.7.1)
111
110
  mini_mime (>= 0.1.1)
112
111
  memory_profiler (0.9.14)
113
- mime-types (3.1)
112
+ mime-types (3.3.1)
114
113
  mime-types-data (~> 3.2015)
115
- mime-types-data (3.2019.1009)
114
+ mime-types-data (3.2021.0901)
116
115
  mimetype-fu (0.1.2)
117
- mini_mime (1.0.2)
118
- mini_portile2 (2.4.0)
119
- minitest (5.14.0)
116
+ mini_mime (1.1.1)
117
+ mini_portile2 (2.5.3)
118
+ minitest (5.14.4)
120
119
  moneta (1.0.0)
121
- mongo (2.8.0)
122
- bson (>= 4.4.2, < 5.0.0)
120
+ mongo (2.13.1)
121
+ bson (>= 4.8.2, < 5.0.0)
123
122
  morphine (0.1.1)
124
- multi_json (1.13.1)
123
+ multi_json (1.15.0)
125
124
  multi_xml (0.6.0)
126
- nio4r (2.5.2)
127
- nokogiri (1.10.8)
128
- mini_portile2 (~> 2.4.0)
129
- nokogumbo (1.5.0)
130
- nokogiri
125
+ nio4r (2.5.7)
126
+ nokogiri (1.11.7)
127
+ mini_portile2 (~> 2.5.0)
128
+ racc (~> 1.4)
129
+ nokogumbo (2.0.5)
130
+ nokogiri (~> 1.8, >= 1.8.4)
131
131
  origin (2.3.1)
132
132
  pony (1.13.1)
133
133
  mail (>= 2.0)
134
- public_suffix (4.0.3)
135
- puma (4.3.1)
134
+ public_suffix (4.0.6)
135
+ puma (5.3.2)
136
136
  nio4r (~> 2.0)
137
- rack (2.0.8)
137
+ racc (1.5.2)
138
+ rack (2.2.3)
138
139
  rack-cache (1.7.2)
139
140
  rack (>= 0.4)
140
141
  rack-mini-profiler (0.10.7)
@@ -145,9 +146,10 @@ GEM
145
146
  rack_csrf (2.6.0)
146
147
  rack (>= 1.1.0)
147
148
  rake (13.0.1)
148
- rb-fsevent (0.10.3)
149
+ rb-fsevent (0.11.0)
149
150
  rb-inotify (0.10.1)
150
151
  ffi (~> 1.0)
152
+ rexml (3.2.5)
151
153
  rspec (3.7.0)
152
154
  rspec-core (~> 3.7.0)
153
155
  rspec-expectations (~> 3.7.0)
@@ -161,10 +163,10 @@ GEM
161
163
  diff-lcs (>= 1.2.0, < 2.0)
162
164
  rspec-support (~> 3.7.0)
163
165
  rspec-support (3.7.1)
164
- sanitize (4.6.6)
166
+ sanitize (5.2.3)
165
167
  crass (~> 1.0.2)
166
- nokogiri (>= 1.4.4)
167
- nokogumbo (~> 1.4)
168
+ nokogiri (>= 1.8.0)
169
+ nokogumbo (~> 2.0)
168
170
  sass (3.4.25)
169
171
  simplecov (0.16.1)
170
172
  docile (~> 1.1)
@@ -174,17 +176,19 @@ GEM
174
176
  sprockets (3.7.2)
175
177
  concurrent-ruby (~> 1.0)
176
178
  rack (> 1, < 3)
177
- stackprof (0.2.13)
179
+ stackprof (0.2.16)
178
180
  stringex (2.8.5)
181
+ sync (0.5.0)
179
182
  temple (0.8.2)
180
183
  term-ansicolor (1.7.1)
181
184
  tins (~> 1.0)
182
- thor (0.20.3)
185
+ thor (1.0.1)
183
186
  thread_safe (0.3.6)
184
187
  tilt (2.0.10)
185
- timecop (0.9.1)
186
- tins (1.22.2)
187
- tzinfo (1.2.6)
188
+ timecop (0.9.2)
189
+ tins (1.26.0)
190
+ sync
191
+ tzinfo (1.2.9)
188
192
  thread_safe (~> 0.1)
189
193
  uglifier (4.1.20)
190
194
  execjs (>= 0.3.0, < 3)
@@ -193,17 +197,16 @@ PLATFORMS
193
197
  ruby
194
198
 
195
199
  DEPENDENCIES
196
- codeclimate-test-reporter (~> 0.4.7)
197
200
  coveralls (~> 0.8.1)
198
201
  flamegraph
199
- haml (~> 5.0.4)
202
+ haml (~> 5.2.0)
200
203
  i18n-spec (~> 0.6.0)
201
204
  json_spec (~> 1.1.5)
202
205
  locomotivecms_steam!
203
206
  memory_profiler
204
- mongo (~> 2.8.0)
207
+ mongo (~> 2.13.1)
205
208
  origin (~> 2.3.1)
206
- puma (~> 4.3.1)
209
+ puma (~> 5.3.1)
207
210
  rack-mini-profiler (~> 0.10.1)
208
211
  rack-test (~> 0.8.2)
209
212
  rake (~> 13.0.1)
@@ -212,4 +215,4 @@ DEPENDENCIES
212
215
  timecop (~> 0.9.1)
213
216
 
214
217
  BUNDLED WITH
215
- 2.0.2
218
+ 2.1.4
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Code Climate](https://codeclimate.com/github/locomotivecms/steam/badges/gpa.svg)](https://codeclimate.com/github/locomotivecms/steam) [![Build Status](https://travis-ci.com/locomotivecms/steam.svg?branch=master)](https://travis-ci.com/locomotivecms/steam) [![Coverage Status](https://coveralls.io/repos/locomotivecms/steam/badge.svg?branch=master)](https://coveralls.io/r/locomotivecms/steam?branch=master) [![Gitter](https://img.shields.io/badge/gitter-join%20chat%20%E2%86%92-brightgreen.svg)](https://gitter.im/locomotivecms/steam)
4
4
 
5
- The rendering stack used by both Wagon and Engine (WIP). It includes:
5
+ The rendering stack used by both Wagon and Engine. It includes:
6
6
 
7
7
  - the rack stack to serve assets (SCSS, Coffeescript, ...etc) and pages.
8
8
  - the liquid drops/filters/tags libs to parse and render liquid templates.
@@ -13,8 +13,10 @@ The rendering stack used by both Wagon and Engine (WIP). It includes:
13
13
 
14
14
  ## Installation [WIP]
15
15
 
16
- gem install thin
17
- gem install locomotivecms_steam
16
+ ```bash
17
+ gem install puma
18
+ gem install locomotivecms_steam
19
+ ```
18
20
 
19
21
  ## Usage
20
22
 
@@ -24,26 +26,33 @@ The rendering stack used by both Wagon and Engine (WIP). It includes:
24
26
 
25
27
  Display all the options:
26
28
 
27
- steam --help
29
+ ```bash
30
+ steam --help
31
+ ```
28
32
 
29
33
  Render a local Wagon site:
30
34
 
31
- steam --path=<PATH to a Wagon site>
35
+ ```bash
36
+ steam --path=<PATH to a Wagon site>
37
+ ```
32
38
 
33
39
  Render a Engine site:
34
40
 
35
- steam --database=<NAME of the MongoDB database used by the Engine> --assets-path=<PATH to the public folder of the Locomotive>
41
+ ```bash
42
+ steam --database=<NAME of the MongoDB database used by the Engine> --assets-path=<PATH to the public folder of the Locomotive>
43
+ ```
36
44
 
37
45
  Once launched, open your browser
38
46
 
39
- open localhost:8080
47
+ ```bash
48
+ open localhost:8080
49
+ ```
40
50
 
41
51
  ### Inside Engine / Wagon:
42
52
 
43
53
  [https://github.com/locomotivecms/engine/blob/master/lib/locomotive/steam_adaptor.rb](https://github.com/locomotivecms/engine/blob/master/lib/locomotive/steam_adaptor.rb)
44
54
  [https://github.com/locomotivecms/engine/blob/master/spec/dummy/config/routes.rb](https://github.com/locomotivecms/engine/blob/master/spec/dummy/config/routes.rb#L12)
45
55
 
46
-
47
56
  [https://github.com/locomotivecms/wagon/blob/master/lib/locomotive/wagon/commands/serve_command.rb](https://github.com/locomotivecms/wagon/blob/master/lib/locomotive/wagon/commands/serve_command.rb#L65)
48
57
  [https://github.com/locomotivecms/wagon/blob/master/lib/locomotive/wagon/commands/serve_command.rb](https://github.com/locomotivecms/wagon/blob/master/lib/locomotive/wagon/commands/serve_command.rb#L138)
49
58
 
data/bin/steam.rb CHANGED
@@ -68,6 +68,8 @@ end.parse!
68
68
  require_relative '../lib/locomotive/steam'
69
69
  require_relative '../lib/locomotive/steam/server'
70
70
 
71
+ puts options.inspect
72
+
71
73
  Locomotive::Steam.configure do |config|
72
74
  config.mode = :test
73
75
  config.adapter = options[:adapter]
@@ -84,21 +86,9 @@ end
84
86
 
85
87
  app = Locomotive::Steam.to_app
86
88
 
87
- # Thin rack handler
88
- # Note: alt thin settings (Threaded)
89
- # require 'thin'
90
- # server = Thin::Server.new(server_options[:address], server_options[:port], app)
91
- # server.threaded = true
92
- # server.start
93
- # Locomotive::Common::Logger.info 'Server started...'
94
- # FIXME: Rack::Handler::Thin.run app (not threaded)
95
-
96
- # WEBRick rack handler
97
- # Rack::Handler::WEBrick.run app
98
- # Locomotive::Common::Logger.info 'Server started...'
99
-
100
89
  # Puma rack handler
101
90
  require 'puma'
91
+
102
92
  server = ::Puma::Server.new(app)
103
93
  server.add_tcp_listener server_options[:address], server_options[:port]
104
94
  server.min_threads = 4
@@ -53,7 +53,7 @@ module Locomotive::Steam
53
53
 
54
54
  def set_id(entity)
55
55
  # don't override the id if it was set from a MongoDB dump
56
- return if entity._id =~ /[a-z0-9]{12,}/
56
+ return if entity._id.to_s =~ /[a-z0-9]{12,}/
57
57
 
58
58
  if (slug = entity[:_slug]).respond_to?(:translations)
59
59
  entity[:_id] = slug[locale]
@@ -81,8 +81,9 @@ module Locomotive::Steam
81
81
  end
82
82
 
83
83
  def disconnect_session
84
- @session.try(:close)
85
- @session = nil
84
+ @session.try(:close).tap do
85
+ @session = nil
86
+ end
86
87
  end
87
88
 
88
89
  end
@@ -11,7 +11,6 @@ module Locomotive::Steam
11
11
  }.merge(attributes))
12
12
  end
13
13
 
14
-
15
14
  end
16
15
 
17
16
  end
@@ -51,8 +51,25 @@ module Locomotive
51
51
  end
52
52
 
53
53
  def blocks
54
- (@content['blocks'] || []).each_with_index.map do |block, index|
55
- SectionBlock.new(@section, block, index)
54
+ build_blocks(@content['blocks'])
55
+ end
56
+
57
+ def blocks_as_tree
58
+ [].tap do |root|
59
+ parents = []
60
+
61
+ build_blocks(@content['blocks']) do |block, previous_block|
62
+ if block.depth == 0
63
+ parents = [block]
64
+ root
65
+ elsif block.depth > previous_block.depth
66
+ (parents << previous_block).last.leaves
67
+ elsif (diff = previous_block.depth - block.depth) > 0
68
+ parents[parents.size - diff - 1].tap { parents.pop(diff) }.leaves
69
+ else
70
+ parents.last.leaves
71
+ end << block
72
+ end
56
73
  end
57
74
  end
58
75
 
@@ -60,6 +77,18 @@ module Locomotive
60
77
  SectionEditorSettingData.new(@section)
61
78
  end
62
79
 
80
+ private
81
+
82
+ def build_blocks(blocks)
83
+ previous_block = nil
84
+
85
+ (blocks || []).each_with_index.map do |block, index|
86
+ section_block = SectionBlock.new(@section, block, index)
87
+ yield(section_block, previous_block) if block_given?
88
+ previous_block = section_block
89
+ end
90
+ end
91
+
63
92
  end
64
93
 
65
94
  end