cryogen 2022-02-08

Does somebody have something like an auto-refresh in the browser when working with cryogen (and asciidoc)? I'm running clojure -X:serve but whenever I make a change I have to wait at least a few seconds and then refresh the browser manually

Jakub Holý (HolyJak) 2022-02-09T09:56:14.164219Z

But what about your code, do you use this ☝️ code or do you have your own? Perhaps also worth checking version of ring? You could also inspect the middleware to verify that wrap-refresh was executed, perhaps add some logging to https://github.com/weavejester/ring-refresh/blob/master/src/ring/middleware/refresh.clj to find out what is happening? If refresh is really enabled, it will inject a piece of JS right under <html>, this one https://github.com/weavejester/ring-refresh/blob/master/src/ring/middleware/refresh.clj#L20 - do you see it injected?

Yes it's used by default with fast alias. I can try to debug this a bit later.

Jakub Holý (HolyJak) 2022-02-09T16:25:58.898679Z

In theory != in practice :)

Well, that's not in theory- that code is used. But I guess I need to debug it to know more :)

I'd say all looks good but it's simply not refreshed. The javascript is there, injected in <head>

Ok, mystery solved. The problem is in the Nucleus template I'm using. It's overriding window.onload set by ring's refresh mechanism: https://github.com/curiousprogrammer-net/curiousprogrammer.blog/blob/develop/themes/nucleus/js/scripts.js#L3

Thanks Jakub a lot for showing me where to look.

Jakub Holý (HolyJak) 2022-02-09T21:13:17.546119Z

Thx a lot for the fix and for creating the issue!

Jakub Holý (HolyJak) 2022-02-09T21:14:14.477469Z

Perhaps a generic fix would be not to override the onload fn but first check if it is set, copy it, and call it as well?

Thanks @holyjak From what I can tell this is actually in cryogen core nowadays: https://github.com/cryogen-project/cryogen/blob/master/src/leiningen/new/cryogen/src/cryogen/server.clj I tried to run clojure -X:fast but it makes no difference - the browser simply isn't auto-refreshed. Am I missing some little piece in the configuration?