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

The OpenSearch description specifies a broken suggestions endpoint #389

Open
lf- opened this issue Oct 2, 2022 · 0 comments · May be fixed by #390
Open

The OpenSearch description specifies a broken suggestions endpoint #389

lf- opened this issue Oct 2, 2022 · 0 comments · May be fixed by #390

Comments

@lf-
Copy link

lf- commented Oct 2, 2022

Hoogle seems to support OpenSearch discovery, for integrating as a browser search engine. The docs for that are here: https://developer.mozilla.org/en-US/docs/Web/OpenSearch#autodiscovery_of_search_plugins

However, in Hoogle's description file here: https://github.com/ndmitchell/hoogle/blob/master/html/search.xml
it's specified that Hoogle should be invoked with mode=suggest via this URL: https://hoogle.haskell.org/?hoogle={searchTerms}&mode=suggest

(an independent bug is that this doesn't vary based on the server URL so this doesn't correctly work on localhost hoogle)

However, this mode doesn't exist in the source code:

hoogle/src/Action/Server.hs

Lines 102 to 123 in 62a2a8a

case lookup "mode" inputArgs of
Nothing | qSource /= [] -> fmap OutputHTML $ templateRender templateIndex
[("tags", html $ tagOptions qScope)
,("body", html body)
,("title", text $ unwords qSource ++ " - Hoogle")
,("search", text $ unwords qSearch)
,("robots", text $ if any isQueryScope q then "none" else "index")]
| otherwise -> OutputHTML <$> templateRender templateHome []
Just "body" -> OutputHTML <$> if null qSource then templateRender templateEmpty [] else templateRender (html body) []
Just "json" ->
let -- 1 means don't drop anything, if it's less than 1 ignore it
start :: Int
start = max 0 $ grabInt "start" 1 - 1
-- by default it returns 100 entries
count :: Int
count = min 500 $ grabInt "count" 100
filteredResults = take count $ drop start results
in case lookup "format" inputArgs of
Just "text" -> pure $ OutputJSON $ JSON.toEncoding $ map unHTMLTarget filteredResults
Just f -> pure $ OutputFail $ lbstrPack $ "Format mode " ++ f ++ " not (currently) supported"
Nothing -> pure $ OutputJSON $ JSON.toEncoding filteredResults
Just m -> pure $ OutputFail $ lbstrPack $ "Mode " ++ m ++ " not (currently) supported"

Thus, suggestions don't work. I might go add that mode, since it is likely not that tricky.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant