locomotivecms_steam 1.0.0.pre.alpha.2 → 1.0.0.pre.alpha.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d356e35a4a40eb38ba622e0f11c80c6c4f96f60c
4
- data.tar.gz: 271c77fcbd49d0f728b696b42c5cb53893710876
3
+ metadata.gz: 4b4546173ae3156b352326063ab3f4627794f376
4
+ data.tar.gz: cf990d7b68ff7214aea8b6751fbd21364242d9c6
5
5
  SHA512:
6
- metadata.gz: 9f2b709d5db8a35b9d2f3d17cbf05ed9f47a40190b73336b50c8e7bcbdda1fa83107149618e391db6374efbe8a6e6ed884ebdc6e3163ca988edc11ae887ca92d
7
- data.tar.gz: 7665c557df441bcda5e23321d02945712585a1f75b989ade5fd41a414ab3d9733a84e9f6adba2e008714114083c6513ba9296ebfbeff0350ca22d7cf82b077da
6
+ metadata.gz: c99b54430322c95af6613c5092fe0d37098d312fa1d4b1552733e4fe28af2cacc17c3df3d7d3818909456290db94235a16720c3e0091de563e3cf8d7e4e027f1
7
+ data.tar.gz: 9d5dea9b461f371a46eec6f43ee8dfde680df5a3794098ea7c63d856232cb8100ed034958a34533de7cdf30450daa1a7643be39f8473ba27eeb02bff9c811132
data/Gemfile CHANGED
@@ -13,18 +13,18 @@ group :development do
13
13
  end
14
14
 
15
15
  group :test do
16
- gem 'rspec', '~> 3.2.0'
16
+ gem 'rspec', '~> 3.3.0'
17
17
  gem 'json_spec', '~> 1.1.4'
18
18
  gem 'i18n-spec', '~> 0.6.0'
19
19
 
20
- gem 'timecop', '~> 0.7.1'
20
+ gem 'timecop', '~> 0.7.4'
21
21
 
22
22
  gem 'pry-byebug', '~> 3.1.0'
23
23
 
24
24
  gem 'rack-test', '~> 0.6.3'
25
25
 
26
26
  gem 'codeclimate-test-reporter', '~> 0.4.7', require: false
27
- gem 'coveralls', '~> 0.7.12', require: false
27
+ gem 'coveralls', '~> 0.8.1', require: false
28
28
  end
29
29
 
30
30
  platform :ruby do
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- locomotivecms_steam (1.0.0.pre.alpha.2)
4
+ locomotivecms_steam (1.0.0.pre.alpha.3)
5
5
  RedCloth (~> 4.2.9)
6
6
  chronic (~> 0.10.2)
7
7
  coffee-script (~> 2.4.1)
@@ -28,14 +28,14 @@ GEM
28
28
  remote: https://rubygems.org/
29
29
  specs:
30
30
  RedCloth (4.2.9)
31
- activesupport (4.2.1)
31
+ activesupport (4.2.3)
32
32
  i18n (~> 0.7)
33
33
  json (~> 1.7, >= 1.7.7)
34
34
  minitest (~> 5.1)
35
35
  thread_safe (~> 0.3, >= 0.3.4)
36
36
  tzinfo (~> 1.1)
37
37
  addressable (2.3.8)
38
- bson (2.3.0)
38
+ bson (3.1.0)
39
39
  byebug (4.0.5)
40
40
  columnize (= 0.9.0)
41
41
  chronic (0.10.2)
@@ -63,10 +63,10 @@ GEM
63
63
  compass-import-once (1.0.5)
64
64
  sass (>= 3.2, < 3.5)
65
65
  connection_pool (2.2.0)
66
- coveralls (0.7.12)
67
- multi_json (~> 1.10)
66
+ coveralls (0.8.1)
67
+ json (~> 1.8)
68
68
  rest-client (>= 1.6.8, < 2)
69
- simplecov (~> 0.9.1)
69
+ simplecov (~> 0.10.0)
70
70
  term-ansicolor (~> 1.3)
71
71
  thor (~> 0.19.1)
72
72
  crass (1.0.2)
@@ -95,7 +95,7 @@ GEM
95
95
  iso
96
96
  iso (0.2.1)
97
97
  i18n
98
- json (1.8.2)
98
+ json (1.8.3)
99
99
  json_spec (1.1.4)
100
100
  multi_json (~> 1.0)
101
101
  rspec (>= 2.0, < 4.0)
@@ -113,14 +113,14 @@ GEM
113
113
  mime-types (2.6.1)
114
114
  mimetype-fu (0.1.2)
115
115
  mini_portile (0.6.2)
116
- minitest (5.6.1)
116
+ minitest (5.7.0)
117
117
  moneta (0.8.0)
118
- moped (2.0.4)
119
- bson (~> 2.2)
118
+ moped (2.0.6)
119
+ bson (~> 3.0)
120
120
  connection_pool (~> 2.0)
121
121
  optionable (~> 0.2.0)
122
122
  morphine (0.1.1)
123
- multi_json (1.11.0)
123
+ multi_json (1.11.1)
124
124
  multi_xml (0.5.5)
125
125
  netrc (0.10.3)
126
126
  nokogiri (1.6.6.2)
@@ -152,29 +152,29 @@ GEM
152
152
  http-cookie (>= 1.0.2, < 2.0)
153
153
  mime-types (>= 1.16, < 3.0)
154
154
  netrc (~> 0.7)
155
- rspec (3.2.0)
156
- rspec-core (~> 3.2.0)
157
- rspec-expectations (~> 3.2.0)
158
- rspec-mocks (~> 3.2.0)
159
- rspec-core (3.2.3)
160
- rspec-support (~> 3.2.0)
161
- rspec-expectations (3.2.1)
155
+ rspec (3.3.0)
156
+ rspec-core (~> 3.3.0)
157
+ rspec-expectations (~> 3.3.0)
158
+ rspec-mocks (~> 3.3.0)
159
+ rspec-core (3.3.0)
160
+ rspec-support (~> 3.3.0)
161
+ rspec-expectations (3.3.0)
162
162
  diff-lcs (>= 1.2.0, < 2.0)
163
- rspec-support (~> 3.2.0)
164
- rspec-mocks (3.2.1)
163
+ rspec-support (~> 3.3.0)
164
+ rspec-mocks (3.3.0)
165
165
  diff-lcs (>= 1.2.0, < 2.0)
166
- rspec-support (~> 3.2.0)
167
- rspec-support (3.2.2)
166
+ rspec-support (~> 3.3.0)
167
+ rspec-support (3.3.0)
168
168
  sanitize (4.0.0)
169
169
  crass (~> 1.0.2)
170
170
  nokogiri (>= 1.4.4)
171
171
  nokogumbo (= 1.4.1)
172
172
  sass (3.4.14)
173
- simplecov (0.9.2)
173
+ simplecov (0.10.0)
174
174
  docile (~> 1.1.0)
175
- multi_json (~> 1.0)
176
- simplecov-html (~> 0.9.0)
177
- simplecov-html (0.9.0)
175
+ json (~> 1.8)
176
+ simplecov-html (~> 0.10.0)
177
+ simplecov-html (0.10.0)
178
178
  slop (3.6.0)
179
179
  sprockets (2.12.3)
180
180
  hike (~> 1.2)
@@ -197,8 +197,8 @@ GEM
197
197
  thor (0.19.1)
198
198
  thread_safe (0.3.5)
199
199
  tilt (1.4.1)
200
- timecop (0.7.3)
201
- tins (1.5.1)
200
+ timecop (0.7.4)
201
+ tins (1.5.2)
202
202
  tzinfo (1.2.2)
203
203
  thread_safe (~> 0.1)
204
204
  unf (0.1.4)
@@ -212,16 +212,16 @@ PLATFORMS
212
212
  DEPENDENCIES
213
213
  bundler (~> 1.7)
214
214
  codeclimate-test-reporter (~> 0.4.7)
215
- coveralls (~> 0.7.12)
215
+ coveralls (~> 0.8.1)
216
216
  i18n-spec (~> 0.6.0)
