benpickles / parklife

Render a Rack app (Rails/Sinatra/etc) to a static build so it can be served by Netlify, Now, GitHub Pages, S3, or any other web server.
https://www.benpickles.com/articles/90-introducing-parklife
MIT License
188 stars 7 forks source link

Crawl images and other HTML linked resources as well #103

Open dramalho opened 5 months ago

dramalho commented 5 months ago

A small follow up to https://github.com/benpickles/parklife/issues/102 where I was trying to figure out the best strategy to include ActiveStorage attachments into the static build.

TL;DR; I first tried to generate and copy the attachment files via a rake task but there are - to the best of my present knowledge - quite a few hoops to jump through to get the right final URL so that it matches what the markup expects, so much so that I think it's extremely error prone. The other option I explored was for parklife to merely collect more URLs and - maybe - get and save those files, which I ended up doing in Utils#scan_for_links

The code is simple enough but I'm unsure what scenarios exist that might hamper this approach, so I though I would open a PR just the same as that makes discussion easier .. maybe :)