srid / ema

Change-aware static site generator for Haskell programmers
https://ema.srid.ca
GNU Affero General Public License v3.0
117 stars 9 forks source link

Live server shim/websocket customization #152

Closed sophicshift closed 11 months ago

sophicshift commented 1 year ago

Allows Ema users to specify the Ema Shim or a custom websocket response.

This can be used, for instance, to make the server open files in the user's favorite editor in response to a websocket request. So it could address #59, #69 (in some sense, since we can just use a custom shim).

srid commented 1 year ago

diff for review: https://github.com/lucasvreis/ema/compare/refactor-server..customize-server

sophicshift commented 1 year ago

Rebased on top of https://github.com/srid/ema/pull/154

sophicshift commented 1 year ago

Cool "page-following" demo with emacs and organon (using this PR).

cut.webm

srid commented 1 year ago

@lucasvreis Could you link me to your source that uses this feature (the custom shim as well as the custom renderer)? Just curious to see how it gets used, so I can understand the change better.

sophicshift commented 1 year ago

@srid I've changed some things. Here is a more recent demo, at the end I explain how it works briefly: video.webm

The code referenced in the video is here: https://github.com/lucasvreis/organon/blob/48eb54a9b4026cff542ce5b4cf1a77b16d138b8f/organon/src/Site/Organon/Server.hs#L63-L81 https://github.com/lucasvreis/organon/blob/48eb54a9b4026cff542ce5b4cf1a77b16d138b8f/organon/src/Site/Organon/Dynamic.hs#L40-L52

I can explain the PR in matrix chat too, if you prefer.

srid commented 1 year ago

Whoa, nice demo! That makes me want to switch back (again) to org. 😁 Waiting for organon release ...

sophicshift commented 1 year ago

demo.webm

srid commented 1 year ago

@lucasvreis Does it make sense to simplify this example by upstreaming the SWITCH case (even if unused)? Because then we won't need to write a whole new shim, and can just use the default one. Only a custom server handler is defined.

sophicshift commented 1 year ago

@srid I rebased on top of master and updated the second commit with your suggestion

srid commented 1 year ago

I really let this slip by. This weekend I'll spend some time merging this and other PRs, and then make a release of ema, emanote and relevant libraries.