locomotivecms_wagon 3.0.0.beta2 → 3.0.0.rc0
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/.gitignore +7 -0
- data/generators/blank/Gemfile.tt +0 -2
- data/generators/blank/app/assets/.babelrc +2 -1
- data/generators/blank/app/assets/javascripts/sections/index.js +1 -1
- data/generators/blank/app/assets/webpack.common.js +13 -3
- data/generators/blank/app/assets/webpack.dev.js +5 -1
- data/generators/blank/app/views/pages/layouts/default.liquid +4 -0
- data/generators/blank/config/site.yml.tt +4 -0
- data/generators/blank/{app/assets/package.json.tt → package.json.tt} +10 -9
- data/generators/cloned/Gemfile.tt +0 -2
- data/generators/content_type/app/content_types/%slug%.yml.tt +4 -0
- data/generators/public_form/content_type.yml.tt +53 -0
- data/generators/public_form/page.liquid.tt +75 -0
- data/generators/webpack/app/assets/.babelrc +4 -0
- data/generators/webpack/app/assets/fonts/.empty_directory +1 -0
- data/generators/webpack/app/assets/javascripts/app.js +19 -0
- data/generators/webpack/app/assets/javascripts/sections/_manager.js +94 -0
- data/generators/webpack/app/assets/javascripts/sections/index.js +5 -0
- data/generators/webpack/app/assets/postcss.config.js +6 -0
- data/generators/webpack/app/assets/stylesheets/app.scss +1 -0
- data/generators/webpack/app/assets/webpack.common.js +57 -0
- data/generators/webpack/app/assets/webpack.dev.js +11 -0
- data/generators/webpack/app/assets/webpack.prod.js +12 -0
- data/generators/webpack/package.json.tt +36 -0
- data/lib/locomotive/wagon/cli.rb +21 -4
- data/lib/locomotive/wagon/commands/push_sub_commands/push_content_types_command.rb +1 -1
- data/lib/locomotive/wagon/commands/serve_command.rb +1 -6
- data/lib/locomotive/wagon/decorators/concerns/persist_assets_concern.rb +1 -1
- data/lib/locomotive/wagon/generators/public_form.rb +97 -0
- data/lib/locomotive/wagon/generators/site.rb +0 -1
- data/lib/locomotive/wagon/generators/webpack.rb +29 -0
- data/lib/locomotive/wagon/tools/listen.rb +10 -4
- data/lib/locomotive/wagon/version.rb +1 -1
- data/locomotivecms_wagon.gemspec +1 -2
- data/spec/fixtures/cassettes/authenticate.yml +42 -42
- data/spec/fixtures/cassettes/delete.yml +232 -232
- data/spec/fixtures/cassettes/push.yml +1728 -1728
- data/spec/fixtures/cassettes/sync.yml +1999 -1999
- data/spec/unit/decorators/content_entry_decorator_spec.rb +1 -1
- data/spec/unit/decorators/site_decorator_spec.rb +28 -3
- metadata +21 -22
- data/generators/blank/Guardfile +0 -22
- data/generators/cloned/Guardfile +0 -22
- data/lib/locomotive/wagon/generators/site/unzip.rb +0 -89
@@ -47,7 +47,7 @@ describe Locomotive::Wagon::ContentEntryDecorator do
|
|
47
47
|
let(:field) { instance_double('Field', name: 'body', type: 'text') }
|
48
48
|
let(:fields) { instance_double('Fields', by_name: field, no_associations: [field]) }
|
49
49
|
let(:attributes) { { body: 'Hello world ! http://domain.tld/samples/foo.png ! <img src="/samples/bar.png" /> <div style="background: url(/samples/42.png);"/>' } }
|
50
|
-
let(:asset_pusher) { SimpleAssetPusher.new}
|
50
|
+
let(:asset_pusher) { SimpleAssetPusher.new }
|
51
51
|
|
52
52
|
before { allow(decorator).to receive(:__content_assets_pusher__).and_return(asset_pusher) }
|
53
53
|
|
@@ -4,6 +4,7 @@ require 'spec_helper'
|
|
4
4
|
require 'ostruct'
|
5
5
|
|
6
6
|
require 'locomotive/wagon/decorators/concerns/to_hash_concern'
|
7
|
+
require 'locomotive/wagon/decorators/concerns/persist_assets_concern'
|
7
8
|
require 'locomotive/wagon/decorators/site_decorator'
|
8
9
|
|
9
10
|
describe Locomotive::Wagon::SiteDecorator do
|
@@ -23,14 +24,38 @@ describe Locomotive::Wagon::SiteDecorator do
|
|
23
24
|
|
24
25
|
describe '#to_hash' do
|
25
26
|
|
26
|
-
let(:seo_title)
|
27
|
-
let(:attributes)
|
28
|
-
let(:site)
|
27
|
+
let(:seo_title) { instance_double('I18nField', translations: { en: 'Hi', fr: 'Bonjour' }) }
|
28
|
+
let(:attributes) { { name: 'Acme', handle: nil, seo_title: seo_title, locales: nil } }
|
29
|
+
let(:site) { OpenStruct.new(attributes) }
|
29
30
|
|
30
31
|
subject { decorator.to_hash }
|
31
32
|
|
32
33
|
it { is_expected.to eq(name: 'Acme', seo_title: { en: 'Hi', fr: 'Bonjour' }) }
|
33
34
|
|
35
|
+
context 'with image metafields' do
|
36
|
+
|
37
|
+
let(:metafields) { { some: 'Acme', img: '/samples/42.png', img2: '/samples/bar.png' } }
|
38
|
+
let(:schema) { { some: { label: 'Some', type: 'string' }, img: { label: 'img', type: 'image' }, img2: { label: 'img2', type: 'image' } } }
|
39
|
+
let(:attributes) { { name: 'Acme', handle: nil, seo_title: seo_title, locales: nil, metafields: metafields, metafields_schema: schema } }
|
40
|
+
let(:asset_pusher) { SimpleAssetPusher.new }
|
41
|
+
|
42
|
+
before { allow(decorator).to receive(:__content_assets_pusher__).and_return(asset_pusher) }
|
43
|
+
|
44
|
+
it 'only replaces assets wrapped by a double quotes' do
|
45
|
+
expect(decorator.metafields).to eq(metafields.to_json)
|
46
|
+
is_expected.to eq(name: 'Acme', seo_title: { en: 'Hi', fr: 'Bonjour' },
|
47
|
+
metafields: metafields.to_json,
|
48
|
+
metafields_schema: schema.to_json)
|
49
|
+
expect(asset_pusher.assets).to eq(['/samples/42.png', '/samples/bar.png'])
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
class SimpleAssetPusher
|
57
|
+
attr_reader :assets
|
58
|
+
def persist(asset); (@assets ||= []).push(asset); 'done'; end
|
34
59
|
end
|
35
60
|
|
36
61
|
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: 3.0.0.
|
4
|
+
version: 3.0.0.rc0
|
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: 2019-
|
12
|
+
date: 2019-04-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -115,14 +115,14 @@ dependencies:
|
|
115
115
|
requirements:
|
116
116
|
- - "~>"
|
117
117
|
- !ruby/object:Gem::Version
|
118
|
-
version: 1.5.0.
|
118
|
+
version: 1.5.0.rc0
|
119
119
|
type: :runtime
|
120
120
|
prerelease: false
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
123
|
- - "~>"
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: 1.5.0.
|
125
|
+
version: 1.5.0.rc0
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: haml
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,20 +151,6 @@ dependencies:
|
|
151
151
|
- - "~>"
|
152
152
|
- !ruby/object:Gem::Version
|
153
153
|
version: 3.1.5
|
154
|
-
- !ruby/object:Gem::Dependency
|
155
|
-
name: rack-livereload
|
156
|
-
requirement: !ruby/object:Gem::Requirement
|
157
|
-
requirements:
|
158
|
-
- - "~>"
|
159
|
-
- !ruby/object:Gem::Version
|
160
|
-
version: 0.3.16
|
161
|
-
type: :runtime
|
162
|
-
prerelease: false
|
163
|
-
version_requirements: !ruby/object:Gem::Requirement
|
164
|
-
requirements:
|
165
|
-
- - "~>"
|
166
|
-
- !ruby/object:Gem::Version
|
167
|
-
version: 0.3.16
|
168
154
|
- !ruby/object:Gem::Dependency
|
169
155
|
name: neatjson
|
170
156
|
requirement: !ruby/object:Gem::Requirement
|
@@ -211,14 +197,13 @@ files:
|
|
211
197
|
- Rakefile
|
212
198
|
- TODO
|
213
199
|
- bin/wagon
|
200
|
+
- generators/blank/.gitignore
|
214
201
|
- generators/blank/Gemfile.tt
|
215
|
-
- generators/blank/Guardfile
|
216
202
|
- generators/blank/app/assets/.babelrc
|
217
203
|
- generators/blank/app/assets/fonts/.empty_directory
|
218
204
|
- generators/blank/app/assets/javascripts/app.js
|
219
205
|
- generators/blank/app/assets/javascripts/sections/_manager.js
|
220
206
|
- generators/blank/app/assets/javascripts/sections/index.js
|
221
|
-
- generators/blank/app/assets/package.json.tt
|
222
207
|
- generators/blank/app/assets/postcss.config.js
|
223
208
|
- generators/blank/app/assets/stylesheets/app.scss
|
224
209
|
- generators/blank/app/assets/webpack.common.js
|
@@ -235,13 +220,13 @@ files:
|
|
235
220
|
- generators/blank/config/site.yml.tt
|
236
221
|
- generators/blank/config/translations.yml
|
237
222
|
- generators/blank/data/.empty_directory
|
223
|
+
- generators/blank/package.json.tt
|
238
224
|
- generators/blank/public/fonts/.empty_directory
|
239
225
|
- generators/blank/public/images/.empty_directory
|
240
226
|
- generators/blank/public/javascripts/.empty_directory
|
241
227
|
- generators/blank/public/samples/.empty_directory
|
242
228
|
- generators/blank/public/stylesheets/.empty_directory
|
243
229
|
- generators/cloned/Gemfile.tt
|
244
|
-
- generators/cloned/Guardfile
|
245
230
|
- generators/cloned/app/content_types/.empty_directory
|
246
231
|
- generators/cloned/app/views/pages/.empty_directory
|
247
232
|
- generators/cloned/app/views/snippets/.empty_directory
|
@@ -255,10 +240,23 @@ files:
|
|
255
240
|
- generators/content_type/app/content_types/%slug%.yml.tt
|
256
241
|
- generators/content_type/data/%slug%.yml.tt
|
257
242
|
- generators/page/template.liquid.tt
|
243
|
+
- generators/public_form/content_type.yml.tt
|
244
|
+
- generators/public_form/page.liquid.tt
|
258
245
|
- generators/section/%type%.js.tt
|
259
246
|
- generators/section/template.liquid.tt
|
260
247
|
- generators/site_metafields/schema.yml.tt
|
261
248
|
- generators/snippet/template.liquid.tt
|
249
|
+
- generators/webpack/app/assets/.babelrc
|
250
|
+
- generators/webpack/app/assets/fonts/.empty_directory
|
251
|
+
- generators/webpack/app/assets/javascripts/app.js
|
252
|
+
- generators/webpack/app/assets/javascripts/sections/_manager.js
|
253
|
+
- generators/webpack/app/assets/javascripts/sections/index.js
|
254
|
+
- generators/webpack/app/assets/postcss.config.js
|
255
|
+
- generators/webpack/app/assets/stylesheets/app.scss
|
256
|
+
- generators/webpack/app/assets/webpack.common.js
|
257
|
+
- generators/webpack/app/assets/webpack.dev.js
|
258
|
+
- generators/webpack/app/assets/webpack.prod.js
|
259
|
+
- generators/webpack/package.json.tt
|
262
260
|
- lib/locomotive/wagon.rb
|
263
261
|
- lib/locomotive/wagon/cli.rb
|
264
262
|
- lib/locomotive/wagon/commands/authenticate_command.rb
|
@@ -321,15 +319,16 @@ files:
|
|
321
319
|
- lib/locomotive/wagon/exceptions.rb
|
322
320
|
- lib/locomotive/wagon/generators/content_type.rb
|
323
321
|
- lib/locomotive/wagon/generators/page.rb
|
322
|
+
- lib/locomotive/wagon/generators/public_form.rb
|
324
323
|
- lib/locomotive/wagon/generators/relationship.rb
|
325
324
|
- lib/locomotive/wagon/generators/section.rb
|
326
325
|
- lib/locomotive/wagon/generators/site.rb
|
327
326
|
- lib/locomotive/wagon/generators/site/base.rb
|
328
327
|
- lib/locomotive/wagon/generators/site/blank.rb
|
329
328
|
- lib/locomotive/wagon/generators/site/cloned.rb
|
330
|
-
- lib/locomotive/wagon/generators/site/unzip.rb
|
331
329
|
- lib/locomotive/wagon/generators/site_metafields.rb
|
332
330
|
- lib/locomotive/wagon/generators/snippet.rb
|
331
|
+
- lib/locomotive/wagon/generators/webpack.rb
|
333
332
|
- lib/locomotive/wagon/middlewares/error_page.rb
|
334
333
|
- lib/locomotive/wagon/tools/glob.rb
|
335
334
|
- lib/locomotive/wagon/tools/listen.rb
|
data/generators/blank/Guardfile
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# LiveReload installation
|
2
|
-
#
|
3
|
-
# 1. Add the guard-livereload gem to your Gemfile OR uncomment the line:
|
4
|
-
#
|
5
|
-
# gem 'guard-livereload'
|
6
|
-
#
|
7
|
-
# 2. Install the gem on your machine
|
8
|
-
#
|
9
|
-
# bundle install
|
10
|
-
#
|
11
|
-
# 3. Launch Guard
|
12
|
-
#
|
13
|
-
# bundle exec guard
|
14
|
-
#
|
15
|
-
|
16
|
-
guard 'livereload', host: '0.0.0.0', port: ENV['WAGON_LIVERELOAD_PORT'] || 35729, grace_period: 0.5 do
|
17
|
-
watch(%r{app/content_types/.+\.yml$})
|
18
|
-
watch(%r{app/views/.+\.liquid})
|
19
|
-
watch(%r{config/.+\.yml$})
|
20
|
-
watch(%r{data/.+\.yml$})
|
21
|
-
watch(%r{public/((stylesheets|javascripts)/(.+\.(css|js))).*}) { |m| "/#{m[1]}" }
|
22
|
-
end
|
data/generators/cloned/Guardfile
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# LiveReload installation
|
2
|
-
#
|
3
|
-
# 1. Add the guard-livereload gem to your Gemfile OR uncomment the line:
|
4
|
-
#
|
5
|
-
# gem 'guard-livereload'
|
6
|
-
#
|
7
|
-
# 2. Install the gem on your machine
|
8
|
-
#
|
9
|
-
# bundle install
|
10
|
-
#
|
11
|
-
# 3. Launch Guard
|
12
|
-
#
|
13
|
-
# bundle exec guard
|
14
|
-
#
|
15
|
-
|
16
|
-
guard 'livereload', host: '0.0.0.0', port: ENV['WAGON_LIVERELOAD_PORT'] || 35729, grace_period: 0.5 do
|
17
|
-
watch(%r{app/content_types/.+\.yml$})
|
18
|
-
watch(%r{app/views/.+\.liquid})
|
19
|
-
watch(%r{config/.+\.yml$})
|
20
|
-
watch(%r{data/.+\.yml$})
|
21
|
-
watch(%r{public/((stylesheets|javascripts)/(.+\.(css|js))).*}) { |m| "/#{m[1]}" }
|
22
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
require 'open-uri'
|
2
|
-
require 'zip'
|
3
|
-
|
4
|
-
module Locomotive
|
5
|
-
module Wagon
|
6
|
-
module Generators
|
7
|
-
module Site
|
8
|
-
|
9
|
-
class Unzip < Base
|
10
|
-
|
11
|
-
class_option :location, type: :string, default: nil, required: false, desc: 'Location of the zip file'
|
12
|
-
|
13
|
-
@@source_root = nil
|
14
|
-
|
15
|
-
def prepare
|
16
|
-
remove_file join('tmp')
|
17
|
-
empty_directory join('tmp')
|
18
|
-
end
|
19
|
-
|
20
|
-
def ask_for_location
|
21
|
-
@location = options[:location] || ask('What is the location (on the filesystem or url) of the zip file ?')
|
22
|
-
raise GeneratorException.new('Please enter a location') if @location.blank?
|
23
|
-
end
|
24
|
-
|
25
|
-
def download_or_copy
|
26
|
-
@template_path = join('tmp', File.basename(@location))
|
27
|
-
|
28
|
-
if @location =~ /^https?:\/\//
|
29
|
-
say "downloading...#{@location}"
|
30
|
-
create_file @template_path, open(@location).read
|
31
|
-
else
|
32
|
-
say "copying...#{@location}"
|
33
|
-
create_file @template_path, open(@location, 'rb') { |io| io.read }
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def unzip
|
38
|
-
say "unzipping...#{@template_path}"
|
39
|
-
|
40
|
-
begin
|
41
|
-
Zip::ZipFile.open(@template_path) do |zipfile|
|
42
|
-
zipfile.each do |file|
|
43
|
-
next if file.name =~ /^__MACOSX/
|
44
|
-
zipfile.extract(file, join('tmp', file.name))
|
45
|
-
|
46
|
-
@path = $1 if file.name =~ /(.*)\/config\/site.yml$/
|
47
|
-
end
|
48
|
-
end
|
49
|
-
rescue Exception => e
|
50
|
-
raise GeneratorException.new("Unable to unzip the archive")
|
51
|
-
end
|
52
|
-
|
53
|
-
raise GeneratorException.new('Not a valid LocomotiveCMS site') if @path.blank?
|
54
|
-
end
|
55
|
-
|
56
|
-
def copy_sources
|
57
|
-
self.class.source_root = File.expand_path(join('tmp', @path, '/'))
|
58
|
-
say "copying files from #{self.class.source_root} / #{self.destination}"
|
59
|
-
directory('.', self.destination, { recursive: true })
|
60
|
-
end
|
61
|
-
|
62
|
-
def bundle_install
|
63
|
-
super
|
64
|
-
end
|
65
|
-
|
66
|
-
def self.source_root
|
67
|
-
# only way to change the source root from the instance
|
68
|
-
@@source_root
|
69
|
-
end
|
70
|
-
|
71
|
-
def self.source_root=(value)
|
72
|
-
@@source_root = value
|
73
|
-
end
|
74
|
-
|
75
|
-
protected
|
76
|
-
|
77
|
-
def join(*args)
|
78
|
-
File.join(self.destination, *args)
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
Locomotive::Wagon::Generators::Site.register(:unzip, Unzip, %{
|
84
|
-
Unzip a local or remote (http, https, ftp) zipped site.
|
85
|
-
})
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|