Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adsf-live does not work with rack 3 #29

Closed
Fjan opened this issue Mar 18, 2023 · 2 comments
Closed

adsf-live does not work with rack 3 #29

Fjan opened this issue Mar 18, 2023 · 2 comments
Labels

Comments

@Fjan
Copy link

Fjan commented Mar 18, 2023

Adsf version 1.4.7 started using lower case headers to support rack 3, however the rack-livereload gem that adsf-live depends on has not yet been updated and expects upper case headers. I realise this is something that needs to be updated in the rack-livereload gem, but that project seems dormant.

Until that gem gets updated, I created this monkey patch that seems to work:

module Rack
  class LiveReload

    class ProcessingSkipAnalyzer
      def html?;@headers['content-type'] =~ %r{text/html}; end
    end

    def call(env)
      result = dup._call(env)
      if (headers=result[1]).is_a?(Hash) && headers['Content-Length']
        headers['content-length']=headers.delete('Content-Length')
        headers.transform_keys!{_1.downcase}
      end
      result
    end

  end
end

It's a bit tricky to get the patch to load at the right time when used with nanoc, I ended up creating a custom nanoc command.

@denisdefreyne
Copy link
Owner

Thanks for reporting!

Here is a bunch more background written up by @pcantrell: nanoc/nanoc#1647 -- and a PR to the most relevant rack-livereload repository: jaredmdobson/rack-livereload#13

The rack-livereload repository doesn’t seem to be publishing new gems, which is a problem (because Rubygems doesn’t support having dependencies on Git repositories, just on published gems). There’s an issue open asking for a new release (jaredmdobson/rack-livereload#10) but so far no movement there.

Not having livereload in Nanoc sucks (I need it) so I might fork rack-livereload and publish my own gem of it, likely this weekend -- I suspect that’ll happen when I start making changes to my own site and realise it’s not working as intended!

CC @pcantrell

@Fjan
Copy link
Author

Fjan commented Apr 14, 2023

The recently updated rack-livereload gem fixed this 🎉

@Fjan Fjan closed this as completed Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants