parklife 0.5.1 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/examples.yml +64 -0
- data/.github/workflows/tests.yml +1 -45
- data/CHANGELOG.md +18 -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/templates/static_build.erb +3 -1
- data/lib/parklife/utils.rb +1 -1
- data/lib/parklife/version.rb +1 -1
- data/parklife.gemspec +6 -10
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c94649aadc5cc8fe79a9215950b461adfdf658ec56c396c42d3e69e9e6082d3
|
4
|
+
data.tar.gz: 54c2b0b8c4f8a8a5149d10b5f649d0009e9c9f32201d85acc8960bb595ea1e9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e77cf82affdd32b75f747c2a9a4bc7aaf8df14d0b847470b241b1fb34e3f98b8aea13fdb55430caff5a420e28a5ba0dc6e80d32505e315428317fb42a5fd9d6
|
7
|
+
data.tar.gz: d80856454fb213de0ef217f18518d42bed3f0a4e57b870f22d2e8eaa72b1cec45123e0c84b38f875b6cd85a62f543381437c8e8200cff87a31f3b2683671f94e
|
@@ -0,0 +1,64 @@
|
|
1
|
+
name: Examples
|
2
|
+
|
3
|
+
on: push
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
rack:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
name: Rack example
|
9
|
+
steps:
|
10
|
+
- uses: actions/checkout@v3
|
11
|
+
- uses: ruby/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
bundler-cache: true
|
14
|
+
ruby-version: '2.7'
|
15
|
+
working-directory: examples/rack
|
16
|
+
- run: bundle exec parklife build
|
17
|
+
working-directory: examples/rack
|
18
|
+
- run: test -f build/index.html
|
19
|
+
working-directory: examples/rack
|
20
|
+
|
21
|
+
rails:
|
22
|
+
runs-on: ubuntu-latest
|
23
|
+
name: Rails example
|
24
|
+
steps:
|
25
|
+
- uses: actions/checkout@v3
|
26
|
+
- uses: ruby/setup-ruby@v1
|
27
|
+
with:
|
28
|
+
bundler-cache: true
|
29
|
+
ruby-version: '3.2'
|
30
|
+
working-directory: examples/rails
|
31
|
+
- run: bin/static-build
|
32
|
+
working-directory: examples/rails
|
33
|
+
- run: test -f build/index.html
|
34
|
+
working-directory: examples/rails
|
35
|
+
|
36
|
+
roda:
|
37
|
+
runs-on: ubuntu-latest
|
38
|
+
name: Roda example
|
39
|
+
steps:
|
40
|
+
- uses: actions/checkout@v3
|
41
|
+
- uses: ruby/setup-ruby@v1
|
42
|
+
with:
|
43
|
+
bundler-cache: true
|
44
|
+
ruby-version: '3.2'
|
45
|
+
working-directory: examples/roda
|
46
|
+
- run: bundle exec parklife build
|
47
|
+
working-directory: examples/roda
|
48
|
+
- run: test -f build/index.html
|
49
|
+
working-directory: examples/roda
|
50
|
+
|
51
|
+
sinatra:
|
52
|
+
runs-on: ubuntu-latest
|
53
|
+
name: Sinatra example
|
54
|
+
steps:
|
55
|
+
- uses: actions/checkout@v3
|
56
|
+
- uses: ruby/setup-ruby@v1
|
57
|
+
with:
|
58
|
+
bundler-cache: true
|
59
|
+
ruby-version: '2.7'
|
60
|
+
working-directory: examples/sinatra
|
61
|
+
- run: bundle exec parklife build
|
62
|
+
working-directory: examples/sinatra
|
63
|
+
- run: test -f build/index.html
|
64
|
+
working-directory: examples/sinatra
|
data/.github/workflows/tests.yml
CHANGED
@@ -3,51 +3,6 @@ name: Tests
|
|
3
3
|
on: push
|
4
4
|
|
5
5
|
jobs:
|
6
|
-
example_rack:
|
7
|
-
runs-on: ubuntu-latest
|
8
|
-
name: Rack example
|
9
|
-
steps:
|
10
|
-
- uses: actions/checkout@v3
|
11
|
-
- uses: ruby/setup-ruby@v1
|
12
|
-
with:
|
13
|
-
bundler-cache: true
|
14
|
-
ruby-version: '2.7'
|
15
|
-
working-directory: examples/rack
|
16
|
-
- run: bundle exec parklife build
|
17
|
-
working-directory: examples/rack
|
18
|
-
- run: test -f build/index.html
|
19
|
-
working-directory: examples/rack
|
20
|
-
|
21
|
-
example_rails:
|
22
|
-
runs-on: ubuntu-latest
|
23
|
-
name: Rails example
|
24
|
-
steps:
|
25
|
-
- uses: actions/checkout@v3
|
26
|
-
- uses: ruby/setup-ruby@v1
|
27
|
-
with:
|
28
|
-
bundler-cache: true
|
29
|
-
ruby-version: '3.2'
|
30
|
-
working-directory: examples/rails
|
31
|
-
- run: bin/static-build
|
32
|
-
working-directory: examples/rails
|
33
|
-
- run: test -f build/index.html
|
34
|
-
working-directory: examples/rails
|
35
|
-
|
36
|
-
example_sinatra:
|
37
|
-
runs-on: ubuntu-latest
|
38
|
-
name: Sinatra example
|
39
|
-
steps:
|
40
|
-
- uses: actions/checkout@v3
|
41
|
-
- uses: ruby/setup-ruby@v1
|
42
|
-
with:
|
43
|
-
bundler-cache: true
|
44
|
-
ruby-version: '2.7'
|
45
|
-
working-directory: examples/sinatra
|
46
|
-
- run: bundle exec parklife build
|
47
|
-
working-directory: examples/sinatra
|
48
|
-
- run: test -f build/index.html
|
49
|
-
working-directory: examples/sinatra
|
50
|
-
|
51
6
|
rspec:
|
52
7
|
runs-on: ubuntu-latest
|
53
8
|
strategy:
|
@@ -57,6 +12,7 @@ jobs:
|
|
57
12
|
- '3.0'
|
58
13
|
- '3.1'
|
59
14
|
- '3.2'
|
15
|
+
- '3.3'
|
60
16
|
name: Ruby ${{ matrix.ruby }} RSpec
|
61
17
|
steps:
|
62
18
|
- uses: actions/checkout@v3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
## Version 0.6.1 - 2024-08-23
|
2
|
+
|
3
|
+
- Don't error when the public directory doesn't exist <https://github.com/benpickles/parklife/pull/105>
|
4
|
+
|
5
|
+
## Version 0.6.0 - 2023-03-26
|
6
|
+
|
7
|
+
- Allow assigning a URI object to config.base <https://github.com/benpickles/parklife/pull/98>
|
8
|
+
|
9
|
+
- Add a `parklife config` command to output the full Parklife config <https://github.com/benpickles/parklife/pull/97>
|
10
|
+
|
11
|
+
- Improved Rails integration <https://github.com/benpickles/parklife/pull/96>
|
12
|
+
|
13
|
+
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.
|
14
|
+
|
15
|
+
**Upgrading**: For an existing Parklife+Rails integration move requiring `parklife/rails` above requiring `config/environment` in the Parkfile.
|
16
|
+
|
17
|
+
- Prevent `Encoding::UndefinedConversionError` error when writing a binary response <https://github.com/benpickles/parklife/pull/94>
|
18
|
+
|
1
19
|
## Version 0.5.1 - 2023-03-22
|
2
20
|
|
3
21
|
- 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
|
@@ -22,7 +22,9 @@ bundle exec rails assets:precompile
|
|
22
22
|
bundle exec parklife build "$@"
|
23
23
|
|
24
24
|
# Copy all public resources to ./build.
|
25
|
-
|
25
|
+
if [ -d public ]; then
|
26
|
+
cp -R public/* build
|
27
|
+
fi
|
26
28
|
|
27
29
|
# List all files in the build (useful for debugging).
|
28
30
|
find build -type f | sort
|
data/lib/parklife/utils.rb
CHANGED
data/lib/parklife/version.rb
CHANGED
data/parklife.gemspec
CHANGED
@@ -11,19 +11,15 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.email = ['spideryoung@gmail.com']
|
12
12
|
|
13
13
|
spec.summary = 'Convert a Rack app into a static HTML site.'
|
14
|
-
spec.homepage = 'https://
|
14
|
+
spec.homepage = 'https://parklife.dev'
|
15
15
|
spec.license = 'MIT'
|
16
|
-
|
17
|
-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
-
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
-
spec.metadata = {
|
20
|
-
'changelog_uri' => 'https://github.com/benpickles/parklife/blob/main/CHANGELOG.md',
|
21
|
-
'rubygems_mfa_required' => 'true',
|
22
|
-
'source_code_uri' => 'https://github.com/benpickles/parklife',
|
23
|
-
}
|
24
|
-
|
25
16
|
spec.required_ruby_version = '>= 2.5.0'
|
26
17
|
|
18
|
+
spec.metadata['changelog_uri'] = 'https://github.com/benpickles/parklife/blob/main/CHANGELOG.md'
|
19
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
20
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
21
|
+
spec.metadata['source_code_uri'] = 'https://github.com/benpickles/parklife'
|
22
|
+
|
27
23
|
# Specify which files should be added to the gem when it is released.
|
28
24
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
29
25
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Pickles
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -60,6 +60,7 @@ executables:
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
+
- ".github/workflows/examples.yml"
|
63
64
|
- ".github/workflows/tests.yml"
|
64
65
|
- ".gitignore"
|
65
66
|
- ".rspec"
|
@@ -89,11 +90,12 @@ files:
|
|
89
90
|
- lib/parklife/utils.rb
|
90
91
|
- lib/parklife/version.rb
|
91
92
|
- parklife.gemspec
|
92
|
-
homepage: https://
|
93
|
+
homepage: https://parklife.dev
|
93
94
|
licenses:
|
94
95
|
- MIT
|
95
96
|
metadata:
|
96
97
|
changelog_uri: https://github.com/benpickles/parklife/blob/main/CHANGELOG.md
|
98
|
+
homepage_uri: https://parklife.dev
|
97
99
|
rubygems_mfa_required: 'true'
|
98
100
|
source_code_uri: https://github.com/benpickles/parklife
|
99
101
|
post_install_message:
|
@@ -111,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
113
|
- !ruby/object:Gem::Version
|
112
114
|
version: '0'
|
113
115
|
requirements: []
|
114
|
-
rubygems_version: 3.
|
116
|
+
rubygems_version: 3.5.17
|
115
117
|
signing_key:
|
116
118
|
specification_version: 4
|
117
119
|
summary: Convert a Rack app into a static HTML site.
|