Parklife::Sinatra
Parklife's Sinatra integration ensures Sinatra's host authorization is disabled during a parklife build.
Getting started
Add the gem to your application's Gemfile:
gem 'parklife-sinatra'Parklife is configured with a file called Parkfile in the root of your project, here's an example Parkfile for an imaginary Sinatra app:
# Assuming your Sinatra app lives in ./app.rb:
require_relative 'app'
Parklife.application.configure do |config|
# For a Sinatra "classic" app:
config.app = Sinatra::Application
# Or for Sinatra modular style:
# config.app = App
#
# The Parklife extension must be registered for a modular style Sinatra app:
# App.register Parklife::Sinatra
end
Parkfile.application.routes do
# Start from the homepage and crawl all links.
root crawl: true
# Some extra paths that aren't discovered while crawling.
get '/feed.atom'
get '/sitemap.xml'
# A couple more hidden pages.
get '/easter_egg', crawl: true
# Services typically allow a custom 404 page.
get '/404.html'
endListing the routes included in the above Parklife application with parklife routes would output the following:
$ bundle exec parklife routes
/ crawl=true
/feed.atom
/sitemap.xml
/easter_egg crawl=true
/404.html
Now you can run parklife build which will fetch all the routes and save them to the build directory ready to be served as a static site. Inspecting the build directory might look like this:
$ find build -type f
build/404.html
build/about/index.html
build/blog/index.html
build/blog/2019/03/07/developers-developers-developers/index.html
build/blog/2019/04/21/modern-life-is-rubbish/index.html
build/blog/2019/05/15/introducing-parklife/index.html
build/easter_egg/index.html
build/easter_egg/surprise/index.html
build/index.html
build/location/index.html
build/feed.atom
build/sitemap.xml
Parklife doesn't know about assets (images, CSS, etc) so you likely also need to generate those and copy them to the build directory.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/benpickles/parklife-sinatra. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the Parklife::Sinatra project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.