stackage-server/Import.hs

39 lines
1 KiB
Haskell
Raw Permalink Normal View History

2014-04-09 07:52:04 +00:00
module Import
( module Import
) where
2014-06-03 13:10:35 +00:00
import ClassyPrelude.Yesod as Import
import Foundation as Import
import Settings as Import
import Settings.Development as Import
import Settings.StaticFiles as Import
import Types as Import
import Yesod.Auth as Import
2014-12-09 12:01:38 +00:00
import Data.WebsiteContent as Import (WebsiteContent (..))
import Data.Text.Read (decimal)
2015-05-13 11:08:58 +00:00
import Stackage.Database (SnapName)
2014-10-20 11:46:57 +00:00
parseLtsPair :: Text -> Maybe (Int, Int)
parseLtsPair t1 = do
(x, t2) <- either (const Nothing) Just $ decimal t1
t3 <- stripPrefix "." t2
(y, "") <- either (const Nothing) Just $ decimal t3
Just (x, y)
2015-05-13 11:08:58 +00:00
2016-04-20 12:32:57 +00:00
packageUrl :: SnapName -> PackageName -> Version -> Route App
packageUrl sname pkgname pkgver = SnapshotR sname sdistR
where
sdistR = StackageSdistR (PNVNameVersion pkgname pkgver)
2015-05-13 11:08:58 +00:00
haddockUrl :: SnapName
-> Text -- ^ package-version
-> Text -- ^ module name
-> Route App
haddockUrl sname pkgver name = HaddockR sname
[ pkgver
, omap toDash name ++ ".html"
]
where
toDash '.' = '-'
toDash c = c