parklife 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/Gemfile +1 -0
- data/README.md +5 -5
- data/lib/parklife/cli.rb +15 -0
- data/lib/parklife/config.rb +1 -1
- data/lib/parklife/errors.rb +0 -6
- data/lib/parklife/rails.rb +30 -7
- data/lib/parklife/templates/Parkfile.erb +1 -1
- data/lib/parklife/utils.rb +1 -1
- data/lib/parklife/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a1770a5f09524a3c16e3becb527d6d6fc0fdb723095b3365ee583a0a91722a4
|
4
|
+
data.tar.gz: 0be599051686b0dab89aba57dfe72813de074c694c31de876f66b9c8aeb61223
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c473fd98d0162b43ff8b09399e05f827fd478b30bf33d563a21f463dcc873366c56e72ae91c3c236da5823f44154dc6f59e2ddb49f4526b1691e636fda7bcf9
|
7
|
+
data.tar.gz: 466f130fb18b8fea3deb6ff126c767009b2e9341d04deb5c0f8ee8c4705e3987d734094976a33886dd0f152cfd4ba2c1ac4c4941859ef11e703a63195b5e8bc4
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## Version 0.6.0 - 2023-03-26
|
2
|
+
|
3
|
+
- Allow assigning a URI object to config.base <https://github.com/benpickles/parklife/pull/98>
|
4
|
+
|
5
|
+
- Add a `parklife config` command to output the full Parklife config <https://github.com/benpickles/parklife/pull/97>
|
6
|
+
|
7
|
+
- Improved Rails integration <https://github.com/benpickles/parklife/pull/96>
|
8
|
+
|
9
|
+
Parklife now integrates with Rails via Railties and can therefore hook into the app's configuration before it's initialised. This allows Parklife to remove the host authorisation middleware that's present in development and otherwise causes Parklife requests to receive a 403 response.
|
10
|
+
|
11
|
+
**Upgrading**: For an existing Parklife+Rails integration move requiring `parklife/rails` above requiring `config/environment` in the Parkfile.
|
12
|
+
|
13
|
+
- Prevent `Encoding::UndefinedConversionError` error when writing a binary response <https://github.com/benpickles/parklife/pull/94>
|
14
|
+
|
1
15
|
## Version 0.5.1 - 2023-03-22
|
2
16
|
|
3
17
|
- Ensure the generated static-build script is executable. <https://github.com/benpickles/parklife/pull/89>
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -23,14 +23,14 @@ $ bundle exec parklife init
|
|
23
23
|
Parklife is configured with a file called `Parkfile` in the root of your project, here's an example `Parkfile` for an imaginary Rails app:
|
24
24
|
|
25
25
|
```ruby
|
26
|
+
# Load Parklife's Rails-specific integration which, among other things, allows
|
27
|
+
# you to use URL helpers within the `routes` block below.
|
28
|
+
require 'parklife/rails'
|
29
|
+
|
26
30
|
# Load the Rails application, this gives you full access to the application's
|
27
31
|
# environment from this file - using models for example.
|
28
32
|
require_relative 'config/environment'
|
29
33
|
|
30
|
-
# Load Parklife and some Rails-specific settings allowing you to use URL
|
31
|
-
# helpers within the `routes` block below.
|
32
|
-
require 'parklife/rails'
|
33
|
-
|
34
34
|
Parkfile.application.routes do
|
35
35
|
# Start from the homepage and crawl all links.
|
36
36
|
root crawl: true
|
@@ -76,7 +76,7 @@ build/feed.atom
|
|
76
76
|
build/sitemap.xml
|
77
77
|
```
|
78
78
|
|
79
|
-
Parklife doesn't know about assets (images, CSS, etc) so you likely also need to generate those and copy them to the build directory, see the [Rails example's full build script](examples/rails/
|
79
|
+
Parklife doesn't know about assets (images, CSS, etc) so you likely also need to generate those and copy them to the build directory, see the [Rails example's full build script](examples/rails/bin/static-build) for how you might do this.
|
80
80
|
|
81
81
|
## More examples
|
82
82
|
|
data/lib/parklife/cli.rb
CHANGED
@@ -15,6 +15,21 @@ module Parklife
|
|
15
15
|
application.build
|
16
16
|
end
|
17
17
|
|
18
|
+
desc 'config', 'Output the full Parklife config'
|
19
|
+
def config
|
20
|
+
reporter = application.config.reporter
|
21
|
+
|
22
|
+
shell.print_table([
|
23
|
+
['app', application.config.app.inspect],
|
24
|
+
['base', application.config.base.to_s],
|
25
|
+
['build_dir', application.config.build_dir],
|
26
|
+
['nested_index', application.config.nested_index],
|
27
|
+
['on_404', application.config.on_404.inspect],
|
28
|
+
['parklife/rails', defined?(::Parklife::Railtie) ? 'enabled' : '-'],
|
29
|
+
['reporter', reporter == $stdout ? '$stdout' : reporter],
|
30
|
+
])
|
31
|
+
end
|
32
|
+
|
18
33
|
desc 'get PATH', 'Fetch PATH from the app and output its contents'
|
19
34
|
def get(path)
|
20
35
|
puts application.crawler.get(path).body
|
data/lib/parklife/config.rb
CHANGED
data/lib/parklife/errors.rb
CHANGED
data/lib/parklife/rails.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require 'rails'
|
4
4
|
|
5
5
|
module Parklife
|
6
6
|
module RailsConfigRefinements
|
@@ -18,12 +18,35 @@ module Parklife
|
|
18
18
|
}
|
19
19
|
end
|
20
20
|
end
|
21
|
-
end
|
22
21
|
|
23
|
-
|
22
|
+
class Railtie < Rails::Railtie
|
23
|
+
initializer 'parklife.disable_host_authorization' do |app|
|
24
|
+
# The offending middleware is included in Rails (6+) development mode and
|
25
|
+
# rejects a request with a 403 response if its host isn't present in the
|
26
|
+
# allowlist (a security feature). This prevents Parklife from working in
|
27
|
+
# a Rails app out of the box unless you manually add the expected
|
28
|
+
# Parklife base to the hosts allowlist or set it to nil to disable it -
|
29
|
+
# both of which aren't great because they disable the security feature
|
30
|
+
# whenever the development server is booted.
|
31
|
+
#
|
32
|
+
# https://guides.rubyonrails.org/configuring.html#actiondispatch-hostauthorization
|
33
|
+
#
|
34
|
+
# However it's safe to remove the middleware at this point because it
|
35
|
+
# won't be executed in the normal Rails development flow, only via a
|
36
|
+
# Parkfile when parklife/rails is required.
|
37
|
+
if defined?(ActionDispatch::HostAuthorization)
|
38
|
+
app.middleware.delete(ActionDispatch::HostAuthorization)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
config.after_initialize do
|
43
|
+
Parklife.application.config.app = Rails.application
|
24
44
|
|
25
|
-
# Allow use of the Rails application's route helpers when defining
|
26
|
-
# routes in the block form.
|
27
|
-
Parklife.application.routes.singleton_class.include(Rails.application.routes.url_helpers)
|
45
|
+
# Allow use of the Rails application's route helpers when defining
|
46
|
+
# Parklife routes in the block form.
|
47
|
+
Parklife.application.routes.singleton_class.include(Rails.application.routes.url_helpers)
|
28
48
|
|
29
|
-
Parklife.application.config.extend(
|
49
|
+
Parklife.application.config.extend(RailsConfigRefinements)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/parklife/utils.rb
CHANGED
data/lib/parklife/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parklife
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Pickles
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|