locomotivecms_steam 1.0.0.pre.alpha → 1.0.0.pre.alpha.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/Gemfile.lock +49 -34
- data/bin/steam.rb +1 -1
- data/lib/locomotive/steam.rb +8 -6
- data/lib/locomotive/steam/adapters/filesystem/simple_cache_store.rb +4 -0
- data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/content_type.rb +1 -1
- data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/page.rb +32 -10
- data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/theme_asset.rb +31 -1
- data/lib/locomotive/steam/decorators/i18n_decorator.rb +1 -1
- data/lib/locomotive/steam/decorators/template_decorator.rb +1 -0
- data/lib/locomotive/steam/entities/content_entry.rb +9 -1
- data/lib/locomotive/steam/entities/content_type_field.rb +4 -0
- data/lib/locomotive/steam/entities/theme_asset.rb +8 -0
- data/lib/locomotive/steam/initializers/sprockets.rb +49 -0
- data/lib/locomotive/steam/liquid/filters/base.rb +5 -6
- data/lib/locomotive/steam/liquid/tags/editable/base.rb +4 -5
- data/lib/locomotive/steam/liquid/tags/extends.rb +1 -36
- data/lib/locomotive/steam/liquid/tags/inherited_block.rb +10 -4
- data/lib/locomotive/steam/liquid/tags/snippet.rb +8 -9
- data/lib/locomotive/steam/middlewares/dynamic_assets.rb +6 -36
- data/lib/locomotive/steam/middlewares/helpers.rb +9 -2
- data/lib/locomotive/steam/middlewares/site.rb +10 -2
- data/lib/locomotive/steam/models/associations/embedded.rb +1 -1
- data/lib/locomotive/steam/models/mapper.rb +2 -1
- data/lib/locomotive/steam/repositories.rb +1 -1
- data/lib/locomotive/steam/repositories/content_type_field_repository.rb +8 -0
- data/lib/locomotive/steam/repositories/theme_asset_repository.rb +1 -1
- data/lib/locomotive/steam/server.rb +0 -1
- data/lib/locomotive/steam/services.rb +7 -3
- data/lib/locomotive/steam/services/asset_host_service.rb +1 -3
- data/lib/locomotive/steam/services/image_resizer_service.rb +1 -3
- data/lib/locomotive/steam/services/liquid_parser_service.rb +1 -2
- data/lib/locomotive/steam/services/url_builder_service.rb +18 -1
- data/lib/locomotive/steam/version.rb +1 -1
- data/locomotivecms_steam.gemspec +9 -11
- data/spec/integration/repositories/theme_asset_repository_spec.rb +10 -0
- data/spec/support/helpers.rb +1 -0
- data/spec/support/liquid.rb +5 -0
- data/spec/unit/adapters/filesystem/simple_cache_store_spec.rb +27 -0
- data/spec/unit/adapters/filesystem/yaml_loaders/page_spec.rb +2 -0
- data/spec/unit/decorators/i18n_decorator_spec.rb +10 -0
- data/spec/unit/entities/content_entry_spec.rb +2 -2
- data/spec/unit/entities/content_type_field_spec.rb +15 -5
- data/spec/unit/entities/snippet_spec.rb +17 -0
- data/spec/unit/initializers/sprockets_spec.rb +25 -0
- data/spec/unit/liquid/drops/content_entry_collection_spec.rb +2 -0
- data/spec/unit/liquid/filters/html_spec.rb +28 -37
- data/spec/unit/liquid/tags/editable/control_spec.rb +4 -3
- data/spec/unit/liquid/tags/editable/file_spec.rb +7 -4
- data/spec/unit/liquid/tags/editable/text_spec.rb +4 -6
- data/spec/unit/liquid/tags/extends_spec.rb +3 -3
- data/spec/unit/liquid/tags/inherited_block_spec.rb +2 -2
- data/spec/unit/liquid/tags/nav_spec.rb +2 -2
- data/spec/unit/liquid/tags/snippet_spec.rb +3 -3
- data/spec/unit/middlewares/dynamic_assets_spec.rb +18 -9
- data/spec/unit/repositories/content_type_field_repository_spec.rb +51 -0
- data/spec/unit/services/url_builder_service_spec.rb +20 -3
- metadata +39 -56
- data/lib/locomotive/steam/core_ext.rb +0 -6
- data/lib/locomotive/steam/core_ext/array.rb +0 -3
- data/lib/locomotive/steam/core_ext/boolean/false.rb +0 -3
- data/lib/locomotive/steam/core_ext/boolean/true.rb +0 -3
- data/lib/locomotive/steam/core_ext/hash.rb +0 -39
- data/lib/locomotive/steam/core_ext/kernel.rb +0 -14
- data/lib/locomotive/steam/core_ext/string.rb +0 -37
- data/spec/fixtures/default/app/views/pages/songs.liquid +0 -6
- data/spec/unit/core_ext/string_spec.rb +0 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4defa074871fdae0481e4f65d6e33dfea1fede03
|
4
|
+
data.tar.gz: 3beda891d09f56d5883e284d958f42288be36c40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91b5751d14bdf87d35ab308399a222983bc91edbfe5cd9f7cca1c8a0036a12327930d3fe5196494ed4160ff6159db430df6ec7a4beb7a02374e81954472c1341
|
7
|
+
data.tar.gz: c7b56474a51cd689f9c0229d89c0630b376a699aa253909bdcaf1cdb8fc4dc70bc18f9986e20e32b84fd1d6f417fa460e7a97098812317d19f4ad82b0bc2b00f
|
data/Gemfile
CHANGED
@@ -3,7 +3,7 @@ source 'https://rubygems.org'
|
|
3
3
|
gemspec
|
4
4
|
|
5
5
|
group :development do
|
6
|
-
# gem 'locomotivecms_common', '~> 0.0.
|
6
|
+
# gem 'locomotivecms_common', '~> 0.0.3', path: '../common'
|
7
7
|
# gem 'locomotivecms_models', '~> 0.0.1', path: '../models'
|
8
8
|
# gem 'locomotivecms_models', '0.0.1.pre.alpha'
|
9
9
|
# gem 'locomotivecms-liquid', path: '/Users/didier/Documents/LocomotiveCMS/gems/liquid'
|
data/Gemfile.lock
CHANGED
@@ -1,29 +1,28 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
locomotivecms_steam (1.0.0.pre.alpha)
|
4
|
+
locomotivecms_steam (1.0.0.pre.alpha.1)
|
5
5
|
RedCloth (~> 4.2.9)
|
6
|
-
activesupport (~> 4.2.1)
|
7
6
|
chronic (~> 0.10.2)
|
8
|
-
coffee-script (~> 2.
|
7
|
+
coffee-script (~> 2.4.1)
|
9
8
|
compass (~> 1.0.3)
|
10
|
-
dragonfly (~> 1.0.
|
9
|
+
dragonfly (~> 1.0.9)
|
11
10
|
haml (~> 4.0.6)
|
12
11
|
httparty (~> 0.13.3)
|
13
|
-
kramdown (~> 1.
|
12
|
+
kramdown (~> 1.7.0)
|
14
13
|
locomotivecms-solid (~> 4.0.0.alpha2)
|
15
|
-
locomotivecms_common (~> 0.0.
|
16
|
-
mime-types (~> 2.
|
14
|
+
locomotivecms_common (~> 0.0.4)
|
15
|
+
mime-types (~> 2.5.0)
|
17
16
|
mimetype-fu (~> 0.1.2)
|
18
17
|
moneta (~> 0.8.0)
|
19
18
|
morphine (~> 0.1.1)
|
20
19
|
rack-cache (~> 1.2)
|
21
20
|
rack-rewrite (~> 1.5.1)
|
22
21
|
rack_csrf (~> 2.5.0)
|
23
|
-
sanitize (~>
|
22
|
+
sanitize (~> 4.0.0)
|
24
23
|
sprockets (~> 2.12.3)
|
24
|
+
sprockets-less (~> 0.6.1)
|
25
25
|
sprockets-sass (~> 1.3.1)
|
26
|
-
stringex (~> 2.5.2)
|
27
26
|
|
28
27
|
GEM
|
29
28
|
remote: https://rubygems.org/
|
@@ -35,21 +34,22 @@ GEM
|
|
35
34
|
minitest (~> 5.1)
|
36
35
|
thread_safe (~> 0.3, >= 0.3.4)
|
37
36
|
tzinfo (~> 1.1)
|
38
|
-
addressable (2.3.
|
37
|
+
addressable (2.3.8)
|
39
38
|
bson (2.3.0)
|
40
|
-
byebug (4.0.
|
39
|
+
byebug (4.0.5)
|
41
40
|
columnize (= 0.9.0)
|
42
41
|
chronic (0.10.2)
|
43
42
|
chunky_png (1.3.4)
|
44
43
|
codeclimate-test-reporter (0.4.7)
|
45
44
|
simplecov (>= 0.7.1, < 1.0.0)
|
46
45
|
coderay (1.1.0)
|
47
|
-
coffee-script (2.
|
46
|
+
coffee-script (2.4.1)
|
48
47
|
coffee-script-source
|
49
48
|
execjs
|
50
|
-
coffee-script-source (1.9.1)
|
51
|
-
colorize (0.7.
|
49
|
+
coffee-script-source (1.9.1.1)
|
50
|
+
colorize (0.7.7)
|
52
51
|
columnize (0.9.0)
|
52
|
+
commonjs (0.2.7)
|
53
53
|
compass (1.0.3)
|
54
54
|
chunky_png (~> 1.2)
|
55
55
|
compass-core (~> 1.0.2)
|
@@ -62,27 +62,31 @@ GEM
|
|
62
62
|
sass (>= 3.3.0, < 3.5)
|
63
63
|
compass-import-once (1.0.5)
|
64
64
|
sass (>= 3.2, < 3.5)
|
65
|
-
connection_pool (2.
|
65
|
+
connection_pool (2.2.0)
|
66
66
|
coveralls (0.7.12)
|
67
67
|
multi_json (~> 1.10)
|
68
68
|
rest-client (>= 1.6.8, < 2)
|
69
69
|
simplecov (~> 0.9.1)
|
70
70
|
term-ansicolor (~> 1.3)
|
71
71
|
thor (~> 0.19.1)
|
72
|
-
crass (1.0.
|
73
|
-
daemons (1.
|
72
|
+
crass (1.0.2)
|
73
|
+
daemons (1.2.2)
|
74
74
|
diff-lcs (1.2.5)
|
75
75
|
docile (1.1.5)
|
76
|
-
|
76
|
+
domain_name (0.5.24)
|
77
|
+
unf (>= 0.0.5, < 1.0.0)
|
78
|
+
dragonfly (1.0.9)
|
77
79
|
addressable (~> 2.3)
|
78
80
|
multi_json (~> 1.0)
|
79
81
|
rack
|
80
|
-
eventmachine (1.0.
|
81
|
-
execjs (2.
|
82
|
+
eventmachine (1.0.7)
|
83
|
+
execjs (2.5.2)
|
82
84
|
ffi (1.9.8)
|
83
85
|
haml (4.0.6)
|
84
86
|
tilt
|
85
87
|
hike (1.2.3)
|
88
|
+
http-cookie (1.0.2)
|
89
|
+
domain_name (~> 0.5)
|
86
90
|
httparty (0.13.3)
|
87
91
|
json (~> 1.8)
|
88
92
|
multi_xml (>= 0.5.2)
|
@@ -95,29 +99,33 @@ GEM
|
|
95
99
|
json_spec (1.1.4)
|
96
100
|
multi_json (~> 1.0)
|
97
101
|
rspec (>= 2.0, < 4.0)
|
98
|
-
kramdown (1.
|
102
|
+
kramdown (1.7.0)
|
103
|
+
less (2.6.0)
|
104
|
+
commonjs (~> 0.2.7)
|
99
105
|
locomotivecms-liquid (4.0.0.alpha2)
|
100
106
|
locomotivecms-solid (4.0.0.alpha2)
|
101
107
|
locomotivecms-liquid (~> 4.0.0.alpha2)
|
102
|
-
locomotivecms_common (0.0.
|
108
|
+
locomotivecms_common (0.0.4)
|
109
|
+
activesupport (~> 4.2.1)
|
103
110
|
colorize
|
111
|
+
stringex (~> 2.5.2)
|
104
112
|
method_source (0.8.2)
|
105
|
-
mime-types (2.
|
113
|
+
mime-types (2.5)
|
106
114
|
mimetype-fu (0.1.2)
|
107
115
|
mini_portile (0.6.2)
|
108
|
-
minitest (5.
|
116
|
+
minitest (5.6.1)
|
109
117
|
moneta (0.8.0)
|
110
118
|
moped (2.0.4)
|
111
119
|
bson (~> 2.2)
|
112
120
|
connection_pool (~> 2.0)
|
113
121
|
optionable (~> 0.2.0)
|
114
122
|
morphine (0.1.1)
|
115
|
-
multi_json (1.
|
123
|
+
multi_json (1.11.0)
|
116
124
|
multi_xml (0.5.5)
|
117
125
|
netrc (0.10.3)
|
118
126
|
nokogiri (1.6.6.2)
|
119
127
|
mini_portile (~> 0.6.0)
|
120
|
-
nokogumbo (1.
|
128
|
+
nokogumbo (1.4.1)
|
121
129
|
nokogiri
|
122
130
|
optionable (0.2.0)
|
123
131
|
origin (2.1.1)
|
@@ -128,7 +136,7 @@ GEM
|
|
128
136
|
pry-byebug (3.1.0)
|
129
137
|
byebug (~> 4.0)
|
130
138
|
pry (~> 0.10)
|
131
|
-
rack (1.6.
|
139
|
+
rack (1.6.1)
|
132
140
|
rack-cache (1.2)
|
133
141
|
rack (>= 0.4)
|
134
142
|
rack-rewrite (1.5.1)
|
@@ -140,26 +148,27 @@ GEM
|
|
140
148
|
rb-fsevent (0.9.4)
|
141
149
|
rb-inotify (0.9.5)
|
142
150
|
ffi (>= 0.5.0)
|
143
|
-
rest-client (1.
|
151
|
+
rest-client (1.8.0)
|
152
|
+
http-cookie (>= 1.0.2, < 2.0)
|
144
153
|
mime-types (>= 1.16, < 3.0)
|
145
154
|
netrc (~> 0.7)
|
146
155
|
rspec (3.2.0)
|
147
156
|
rspec-core (~> 3.2.0)
|
148
157
|
rspec-expectations (~> 3.2.0)
|
149
158
|
rspec-mocks (~> 3.2.0)
|
150
|
-
rspec-core (3.2.
|
159
|
+
rspec-core (3.2.3)
|
151
160
|
rspec-support (~> 3.2.0)
|
152
|
-
rspec-expectations (3.2.
|
161
|
+
rspec-expectations (3.2.1)
|
153
162
|
diff-lcs (>= 1.2.0, < 2.0)
|
154
163
|
rspec-support (~> 3.2.0)
|
155
164
|
rspec-mocks (3.2.1)
|
156
165
|
diff-lcs (>= 1.2.0, < 2.0)
|
157
166
|
rspec-support (~> 3.2.0)
|
158
167
|
rspec-support (3.2.2)
|
159
|
-
sanitize (
|
160
|
-
crass (~> 1.0.
|
168
|
+
sanitize (4.0.0)
|
169
|
+
crass (~> 1.0.2)
|
161
170
|
nokogiri (>= 1.4.4)
|
162
|
-
nokogumbo (= 1.
|
171
|
+
nokogumbo (= 1.4.1)
|
163
172
|
sass (3.4.13)
|
164
173
|
simplecov (0.9.2)
|
165
174
|
docile (~> 1.1.0)
|
@@ -172,6 +181,9 @@ GEM
|
|
172
181
|
multi_json (~> 1.0)
|
173
182
|
rack (~> 1.0)
|
174
183
|
tilt (~> 1.1, != 1.3.0)
|
184
|
+
sprockets-less (0.6.1)
|
185
|
+
less (~> 2.4)
|
186
|
+
tilt (~> 1.1)
|
175
187
|
sprockets-sass (1.3.1)
|
176
188
|
sprockets (~> 2.0)
|
177
189
|
tilt (~> 1.1)
|
@@ -186,9 +198,12 @@ GEM
|
|
186
198
|
thread_safe (0.3.5)
|
187
199
|
tilt (1.4.1)
|
188
200
|
timecop (0.7.3)
|
189
|
-
tins (1.
|
201
|
+
tins (1.5.1)
|
190
202
|
tzinfo (1.2.2)
|
191
203
|
thread_safe (~> 0.1)
|
204
|
+
unf (0.1.4)
|
205
|
+
unf_ext
|
206
|
+
unf_ext (0.0.7.1)
|
192
207
|
yui-compressor (0.12.0)
|
193
208
|
|
194
209
|
PLATFORMS
|
data/bin/steam.rb
CHANGED
@@ -22,7 +22,7 @@ OptionParser.new do |opts|
|
|
22
22
|
opts.banner = 'Usage: steam.rb [options]'
|
23
23
|
|
24
24
|
# Filesystem adapter
|
25
|
-
opts.on('
|
25
|
+
opts.on('--path PATH', 'Serve a Wagon site from a path in your filesystem') do |path|
|
26
26
|
options[:adapter][:path] = File.expand_path(path)
|
27
27
|
options[:asset_path] = File.expand_path(File.join(path, 'public'))
|
28
28
|
options[:database] = options[:hosts] = nil
|
data/lib/locomotive/steam.rb
CHANGED
@@ -1,11 +1,5 @@
|
|
1
1
|
require 'locomotive/common'
|
2
2
|
|
3
|
-
require 'active_support'
|
4
|
-
require 'active_support/concern'
|
5
|
-
require 'active_support/deprecation'
|
6
|
-
require 'active_support/core_ext'
|
7
|
-
|
8
|
-
require_relative 'steam/core_ext'
|
9
3
|
require_relative 'steam/configuration'
|
10
4
|
require_relative_all 'steam/decorators'
|
11
5
|
require_relative 'steam/liquid'
|
@@ -24,6 +18,8 @@ module Locomotive
|
|
24
18
|
|
25
19
|
CONTENT_ENTRY_ENGINE_CLASS_NAME = /^Locomotive::ContentEntry(.*)$/o
|
26
20
|
|
21
|
+
IsHTTP = /^https?:\/\//o
|
22
|
+
|
27
23
|
class << self
|
28
24
|
attr_writer :configuration
|
29
25
|
end
|
@@ -42,6 +38,12 @@ module Locomotive
|
|
42
38
|
require_relative 'steam/initializers'
|
43
39
|
end
|
44
40
|
|
41
|
+
# Shortcut to build the Rack stack
|
42
|
+
def self.to_app
|
43
|
+
require_relative 'steam/server'
|
44
|
+
Server.to_app
|
45
|
+
end
|
46
|
+
|
45
47
|
# FIXME: not sure it will ever be needed
|
46
48
|
# class << self
|
47
49
|
# def method_missing(name, *args, &block)
|
@@ -34,7 +34,7 @@ module Locomotive
|
|
34
34
|
def build_field(name, attributes)
|
35
35
|
attributes.tap do |attributes|
|
36
36
|
attributes[:name] = name.to_s
|
37
|
-
attributes[:type] = attributes[:type].
|
37
|
+
attributes[:type] = (attributes[:type] || 'string').to_s.downcase
|
38
38
|
|
39
39
|
if attributes[:label].blank?
|
40
40
|
attributes[:label] = name.to_s.humanize
|
@@ -21,7 +21,7 @@ module Locomotive
|
|
21
21
|
|
22
22
|
def load_tree
|
23
23
|
{}.tap do |hash|
|
24
|
-
each_file do |filepath,
|
24
|
+
each_file do |filepath, fullpath, locale|
|
25
25
|
|
26
26
|
if leaf = hash[fullpath]
|
27
27
|
update(leaf, filepath, fullpath, locale)
|
@@ -31,6 +31,10 @@ module Locomotive
|
|
31
31
|
|
32
32
|
hash[fullpath] = leaf
|
33
33
|
end
|
34
|
+
|
35
|
+
each_directory do |filepath, fullpath, locale|
|
36
|
+
hash[fullpath] ||= build(filepath, fullpath, locale)
|
37
|
+
end
|
34
38
|
end.values
|
35
39
|
end
|
36
40
|
|
@@ -40,7 +44,7 @@ module Locomotive
|
|
40
44
|
|
41
45
|
{
|
42
46
|
title: { locale => attributes.delete(:title) || (default_locale == locale ? slug.humanize : nil) },
|
43
|
-
slug: { locale => attributes.delete(:slug) || slug },
|
47
|
+
slug: { locale => attributes.delete(:slug) || slug.dasherize },
|
44
48
|
template_path: { locale => template_path(filepath, attributes, locale) },
|
45
49
|
redirect_url: { locale => attributes.delete(:redirect_url) },
|
46
50
|
editable_elements: build_editable_elements(attributes.delete(:editable_elements), locale),
|
@@ -53,7 +57,7 @@ module Locomotive
|
|
53
57
|
attributes = get_attributes(filepath, fullpath)
|
54
58
|
|
55
59
|
leaf[:title][locale] = attributes.delete(:title) || slug.humanize
|
56
|
-
leaf[:slug][locale] = attributes.delete(:slug) || slug
|
60
|
+
leaf[:slug][locale] = attributes.delete(:slug) || slug.dasherize
|
57
61
|
leaf[:template_path][locale] = template_path(filepath, attributes, locale)
|
58
62
|
leaf[:redirect_url][locale] = attributes.delete(:redirect_url)
|
59
63
|
|
@@ -63,12 +67,20 @@ module Locomotive
|
|
63
67
|
end
|
64
68
|
|
65
69
|
def get_attributes(filepath, fullpath)
|
66
|
-
|
67
|
-
|
68
|
-
|
70
|
+
if File.directory?(filepath)
|
71
|
+
{
|
72
|
+
title: File.basename(filepath).humanize,
|
73
|
+
listed: false,
|
74
|
+
published: false
|
75
|
+
}
|
76
|
+
else
|
77
|
+
_load(filepath, true) do |attributes, template|
|
78
|
+
# make sure index/404 are the slugs of the index/404 pages
|
79
|
+
attributes.delete(:slug) if %w(index 404).include?(fullpath)
|
69
80
|
|
70
|
-
|
71
|
-
|
81
|
+
# trick to use the template of the default locale (if available)
|
82
|
+
attributes[:template_path] = false if template.blank?
|
83
|
+
end
|
72
84
|
end
|
73
85
|
end
|
74
86
|
|
@@ -82,7 +94,17 @@ module Locomotive
|
|
82
94
|
|
83
95
|
locale = template_extensions.include?(extension_or_locale) ? default_locale : extension_or_locale
|
84
96
|
|
85
|
-
yield(filepath,
|
97
|
+
yield(filepath, fullpath, locale.to_sym)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def each_directory(&block)
|
102
|
+
Dir.glob(File.join(path, '**', '*')).each do |filepath|
|
103
|
+
next unless File.directory?(filepath)
|
104
|
+
|
105
|
+
fullpath = get_relative_path(filepath)
|
106
|
+
|
107
|
+
yield(filepath, fullpath, default_locale.to_sym)
|
86
108
|
end
|
87
109
|
end
|
88
110
|
|
@@ -91,7 +113,7 @@ module Locomotive
|
|
91
113
|
end
|
92
114
|
|
93
115
|
def template_path(filepath, attributes, locale)
|
94
|
-
if attributes.delete(:template_path) == false && locale != default_locale
|
116
|
+
if File.directory?(filepath) || (attributes.delete(:template_path) == false && locale != default_locale)
|
95
117
|
false
|
96
118
|
else
|
97
119
|
filepath
|
@@ -9,7 +9,37 @@ module Locomotive
|
|
9
9
|
include Adapters::Filesystem::YAMLLoader
|
10
10
|
|
11
11
|
def load(scope)
|
12
|
-
|
12
|
+
super
|
13
|
+
[].tap do |list|
|
14
|
+
each_file do |filepath, folder|
|
15
|
+
list << { source: filepath, folder: folder }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def each_file(&block)
|
23
|
+
# Follows symlinks and makes sure subdirectories are handled
|
24
|
+
pattern = ['**', '*', '**', '*']
|
25
|
+
|
26
|
+
Dir.glob(File.join(path, *pattern)).each do |file|
|
27
|
+
next if exclude?(file)
|
28
|
+
|
29
|
+
folder = File.dirname(file.gsub(File.join(path, ''), ''))
|
30
|
+
|
31
|
+
yield(file, folder)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def exclude?(file)
|
36
|
+
File.directory?(file) ||
|
37
|
+
file.starts_with?(File.join(path, 'samples')) ||
|
38
|
+
File.basename(file).starts_with?('_')
|
39
|
+
end
|
40
|
+
|
41
|
+
def path
|
42
|
+
@path ||= File.join(site_path, 'public')
|
13
43
|
end
|
14
44
|
|
15
45
|
end
|
@@ -65,7 +65,7 @@ module Locomotive
|
|
65
65
|
|
66
66
|
def __get_localized_value__(name)
|
67
67
|
field = __getobj__.public_send(name.to_sym)
|
68
|
-
field[__locale__] || field[__default_locale__]
|
68
|
+
field ? field[__locale__] || field[__default_locale__] : nil
|
69
69
|
end
|
70
70
|
|
71
71
|
def __set_localized_value__(name, value)
|
@@ -61,6 +61,14 @@ module Locomotive::Steam
|
|
61
61
|
self[content_type.label_field_name]
|
62
62
|
end
|
63
63
|
|
64
|
+
def localized_attributes
|
65
|
+
@localized_attributes.tap do |hash|
|
66
|
+
if hash && hash.has_key?(content_type.label_field_name.to_sym)
|
67
|
+
hash[:_label] = true
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
64
72
|
def to_liquid
|
65
73
|
Locomotive::Steam::Liquid::Drops::ContentEntry.new(self)
|
66
74
|
end
|
@@ -137,7 +145,7 @@ module Locomotive::Steam
|
|
137
145
|
class FileField < Struct.new(:filename, :base, :updated_at)
|
138
146
|
|
139
147
|
def url
|
140
|
-
"#{base}/#{filename}"
|
148
|
+
base.blank? ? filename : "#{base}/#{filename}"
|
141
149
|
end
|
142
150
|
|
143
151
|
def to_liquid
|