217
217
  json_spec (~> 1.1.4)
218
218
  locomotivecms_steam!
219
- moped (~> 2.0.4)
219
+ moped (~> 2.0.6)
220
220
  origin (~> 2.1.1)
221
221
  pry-byebug (~> 3.1.0)
222
222
  rack-test (~> 0.6.3)
223
223
  rake (~> 10.4.2)
224
- rspec (~> 3.2.0)
224
+ rspec (~> 3.3.0)
225
225
  thin
226
- timecop (~> 0.7.1)
226
+ timecop (~> 0.7.4)
227
227
  yui-compressor (~> 0.12.0)
@@ -9,7 +9,7 @@ module Locomotive
9
9
 
10
10
  def default_element_attributes
11
11
  super.merge({
12
- content: render_default_content,
12
+ content_from_default: self.render_default_content,
13
13
  options: @element_options[:options]
14
14
  })
15
15
  end
@@ -19,25 +19,30 @@ module Locomotive
19
19
 
20
20
  def with_inline_editing(context, element, &block)
21
21
  if editable?(context, element)
22
- %{<span class="locomotive-editable-text" data-element-id="#{element.id}">#{yield}</span>}
22
+ %{<span class="locomotive-editable-text" id="#{dom_id(context)}" data-element-id="#{element._id}">#{yield}</span>}
23
23
  else
24
24
  yield
25
25
  end
26
26
  end
27
27
 
28
28
  def editable?(context, element)
29
- !!context['inline_editing'] && element.inline_editing?
29
+ !!context.registers[:live_editing]
30
30
  end
31
31
 
32
32
  def default_element_attributes
33
33
  super.merge(
34
34
  content_from_default: self.render_default_content,
35
- format: @options[:format] || 'html',
36
- rows: @options[:rows] || 10,
37
- line_break: @options[:line_break].blank? ? true : @options[:line_break]
35
+ format: @element_options[:format] || 'html',
36
+ rows: @element_options[:rows] || 10,
37
+ line_break: @element_options[:line_break].blank? ? true : @element_options[:line_break]
38
38
  )
39
39
  end
40
40
 
41
+ def dom_id(context)
42
+ block_name = context['block'].try(:name).try(:gsub, '/', '-')
43
+ ['locomotive-editable-text', block_name, @slug].compact.join('-')
44
+ end
45
+
41
46
  end
42
47
 
43
48
  ::Liquid::Template.register_tag('editable_text'.freeze, Text)
@@ -12,7 +12,7 @@ module Locomotive
12
12
  # no need to go further if the parent does not exist
13
13
  raise PageNotFound.new("Extending a missing page. Page/Layout with fullpath '#{@template_name}' was not found") if parent.nil?
14
14
 
15
- ActiveSupport::Notifications.instrument("steam.parse.extends", page: options[:page], parent: parent)
15
+ ActiveSupport::Notifications.instrument('steam.parse.extends', page: options[:page], parent: parent)
16
16
 
17
17
  # the source has already been parsed before
18
18
  options[:parser]._parse(parent, options.merge(page: parent))
@@ -6,7 +6,7 @@ module Locomotive
6
6
 
7
7
  def parse(tokens)
8
8
  super.tap do
9
- ActiveSupport::Notifications.instrument("steam.parse.inherited_block", page: options[:page], name: @name, found_super: self.contains_super?(nodelist))
9
+ ActiveSupport::Notifications.instrument('steam.parse.inherited_block', page: options[:page], name: @name, found_super: self.contains_super?(nodelist))
10
10
  end
11
11
  end
12
12
 
@@ -15,12 +15,12 @@ module Locomotive
15
15
  #
16
16
  class Paginate < ::Liquid::Block
17
17
 
18
- Syntax = /(#{::Liquid::QuotedFragment}+)\s+by\s+([0-9]+)/o
18
+ Syntax = /(#{::Liquid::QuotedFragment}+)\s+by\s+(#{::Liquid::QuotedFragment}+)/o
19
19
 
20
20
  def initialize(tag_name, markup, options)
21
21
  if markup =~ Syntax
22
22
  @collection_name = $1
23
- @per_page = $2.to_i
23
+ @per_page = $2
24
24
  @paginate_options = {}
25
25
  markup.scan(::Liquid::TagAttributes) { |key, value| @paginate_options[key.to_sym] = value.gsub(/^'/, '').gsub(/'$/, '') }
26
26
  else
@@ -54,11 +54,12 @@ module Locomotive
54
54
  #
55
55
  def paginate_collection(context)
56
56
  collection = context[@collection_name]
57
+ per_page = context[@per_page].to_i
57
58
  current_page = context['current_page'].try(:to_i)
58
59
 
59
60
  raise ::Liquid::ArgumentError.new("Cannot paginate '#{@collection_name}'. Not found.") if collection.nil?
60
61
 
61
- pager = Locomotive::Steam::Models::Pager.new(collection, current_page, @per_page)
62
+ pager = Locomotive::Steam::Models::Pager.new(collection, current_page, per_page)
62
63
 
63
64
  # make sure the pagination object is a hash with strings as keys (and not symbol)
64
65
  HashConverter.to_string(pager.to_liquid).tap do |_pagination|
@@ -18,7 +18,7 @@ module Locomotive::Steam
18
18
  end
19
19
 
20
20
  def redirect_to(location, type = 301)
21
- _location = mounted_on && (location =~ Steam::IsHTTP).nil? ? "#{mounted_on}#{location}" : location
21
+ _location = mounted_on && (location =~ Locomotive::Steam::IsHTTP).nil? ? "#{mounted_on}#{location}" : location
22
22
 
23
23
  self.log "Redirected to #{_location}".blue
24
24
 
@@ -16,7 +16,7 @@ module Locomotive::Steam
16
16
  private
17
17
 
18
18
  def render_page
19
- if page.redirect_url
19
+ if page.redirect_url.presence
20
20
  redirect_to(page.redirect_url, page.redirect_type)
21
21
  else
22
22
  content = parse_and_render_liquid
@@ -46,7 +46,8 @@ module Locomotive::Steam
46
46
  page: page,
47
47
  services: services,
48
48
  repositories: services.repositories,
49
- logger: Locomotive::Common::Logger
49
+ logger: Locomotive::Common::Logger,
50
+ live_editing: !!env['steam.live_editing']
50
51
  }
51
52
  end
52
53
 
@@ -3,6 +3,6 @@
3
3
  # 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0
4
4
  module Locomotive
5
5
  module Steam
6
- VERSION = '1.0.0-alpha.2'
6
+ VERSION = '1.0.0-alpha.3'
7
7
  end
8
8
  end
@@ -19,7 +19,7 @@ module Locomotive
19
19
 
20
20
  CONTENT_ENTRY_ENGINE_CLASS_NAME = /^Locomotive::ContentEntry(.*)$/o
21
21
 
22
- IsHTTP = /^https?:\/\//o
22
+ IsHTTP = /\Ahttps?:\/\//o
23
23
 
24
24
  class << self
25
25
  attr_writer :configuration
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.add_development_dependency 'bundler', '~> 1.7'
19
19
  spec.add_development_dependency 'rake', '~> 10.4.2'
20
20
 
21
- spec.add_development_dependency 'moped', '~> 2.0.4'
21
+ spec.add_development_dependency 'moped', '~> 2.0.6'
22
22
  spec.add_development_dependency 'origin', '~> 2.1.1'
23
23
 
24
24
  spec.add_dependency 'sanitize', '~> 4.0.0'
@@ -30,7 +30,7 @@ describe Locomotive::Steam::Liquid::Tags::Consume do
30
30
 
31
31
  describe 'raises an error if the syntax is incorrect' do
32
32
  let(:source) { '{% consume blog http://www.locomotiveapp.org %}{% endconsume %}' }
33
- it { expect { subject }.to raise_exception }
33
+ it { expect { subject }.to raise_exception(Liquid::SyntaxError) }
34
34
  end
35
35
 
36
36
  end
@@ -59,7 +59,8 @@ describe Locomotive::Steam::Liquid::Tags::Editable::Control do
59
59
  it { is_expected.to include(slug: 'menu') }
60
60
  it { is_expected.to include(options: 'true=Yes,false=No') }
61
61
  it { is_expected.to include(hint: 'some text') }
62
- it { is_expected.to include(content: 'false') }
62
+ it { is_expected.to include(content_from_default: 'false') }
63
+ it { is_expected.not_to include(content: 'false') }
63
64
 
64
65
  end
65
66
 
@@ -71,12 +71,12 @@ describe Locomotive::Steam::Liquid::Tags::Editable::Text do
71
71
 
72
72
  describe 'rendering' do
73
73
 
74
- let(:inline_editing) { false }
74
+ let(:live_editing) { false }
75
75
 
76
76
  let(:page) { instance_double('Page', fullpath: 'hello-world') }
77
- let(:element) { instance_double('EditableText', id: 42, default_content?: true, inline_editing?: true) }
77
+ let(:element) { instance_double('EditableText', _id: 42, id: 42, default_content?: true, inline_editing?: true) }
78
78
  let(:services) { Locomotive::Steam::Services.build_instance(nil) }
79
- let(:context) { ::Liquid::Context.new({ 'inline_editing' => inline_editing }, {}, { page: page, services: services }) }
79
+ let(:context) { ::Liquid::Context.new({}, {}, { page: page, services: services, live_editing: live_editing }) }
80
80
 
81
81
  before { allow(services.editable_element).to receive(:find).and_return(element) }
82
82
 
@@ -109,8 +109,15 @@ describe Locomotive::Steam::Liquid::Tags::Editable::Text do
109
109
 
110
110
  context 'inline-editing mode' do
111
111
 
112
- let(:inline_editing) { true }
113
- it { is_expected.to eq '<span class="locomotive-editable-text" data-element-id="42">Hello world</span>' }
112
+ let(:live_editing) { true }
113
+ it { is_expected.to eq '<span class="locomotive-editable-text" id="locomotive-editable-text-title" data-element-id="42">Hello world</span>' }
114
+
115
+ context 'with inside blocks' do
116
+
117
+ let(:source) { '{% block wrapper %}{% block sidebar %}{% editable_text title %}Hello world{% endeditable_text %}{% endblock %}{% endblock %}' }
118
+ it { is_expected.to eq '<span class="locomotive-editable-text" id="locomotive-editable-text-wrapper-sidebar-title" data-element-id="42">Hello world</span>' }
119
+
120
+ end
114
121
 
115
122
  end
116
123
 
@@ -18,7 +18,7 @@ describe Locomotive::Steam::Liquid::Tags::FetchPage do
18
18
 
19
19
  describe 'raises an error if the syntax is incorrect' do
20
20
  let(:source) { "{% fetch_page 'about_us' %}{{ a_page.title }}" }
21
- it { expect { subject }.to raise_exception }
21
+ it { expect { subject }.to raise_exception(::SyntaxError) }
22
22
  end
23
23
 
24
24
  end
@@ -10,7 +10,7 @@ describe Locomotive::Steam::Liquid::Tags::GoogleAnalytics do
10
10
 
11
11
  describe 'raises an error if the syntax is incorrect' do
12
12
  let(:source) { '{% google_analytics %}' }
13
- it { expect { subject }.to raise_exception }#(::Liquid::SyntaxError) }
13
+ it { expect { subject }.to raise_exception(::Liquid::SyntaxError) }
14
14
  end
15
15
 
16
16
  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: 1.0.0.pre.alpha.2
4
+ version: 1.0.0.pre.alpha.3
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: 2015-05-27 00:00:00.000000000 Z
14
+ date: 2015-06-29 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -47,14 +47,14 @@ dependencies:
47
47
  requirements:
48
48
  - - "~>"
49
49
  - !ruby/object:Gem::Version
50
- version: 2.0.4
50
+ version: 2.0.6
51
51
  type: :development
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
55
  - - "~>"
56
56
  - !ruby/object:Gem::Version
57
- version: 2.0.4
57
+ version: 2.0.6
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: origin
60
60
  requirement: !ruby/object:Gem::Requirement