sitepress-rails 1.0.0 → 2.0.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +7 -0
- data/README.md +1 -1
- data/bin/rails +13 -0
- data/lib/sitepress/build_paths/directory_index_path.rb +12 -0
- data/lib/sitepress/build_paths/index_path.rb +20 -0
- data/lib/sitepress/build_paths/root_path.rb +40 -0
- data/lib/sitepress/compiler.rb +68 -0
- data/lib/sitepress/engine.rb +44 -12
- data/lib/sitepress/rails.rb +12 -10
- data/lib/sitepress/rails_configuration.rb +8 -6
- data/lib/sitepress/renderers/controller.rb +51 -0
- data/lib/sitepress/renderers/server.rb +25 -0
- data/{app → rails/app}/controllers/concerns/sitepress/site_pages.rb +49 -8
- data/{app → rails/app}/controllers/sitepress/site_controller.rb +1 -1
- data/{config → rails/config}/routes.rb +5 -0
- data/sitepress-rails.gemspec +32 -0
- data/spec/dummy/log/test.log +2440 -79076
- data/spec/sitepress-rails_spec.rb +1 -30
- data/spec/sitepress/compiler_spec.rb +19 -0
- data/spec/sitepress/sitepress_site_controller_spec.rb +47 -6
- metadata +108 -71
- data/app/helpers/sitepress/application_helper.rb +0 -4
- data/lib/sitepress/extensions/index_request_path.rb +0 -24
- data/lib/sitepress/extensions/partials_remover.rb +0 -19
- data/lib/sitepress/extensions/rails_request_paths.rb +0 -20
- data/spec/dummy/db/production.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/production.log +0 -1360
- data/spec/sitepress/extensions/index_request_path_spec.rb +0 -15
- data/spec/sitepress/extensions/partials_remover_spec.rb +0 -12
- data/spec/sitepress/extensions/rails_request_paths_spec.rb +0 -9
@@ -8,10 +8,6 @@ describe "Sitepress.configuration" do
|
|
8
8
|
before do
|
9
9
|
app.config.eager_load = cache_classes # WTF?
|
10
10
|
end
|
11
|
-
it "has site" do
|
12
|
-
app.initialize!
|
13
|
-
expect(subject.site.root_path).to eql(app.root.join("app/content"))
|
14
|
-
end
|
15
11
|
it "has Rails.application as parent engine" do
|
16
12
|
app.initialize!
|
17
13
|
expect(subject.parent_engine).to eql(app)
|
@@ -43,29 +39,4 @@ describe "Sitepress.configuration" do
|
|
43
39
|
end
|
44
40
|
end
|
45
41
|
end
|
46
|
-
|
47
|
-
it "is in Rails middleware stack" do
|
48
|
-
expect(Rails.configuration.middleware).to include(Sitepress::Middleware::RequestCache)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
context "Rails.configuration.paths" do
|
52
|
-
subject { Rails.configuration.paths[path].to_a }
|
53
|
-
context "views" do
|
54
|
-
let(:path) { "app/views" }
|
55
|
-
it { should include(app.root.join("app/content").to_s) }
|
56
|
-
end
|
57
|
-
context "helpers" do
|
58
|
-
let(:path) { "app/helpers" }
|
59
|
-
it { should include(app.root.join("app/content/helpers").to_s) }
|
60
|
-
end
|
61
|
-
context "assets" do
|
62
|
-
let(:path) { "app/assets" }
|
63
|
-
it { should include(app.root.join("app/content/assets").to_s) }
|
64
|
-
end
|
65
|
-
end
|
66
|
-
context "#partals" do
|
67
|
-
it "excludes partials" do
|
68
|
-
expect(subject.site.resources.size).to eql(2)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
42
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "tmpdir"
|
3
|
+
require "fileutils"
|
4
|
+
|
5
|
+
describe Sitepress::Compiler do
|
6
|
+
let(:site) { Sitepress.site }
|
7
|
+
let(:target) { Pathname.new(Dir::tmpdir).join("build") }
|
8
|
+
# Write compiler output to /dev/null so our test output remains clean.
|
9
|
+
let(:stdout) { File.open(File::NULL, "w") }
|
10
|
+
subject { Sitepress::Compiler.new(site: site, stdout: stdout) }
|
11
|
+
describe "#compile" do
|
12
|
+
before { FileUtils.mkdir_p(target) }
|
13
|
+
after { FileUtils.rm_rf(target) }
|
14
|
+
it "writes files to target" do
|
15
|
+
subject.compile(target_path: target)
|
16
|
+
expect(Dir.glob(target.join("**")).size).to eql(2) # 2 items in the site... mkay?
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -10,10 +10,12 @@ describe Sitepress::SiteController, type: :controller do
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
+
let(:site) { Sitepress.configuration.site }
|
14
|
+
|
13
15
|
context "templated page" do
|
14
16
|
render_views
|
15
17
|
before { get_resource "/time" }
|
16
|
-
let(:resource) {
|
18
|
+
let(:resource) { site.get("/time") }
|
17
19
|
it "is status 200" do
|
18
20
|
expect(response.status).to eql(200)
|
19
21
|
end
|
@@ -24,7 +26,7 @@ describe Sitepress::SiteController, type: :controller do
|
|
24
26
|
expect(response.body).to include("<title>Test layout</title>")
|
25
27
|
end
|
26
28
|
it "responds with content type" do
|
27
|
-
expect(response.content_type).to
|
29
|
+
expect(response.content_type).to include("text/html")
|
28
30
|
end
|
29
31
|
context "helper methods" do
|
30
32
|
subject { @controller }
|
@@ -32,7 +34,7 @@ describe Sitepress::SiteController, type: :controller do
|
|
32
34
|
expect(subject.send(:current_page).asset.path).to eql(resource.asset.path)
|
33
35
|
end
|
34
36
|
it "#site" do
|
35
|
-
expect(subject.send(:site)).to eql(
|
37
|
+
expect(subject.send(:site)).to eql(site)
|
36
38
|
end
|
37
39
|
end
|
38
40
|
end
|
@@ -46,11 +48,11 @@ describe Sitepress::SiteController, type: :controller do
|
|
46
48
|
it "renders body" do
|
47
49
|
expect(response.body).to include("<h1>Hi!</h1>")
|
48
50
|
end
|
49
|
-
it "
|
50
|
-
expect(response.body).
|
51
|
+
it "does not render layout" do
|
52
|
+
expect(response.body).to_not include("<title>Dummy</title>")
|
51
53
|
end
|
52
54
|
it "responds with content type" do
|
53
|
-
expect(response.content_type).to
|
55
|
+
expect(response.content_type).to include("text/html")
|
54
56
|
end
|
55
57
|
end
|
56
58
|
|
@@ -61,4 +63,43 @@ describe Sitepress::SiteController, type: :controller do
|
|
61
63
|
}.to raise_exception(ActionController::RoutingError)
|
62
64
|
end
|
63
65
|
end
|
66
|
+
|
67
|
+
context "paths" do
|
68
|
+
context "view_paths" do
|
69
|
+
subject { Sitepress::SiteController.view_paths.map(&:path) }
|
70
|
+
it { is_expected.to include(site.root_path.to_s) }
|
71
|
+
it { is_expected.to include(site.pages_path.to_s) }
|
72
|
+
end
|
73
|
+
context "helper_paths" do
|
74
|
+
subject{ Sitepress::SiteController.helpers_path }
|
75
|
+
it { is_expected.to include(site.helpers_path.to_s) }
|
76
|
+
it "has site#helper_paths in ActiveSupport::Dependencies.autoload_paths" do
|
77
|
+
expect(ActiveSupport::Dependencies.autoload_paths).to include(site.helpers_path.to_s)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context "render cache" do
|
83
|
+
context "cache_resources=true" do
|
84
|
+
before { site.cache_resources = true }
|
85
|
+
it "enables cache" do
|
86
|
+
expect(site.cache_resources).to be true
|
87
|
+
expect(site).to receive(:cache_resources=).with(true)
|
88
|
+
expect(site).to receive(:cache_resources=).with(true)
|
89
|
+
get_resource "/time"
|
90
|
+
expect(site.cache_resources).to be true
|
91
|
+
end
|
92
|
+
end
|
93
|
+
context "cache_resources=false" do
|
94
|
+
before { site.cache_resources = false }
|
95
|
+
it "enables cache" do
|
96
|
+
expect(site.cache_resources).to be false
|
97
|
+
expect(site).to receive(:cache_resources=).with(true)
|
98
|
+
expect(site).to receive(:cache_resources=).with(false)
|
99
|
+
get_resource "/time"
|
100
|
+
expect(site.cache_resources).to be false
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
64
105
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sitepress-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0.beta4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brad Gessler
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec-rails
|
@@ -45,7 +45,7 @@ dependencies:
|
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '4.0'
|
48
|
-
type: :
|
48
|
+
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
@@ -58,36 +58,83 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 2.0.0.beta4
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
69
|
-
|
68
|
+
version: 2.0.0.beta4
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: railties
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5.0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: actionpack
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '5.0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '5.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: sprockets-rails
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 2.0.0
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 2.0.0
|
111
|
+
description:
|
70
112
|
email:
|
71
113
|
- bradgessler@gmail.com
|
72
114
|
executables: []
|
73
115
|
extensions: []
|
74
116
|
extra_rdoc_files: []
|
75
117
|
files:
|
118
|
+
- ".gitignore"
|
76
119
|
- README.md
|
77
120
|
- Rakefile
|
78
|
-
-
|
79
|
-
- app/controllers/sitepress/site_controller.rb
|
80
|
-
- app/helpers/sitepress/application_helper.rb
|
81
|
-
- config/routes.rb
|
121
|
+
- bin/rails
|
82
122
|
- lib/sitepress-rails.rb
|
123
|
+
- lib/sitepress/build_paths/directory_index_path.rb
|
124
|
+
- lib/sitepress/build_paths/index_path.rb
|
125
|
+
- lib/sitepress/build_paths/root_path.rb
|
126
|
+
- lib/sitepress/compiler.rb
|
83
127
|
- lib/sitepress/engine.rb
|
84
|
-
- lib/sitepress/extensions/index_request_path.rb
|
85
|
-
- lib/sitepress/extensions/partials_remover.rb
|
86
|
-
- lib/sitepress/extensions/rails_request_paths.rb
|
87
128
|
- lib/sitepress/rails.rb
|
88
129
|
- lib/sitepress/rails_configuration.rb
|
130
|
+
- lib/sitepress/renderers/controller.rb
|
131
|
+
- lib/sitepress/renderers/server.rb
|
89
132
|
- lib/sitepress/route_constraint.rb
|
90
133
|
- lib/tasks/sitepress_tasks.rake
|
134
|
+
- rails/app/controllers/concerns/sitepress/site_pages.rb
|
135
|
+
- rails/app/controllers/sitepress/site_controller.rb
|
136
|
+
- rails/config/routes.rb
|
137
|
+
- sitepress-rails.gemspec
|
91
138
|
- spec/dummy/Rakefile
|
92
139
|
- spec/dummy/app/assets/config/manifest.js
|
93
140
|
- spec/dummy/app/assets/javascripts/application.js
|
@@ -137,9 +184,6 @@ files:
|
|
137
184
|
- spec/dummy/config/routes.rb
|
138
185
|
- spec/dummy/config/secrets.yml
|
139
186
|
- spec/dummy/config/spring.rb
|
140
|
-
- spec/dummy/db/production.sqlite3
|
141
|
-
- spec/dummy/db/test.sqlite3
|
142
|
-
- spec/dummy/log/production.log
|
143
187
|
- spec/dummy/log/test.log
|
144
188
|
- spec/dummy/public/404.html
|
145
189
|
- spec/dummy/public/422.html
|
@@ -148,9 +192,7 @@ files:
|
|
148
192
|
- spec/dummy/public/apple-touch-icon.png
|
149
193
|
- spec/dummy/public/favicon.ico
|
150
194
|
- spec/sitepress-rails_spec.rb
|
151
|
-
- spec/sitepress/
|
152
|
-
- spec/sitepress/extensions/partials_remover_spec.rb
|
153
|
-
- spec/sitepress/extensions/rails_request_paths_spec.rb
|
195
|
+
- spec/sitepress/compiler_spec.rb
|
154
196
|
- spec/sitepress/rails_configuration_spec.rb
|
155
197
|
- spec/sitepress/route_constraint_spec.rb
|
156
198
|
- spec/sitepress/routes_spec.rb
|
@@ -165,7 +207,7 @@ files:
|
|
165
207
|
homepage: https://github.com/sitepress/sitepress
|
166
208
|
licenses: []
|
167
209
|
metadata: {}
|
168
|
-
post_install_message:
|
210
|
+
post_install_message:
|
169
211
|
rdoc_options: []
|
170
212
|
require_paths:
|
171
213
|
- lib
|
@@ -176,86 +218,81 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
176
218
|
version: '0'
|
177
219
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
220
|
requirements:
|
179
|
-
- - "
|
221
|
+
- - ">"
|
180
222
|
- !ruby/object:Gem::Version
|
181
|
-
version:
|
223
|
+
version: 1.3.1
|
182
224
|
requirements: []
|
183
|
-
rubygems_version: 3.
|
184
|
-
signing_key:
|
225
|
+
rubygems_version: 3.2.3
|
226
|
+
signing_key:
|
185
227
|
specification_version: 4
|
186
228
|
summary: Sitepress rails integration.
|
187
229
|
test_files:
|
188
|
-
- spec/
|
189
|
-
- spec/
|
190
|
-
- spec/dummy/app/
|
230
|
+
- spec/dummy/Rakefile
|
231
|
+
- spec/dummy/app/assets/config/manifest.js
|
232
|
+
- spec/dummy/app/assets/javascripts/application.js
|
233
|
+
- spec/dummy/app/assets/javascripts/cable.js
|
234
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
235
|
+
- spec/dummy/app/content/helpers/sample_helper.rb
|
191
236
|
- spec/dummy/app/content/layouts/sitepress_test_layout.html.erb
|
192
|
-
- spec/dummy/app/content/pages/time.html.erb
|
193
237
|
- spec/dummy/app/content/pages/_stupid.html.erb
|
194
238
|
- spec/dummy/app/content/pages/hi.html
|
195
239
|
- spec/dummy/app/content/pages/partials/_really_stupid.html.erb
|
196
|
-
- spec/dummy/app/content/
|
197
|
-
- spec/dummy/app/jobs/application_job.rb
|
240
|
+
- spec/dummy/app/content/pages/time.html.erb
|
198
241
|
- spec/dummy/app/controllers/application_controller.rb
|
199
242
|
- spec/dummy/app/controllers/baseline_controller.rb
|
243
|
+
- spec/dummy/app/helpers/application_helper.rb
|
244
|
+
- spec/dummy/app/jobs/application_job.rb
|
245
|
+
- spec/dummy/app/mailers/application_mailer.rb
|
200
246
|
- spec/dummy/app/views/baseline/show.html.erb
|
201
247
|
- spec/dummy/app/views/layouts/application.html.erb
|
202
248
|
- spec/dummy/app/views/layouts/mailer.html.erb
|
203
249
|
- spec/dummy/app/views/layouts/mailer.text.erb
|
204
|
-
- spec/dummy/app/assets/config/manifest.js
|
205
|
-
- spec/dummy/app/assets/javascripts/cable.js
|
206
|
-
- spec/dummy/app/assets/javascripts/application.js
|
207
|
-
- spec/dummy/app/assets/stylesheets/application.css
|
208
|
-
- spec/dummy/app/helpers/application_helper.rb
|
209
|
-
- spec/dummy/bin/update
|
210
|
-
- spec/dummy/bin/rake
|
211
|
-
- spec/dummy/bin/setup
|
212
250
|
- spec/dummy/bin/bundle
|
213
251
|
- spec/dummy/bin/rails
|
214
|
-
- spec/dummy/
|
215
|
-
- spec/dummy/
|
216
|
-
- spec/dummy/
|
252
|
+
- spec/dummy/bin/rake
|
253
|
+
- spec/dummy/bin/setup
|
254
|
+
- spec/dummy/bin/update
|
255
|
+
- spec/dummy/config/application.rb
|
256
|
+
- spec/dummy/config/boot.rb
|
217
257
|
- spec/dummy/config/cable.yml
|
218
|
-
- spec/dummy/config/
|
258
|
+
- spec/dummy/config/database.yml
|
259
|
+
- spec/dummy/config/environment.rb
|
219
260
|
- spec/dummy/config/environments/development.rb
|
261
|
+
- spec/dummy/config/environments/production.rb
|
220
262
|
- spec/dummy/config/environments/test.rb
|
221
|
-
- spec/dummy/config/spring.rb
|
222
|
-
- spec/dummy/config/environment.rb
|
223
|
-
- spec/dummy/config/application.rb
|
224
|
-
- spec/dummy/config/puma.rb
|
225
|
-
- spec/dummy/config/database.yml
|
226
|
-
- spec/dummy/config/boot.rb
|
227
263
|
- spec/dummy/config/initializers/application_controller_renderer.rb
|
264
|
+
- spec/dummy/config/initializers/assets.rb
|
228
265
|
- spec/dummy/config/initializers/backtrace_silencers.rb
|
229
|
-
- spec/dummy/config/initializers/
|
230
|
-
- spec/dummy/config/initializers/mime_types.rb
|
266
|
+
- spec/dummy/config/initializers/cookies_serializer.rb
|
231
267
|
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
268
|
+
- spec/dummy/config/initializers/inflections.rb
|
269
|
+
- spec/dummy/config/initializers/mime_types.rb
|
270
|
+
- spec/dummy/config/initializers/null_logger.rb
|
232
271
|
- spec/dummy/config/initializers/session_store.rb
|
233
272
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
234
|
-
- spec/dummy/config/
|
235
|
-
- spec/dummy/config/
|
236
|
-
- spec/dummy/config/
|
273
|
+
- spec/dummy/config/locales/en.yml
|
274
|
+
- spec/dummy/config/puma.rb
|
275
|
+
- spec/dummy/config/routes.rb
|
276
|
+
- spec/dummy/config/secrets.yml
|
277
|
+
- spec/dummy/config/spring.rb
|
237
278
|
- spec/dummy/config.ru
|
238
|
-
- spec/dummy/
|
239
|
-
- spec/dummy/public/
|
279
|
+
- spec/dummy/log/test.log
|
280
|
+
- spec/dummy/public/404.html
|
240
281
|
- spec/dummy/public/422.html
|
241
|
-
- spec/dummy/public/apple-touch-icon.png
|
242
282
|
- spec/dummy/public/500.html
|
243
|
-
- spec/dummy/public/404.html
|
244
283
|
- spec/dummy/public/apple-touch-icon-precomposed.png
|
245
|
-
- spec/dummy/
|
246
|
-
- spec/dummy/
|
247
|
-
- spec/
|
248
|
-
- spec/
|
284
|
+
- spec/dummy/public/apple-touch-icon.png
|
285
|
+
- spec/dummy/public/favicon.ico
|
286
|
+
- spec/sitepress/compiler_spec.rb
|
287
|
+
- spec/sitepress/rails_configuration_spec.rb
|
288
|
+
- spec/sitepress/route_constraint_spec.rb
|
289
|
+
- spec/sitepress/routes_spec.rb
|
290
|
+
- spec/sitepress/sitepress_site_controller_spec.rb
|
291
|
+
- spec/sitepress-rails_spec.rb
|
249
292
|
- spec/sites/sample/pages/index.html.erb
|
250
|
-
- spec/sites/sample/pages/
|
293
|
+
- spec/sites/sample/pages/nothing
|
251
294
|
- spec/sites/sample/pages/sin_frontmatter.html.haml
|
252
295
|
- spec/sites/sample/pages/super.duper/index.html
|
253
|
-
- spec/sites/sample/pages/
|
296
|
+
- spec/sites/sample/pages/test.html.haml
|
254
297
|
- spec/sites/sample/pages/text.txt
|
255
|
-
- spec/
|
256
|
-
- spec/sitepress/extensions/partials_remover_spec.rb
|
257
|
-
- spec/sitepress/extensions/index_request_path_spec.rb
|
258
|
-
- spec/sitepress/sitepress_site_controller_spec.rb
|
259
|
-
- spec/sitepress/rails_configuration_spec.rb
|
260
|
-
- spec/sitepress/routes_spec.rb
|
261
|
-
- spec/sitepress/route_constraint_spec.rb
|
298
|
+
- spec/spec_helper.rb
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module Sitepress
|
2
|
-
module Extensions
|
3
|
-
# Removes files beginning with "_" from the resource collection.
|
4
|
-
class IndexRequestPath
|
5
|
-
# Name of the file that we'll want to change to a / path
|
6
|
-
FILE_NAME = "index.html".freeze
|
7
|
-
|
8
|
-
def initialize(file_name: FILE_NAME)
|
9
|
-
@file_name = file_name
|
10
|
-
end
|
11
|
-
|
12
|
-
def process_resources(node)
|
13
|
-
node.flatten.each do |r|
|
14
|
-
asset = r.asset
|
15
|
-
if asset.path.basename.to_s.start_with? @file_name
|
16
|
-
request_path = Pathname.new("/").join(r.request_path).dirname.cleanpath.to_s
|
17
|
-
node.formats.remove(r)
|
18
|
-
node.add(path: request_path, asset: asset)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|