locomotivecms_steam 0.1.1 → 0.1.2.pre.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -2
  3. data/CHANGELOG.md +5 -0
  4. data/Gemfile +10 -2
  5. data/Gemfile.lock +37 -49
  6. data/Rakefile +5 -10
  7. data/example/server.rb +10 -6
  8. data/lib/locomotive/steam.rb +46 -0
  9. data/lib/locomotive/steam/configuration.rb +13 -0
  10. data/lib/locomotive/steam/decorators.rb +1 -0
  11. data/lib/locomotive/steam/decorators/page_decorator.rb +50 -0
  12. data/lib/locomotive/steam/entities/content_type.rb +11 -0
  13. data/lib/locomotive/steam/entities/page.rb +136 -0
  14. data/lib/locomotive/steam/entities/site.rb +30 -0
  15. data/lib/locomotive/steam/initializers/dragonfly.rb +3 -4
  16. data/lib/locomotive/steam/liquid.rb +1 -12
  17. data/lib/locomotive/steam/liquid/drops/base.rb +1 -1
  18. data/lib/locomotive/steam/liquid/drops/content_entry.rb +3 -2
  19. data/lib/locomotive/steam/liquid/drops/content_types.rb +4 -2
  20. data/lib/locomotive/steam/liquid/drops/page.rb +4 -3
  21. data/lib/locomotive/steam/liquid/drops/site.rb +3 -2
  22. data/lib/locomotive/steam/liquid/patches.rb +4 -8
  23. data/lib/locomotive/steam/liquid/tags/nav.rb +19 -17
  24. data/lib/locomotive/steam/loaders/yml/pages_loader.rb +193 -0
  25. data/lib/locomotive/steam/loaders/yml/site_loader.rb +49 -0
  26. data/lib/locomotive/steam/loaders/yml/utils/localized_tree.rb +33 -0
  27. data/lib/locomotive/steam/loaders/yml/utils/yaml_front_matters_template.rb +66 -0
  28. data/lib/locomotive/steam/loaders/yml_loader.rb +33 -0
  29. data/lib/locomotive/steam/mapper.rb +86 -0
  30. data/lib/locomotive/steam/middlewares/base.rb +12 -10
  31. data/lib/locomotive/steam/middlewares/locale.rb +3 -4
  32. data/lib/locomotive/steam/middlewares/page.rb +18 -18
  33. data/lib/locomotive/steam/middlewares/renderer.rb +41 -15
  34. data/lib/locomotive/steam/middlewares/stack.rb +1 -1
  35. data/lib/locomotive/steam/monkey_patches.rb +1 -2
  36. data/lib/locomotive/steam/monkey_patches/haml.rb +1 -1
  37. data/lib/locomotive/steam/repositories/content_types_repository.rb +14 -0
  38. data/lib/locomotive/steam/repositories/pages_repository.rb +23 -0
  39. data/lib/locomotive/steam/repositories/sites_repository.rb +16 -0
  40. data/lib/locomotive/steam/server.rb +14 -11
  41. data/lib/locomotive/steam/services/external_api.rb +2 -1
  42. data/lib/locomotive/steam/services/markdown.rb +3 -12
  43. data/lib/locomotive/steam/standalone_server.rb +2 -2
  44. data/lib/locomotive/steam/version.rb +4 -1
  45. data/locomotivecms_steam.gemspec +11 -5
  46. data/spec/fixtures/default/app/views/pages/basic.liquid.haml +13 -0
  47. data/spec/fixtures/default/config/site.yml +2 -2
  48. data/spec/integration/server/basic_spec.rb +22 -17
  49. data/spec/integration/server/contact_form_spec.rb +1 -1
  50. data/spec/integration/server/liquid_spec.rb +2 -2
  51. data/spec/integration/server/with_scope_spec.rb +2 -2
  52. data/spec/spec_helper.rb +15 -4
  53. data/spec/support/helpers.rb +26 -8
  54. data/spec/unit/decorators/page_decorator_spec.rb +55 -0
  55. data/spec/unit/entities/page_spec.rb +50 -0
  56. data/spec/unit/entities/site_spec.rb +12 -0
  57. data/spec/unit/liquid/tags/nav_spec.rb +159 -0
  58. data/spec/unit/loaders/pages_loader_spec.rb +42 -0
  59. data/spec/unit/loaders/site_loader_spec.rb +21 -0
  60. data/spec/unit/loaders/utils/localized_tree_spec.rb +33 -0
  61. data/spec/unit/loaders/utils/yaml_front_matters_template_spec.rb +39 -0
  62. data/spec/unit/middlewares/base_spec.rb +20 -0
  63. data/spec/unit/middlewares/page_spec.rb +51 -0
  64. data/spec/unit/repositories/pages_spec.rb +11 -0
  65. metadata +128 -23
  66. data/bin/publish +0 -28
  67. data/lib/locomotive/steam/misc.rb +0 -10
  68. data/lib/locomotive/steam/monkey_patches/mounter.rb +0 -54
  69. data/lib/steam.rb +0 -3
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ require_relative '../../../lib/locomotive/steam/middlewares/base'
4
+
5
+ describe Locomotive::Steam::Middlewares::Base do
6
+ let(:app) { ->(env) { [200, env, 'app'] }}
7
+
8
+ let :middleware do
9
+ Locomotive::Steam::Middlewares::Base.new(app)
10
+ end
11
+
12
+ specify "return 200" do
13
+ code, headers, response = middleware.call env_for('http://www.example.com', { 'steam.path' => 'my path' })
14
+ expect(code).to eq(200)
15
+ end
16
+
17
+ def env_for url, opts={}
18
+ Rack::MockRequest.env_for(url, opts)
19
+ end
20
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ require_relative '../../../lib/locomotive/steam/middlewares/base'
4
+ require_relative '../../../lib/locomotive/steam/middlewares/page'
5
+
6
+ describe Locomotive::Steam::Middlewares::Page do
7
+ let(:app) { ->(env) { [200, env, 'app'] }}
8
+
9
+ let :middleware do
10
+ Locomotive::Steam::Middlewares::Page.new(app)
11
+ end
12
+
13
+ context 'rack testing' do
14
+ let(:page) do
15
+ double(title: 'title', fullpath: 'fullpath')
16
+ end
17
+
18
+ before do
19
+ expect(middleware).to receive(:fetch_page).with('wk') { page }
20
+ expect(Locomotive::Common::Logger).to receive(:info).with("Found page \"title\" [fullpath]") { nil }
21
+ end
22
+
23
+ subject do
24
+ middleware.call env_for('http://www.example.com', { 'steam.locale' => 'wk' })
25
+ end
26
+
27
+ specify 'return 200' do
28
+ code, headers, response = subject
29
+ expect(code).to eq(200)
30
+ end
31
+
32
+ specify 'set page' do
33
+ code, headers, response = subject
34
+ expect(headers['steam.page']).to eq(page)
35
+ end
36
+ end
37
+
38
+ context 'test in isolation' do
39
+ describe '#path_combinations' do
40
+ specify do
41
+ expect(
42
+ middleware.send(:path_combinations, 'projects/project-2')
43
+ ).to eq(['projects/project-2', 'projects/*', '*/project-2'])
44
+ end
45
+ end
46
+ end
47
+
48
+ def env_for url, opts={}
49
+ Rack::MockRequest.env_for(url, opts)
50
+ end
51
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Locomotive::Steam::Repository::PagesRepository' do
4
+
5
+ describe '#[]' do
6
+ end
7
+
8
+ describe '#matching_path' do
9
+ end
10
+
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: locomotivecms_steam
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2.pre.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - Didier Lafforgue
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-04-14 00:00:00.000000000 Z
14
+ date: 2014-06-24 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -125,6 +125,34 @@ dependencies:
125
125
  - - ">="
126
126
  - !ruby/object:Gem::Version
127
127
  version: '0'
128
+ - !ruby/object:Gem::Dependency
129
+ name: httparty
130
+ requirement: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - "~>"
133
+ - !ruby/object:Gem::Version
134
+ version: '0.13'
135
+ type: :runtime
136
+ prerelease: false
137
+ version_requirements: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - "~>"
140
+ - !ruby/object:Gem::Version
141
+ version: '0.13'
142
+ - !ruby/object:Gem::Dependency
143
+ name: httmultiparty
144
+ requirement: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - "~>"
147
+ - !ruby/object:Gem::Version
148
+ version: 0.3.10
149
+ type: :runtime
150
+ prerelease: false
151
+ version_requirements: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - "~>"
154
+ - !ruby/object:Gem::Version
155
+ version: 0.3.10
128
156
  - !ruby/object:Gem::Dependency
129
157
  name: rack-cache
130
158
  requirement: !ruby/object:Gem::Requirement
@@ -210,33 +238,75 @@ dependencies:
210
238
  - !ruby/object:Gem::Version
211
239
  version: '3.0'
212
240
  - !ruby/object:Gem::Dependency
213
- name: redcarpet
241
+ name: kramdown
214
242
  requirement: !ruby/object:Gem::Requirement
