adsf icon indicating copy to clipboard operation
adsf copied to clipboard

adsf-live sends the path of the changed file instead of the path of the web page

Open Fjan opened this issue 1 year ago • 2 comments

Steps to reproduce

  1. Use nanoc with adsf-live
  2. Make a change to a page

Expected behavior

adsf-live should send the path of the web page to live reload.

Actual behavior

adsf-live sends the path to the file here path: "#{Dir.pwd}#{path}"

instead of path: path

Details

You typically only want to reload the page if the change occurred on the page you are viewing. When you change a layout in nanoc it will send many changed pages over the web socket. For livereload to know if the current page changed it needs to compare document.location.pathname with path. At this time it always reloads even if no match is found, but that results in ugly flickering if many pages change. It's not hard to modify the livereload.js to only reload if the path matches, but this comparison is needlessly complicated because the file path is being sent, from which the path first needs to be extracted.

Fjan avatar Apr 04 '24 09:04 Fjan

Ooh, I’ve seen this behavior but never managed to figure out what was causing it. Good catch!

denisdefreyne avatar Apr 04 '24 09:04 denisdefreyne

To be clear, I also needed to make a small change to the livereload.js included with rack-livereload to completely fix the issue, but that fix will be much easier if adsf-live sends the path

(If you use your own copy of livereload and change this line to become

if (path == document.location.pathname) return this.reloadPage()

then the reloading works properly with the change suggested above)

Fjan avatar Apr 04 '24 09:04 Fjan

See #38 — This is now merged (see e2b15cd006b18d2cdeef682867dfc984f692bbf3). I’ll do a release soon. Thank you!

denisdefreyne avatar Sep 29 '24 06:09 denisdefreyne

This is fixed in the adsf 1.5.1 release.

denisdefreyne avatar Sep 29 '24 06:09 denisdefreyne