summaryrefslogtreecommitdiff
path: root/src/Site.hs
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2015-11-06 20:46:58 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2015-11-06 20:46:58 +0100
commita1068fbdeea74a12e4f33069cf091302f87e8d17 (patch)
treeb5483ab2b71133f9445c6479fb0287e8a62263ea /src/Site.hs
parent14623524bd0d2d01c7a539c771f506a010a46695 (diff)
downloaddirty-haskell.org-a1068fbdeea74a12e4f33069cf091302f87e8d17.tar
dirty-haskell.org-a1068fbdeea74a12e4f33069cf091302f87e8d17.tar.gz
dirty-haskell.org-a1068fbdeea74a12e4f33069cf091302f87e8d17.tar.bz2
dirty-haskell.org-a1068fbdeea74a12e4f33069cf091302f87e8d17.tar.xz
dirty-haskell.org-a1068fbdeea74a12e4f33069cf091302f87e8d17.zip
Started work on math compilation
Diffstat (limited to 'src/Site.hs')
-rw-r--r--src/Site.hs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/Site.hs b/src/Site.hs
index 1bda7ec..e821322 100644
--- a/src/Site.hs
+++ b/src/Site.hs
@@ -20,9 +20,12 @@ import Control.Applicative (Alternative(..), Applicative(..))
20import qualified Crypto.Hash.SHA256 as SHA256 (hash) 20import qualified Crypto.Hash.SHA256 as SHA256 (hash)
21import qualified Data.ByteString.Char8 as CBS 21import qualified Data.ByteString.Char8 as CBS
22import Data.Hex 22import Data.Hex
23import Data.Char (toLower)
23 24
24import System.FilePath (takeBaseName, (</>), (<.>)) 25import System.FilePath (takeBaseName, (</>), (<.>))
25 26
27import Math (compileMath)
28
26main :: IO () 29main :: IO ()
27main = hakyllWith config $ do 30main = hakyllWith config $ do
28 match "templates/*" $ compile templateCompiler 31 match "templates/*" $ compile templateCompiler
@@ -45,7 +48,9 @@ main = hakyllWith config $ do
45 create [mathTranslation' mathStr] $ do 48 create [mathTranslation' mathStr] $ do
46 route idRoute 49 route idRoute
47 compile $ do 50 compile $ do
48 makeItem $ mathStr 51 makeItem mathStr
52 >>= loadAndApplyTemplate "templates/math.tex" defaultContext
53 >>= withItemBody (unsafeCompiler . compileMath)
49 54
50 tags <- buildTags "posts/*" tagTranslation' >>= addTag "All Posts" "posts/*" 55 tags <- buildTags "posts/*" tagTranslation' >>= addTag "All Posts" "posts/*"
51 56
@@ -139,7 +144,7 @@ tagTranslation = mapMaybe charTrans
139 | otherwise = Nothing 144 | otherwise = Nothing
140 145
141mathTranslation' :: String -> Identifier 146mathTranslation' :: String -> Identifier
142mathTranslation' = fromCapture "math/*.svg" . CBS.unpack . hex . SHA256.hash . CBS.pack 147mathTranslation' = fromCapture "math/*.svg" . map toLower . CBS.unpack . hex . SHA256.hash . CBS.pack
143 148
144addTag :: MonadMetadata m => String -> Pattern -> Tags -> m Tags 149addTag :: MonadMetadata m => String -> Pattern -> Tags -> m Tags
145addTag name pattern tags = do 150addTag name pattern tags = do