215
243
  requirements:
216
244
  - - "~>"
217
245
  - !ruby/object:Gem::Version
218
- version: '3.1'
246
+ version: 1.3.3
219
247
  type: :runtime
220
248
  prerelease: false
221
249
  version_requirements: !ruby/object:Gem::Requirement
222
250
  requirements:
223
251
  - - "~>"
224
252
  - !ruby/object:Gem::Version
225
- version: '3.1'
253
+ version: 1.3.3
226
254
  - !ruby/object:Gem::Dependency
227
- name: locomotivecms_mounter
255
+ name: coffee-script
228
256
  requirement: !ruby/object:Gem::Requirement
229
257
  requirements:
230
- - - ">="
258
+ - - "~>"
231
259
  - !ruby/object:Gem::Version
232
- version: '0'
260
+ version: 2.2.0
233
261
  type: :runtime
234
262
  prerelease: false
235
263
  version_requirements: !ruby/object:Gem::Requirement
236
264
  requirements:
237
- - - ">="
265
+ - - "~>"
238
266
  - !ruby/object:Gem::Version
239
- version: '0'
267
+ version: 2.2.0
268
+ - !ruby/object:Gem::Dependency
269
+ name: haml
270
+ requirement: !ruby/object:Gem::Requirement
271
+ requirements:
272
+ - - "~>"
273
+ - !ruby/object:Gem::Version
274
+ version: 4.0.3
275
+ type: :runtime
276
+ prerelease: false
277
+ version_requirements: !ruby/object:Gem::Requirement
278
+ requirements:
279
+ - - "~>"
280
+ - !ruby/object:Gem::Version
281
+ version: 4.0.3
282
+ - !ruby/object:Gem::Dependency
283
+ name: compass
284
+ requirement: !ruby/object:Gem::Requirement
285
+ requirements:
286
+ - - "~>"
287
+ - !ruby/object:Gem::Version
288
+ version: 0.12.2
289
+ type: :runtime
290
+ prerelease: false
291
+ version_requirements: !ruby/object:Gem::Requirement
292
+ requirements:
293
+ - - "~>"
294
+ - !ruby/object:Gem::Version
295
+ version: 0.12.2
296
+ - !ruby/object:Gem::Dependency
297
+ name: locomotivecms_models
298
+ requirement: !ruby/object:Gem::Requirement
299
+ requirements:
300
+ - - "~>"
301
+ - !ruby/object:Gem::Version
302
+ version: 0.0.1.pre.alpha
303
+ type: :runtime
304
+ prerelease: false
305
+ version_requirements: !ruby/object:Gem::Requirement
306
+ requirements:
307
+ - - "~>"
308
+ - !ruby/object:Gem::Version
309
+ version: 0.0.1.pre.alpha
240
310
  - !ruby/object:Gem::Dependency
241
311
  name: locomotivecms-solid
242
312
  requirement: !ruby/object:Gem::Requirement
@@ -257,22 +327,21 @@ dependencies:
257
327
  requirements:
258
328
  - - "~>"
259
329
  - !ruby/object:Gem::Version
260
- version: 0.0.1
330
+ version: 0.0.2
261
331
  type: :runtime
262
332
  prerelease: false
263
333
  version_requirements: !ruby/object:Gem::Requirement
264
334
  requirements:
265
335
  - - "~>"
266
336
  - !ruby/object:Gem::Version
267
- version: 0.0.1
337
+ version: 0.0.2
268
338
  description: The LocomotiveCMS steam is a front end server LocomotiveCMS libraries
269
339
  email:
270
340
  - did@locomotivecms.com
271
341
  - papipo@gmail.com
272
342
  - arnaud@sellenet.fr
273
343
  - joel.azemar@gmail.com
274
- executables:
275
- - publish
344
+ executables: []
276
345
  extensions: []
277
346
  extra_rdoc_files: []
278
347
  files:
@@ -284,7 +353,6 @@ files:
284
353
  - LICENSE
285
354
  - README.md
286
355
  - Rakefile
287
- - bin/publish
288
356
  - config/locales/de.yml
289
357
  - config/locales/en.yml
290
358
  - config/locales/es.yml
@@ -297,12 +365,19 @@ files:
297
365
  - config/locales/pt-BR.yml
298
366
  - config/locales/ru.yml
299
367
  - example/server.rb
368
+ - lib/locomotive/steam.rb
369
+ - lib/locomotive/steam/configuration.rb
300
370
  - lib/locomotive/steam/core_ext.rb
301
371
  - lib/locomotive/steam/core_ext/array.rb
302
372
  - lib/locomotive/steam/core_ext/boolean/false.rb
303
373
  - lib/locomotive/steam/core_ext/boolean/true.rb
304
374
  - lib/locomotive/steam/core_ext/hash.rb
305
375
  - lib/locomotive/steam/core_ext/string.rb
376
+ - lib/locomotive/steam/decorators.rb
377
+ - lib/locomotive/steam/decorators/page_decorator.rb
378
+ - lib/locomotive/steam/entities/content_type.rb
379
+ - lib/locomotive/steam/entities/page.rb
380
+ - lib/locomotive/steam/entities/site.rb
306
381
  - lib/locomotive/steam/exceptions.rb
307
382
  - lib/locomotive/steam/initializers.rb
308
383
  - lib/locomotive/steam/initializers/dragonfly.rb
@@ -347,6 +422,12 @@ files:
347
422
  - lib/locomotive/steam/liquid/tags/session_assign.rb
348
423
  - lib/locomotive/steam/liquid/tags/snippet.rb
349
424
  - lib/locomotive/steam/liquid/tags/with_scope.rb
425
+ - lib/locomotive/steam/loaders/yml/pages_loader.rb
426
+ - lib/locomotive/steam/loaders/yml/site_loader.rb
427
+ - lib/locomotive/steam/loaders/yml/utils/localized_tree.rb
428
+ - lib/locomotive/steam/loaders/yml/utils/yaml_front_matters_template.rb
429
+ - lib/locomotive/steam/loaders/yml_loader.rb
430
+ - lib/locomotive/steam/mapper.rb
350
431
  - lib/locomotive/steam/middlewares.rb
351
432
  - lib/locomotive/steam/middlewares/base.rb
352
433
  - lib/locomotive/steam/middlewares/dynamic_assets.rb
@@ -361,10 +442,11 @@ files:
361
442
  - lib/locomotive/steam/middlewares/static_assets.rb
362
443
  - lib/locomotive/steam/middlewares/templatized_page.rb
363
444
  - lib/locomotive/steam/middlewares/timezone.rb
364
- - lib/locomotive/steam/misc.rb
365
445
  - lib/locomotive/steam/monkey_patches.rb
