locomotivecms_wagon 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/generators/blank/app/views/pages/index.liquid.haml +4 -0
- data/generators/blank/config/deploy.yml +15 -15
- data/generators/content_type/app/content_types/%slug%.yml.tt +1 -1
- data/generators/page/template.liquid.haml.tt +4 -1
- data/generators/page/template.liquid.tt +3 -0
- data/lib/locomotive/wagon/generators/content_type.rb +1 -1
- data/lib/locomotive/wagon/liquid/drops/content_entry.rb +1 -0
- data/lib/locomotive/wagon/liquid/drops/content_types.rb +2 -2
- data/lib/locomotive/wagon/liquid/drops/page.rb +55 -7
- data/lib/locomotive/wagon/liquid/drops/site.rb +1 -1
- data/lib/locomotive/wagon/liquid/scopeable.rb +2 -0
- data/lib/locomotive/wagon/liquid/tags/consume.rb +13 -10
- data/lib/locomotive/wagon/liquid/tags/path_helper.rb +0 -1
- data/lib/locomotive/wagon/misc/hosting_api.rb +6 -4
- data/lib/locomotive/wagon/server/renderer.rb +1 -1
- data/lib/locomotive/wagon/version.rb +1 -1
- data/lib/locomotive/wagon.rb +2 -1
- data/locomotivecms_wagon.gemspec +1 -1
- data/spec/fixtures/default/app/views/pages/layouts/simple.liquid.haml +13 -0
- data/spec/unit/locomotive/wagon/liquid/drops/page_spec.rb +41 -0
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74651ede61e4a001e1a1aabffd7fc88115a80348
|
4
|
+
data.tar.gz: b081bf5ca8a03d1fabcd5975419eaf1535ac4312
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 211391f7500d225cf946181e9685ecd04d4a9174e0631bf2b65c27f2b30917e32976facda2661d68b79f10cd2e1dcc0e3733496cbdb337e0848893e434538f7d
|
7
|
+
data.tar.gz: 83bdfb0190f7a255a9e7203196220a17a96b4320e4b1771363cd656c3a5d7363c7a8461f851570b70782d982a1c64b8a3ce0be247ecbdeff9779cc8f21e35cef
|
data/Gemfile
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
development:
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
staging:
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
production:
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
1
|
+
# development:
|
2
|
+
# host: dev.example.com
|
3
|
+
# email: john@doe.net
|
4
|
+
# password: apassword
|
5
|
+
# # api_key: <your api key here>
|
6
|
+
# staging:
|
7
|
+
# host: staging.example.com
|
8
|
+
# email: john@doe.net
|
9
|
+
# password: apassword
|
10
|
+
# # api_key: <your api key here>
|
11
|
+
# production:
|
12
|
+
# host: www.example.com
|
13
|
+
# email: john@doe.net
|
14
|
+
# password: apassword
|
15
|
+
# # api_key: <your api key here>
|
@@ -32,7 +32,7 @@ fields: <% config[:fields].each_with_index do |field, index| %>
|
|
32
32
|
type: <%= field.type %>
|
33
33
|
required: <%= index == 0 ? true : field.required %>
|
34
34
|
hint: Explanatory text displayed in the back office
|
35
|
-
localized: <%= field.
|
35
|
+
localized: <%= field.localized %><% if field.type == 'text' %>
|
36
36
|
# text_formatting: html # html (uses rich text editor) or text (uses plain text editor)<% end -%><% if field.type == 'select' -%>
|
37
37
|
# if localized, use
|
38
38
|
# en: ['option1_en', 'option2_en']
|
@@ -11,6 +11,9 @@ listed: <% if config[:listed] -%><%= config[:listed] %><% else -%>true<% end %>
|
|
11
11
|
# true if the page is published
|
12
12
|
published: true
|
13
13
|
|
14
|
+
# true if the page can be used as a layout for new pages created by the editors
|
15
|
+
# is_layout: true
|
16
|
+
|
14
17
|
# position among sibling pages
|
15
18
|
# position: 1
|
16
19
|
|
@@ -34,4 +37,4 @@ content_type: <%= config[:content_type] -%>
|
|
34
37
|
|
35
38
|
%p Hello world
|
36
39
|
|
37
|
-
{% endblock %}
|
40
|
+
{% endblock %}
|
@@ -12,6 +12,9 @@ listed: <% if config[:listed] -%><%= config[:listed] %><% else -%>true<% end -%>
|
|
12
12
|
# true if the page is published
|
13
13
|
published: true
|
14
14
|
|
15
|
+
# true if the page can be used as a layout for new pages created by the editors
|
16
|
+
# is_layout: true
|
17
|
+
|
15
18
|
# position among sibling pages
|
16
19
|
# position: 1
|
17
20
|
|
@@ -43,7 +43,7 @@ module Locomotive
|
|
43
43
|
label: label || name.humanize,
|
44
44
|
type: type || 'string',
|
45
45
|
required: %w(true required).include?(required),
|
46
|
-
localized: %w(true
|
46
|
+
localized: %w(true localized).include?(localized)
|
47
47
|
).tap do |field|
|
48
48
|
if %w(belongs_to has_many many_to_many).include?(type)
|
49
49
|
field.class_name = target_content_type_slug
|
@@ -88,7 +88,7 @@ module Locomotive
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def paginate(options = {})
|
91
|
-
@collection
|
91
|
+
@collection = self.collection.paginate(options)
|
92
92
|
{
|
93
93
|
collection: @collection,
|
94
94
|
current_page: @collection.current_page,
|
@@ -101,7 +101,7 @@ module Locomotive
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def collection
|
104
|
-
return unless @collection.blank?
|
104
|
+
return @collection unless @collection.blank?
|
105
105
|
|
106
106
|
# define the default order_by if not set
|
107
107
|
if @context['with_scope'] && @context['with_scope']['order_by'].blank? && !%w(manually position).include?(@content_type.order_by)
|
@@ -4,15 +4,29 @@ module Locomotive
|
|
4
4
|
module Drops
|
5
5
|
class Page < Base
|
6
6
|
|
7
|
-
delegate :
|
7
|
+
delegate :fullpath, :parent, :depth, :seo_title, :redirect_url, :meta_description, :meta_keywords,
|
8
8
|
:templatized?, :published?, :redirect?, :listed?, :handle, to: :@_source
|
9
9
|
|
10
10
|
def title
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
title = @_source.templatized? ? @context['entry'].try(:_label) : nil
|
12
|
+
title || @_source.title
|
13
|
+
end
|
14
|
+
|
15
|
+
def slug
|
16
|
+
slug = @_source.templatized? ? @context['entry'].try(:_slug).try(:singularize) : nil
|
17
|
+
slug || @_source.slug
|
18
|
+
end
|
19
|
+
|
20
|
+
def is_layout?
|
21
|
+
@_source.is_layout
|
22
|
+
end
|
23
|
+
|
24
|
+
def original_title
|
25
|
+
@_source.title
|
26
|
+
end
|
27
|
+
|
28
|
+
def original_slug
|
29
|
+
@_source.slug
|
16
30
|
end
|
17
31
|
|
18
32
|
def children
|
@@ -25,12 +39,46 @@ module Locomotive
|
|
25
39
|
ProxyCollection.new(@_source.content_type) if @_source.content_type
|
26
40
|
end
|
27
41
|
|
42
|
+
def editable_elements
|
43
|
+
@editable_elements_hash ||= build_editable_elements_hash
|
44
|
+
end
|
45
|
+
|
28
46
|
def breadcrumbs
|
29
47
|
# TODO
|
30
48
|
''
|
31
49
|
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def build_editable_elements_hash
|
54
|
+
{}.tap do |hash|
|
55
|
+
@_source.editable_elements.each do |el|
|
56
|
+
safe_slug = el.slug.parameterize.underscore
|
57
|
+
keys = el.block.try(:split, '/').try(:compact) || []
|
58
|
+
|
59
|
+
_hash = _build_editable_elements_hashes(hash, keys)
|
60
|
+
|
61
|
+
_hash[safe_slug] = el.content
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def _build_editable_elements_hashes(hash, keys)
|
67
|
+
_hash = hash
|
68
|
+
|
69
|
+
keys.each do |key|
|
70
|
+
safe_key = key.parameterize.underscore
|
71
|
+
|
72
|
+
_hash[safe_key] = {} if _hash[safe_key].nil?
|
73
|
+
|
74
|
+
_hash = _hash[safe_key]
|
75
|
+
end
|
76
|
+
|
77
|
+
_hash
|
78
|
+
end
|
79
|
+
|
32
80
|
end
|
33
81
|
end
|
34
82
|
end
|
35
83
|
end
|
36
|
-
end
|
84
|
+
end
|
@@ -14,14 +14,14 @@ module Locomotive
|
|
14
14
|
#
|
15
15
|
class Consume < ::Liquid::Block
|
16
16
|
|
17
|
-
Syntax = /(#{::Liquid::VariableSignature}+)\s*from\s*(#{::Liquid::QuotedString}|#{::Liquid::VariableSignature}+)
|
17
|
+
Syntax = /(#{::Liquid::VariableSignature}+)\s*from\s*(#{::Liquid::QuotedString}|#{::Liquid::VariableSignature}+)(.*)?/
|
18
18
|
|
19
19
|
def initialize(tag_name, markup, tokens, options)
|
20
20
|
if markup =~ Syntax
|
21
21
|
@target = $1
|
22
22
|
|
23
23
|
self.prepare_url($2)
|
24
|
-
self.
|
24
|
+
self.prepare_api_arguments($3)
|
25
25
|
else
|
26
26
|
raise ::Liquid::SyntaxError.new(options[:locale].t("errors.syntax.consume"), options[:line])
|
27
27
|
end
|
@@ -32,6 +32,8 @@ module Locomotive
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def render(context)
|
35
|
+
self.set_api_options(context)
|
36
|
+
|
35
37
|
if instance_variable_defined? :@variable_name
|
36
38
|
@url = context[@variable_name]
|
37
39
|
end
|
@@ -50,13 +52,14 @@ module Locomotive
|
|
50
52
|
end
|
51
53
|
end
|
52
54
|
|
53
|
-
def
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
@
|
55
|
+
def prepare_api_arguments(string)
|
56
|
+
string = string.gsub(/^(\s*,)/, '').strip
|
57
|
+
@api_arguments = Solid::Arguments.parse(string)
|
58
|
+
end
|
59
|
+
|
60
|
+
def set_api_options(context)
|
61
|
+
@api_options = @api_arguments.interpolate(context).first || {}
|
62
|
+
@expires_in = @api_options.delete(:expires_in) || 0
|
60
63
|
end
|
61
64
|
|
62
65
|
def cached_response
|
@@ -72,7 +75,7 @@ module Locomotive
|
|
72
75
|
def render_all_without_cache(context)
|
73
76
|
context.stack do
|
74
77
|
begin
|
75
|
-
context.scopes.last[@target.to_s] = Locomotive::Wagon::Httparty::Webservice.consume(@url, @
|
78
|
+
context.scopes.last[@target.to_s] = Locomotive::Wagon::Httparty::Webservice.consume(@url, @api_options)
|
76
79
|
self.cached_response = context.scopes.last[@target.to_s]
|
77
80
|
rescue Timeout::Error
|
78
81
|
context.scopes.last[@target.to_s] = self.cached_response
|
@@ -50,7 +50,6 @@ module Locomotive
|
|
50
50
|
if templatized
|
51
51
|
page = mounting_point.pages.values.find do |_page|
|
52
52
|
_page.templatized? &&
|
53
|
-
!_page.templatized_from_parent &&
|
54
53
|
_page.content_type.slug == handle.content_type.slug &&
|
55
54
|
(@_options['with'].nil? || _page.handle == @_options['with'])
|
56
55
|
end
|
@@ -94,13 +94,15 @@ module Locomotive
|
|
94
94
|
end
|
95
95
|
|
96
96
|
def errors
|
97
|
-
return nil if success?
|
97
|
+
return nil if success?
|
98
98
|
|
99
99
|
@errors ||= if self['error']
|
100
100
|
[[nil, [self['error']]]]
|
101
|
+
elsif self['errors']
|
102
|
+
self['errors']
|
101
103
|
else
|
102
|
-
self
|
103
|
-
end
|
104
|
+
self.to_a
|
105
|
+
end.delete_if { |attribute, errors| errors.empty? }
|
104
106
|
end
|
105
107
|
|
106
108
|
def error_messages
|
@@ -112,4 +114,4 @@ module Locomotive
|
|
112
114
|
end
|
113
115
|
|
114
116
|
end
|
115
|
-
end
|
117
|
+
end
|
data/lib/locomotive/wagon.rb
CHANGED
@@ -103,6 +103,7 @@ module Locomotive
|
|
103
103
|
if Process.pid != parent_pid
|
104
104
|
# A "new logger" inside the daemon.
|
105
105
|
Locomotive::Wagon::Logger.setup(path, false)
|
106
|
+
Locomotive::Mounter.logger = Locomotive::Wagon::Logger.instance.logger
|
106
107
|
end
|
107
108
|
end
|
108
109
|
|
@@ -294,4 +295,4 @@ module Locomotive
|
|
294
295
|
end
|
295
296
|
|
296
297
|
end
|
297
|
-
end
|
298
|
+
end
|
data/locomotivecms_wagon.gemspec
CHANGED
@@ -35,7 +35,7 @@ Gem::Specification.new do |gem|
|
|
35
35
|
|
36
36
|
gem.add_dependency 'httmultiparty', '0.3.10'
|
37
37
|
gem.add_dependency 'will_paginate', '~> 3.0.3'
|
38
|
-
gem.add_dependency 'locomotivecms_mounter', '~> 1.
|
38
|
+
gem.add_dependency 'locomotivecms_mounter', '~> 1.5.0'
|
39
39
|
|
40
40
|
gem.add_dependency 'faker', '~> 0.9.5'
|
41
41
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: My simple layout
|
3
|
+
is_layout: true
|
4
|
+
---
|
5
|
+
!!! XML
|
6
|
+
!!!
|
7
|
+
%html{ lang: "en" }
|
8
|
+
%head
|
9
|
+
|
10
|
+
%body
|
11
|
+
%h1 {% editable_short_text title %}[TODO]{% endeditable_short_text %}
|
12
|
+
.text
|
13
|
+
{% editable_text content, format: html, rows: 5 %}[TODO]{% editable_text %}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'locomotive/wagon/liquid'
|
4
|
+
|
5
|
+
describe Locomotive::Wagon::Liquid::Drops::Page do
|
6
|
+
|
7
|
+
let(:attributes) { { title: "Hello world" } }
|
8
|
+
let(:source) { Locomotive::Mounter::Models::Page.new(attributes) }
|
9
|
+
|
10
|
+
subject { source.to_liquid }
|
11
|
+
|
12
|
+
describe 'the title' do
|
13
|
+
|
14
|
+
its(:title) { should eq "Hello world" }
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'with editable elements' do
|
19
|
+
|
20
|
+
let(:text_a) { Locomotive::Mounter::Models::EditableElement.new(block: 'sidebar/header', slug: 'ads', content: 'foo' ) }
|
21
|
+
let(:text_b) { Locomotive::Mounter::Models::EditableElement.new(block: 'sidebar/footer', slug: 'ads', content: 'foo ter' ) }
|
22
|
+
let(:text_c) { Locomotive::Mounter::Models::EditableElement.new(block: '', slug: 'simple_text', content: 'bar' ) }
|
23
|
+
let(:text_d) { Locomotive::Mounter::Models::EditableElement.new(block: 'My footer/wrapper/inner', slug: 'text', content: 'hello world' ) }
|
24
|
+
let(:attributes) { { editable_elements: [text_a, text_b, text_c, text_d] } }
|
25
|
+
|
26
|
+
its(:editable_elements) do
|
27
|
+
should eq({
|
28
|
+
'sidebar' => {
|
29
|
+
'header' => { 'ads' => 'foo' },
|
30
|
+
'footer' => { 'ads' => 'foo ter' }
|
31
|
+
},
|
32
|
+
'simple_text' => 'bar',
|
33
|
+
'my_footer' => {
|
34
|
+
'wrapper' => { 'inner' => { 'text' => 'hello world' } }
|
35
|
+
}
|
36
|
+
})
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: locomotivecms_wagon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Didier Lafforgue
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-11-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -227,14 +227,14 @@ dependencies:
|
|
227
227
|
requirements:
|
228
228
|
- - "~>"
|
229
229
|
- !ruby/object:Gem::Version
|
230
|
-
version: 1.
|
230
|
+
version: 1.5.0
|
231
231
|
type: :runtime
|
232
232
|
prerelease: false
|
233
233
|
version_requirements: !ruby/object:Gem::Requirement
|
234
234
|
requirements:
|
235
235
|
- - "~>"
|
236
236
|
- !ruby/object:Gem::Version
|
237
|
-
version: 1.
|
237
|
+
version: 1.5.0
|
238
238
|
- !ruby/object:Gem::Dependency
|
239
239
|
name: faker
|
240
240
|
requirement: !ruby/object:Gem::Requirement
|
@@ -775,6 +775,7 @@ files:
|
|
775
775
|
- spec/fixtures/default/app/views/pages/grunge_bands.liquid.haml
|
776
776
|
- spec/fixtures/default/app/views/pages/index.fr.liquid.haml
|
777
777
|
- spec/fixtures/default/app/views/pages/index.liquid.haml
|
778
|
+
- spec/fixtures/default/app/views/pages/layouts/simple.liquid.haml
|
778
779
|
- spec/fixtures/default/app/views/pages/music.fr.liquid.haml
|
779
780
|
- spec/fixtures/default/app/views/pages/music.liquid.haml
|
780
781
|
- spec/fixtures/default/app/views/pages/songs/template.fr.liquid.haml
|
@@ -831,6 +832,7 @@ files:
|
|
831
832
|
- spec/spec_helper.rb
|
832
833
|
- spec/support/helpers.rb
|
833
834
|
- spec/support/matchers.rb
|
835
|
+
- spec/unit/locomotive/wagon/liquid/drops/page_spec.rb
|
834
836
|
homepage: http://www.locomotivecms.com
|
835
837
|
licenses: []
|
836
838
|
metadata: {}
|
@@ -879,6 +881,7 @@ test_files:
|
|
879
881
|
- spec/fixtures/default/app/views/pages/grunge_bands.liquid.haml
|
880
882
|
- spec/fixtures/default/app/views/pages/index.fr.liquid.haml
|
881
883
|
- spec/fixtures/default/app/views/pages/index.liquid.haml
|
884
|
+
- spec/fixtures/default/app/views/pages/layouts/simple.liquid.haml
|
882
885
|
- spec/fixtures/default/app/views/pages/music.fr.liquid.haml
|
883
886
|
- spec/fixtures/default/app/views/pages/music.liquid.haml
|
884
887
|
- spec/fixtures/default/app/views/pages/songs/template.fr.liquid.haml
|
@@ -935,3 +938,4 @@ test_files:
|
|
935
938
|
- spec/spec_helper.rb
|
936
939
|
- spec/support/helpers.rb
|
937
940
|
- spec/support/matchers.rb
|
941
|
+
- spec/unit/locomotive/wagon/liquid/drops/page_spec.rb
|