Fork me on GitHub
#cryogen
<
2022-02-08
>
jumar04:02:36

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

jumar03:02:56

Thanks @U0522TWDA 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?

Jakub Holý (HolyJak)09:02:14

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?

jumar14:02:42

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

Jakub Holý (HolyJak)16:02:58

In theory != in practice :)

jumar19:02:52

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

jumar19:02:22

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

jumar19:02:01

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

jumar20:02:49

Btw. I tried to fix the alias definition here: https://github.com/cryogen-project/cryogen/pull/250

jumar20:02:23

Thanks Jakub a lot for showing me where to look.

Jakub Holý (HolyJak)21:02:17

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

Jakub Holý (HolyJak)21:02:14

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?