alfanick / jekyll-related-posts

Proper related posts plugin for Jekyll - uses document correlation matrix on TF-IDF (optionally with Latent Semantic Indexing)
http://jekyll-related-posts.dev.amadeusz.me
MIT License
40 stars 6 forks source link

Enabling gem causes all HTML to be downloaded in the browser #3

Open ghost opened 7 years ago

ghost commented 7 years ago

After updating the gem to the latest version, a new issue cropped up. When serving up the site with:

$ jekyll serve

the site appears fine in the browser at 127.0.0.1:4000. But if I add the gem to my Gemfile (and do nothing else), HTML pages are downloaded instead of displayed in the browser. Doesn't matter what page I try to bring up, the whole site won't display. If I then remove the gem and run jekyll serve, the site displays correctly.

nhoizey commented 7 years ago

I still have the same issue.

I am using Jekyll 3.3.1.

joshkissel commented 7 years ago

@dstout @nhoizey @alfanick Any fix or work around for this? TIA!

Seems to connected to jekyll serve because if you just build the site the gem works as expected.

I noticed that with the gem the base url for the site was not being edited correctly when being updated in _site.

ghost commented 7 years ago

@joshkissel I tried this on a 1000+ post site, and the publish time went from ~20 sec. to over 5 min. It doesn't store the results of its calculations, so every publish took that long. I like the concept, but this plugin didn't work for my needs.

nhoizey commented 7 years ago

@dstout how is it related to this issue?

ghost commented 7 years ago

@nhoizey Relevant because the developer is MIA.

nhoizey commented 7 years ago

@dstout well, I really think you should have open another issue for this…

jamesbrewerdev commented 7 years ago

Not a final solution, but I got around this problem by replacing jekyll serve --watch with jekyll build --watch and running a web server from the _site directory.

Steps:

  1. Open a new tab in your terminal and cd to the root directory of your project.
  2. Run jekyll build --watch or jekyll build --watch --drafts if you want to see your drafts.
  3. Open another tab in your terminal and cd to <root-directory>/_site.
  4. Run a Python web server:
    • If you have Python 2.x, run: python -m SimpleHTTPServer 4000
    • If you have Python 3.x, run: python -m http.server 4000
  5. Load http://localhost:4000/ as normal.

Hope that helps someone.

darekmydlarz commented 6 years ago

Hey, I have the same issue, you can see my code at this branch: https://github.com/dmydlarz/blog/compare/related-posts?expand=1

The Content-Type header is changed to application/octet-stream after applying the plugin.

/cc @alfanick

khliu1238 commented 6 years ago

I encountered this error and digged in a little bit. It was related to this issue. An easy hack would be to explicitly set separator for io.each to avoid being messed up by change made in Packable required by nmatrix required by jekyll-related-posts

In /usr/lib/ruby/2.3.0/webrick/httputils.rb change the following in load_mime_types: io.each{ |line| to: io.each(sep=$/){ |line|

should work fine.

darekmydlarz commented 6 years ago

@khliu1238 I use rbenv and ruby 2.1.3 on macOS. How can I apply this fix?

EDIT I found it at: ~/.rbenv/versions/2.1.3/lib/ruby/2.1.0/webrick. But I believe there should be a better fix for this ;)

khliu1238 commented 6 years ago

I personally think Packable shouldn't overwrite io functions and break other gems that include it and use those functions.