metasoarous / toto

Static site generation in Clojure (with live code reloading!)
Eclipse Public License 1.0
111 stars 3 forks source link

Reflect style & extra header config in live view #5

Open metasoarous opened 3 years ago

metasoarous commented 3 years ago

Static build will reflect style customizations, but not the live view, which is problematic for folks wanting to tweak styles. Should find a way of fixing, but not clear how this will work dynamically.

metasoarous commented 3 years ago

One way to go here could be along the lines of a hack someone figured out for using cryogen to live code reload: https://www.ieugen.ro/posts/2020/2020-11-14-live-reload-for-cryogen-web/

Toto/Oz use a websocket to shuttle data to a live client. However, this means that there's a static index.html file being served up initially, which ends up being responsible for all of the header content, and which doesn't get updated based on individual page meta content. The advantage of this is that it opens up the possibility of smarter page updates, which is especially useful for Oz for shuttling data updates to individual visualizations (in theory at least; this isn't a feature yet). This also prevents the static build files from having to have two different "modes" (IIUC), where in dev mode a script is included which watches the file for changes and reloads, and this could pose a problem if someone accidently deploys the dev compilations. As written this also wouldn't feature Toto's ability to switch between different files depending on what is actively being edited (though the approach could be adapted to facilitate this, presumably).

I'm actually not sure whether the JS (cljs) in toto can be used to update the head content, as I've never tried. But assuming this is possible, that may be the way to go for us. This does have the cost of more maintenance as various header config features are added, but my goal is to keep this to a minimum (turn off default options, some convenience settings like :title, and override with arbitrary :extra-headers).