locomotivecms_steam 1.0.0.pre.beta.1 → 1.0.0.pre.beta.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/locomotive/steam/adapters/mongodb.rb +19 -2
- data/lib/locomotive/steam/entities/editable_element.rb +2 -1
- data/lib/locomotive/steam/liquid/tags/editable/base.rb +3 -3
- data/lib/locomotive/steam/liquid/tags/editable/text.rb +1 -1
- data/lib/locomotive/steam/liquid/tags/model_form.rb +15 -1
- data/lib/locomotive/steam/middlewares/templatized_page.rb +1 -1
- data/lib/locomotive/steam/version.rb +1 -1
- data/spec/unit/liquid/tags/editable/text_spec.rb +10 -2
- data/spec/unit/liquid/tags/model_form_spec.rb +8 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a200877da9098d215eb31f61067aa85e17cdd031
|
4
|
+
data.tar.gz: 7e4a6550691aa4d42578e19471457148004791d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35c4e6ef24a93b95c0a302174bac850a28283cb8a2efb231a0e0fa7398009654c5fa2f9bb0bd87a6c12dd59556e6510a860762a02ab3943830b078306035d15d
|
7
|
+
data.tar.gz: a7f438df4b3685f1da9accf8874fcc1fc18a29f141c29367acb1df52dfaae08027f0143a4a9be61ddb9424cd840656a1adbae92a83355ced83b5036938e05d33
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
locomotivecms_steam (1.0.0.pre.beta.
|
4
|
+
locomotivecms_steam (1.0.0.pre.beta.2)
|
5
5
|
RedCloth (~> 4.2.9)
|
6
6
|
chronic (~> 0.10.2)
|
7
7
|
coffee-script (~> 2.4.1)
|
@@ -82,7 +82,7 @@ GEM
|
|
82
82
|
eventmachine (1.0.7)
|
83
83
|
execjs (2.5.2)
|
84
84
|
ffi (1.9.10)
|
85
|
-
haml (4.0.
|
85
|
+
haml (4.0.7)
|
86
86
|
tilt
|
87
87
|
hike (1.2.3)
|
88
88
|
http-cookie (1.0.2)
|
@@ -80,11 +80,20 @@ module Locomotive::Steam
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def session
|
83
|
-
|
84
|
-
|
83
|
+
if uri
|
84
|
+
Moped::Session.connect(uri)
|
85
|
+
else
|
86
|
+
Moped::Session.new([*hosts]).tap do |session|
|
87
|
+
session.use database
|
88
|
+
session.login(username, password) if username && password
|
89
|
+
end
|
85
90
|
end
|
86
91
|
end
|
87
92
|
|
93
|
+
def uri
|
94
|
+
options[:uri]
|
95
|
+
end
|
96
|
+
|
88
97
|
def database
|
89
98
|
options[:database]
|
90
99
|
end
|
@@ -93,6 +102,14 @@ module Locomotive::Steam
|
|
93
102
|
options[:hosts]
|
94
103
|
end
|
95
104
|
|
105
|
+
def username
|
106
|
+
options[:username]
|
107
|
+
end
|
108
|
+
|
109
|
+
def password
|
110
|
+
options[:password]
|
111
|
+
end
|
112
|
+
|
96
113
|
end
|
97
114
|
|
98
115
|
end
|
@@ -12,7 +12,7 @@ module Locomotive
|
|
12
12
|
def initialize(tag_name, markup, options)
|
13
13
|
if markup =~ Syntax
|
14
14
|
@slug = $1.gsub(/[\"\']/, '')
|
15
|
-
@element_options = { fixed: false }
|
15
|
+
@element_options = { fixed: false, inline_editing: true }
|
16
16
|
markup.scan(::Liquid::TagAttributes) { |key, value| @element_options[key.to_sym] = value.gsub(/^[\"\']/, '').gsub(/[\"\']$/, '') }
|
17
17
|
else
|
18
18
|
raise ::Liquid::SyntaxError.new("Valid syntax: #{tag_name} <slug>(, <options>)")
|
@@ -48,9 +48,9 @@ module Locomotive
|
|
48
48
|
slug: @slug,
|
49
49
|
hint: @element_options[:hint],
|
50
50
|
priority: @element_options[:priority] || 0,
|
51
|
-
fixed:
|
51
|
+
fixed: [true, 'true'].include?(@element_options[:fixed]),
|
52
52
|
disabled: false,
|
53
|
-
inline_editing: true,
|
53
|
+
inline_editing: [true, 'true'].include?(@element_options[:inline_editing]),
|
54
54
|
from_parent: false,
|
55
55
|
type: @tag_name.to_sym
|
56
56
|
}
|
@@ -24,7 +24,7 @@ module Locomotive
|
|
24
24
|
name = options.shift
|
25
25
|
options = options.shift || {}
|
26
26
|
|
27
|
-
form_attributes =
|
27
|
+
form_attributes = prepare_form_attributes(options)
|
28
28
|
|
29
29
|
html_content_tag :form,
|
30
30
|
content_type_html(name) + csrf_html + callbacks_html(options) + yield,
|
@@ -64,6 +64,20 @@ module Locomotive
|
|
64
64
|
(options.stringify_keys.to_a.collect { |a, b| "#{a}=\"#{b}\"" }).join(' ')
|
65
65
|
end
|
66
66
|
|
67
|
+
def prepare_form_attributes(options)
|
68
|
+
action = options[:action]
|
69
|
+
attributes = options.slice(:id, :class, :name, :novalidate)
|
70
|
+
|
71
|
+
if action.blank? && options[:json]
|
72
|
+
action = current_context['path']
|
73
|
+
action = (action.blank? ? 'index' : action) + '.json'
|
74
|
+
end
|
75
|
+
|
76
|
+
{ method: 'POST', enctype: 'multipart/form-data' }.merge(attributes).tap do |_attributes|
|
77
|
+
_attributes[:action] = action if action
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
67
81
|
end
|
68
82
|
|
69
83
|
end
|
@@ -42,7 +42,7 @@ module Locomotive::Steam
|
|
42
42
|
|
43
43
|
def decorate(entry)
|
44
44
|
return nil if entry.nil?
|
45
|
-
Locomotive::Steam::Decorators::I18nDecorator.new(entry, default_locale)
|
45
|
+
Locomotive::Steam::Decorators::I18nDecorator.new(entry, locale, default_locale)
|
46
46
|
end
|
47
47
|
|
48
48
|
def content_type_repository
|
@@ -71,10 +71,11 @@ describe Locomotive::Steam::Liquid::Tags::Editable::Text do
|
|
71
71
|
|
72
72
|
describe 'rendering' do
|
73
73
|
|
74
|
-
let(:live_editing)
|
74
|
+
let(:live_editing) { false }
|
75
|
+
let(:element_editing) { true }
|
75
76
|
|
76
77
|
let(:page) { instance_double('Page', fullpath: 'hello-world') }
|
77
|
-
let(:element) { instance_double('EditableText', _id: 42, id: 42, default_content?: true, inline_editing?:
|
78
|
+
let(:element) { instance_double('EditableText', _id: 42, id: 42, default_content?: true, inline_editing?: element_editing, inline_editing: element_editing) }
|
78
79
|
let(:services) { Locomotive::Steam::Services.build_instance(nil) }
|
79
80
|
let(:context) { ::Liquid::Context.new({}, {}, { page: page, services: services, live_editing: live_editing }) }
|
80
81
|
|
@@ -119,6 +120,13 @@ describe Locomotive::Steam::Liquid::Tags::Editable::Text do
|
|
119
120
|
|
120
121
|
end
|
121
122
|
|
123
|
+
context 'editing disabled for the element' do
|
124
|
+
|
125
|
+
let(:element_editing) { false }
|
126
|
+
it { is_expected.to eq 'Hello world' }
|
127
|
+
|
128
|
+
end
|
129
|
+
|
122
130
|
end
|
123
131
|
|
124
132
|
describe 'deprecated elements' do
|
@@ -11,7 +11,7 @@ describe Locomotive::Steam::Liquid::Tags::ModelForm do
|
|
11
11
|
let(:request) { instance_double('Request', env: {}) }
|
12
12
|
let(:source) { "{% model_form 'newsletter_addresses' %}Newsletter Form{% endmodel_form %}" }
|
13
13
|
let(:services) { Locomotive::Steam::Services.build_instance(request) }
|
14
|
-
let(:context) { ::Liquid::Context.new({}, {}, { services: services }) }
|
14
|
+
let(:context) { ::Liquid::Context.new({ path: '' }, {}, { services: services }) }
|
15
15
|
|
16
16
|
subject { render_template(source, context) }
|
17
17
|
|
@@ -32,4 +32,11 @@ describe Locomotive::Steam::Liquid::Tags::ModelForm do
|
|
32
32
|
|
33
33
|
end
|
34
34
|
|
35
|
+
describe 'json enabled' do
|
36
|
+
|
37
|
+
let(:source) { "{% model_form 'newsletter_addresses', json: true %}Newsletter Form{% endmodel_form %}" }
|
38
|
+
it { is_expected.to eq %(<form method="POST" enctype="multipart/form-data" action="index.json"><input type="hidden" name="content_type_slug" value="newsletter_addresses" /><input type="hidden" name="token" value="42" />Newsletter Form</form>) }
|
39
|
+
|
40
|
+
end
|
41
|
+
|
35
42
|
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.beta.
|
4
|
+
version: 1.0.0.pre.beta.2
|
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-
|
14
|
+
date: 2015-08-11 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|