sitepress-rails 0.1.27 → 2.0.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +8 -2
- data/app/controllers/concerns/sitepress/site_pages.rb +82 -11
- data/app/controllers/sitepress/site_controller.rb +1 -1
- data/config/routes.rb +5 -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 +40 -17
- 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/spec/dummy/config/application.rb +3 -1
- data/spec/dummy/config/environments/development.rb +1 -1
- data/spec/dummy/config/environments/production.rb +1 -1
- data/spec/dummy/log/test.log +2692 -57880
- data/spec/sitepress-rails_spec.rb +11 -33
- data/spec/sitepress/compiler_spec.rb +19 -0
- data/spec/sitepress/sitepress_site_controller_spec.rb +59 -9
- metadata +61 -44
- 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/app/models/application_record.rb +0 -3
- data/spec/dummy/db/production.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/production.log +0 -392
- 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
@@ -4,61 +4,39 @@ require "sitepress-rails"
|
|
4
4
|
describe "Sitepress.configuration" do
|
5
5
|
subject { Sitepress.configuration }
|
6
6
|
let(:app) { Dummy::Application.new }
|
7
|
-
let(:cache_classes) {
|
7
|
+
let(:cache_classes) { false }
|
8
8
|
before do
|
9
9
|
app.config.eager_load = cache_classes # WTF?
|
10
|
-
app.config.cache_classes = cache_classes # This is what I really want to test.
|
11
|
-
app.initialize!
|
12
|
-
end
|
13
|
-
it "has site" do
|
14
|
-
expect(subject.site.root_path).to eql(app.root.join("app/content"))
|
15
10
|
end
|
16
11
|
it "has Rails.application as parent engine" do
|
12
|
+
app.initialize!
|
17
13
|
expect(subject.parent_engine).to eql(app)
|
18
14
|
end
|
19
15
|
it "has Rails.application as parent engine" do
|
20
|
-
|
16
|
+
app.initialize!
|
17
|
+
expect(subject.cache_resources).to be_nil
|
21
18
|
end
|
22
19
|
it "has routes enabled by default" do
|
20
|
+
app.initialize!
|
23
21
|
expect(subject.routes).to be true
|
24
22
|
end
|
25
23
|
context "#cache_resources" do
|
24
|
+
before do
|
25
|
+
app.config.cache_classes = cache_classes # This is what I really want to test.
|
26
|
+
end
|
26
27
|
context "Rails.configuration.cache_classes=true" do
|
27
28
|
let(:cache_classes) { true }
|
28
29
|
it "is true" do
|
30
|
+
app.initialize!
|
29
31
|
expect(subject.cache_resources).to eql(true)
|
30
32
|
end
|
31
33
|
end
|
32
34
|
context "Rails.configuration.cache_classes=false" do
|
33
35
|
let(:cache_classes) { false }
|
34
36
|
it "is false" do
|
37
|
+
app.initialize!
|
35
38
|
expect(subject.cache_resources).to eql(false)
|
36
39
|
end
|
37
40
|
end
|
38
41
|
end
|
39
|
-
|
40
|
-
it "is in Rails middleware stack" do
|
41
|
-
expect(app.config.middleware).to include(Sitepress::Middleware::RequestCache)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
context "Rails.configuration.paths" do
|
45
|
-
subject { Rails.configuration.paths[path].to_a }
|
46
|
-
context "views" do
|
47
|
-
let(:path) { "app/views" }
|
48
|
-
it { should include(app.root.join("app/content").to_s) }
|
49
|
-
end
|
50
|
-
context "helpers" do
|
51
|
-
let(:path) { "app/helpers" }
|
52
|
-
it { should include(app.root.join("app/content/helpers").to_s) }
|
53
|
-
end
|
54
|
-
context "assets" do
|
55
|
-
let(:path) { "app/assets" }
|
56
|
-
it { should include(app.root.join("app/content/assets").to_s) }
|
57
|
-
end
|
58
|
-
end
|
59
|
-
context "#partals" do
|
60
|
-
it "excludes partials" do
|
61
|
-
expect(subject.site.resources.size).to eql(2)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
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
|
@@ -1,10 +1,21 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Sitepress::SiteController, type: :controller do
|
4
|
+
# Rails 5 introduces a new format of calling the `get` rspec helper method.
|
5
|
+
def get_resource(path)
|
6
|
+
if Gem::Version.new(Rails.version) >= Gem::Version.new("5.0.0")
|
7
|
+
get :show, params: { resource_path: path }
|
8
|
+
else
|
9
|
+
get :show, resource_path: path
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:site) { Sitepress.configuration.site }
|
14
|
+
|
4
15
|
context "templated page" do
|
5
16
|
render_views
|
6
|
-
before {
|
7
|
-
let(:resource) {
|
17
|
+
before { get_resource "/time" }
|
18
|
+
let(:resource) { site.get("/time") }
|
8
19
|
it "is status 200" do
|
9
20
|
expect(response.status).to eql(200)
|
10
21
|
end
|
@@ -15,7 +26,7 @@ describe Sitepress::SiteController, type: :controller do
|
|
15
26
|
expect(response.body).to include("<title>Test layout</title>")
|
16
27
|
end
|
17
28
|
it "responds with content type" do
|
18
|
-
expect(response.content_type).to
|
29
|
+
expect(response.content_type).to include("text/html")
|
19
30
|
end
|
20
31
|
context "helper methods" do
|
21
32
|
subject { @controller }
|
@@ -23,33 +34,72 @@ describe Sitepress::SiteController, type: :controller do
|
|
23
34
|
expect(subject.send(:current_page).asset.path).to eql(resource.asset.path)
|
24
35
|
end
|
25
36
|
it "#site" do
|
26
|
-
expect(subject.send(:site)).to eql(
|
37
|
+
expect(subject.send(:site)).to eql(site)
|
27
38
|
end
|
28
39
|
end
|
29
40
|
end
|
30
41
|
|
31
42
|
context "static page" do
|
32
43
|
render_views
|
33
|
-
before {
|
44
|
+
before { get_resource "/hi" }
|
34
45
|
it "is status 200" do
|
35
46
|
expect(response.status).to eql(200)
|
36
47
|
end
|
37
48
|
it "renders body" do
|
38
49
|
expect(response.body).to include("<h1>Hi!</h1>")
|
39
50
|
end
|
40
|
-
it "
|
41
|
-
expect(response.body).
|
51
|
+
it "does not render layout" do
|
52
|
+
expect(response.body).to_not include("<title>Dummy</title>")
|
42
53
|
end
|
43
54
|
it "responds with content type" do
|
44
|
-
expect(response.content_type).to
|
55
|
+
expect(response.content_type).to include("text/html")
|
45
56
|
end
|
46
57
|
end
|
47
58
|
|
48
59
|
context "non-existent page" do
|
49
60
|
it "is status 404" do
|
50
61
|
expect {
|
51
|
-
|
62
|
+
get_resource "/non-existent"
|
52
63
|
}.to raise_exception(ActionController::RoutingError)
|
53
64
|
end
|
54
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
|
55
105
|
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sitepress-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 2.0.0.beta1
|
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-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: rspec-rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: pry
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -39,48 +39,76 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
47
|
+
version: '4.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
54
|
+
version: '4.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: sitepress-core
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 2.0.0.beta1
|
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:
|
68
|
+
version: 2.0.0.beta1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: railties
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0
|
75
|
+
version: '5.0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
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
|
+
- - ">="
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0
|
83
|
-
|
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:
|
84
112
|
email:
|
85
113
|
- bradgessler@gmail.com
|
86
114
|
executables: []
|
@@ -91,15 +119,17 @@ files:
|
|
91
119
|
- Rakefile
|
92
120
|
- app/controllers/concerns/sitepress/site_pages.rb
|
93
121
|
- app/controllers/sitepress/site_controller.rb
|
94
|
-
- app/helpers/sitepress/application_helper.rb
|
95
122
|
- config/routes.rb
|
96
123
|
- lib/sitepress-rails.rb
|
124
|
+
- lib/sitepress/build_paths/directory_index_path.rb
|
125
|
+
- lib/sitepress/build_paths/index_path.rb
|
126
|
+
- lib/sitepress/build_paths/root_path.rb
|
127
|
+
- lib/sitepress/compiler.rb
|
97
128
|
- lib/sitepress/engine.rb
|
98
|
-
- lib/sitepress/extensions/index_request_path.rb
|
99
|
-
- lib/sitepress/extensions/partials_remover.rb
|
100
|
-
- lib/sitepress/extensions/rails_request_paths.rb
|
101
129
|
- lib/sitepress/rails.rb
|
102
130
|
- lib/sitepress/rails_configuration.rb
|
131
|
+
- lib/sitepress/renderers/controller.rb
|
132
|
+
- lib/sitepress/renderers/server.rb
|
103
133
|
- lib/sitepress/route_constraint.rb
|
104
134
|
- lib/tasks/sitepress_tasks.rake
|
105
135
|
- spec/dummy/Rakefile
|
@@ -118,7 +148,6 @@ files:
|
|
118
148
|
- spec/dummy/app/helpers/application_helper.rb
|
119
149
|
- spec/dummy/app/jobs/application_job.rb
|
120
150
|
- spec/dummy/app/mailers/application_mailer.rb
|
121
|
-
- spec/dummy/app/models/application_record.rb
|
122
151
|
- spec/dummy/app/views/baseline/show.html.erb
|
123
152
|
- spec/dummy/app/views/layouts/application.html.erb
|
124
153
|
- spec/dummy/app/views/layouts/mailer.html.erb
|
@@ -152,9 +181,6 @@ files:
|
|
152
181
|
- spec/dummy/config/routes.rb
|
153
182
|
- spec/dummy/config/secrets.yml
|
154
183
|
- spec/dummy/config/spring.rb
|
155
|
-
- spec/dummy/db/production.sqlite3
|
156
|
-
- spec/dummy/db/test.sqlite3
|
157
|
-
- spec/dummy/log/production.log
|
158
184
|
- spec/dummy/log/test.log
|
159
185
|
- spec/dummy/public/404.html
|
160
186
|
- spec/dummy/public/422.html
|
@@ -163,9 +189,7 @@ files:
|
|
163
189
|
- spec/dummy/public/apple-touch-icon.png
|
164
190
|
- spec/dummy/public/favicon.ico
|
165
191
|
- spec/sitepress-rails_spec.rb
|
166
|
-
- spec/sitepress/
|
167
|
-
- spec/sitepress/extensions/partials_remover_spec.rb
|
168
|
-
- spec/sitepress/extensions/rails_request_paths_spec.rb
|
192
|
+
- spec/sitepress/compiler_spec.rb
|
169
193
|
- spec/sitepress/rails_configuration_spec.rb
|
170
194
|
- spec/sitepress/route_constraint_spec.rb
|
171
195
|
- spec/sitepress/routes_spec.rb
|
@@ -180,7 +204,7 @@ files:
|
|
180
204
|
homepage: https://github.com/sitepress/sitepress
|
181
205
|
licenses: []
|
182
206
|
metadata: {}
|
183
|
-
post_install_message:
|
207
|
+
post_install_message:
|
184
208
|
rdoc_options: []
|
185
209
|
require_paths:
|
186
210
|
- lib
|
@@ -191,16 +215,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
191
215
|
version: '0'
|
192
216
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
193
217
|
requirements:
|
194
|
-
- - "
|
218
|
+
- - ">"
|
195
219
|
- !ruby/object:Gem::Version
|
196
|
-
version:
|
220
|
+
version: 1.3.1
|
197
221
|
requirements: []
|
198
|
-
|
199
|
-
|
200
|
-
signing_key:
|
222
|
+
rubygems_version: 3.2.3
|
223
|
+
signing_key:
|
201
224
|
specification_version: 4
|
202
225
|
summary: Sitepress rails integration.
|
203
226
|
test_files:
|
227
|
+
- spec/dummy/Rakefile
|
204
228
|
- spec/dummy/app/assets/config/manifest.js
|
205
229
|
- spec/dummy/app/assets/javascripts/application.js
|
206
230
|
- spec/dummy/app/assets/javascripts/cable.js
|
@@ -216,7 +240,6 @@ test_files:
|
|
216
240
|
- spec/dummy/app/helpers/application_helper.rb
|
217
241
|
- spec/dummy/app/jobs/application_job.rb
|
218
242
|
- spec/dummy/app/mailers/application_mailer.rb
|
219
|
-
- spec/dummy/app/models/application_record.rb
|
220
243
|
- spec/dummy/app/views/baseline/show.html.erb
|
221
244
|
- spec/dummy/app/views/layouts/application.html.erb
|
222
245
|
- spec/dummy/app/views/layouts/mailer.html.erb
|
@@ -250,9 +273,6 @@ test_files:
|
|
250
273
|
- spec/dummy/config/secrets.yml
|
251
274
|
- spec/dummy/config/spring.rb
|
252
275
|
- spec/dummy/config.ru
|
253
|
-
- spec/dummy/db/production.sqlite3
|
254
|
-
- spec/dummy/db/test.sqlite3
|
255
|
-
- spec/dummy/log/production.log
|
256
276
|
- spec/dummy/log/test.log
|
257
277
|
- spec/dummy/public/404.html
|
258
278
|
- spec/dummy/public/422.html
|
@@ -260,10 +280,7 @@ test_files:
|
|
260
280
|
- spec/dummy/public/apple-touch-icon-precomposed.png
|
261
281
|
- spec/dummy/public/apple-touch-icon.png
|
262
282
|
- spec/dummy/public/favicon.ico
|
263
|
-
- spec/
|
264
|
-
- spec/sitepress/extensions/index_request_path_spec.rb
|
265
|
-
- spec/sitepress/extensions/partials_remover_spec.rb
|
266
|
-
- spec/sitepress/extensions/rails_request_paths_spec.rb
|
283
|
+
- spec/sitepress/compiler_spec.rb
|
267
284
|
- spec/sitepress/rails_configuration_spec.rb
|
268
285
|
- spec/sitepress/route_constraint_spec.rb
|
269
286
|
- spec/sitepress/routes_spec.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
|