Skip to content

The OpenSearch description specifies a broken suggestions endpoint #389

@lf-

Description

@lf-

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions