[Try and propagate ajax=1 flags through the web pages, fairly hacky and not very general Neil Mitchell**20110112104341] { hunk ./src/Hoogle/Type/TagStr.hs 123 - -- FIXME: this is overly specific! - g (TagLink "" x) = g (TagLink url x) - where str = showTagText x - url = if "http:" `isPrefixOf` str then str else "?hoogle=" ++% str - g (TagLink url x) = "" ++ showTagHTML x ++ "" + g (TagLink url x) = "" ++ showTagHTML x ++ "" hunk ./src/Web/All.hs 13 --- would like to use datadir, but not sure how +-- FIXME: Should use datadir, but not sure how +-- FIXME: Only server will preserve extra flags hunk ./src/Web/All.hs 16 - res <- response "datadir/resources" q + res <- response "datadir/resources" [] q hunk ./src/Web/Page.hs 2 -module Web.Page(header, footer, welcome) where +module Web.Page(searchLink, header, footer, welcome) where hunk ./src/Web/Page.hs 8 +searchLink :: Args -> String -> URL +searchLink extra x = "?" ++ concat [a ++ "=" ++% b ++ "&" | (a,b) <- extra, a /= "hoogle"] ++ "hoogle=" ++% x + + hunk ./src/Web/Page.hs 56 -welcome = +welcome extra = hunk ./src/Web/Page.hs 82 - search x = "" ++& x ++ "
" + search x = "" ++& x ++ "
" hunk ./src/Web/Response.hs 22 -response :: FilePath -> CmdLine -> IO (Response String) -response resources q = do +response :: FilePath -> Args -> CmdLine -> IO (Response String) +response resources extra q = do hunk ./src/Web/Response.hs 31 - return $ runQuery ajax dbs q + return $ runQuery extra ajax dbs q hunk ./src/Web/Response.hs 63 -runQuery :: Bool -> Database -> CmdLine -> [String] -runQuery ajax dbs Search{queryParsed = Left err} = +runQuery :: Args -> Bool -> Database -> CmdLine -> [String] +runQuery extra ajax dbs Search{queryParsed = Left err} = hunk ./src/Web/Response.hs 80 -runQuery ajax dbs q | isBlankQuery $ fromRight $ queryParsed q = welcome +runQuery extra ajax dbs q | isBlankQuery $ fromRight $ queryParsed q = welcome extra hunk ./src/Web/Response.hs 83 -runQuery ajax dbs cq@Search{queryParsed = Right q} = +runQuery extra ajax dbs cq@Search{queryParsed = Right q, queryText = qt} = hunk ./src/Web/Response.hs 87 - ["

" ++ showTagHTML (transform qurl sug) ++ "

" | Just sug <- [querySuggestions dbs q]] ++ + ["

" ++ showTag extra sug ++ "

" | Just sug <- [querySuggestions dbs q]] ++ hunk ./src/Web/Response.hs 101 - res = [renderRes i (i /= 0 && i == start2 && prefix) x | (i,(_,x)) <- zip [0..] src] + res = [renderRes extra i (i /= 0 && i == start2 && prefix) x | (i,(_,x)) <- zip [0..] src] hunk ./src/Web/Response.hs 106 - ["
  •  " ++ - "" ++ x ++ "
  • " + ["
  •  " ++ + "" ++ x ++ "
  • " hunk ./src/Web/Response.hs 111 - urlMore = "?hoogle=" ++% queryText cq ++ "&start=" ++ show (start2+count2+1) ++ "#more" + urlMore = searchLink extra qt ++ "&start=" ++ show (start2+count2+1) ++ "#more" hunk ./src/Web/Response.hs 113 - qurl (TagLink url x) | "query:" `isPrefixOf` url = TagLink ("?hoogle=" ++% drop 6 url) x - qurl x = x hunk ./src/Web/Response.hs 115 -renderRes :: Int -> Bool -> Result -> [String] -renderRes i more Result{..} = +renderRes :: Args -> Int -> Bool -> Result -> [String] +renderRes extra i more Result{..} = hunk ./src/Web/Response.hs 128 - showTagHTML docs ++? + showTag extra docs ++? hunk ./src/Web/Response.hs 142 + +showTag :: Args -> TagStr -> String +showTag extra = showTagHTML . transform f + where + f (TagLink "" x) = TagLink (if "http:" `isPrefixOf` str then str else searchLink extra str) x + where str = showTagText x + f x = x + hunk ./src/Web/Server.hs 6 +import General.Util hunk ./src/Web/Server.hs 65 - args <- cmdLineWeb $ parseHttpQueryArgs $ drop 1 query - r <- response "/res" args{databases=databases} + let args = parseHttpQueryArgs $ drop 1 query + cmd <- cmdLineWeb args + r <- response "/res" (reps ("mode","ajax") ("ajax","1") args) cmd{databases=databases} }