2010-05-17 18:33:05 +04:00
|
|
|
#!/usr/bin/env runhaskell
|
2011-08-28 22:03:20 +04:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
2013-03-10 01:13:21 +04:00
|
|
|
import Control.Applicative ((<$>))
|
|
|
|
import Data.Monoid (mappend)
|
|
|
|
import Hakyll
|
2011-08-28 22:03:20 +04:00
|
|
|
|
2013-03-10 01:13:21 +04:00
|
|
|
import Control.Monad
|
|
|
|
import Data.List
|
|
|
|
import System.Directory
|
|
|
|
import System.Process
|
|
|
|
import Text.Pandoc.Options
|
|
|
|
import Text.Printf
|
2010-05-17 18:33:05 +04:00
|
|
|
|
2011-08-28 22:03:20 +04:00
|
|
|
main = do
|
|
|
|
symlinkPagesFromParentDir
|
|
|
|
symlinkProfsDir
|
|
|
|
hakyll $ do
|
2013-03-10 01:13:21 +04:00
|
|
|
match ("images/*" .||. "js/**" .||. "robots.txt") $ do
|
|
|
|
route idRoute
|
|
|
|
compile copyFileCompiler
|
|
|
|
match "css/*" $ do
|
|
|
|
route idRoute
|
|
|
|
compile compressCssCompiler
|
|
|
|
match "templates/*" $ compile templateCompiler
|
2013-09-16 00:41:26 +04:00
|
|
|
match ("README.md") $ do
|
|
|
|
route $ constRoute "index.html"
|
|
|
|
compile $
|
|
|
|
pandocCompilerWith def def
|
|
|
|
>>= loadAndApplyTemplate "templates/frontpage.html" defaultContext
|
|
|
|
>>= relativizeUrls
|
|
|
|
match (("*.md" .&&. complement "README.md") .||. "0.21/*.md" .||. "0.20/*.md" .||. "0.19/*.md" .||. "0.18/*.md") $ do
|
2013-03-10 01:13:21 +04:00
|
|
|
route $ setExtension "html"
|
|
|
|
compile $
|
|
|
|
pandocCompilerWith
|
|
|
|
def
|
|
|
|
def{writerTableOfContents=True
|
2013-04-01 02:14:40 +04:00
|
|
|
,writerTOCDepth=4
|
2013-03-10 01:13:21 +04:00
|
|
|
,writerStandalone=True
|
|
|
|
,writerTemplate="<div id=toc>$toc$</div>\n$body$"
|
|
|
|
}
|
|
|
|
>>= loadAndApplyTemplate "templates/default.html" defaultContext
|
|
|
|
>>= relativizeUrls
|
2010-05-21 22:20:07 +04:00
|
|
|
|
2011-08-28 22:03:20 +04:00
|
|
|
symlinkPagesFromParentDir = do
|
|
|
|
fs <- filter (".md" `isSuffixOf`) `fmap` getDirectoryContents ".."
|
|
|
|
forM_ fs $ \f -> system $ printf "[ -f %s ] || ln -s ../%s" f f
|
2013-03-10 01:13:21 +04:00
|
|
|
|
|
|
|
symlinkProfsDir = ensureSiteDir >> system "ln -sf ../../profs _site/profs"
|
2011-08-28 22:03:20 +04:00
|
|
|
|
2013-03-10 01:13:21 +04:00
|
|
|
ensureSiteDir = system "mkdir -p _site"
|
2013-06-08 04:00:04 +04:00
|
|
|
|
2013-06-08 04:02:03 +04:00
|
|
|
|