mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-01-17 06:38:29 +01:00
Add download link for hoogle database
This commit is contained in:
parent
d98d3866ec
commit
bfbe634e5f
@ -9,7 +9,7 @@ import Data.Slug (Slug)
|
|||||||
import Handler.StackageHome (getStackageHomeR, getStackageMetadataR, getStackageCabalConfigR, getSnapshotPackagesR, getDocsR)
|
import Handler.StackageHome (getStackageHomeR, getStackageMetadataR, getStackageCabalConfigR, getSnapshotPackagesR, getDocsR)
|
||||||
import Handler.StackageIndex (getStackageIndexR)
|
import Handler.StackageIndex (getStackageIndexR)
|
||||||
import Handler.StackageSdist (getStackageSdistR)
|
import Handler.StackageSdist (getStackageSdistR)
|
||||||
import Handler.Hoogle (getHoogleR)
|
import Handler.Hoogle (getHoogleR, getHoogleDatabaseR)
|
||||||
import Handler.BuildPlan (getBuildPlanR)
|
import Handler.BuildPlan (getBuildPlanR)
|
||||||
|
|
||||||
handleAliasR :: Slug -> Slug -> [Text] -> Handler ()
|
handleAliasR :: Slug -> Slug -> [Text] -> Handler ()
|
||||||
@ -79,5 +79,6 @@ goSid sid pieces = do
|
|||||||
SnapshotPackagesR -> getSnapshotPackagesR slug >>= sendResponse
|
SnapshotPackagesR -> getSnapshotPackagesR slug >>= sendResponse
|
||||||
DocsR -> getDocsR slug >>= sendResponse
|
DocsR -> getDocsR slug >>= sendResponse
|
||||||
HoogleR -> getHoogleR slug >>= sendResponse
|
HoogleR -> getHoogleR slug >>= sendResponse
|
||||||
|
HoogleDatabaseR -> getHoogleDatabaseR slug >>= sendResponse
|
||||||
BuildPlanR -> getBuildPlanR slug >>= sendResponse
|
BuildPlanR -> getBuildPlanR slug >>= sendResponse
|
||||||
_ -> notFound
|
_ -> notFound
|
||||||
|
|||||||
@ -32,14 +32,7 @@ getHoogleR slug = do
|
|||||||
mdatabasePath <- getHoogleDB dirs stackage
|
mdatabasePath <- getHoogleDB dirs stackage
|
||||||
heDatabase <- case mdatabasePath of
|
heDatabase <- case mdatabasePath of
|
||||||
Just x -> return $ liftIO $ Hoogle.loadDatabase $ fpToString x
|
Just x -> return $ liftIO $ Hoogle.loadDatabase $ fpToString x
|
||||||
Nothing -> (>>= sendResponse) $ defaultLayout $ do
|
Nothing -> hoogleDatabaseNotAvailableFor slug
|
||||||
setTitle "Hoogle database not available"
|
|
||||||
[whamlet|
|
|
||||||
<div .container>
|
|
||||||
<p>The given Hoogle database is not available.
|
|
||||||
<p>
|
|
||||||
<a href=@{SnapshotR slug StackageHomeR}>Return to snapshot homepage
|
|
||||||
|]
|
|
||||||
|
|
||||||
mresults <- case mquery of
|
mresults <- case mquery of
|
||||||
Just query -> runHoogleQuery heDatabase HoogleQueryInput
|
Just query -> runHoogleQuery heDatabase HoogleQueryInput
|
||||||
@ -60,6 +53,25 @@ getHoogleR slug = do
|
|||||||
setTitle "Hoogle Search"
|
setTitle "Hoogle Search"
|
||||||
$(widgetFile "hoogle")
|
$(widgetFile "hoogle")
|
||||||
|
|
||||||
|
getHoogleDatabaseR :: SnapSlug -> Handler Html
|
||||||
|
getHoogleDatabaseR slug = do
|
||||||
|
dirs <- getDirs
|
||||||
|
Entity _ stackage <- runDB $ getBy404 $ UniqueSnapshot slug
|
||||||
|
mdatabasePath <- getHoogleDB dirs stackage
|
||||||
|
case mdatabasePath of
|
||||||
|
Nothing -> hoogleDatabaseNotAvailableFor slug
|
||||||
|
Just path -> sendFile "application/octet-stream" $ fpToString path
|
||||||
|
|
||||||
|
hoogleDatabaseNotAvailableFor :: SnapSlug -> Handler a
|
||||||
|
hoogleDatabaseNotAvailableFor slug = (>>= sendResponse) $ defaultLayout $ do
|
||||||
|
setTitle "Hoogle database not available"
|
||||||
|
[whamlet|
|
||||||
|
<div .container>
|
||||||
|
<p>The given Hoogle database is not available.
|
||||||
|
<p>
|
||||||
|
<a href=@{SnapshotR slug StackageHomeR}>Return to snapshot homepage
|
||||||
|
|]
|
||||||
|
|
||||||
getPageCount :: Int -> Int
|
getPageCount :: Int -> Int
|
||||||
getPageCount totalCount = 1 + div totalCount perPage
|
getPageCount totalCount = 1 + div totalCount perPage
|
||||||
|
|
||||||
|
|||||||
@ -26,6 +26,7 @@
|
|||||||
/packages SnapshotPackagesR GET
|
/packages SnapshotPackagesR GET
|
||||||
/docs DocsR GET
|
/docs DocsR GET
|
||||||
/hoogle HoogleR GET
|
/hoogle HoogleR GET
|
||||||
|
/db.hoo HoogleDatabaseR GET
|
||||||
/build-plan BuildPlanR GET
|
/build-plan BuildPlanR GET
|
||||||
|
|
||||||
/aliases AliasesR PUT
|
/aliases AliasesR PUT
|
||||||
|
|||||||
@ -39,6 +39,8 @@ $newline never
|
|||||||
|
|
||||||
<h3>Hoogle (experimental)
|
<h3>Hoogle (experimental)
|
||||||
^{hoogleForm}
|
^{hoogleForm}
|
||||||
|
<a href=@{SnapshotR slug HoogleDatabaseR}>
|
||||||
|
Download this hoogle database
|
||||||
|
|
||||||
<h3>Packages
|
<h3>Packages
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user