ndmitchell / hoogle

Haskell API search engine
http://hoogle.haskell.org/
Other
738 stars 134 forks source link

hoogle server --local stopped replacing file:// URLs #236

Closed toonn closed 6 years ago

toonn commented 6 years ago

Recently the --local flag stopped working for me. It used to replace file:// urls so browsers wouldn't prevent you from using them. I'm currently on 5.0.16.

ndmitchell commented 6 years ago

Hi @toonn - it used to replace file:/// (in case that makes a difference to you), and to get it working you have to generate the database with --local (so it uses file:/// links) and then run the server with --local (so it strips them). I just ran on my system with Hoogle HEAD and it worked fine. Any way to reproduce?

toonn commented 6 years ago

I'm on using nix's ghcWithHoogle ghc-8.2.2 which generates the database for me. When I hover over the urls they're still file:// urls so firefox prevents me from navigating to them with a click, copying them manually works of course. I could share my config.nix if it would help.

ndmitchell commented 6 years ago

Hmm. What's the complete command line you are invoking the hoogle server with? Can you give me the complete URL of one of the file:// links?

toonn commented 6 years ago

hoogle server --local -p 8008 > $HOOGLELOG 2>&1 & This is the url for ByteArrayAccess on the page for Crypto.KDF.Scrypt: file:///nix/store/igkg5i8zprf428v3il39294v29g5b9vb-memory-0.14.11-doc/share/doc/html/Data-ByteArray.html#t:ByteArrayAccess

I noticed the link for Bounded on the page for Prelude worked fine so it's not failing to replace all links.

ndmitchell commented 6 years ago

I understand what's happening now. When I generate pages in the Hoogle interface I replace file:// links, e.g. when generating a results page. However, when serving up a page off disk (e.g. the cryptonite docs), I just serve the file up raw.

To fix, someone would need to write something at https://github.com/ndmitchell/hoogle/blob/master/src/Action/Server.hs#L127-L129 to change from OutputFile (return the file as-is), to reading the file, doing a string replacement (exactly what string replacement?) and then returning OutputString. A good first patch, if anyone is interested?

toonn commented 6 years ago

Thank you for taking the time to go over my PR, looking forward to an even better local hoogle experience.