Sandboxing

I've almost wrapped up a v0.1 release of Platypub. Here's a GIF demo of sending out a newsletter with it. I'm planning to start using it for this newsletter next week. I have already migrated biffweb.com over to Platypub. There are just a few loose ends I need to tie up. I'm at a little family reunion for the next two weeks, so I might skip sending out this newsletter until the 30th.

This v0.1 release has dragged out a bit because I got sucked into rethinking again and again how to structure themes. It felt like non-voluntary hammock time. Funny how that always strikes when you think you're 10 minutes away from finishing.

In general we want a script of some sort that'll take in your posts from the CMS and spit out a set of HTML files. But again, to allow that in a multi-user web app, we have to sandbox the theme code some how (either that, or only support themes that are enabled by the site admin--which might be what I do at first if I ever run an instance of Platypub for other people to use).

I was leaning towards AWS Lambda for that. We set it up with Babashka pre-installed and expose an endpoint that takes a script + your posts and returns the HTML files in a zip archive or something. However I then realized that maybe we could just do it on Netlify, since we're already using them to host the rendered sites. They have a continuous deployment option where they'll run some site-rendering code in a container for you and then deploy the output. Sounds perfect right?

It looks like their Clojure support isn't good, but Michael Borkient has saved us again: we can just use nbb! nbb comes with Reagent baked in, which we could use instead of Hiccup:

=> (reagent.dom.server/render-to-static-markup [:p "hey"])"<p>hey</p>"

One problem: Netlify's continuous deployment thing only works if you've connected a Git repository and are deploying by pushing to that. Currently Platypub does manual deploys via their API, in which you have to supply the already-rendered files. We could set up a new Git repo behind the scenes whenever a Platypub user creates a new site... but that's starting to feel pretty hacky. Netlify runs the builds on AWS Lambda anyway, so we probably should just go direct. I ended up back where I started.

In the course of that mental goose chase, I also thought of another way to frame Platypub. If you take a look at the Jamstack website, you'll see on the sidebar a Site Generators page and a Headless CMS page. Pick a CMS, set up a static site generator and have it render the content from the CMS, deploy the output to Netlify or similar. Platypub wraps that process in a web app to make it more convenient (and accessible for non-coders). And it does newsletters.