3 ms·
This is pretty cool. I have two questions, regarding the mirroring: 1. For the mirroring, are you using something like rsync (with modifications for the web so
by winter_blue 2y ago
This is pretty cool. I have two questions, regarding the mirroring:
1. For the mirroring, are you using something like rsync (with modifications for the web socket script injection) underneath? Also, will the mirroring reflect destructive changes (like rsync's --delete flag), like if a directory or file is deleted in the original content directory?
2. Could you avoid mirroring the content directory, and just directly serve the original content directory, by just simply on-the-fly injecting the relevant script tag in text/html files? (Or, only mirroring those text/html files, and serving the remaining files from the original content directory.)
- baalimago 2y ago1. No, it doesn't react to file additions/deletions at the moment, but as there's support for this in fnotify which is handling file change notifications [1] I'll add this shortly. wd-41 is still quite early in development. 2. This was my initial idea as well: to simply inject the ws-load script tag on the fly. But it would require basically writing a static file server from scratch, which I didn't feel like doing (I have a blog to write, not static file servers!). Currently the solution is based on the go standard library fileserver handler [2] which makes the solution simple and effective. So i decided on the mirrored approach with the idea that the result for the end user should be the same, apart for the temporary directory where the mirrored files lives. I haven't yet detected any speed-issues in the mirroring process or the file-watch process, which I think is the only downside (please correct me if I'm wrong). [1]: https://pkg.go.dev/github.com/fsnotify/fsnotify#hdr-Watching_directories https://pkg.go.dev/github.com/fsnotify/fsnotify#hdr-Watching... [2]: https://github.com/baalimago/wd-41/blob/main/cmd/serve/serve.go#L68 https://github.com/baalimago/wd-41/blob/main/cmd/serve/serve...