diff options
Diffstat (limited to 'web')
-rw-r--r-- | web/site.hs | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/web/site.hs b/web/site.hs index 6130bea..aac6368 100644 --- a/web/site.hs +++ b/web/site.hs @@ -1,8 +1,12 @@ -------------------------------------------------------------------------------- {-# LANGUAGE OverloadedStrings #-} -import Control.Monad (forM_) -import Data.Monoid (mappend) +import Control.Applicative ((<$>)) +import Control.Arrow (second) +import Control.Monad (forM_) +import Data.List (isPrefixOf) +import Data.Monoid (mappend) import Hakyll +import System.FilePath (dropTrailingPathSeparator, splitPath) import Text.Pandoc @@ -14,7 +18,17 @@ main = hakyllWith config $ do compile compressCssCompiler -- Static directories - forM_ ["images/*", "examples/*", "reference/**"] $ \f -> match f $ do + forM_ ["images/*", "examples/*"] $ \f -> match f $ do + route idRoute + compile copyFileCompiler + + -- Haddock stuff + match "reference/**.html" $ do + route idRoute + compile $ fmap (withUrls hackage) <$> getResourceString + + -- Haddock stuff + match ("reference/**" `mappend` complement "**.html") $ do route idRoute compile copyFileCompiler @@ -69,3 +83,23 @@ config = defaultConfiguration , deployCommand = "rsync --checksum -ave 'ssh -p 2222' \ \_site/* jaspervdj@jaspervdj.be:jaspervdj.be/tmp/hakyll4" } + + +-------------------------------------------------------------------------------- +-- | Turns +-- +-- > /usr/share/doc/ghc/html/libraries/base-4.6.0.0/Data-String.html +-- +-- into +-- +-- > http://hackage.haskell.org/packages/archive/base/4.6.0.0/doc/html/Data-String.html +hackage :: String -> String +hackage url + | "/usr" `isPrefixOf` url = + "http://hackage.haskell.org/packages/archive/" ++ + packageName ++ "/" ++ version' ++ "/doc/html/" ++ baseName + | otherwise = url + where + (packageName, version') = second (drop 1) $ break (== '-') package + (baseName : package : _) = map dropTrailingPathSeparator $ + reverse $ splitPath url |