366
446
  - lib/locomotive/steam/monkey_patches/haml.rb
367
- - lib/locomotive/steam/monkey_patches/mounter.rb
447
+ - lib/locomotive/steam/repositories/content_types_repository.rb
448
+ - lib/locomotive/steam/repositories/pages_repository.rb
449
+ - lib/locomotive/steam/repositories/sites_repository.rb
368
450
  - lib/locomotive/steam/server.rb
369
451
  - lib/locomotive/steam/services.rb
370
452
  - lib/locomotive/steam/services/dragonfly.rb
@@ -372,7 +454,6 @@ files:
372
454
  - lib/locomotive/steam/services/markdown.rb
373
455
  - lib/locomotive/steam/standalone_server.rb
374
456
  - lib/locomotive/steam/version.rb
375
- - lib/steam.rb
376
457
  - locomotivecms_steam.gemspec
377
458
  - spec/fixtures/default/README
378
459
  - spec/fixtures/default/app/content_types/bands.yml
@@ -389,6 +470,7 @@ files:
389
470
  - spec/fixtures/default/app/views/pages/about_us/john_doe.liquid.haml
390
471
  - spec/fixtures/default/app/views/pages/all.liquid.haml
391
472
  - spec/fixtures/default/app/views/pages/archives/news.liquid.haml
473
+ - spec/fixtures/default/app/views/pages/basic.liquid.haml
392
474
  - spec/fixtures/default/app/views/pages/contact.liquid.haml
393
475
  - spec/fixtures/default/app/views/pages/contest.liquid.haml
394
476
  - spec/fixtures/default/app/views/pages/events.liquid.haml
@@ -450,6 +532,17 @@ files:
450
532
  - spec/support/examples/matching_locale.rb
451
533
  - spec/support/helpers.rb
452
534
  - spec/support/matchers/hash.rb
535
+ - spec/unit/decorators/page_decorator_spec.rb
536
+ - spec/unit/entities/page_spec.rb
537
+ - spec/unit/entities/site_spec.rb
538
+ - spec/unit/liquid/tags/nav_spec.rb
539
+ - spec/unit/loaders/pages_loader_spec.rb
540
+ - spec/unit/loaders/site_loader_spec.rb
541
+ - spec/unit/loaders/utils/localized_tree_spec.rb
542
+ - spec/unit/loaders/utils/yaml_front_matters_template_spec.rb
543
+ - spec/unit/middlewares/base_spec.rb
544
+ - spec/unit/middlewares/page_spec.rb
545
+ - spec/unit/repositories/pages_spec.rb
453
546
  homepage: https://github.com/locomotivecms/steam
454
547
  licenses:
455
548
  - MIT
@@ -460,17 +553,17 @@ require_paths:
460
553
  - lib
461
554
  required_ruby_version: !ruby/object:Gem::Requirement
462
555
  requirements:
463
- - - "~>"
556
+ - - ">="
464
557
  - !ruby/object:Gem::Version
465
- version: '2.0'
558
+ version: '0'
466
559
  required_rubygems_version: !ruby/object:Gem::Requirement
467
560
  requirements:
468
- - - ">="
561
+ - - ">"
469
562
  - !ruby/object:Gem::Version
470
- version: '0'
563
+ version: 1.3.1
471
564
  requirements: []
472
565
  rubyforge_project:
473
- rubygems_version: 2.1.11
566
+ rubygems_version: 2.2.2
474
567
  signing_key:
475
568
  specification_version: 4
476
569
  summary: The LocomotiveCMS steam is a technical piece for compiled and steam front
@@ -491,6 +584,7 @@ test_files:
491
584
  - spec/fixtures/default/app/views/pages/about_us/john_doe.liquid.haml
492
585
  - spec/fixtures/default/app/views/pages/all.liquid.haml
493
586
  - spec/fixtures/default/app/views/pages/archives/news.liquid.haml
587
+ - spec/fixtures/default/app/views/pages/basic.liquid.haml
494
588
  - spec/fixtures/default/app/views/pages/contact.liquid.haml
495
589
  - spec/fixtures/default/app/views/pages/contest.liquid.haml
496
590
  - spec/fixtures/default/app/views/pages/events.liquid.haml
@@ -552,3 +646,14 @@ test_files:
552
646
  - spec/support/examples/matching_locale.rb
553
647
  - spec/support/helpers.rb
554
648
  - spec/support/matchers/hash.rb
649
+ - spec/unit/decorators/page_decorator_spec.rb
650
+ - spec/unit/entities/page_spec.rb
651
+ - spec/unit/entities/site_spec.rb
652
+ - spec/unit/liquid/tags/nav_spec.rb
653
+ - spec/unit/loaders/pages_loader_spec.rb
654
+ - spec/unit/loaders/site_loader_spec.rb
655
+ - spec/unit/loaders/utils/localized_tree_spec.rb
656
+ - spec/unit/loaders/utils/yaml_front_matters_template_spec.rb
657
+ - spec/unit/middlewares/base_spec.rb
658
+ - spec/unit/middlewares/page_spec.rb
659
+ - spec/unit/repositories/pages_spec.rb
data/bin/publish DELETED
@@ -1,28 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require_relative '../lib/steam'
4
-
5
- # bin/publish
6
-
7
- class Publish
8
-
9
- def start # version, rvm=false
10
- # system "rvm use #{rvm}"
11
-
12
- system "bundle && bundle exec rspec"
13
- system "gem build locomotivecms_steam.gemspec"
14
- system "git tag -a v#{Locomotive::Steam::VERSION} -m 'version #{Locomotive::Steam::VERSION}'"
15
- system "git push --tags"
16
- system "gem push locomotivecms_steam-#{Locomotive::Steam::VERSION}.gem"
17
- system "git push origin master"
18
- end
19
-
20
- end
21
-
22
- # if ARGV.length != 1 # or !ARGV[0].match(/\d{1,3}.\d{1,3}.\d{1,3}/)
23
- # puts 'HELP: '
24
- # puts '$ bin/publish [ruby-2.1.1@steam]'
25
- # exit 0
26
- # end
27
-
28
- Publish.new.start # ARGV[0]
@@ -1,10 +0,0 @@
1
- require_relative 'core_ext.rb'
2
-
3
- require_relative 'initializers/i18n.rb'
4
- require_relative 'initializers/markdown.rb'
5
- require_relative 'initializers/will_paginate.rb'
6
-
7
- require_relative 'monkey_patches/httparty.rb'
8
- require_relative 'monkey_patches/dragonfly.rb'
9
- require_relative 'monkey_patches/mounter.rb'
10
- require_relative 'monkey_patches/haml.rb'
@@ -1,54 +0,0 @@
1
- require 'locomotive/mounter'
2
-
3
- module Locomotive
4
- module Mounter
5
- module Models
6
- class Page
7
-
8
- def render(context)
9
- self.parse(context).render(context)
10
- end
11
-
12
- protected
13
-
14
- def parse(context)
15
- options = {
16
- page: self,
17
- mounting_point: context.registers[:mounting_point],
18
- error_mode: :strict,
19
- count_lines: true
20
- }
21
-
22
- begin
23
- template = ::Liquid::Template.parse(self.source, options)
24
- rescue Liquid::SyntaxError => e
25
- # do it again on the raw source instead so that the error line matches
26
- # the source file.
27
- ::Liquid::Template.parse(self.template.raw_source, options)
28
- end
29
- end
30
-
31
- end
32
- end
33
-
34
- module Reader
35
- module FileSystem
36
- class Runner
37
-
38
- def new_mounting_point(host)
39
- self.mounting_point
40
- end
41
-
42
- end
43
- end
44
- end
45
-
46
- class MountingPoint
47
-
48
- def assets_path
49
- File.join(self.path, 'public')
50
- end
51
-
52
- end
53
- end
54
- end