diff options
| author | Chris Wells <chris@mathematicaster.org> | 2025-02-10 12:48:38 -0600 |
|---|---|---|
| committer | Chris Wells <chris@mathematicaster.org> | 2025-02-10 12:48:38 -0600 |
| commit | 0c677070edf9978cb85a0b521f7e6e0ef6d6b491 (patch) | |
| tree | 1bf0a024ea2c1ccc9c21c68b916e76017bafd310 /src/WWW | |
| parent | 75ac829ee7d661d758f7828e609e28ee4e05d038 (diff) | |
| download | main-0c677070edf9978cb85a0b521f7e6e0ef6d6b491.tar main-0c677070edf9978cb85a0b521f7e6e0ef6d6b491.tar.gz main-0c677070edf9978cb85a0b521f7e6e0ef6d6b491.tar.bz2 main-0c677070edf9978cb85a0b521f7e6e0ef6d6b491.tar.lz main-0c677070edf9978cb85a0b521f7e6e0ef6d6b491.tar.xz main-0c677070edf9978cb85a0b521f7e6e0ef6d6b491.tar.zst main-0c677070edf9978cb85a0b521f7e6e0ef6d6b491.zip | |
A lot of work on aliases and the like
Diffstat (limited to 'src/WWW')
| -rw-r--r-- | src/WWW/Base.hs | 11 | ||||
| -rw-r--r-- | src/WWW/HW.hs | 19 | ||||
| -rw-r--r-- | src/WWW/Templates.hs | 2 |
3 files changed, 31 insertions, 1 deletions
diff --git a/src/WWW/Base.hs b/src/WWW/Base.hs index 7c752da..ab4f214 100644 --- a/src/WWW/Base.hs +++ b/src/WWW/Base.hs @@ -3,11 +3,14 @@ module WWW.Base , baseHakyll , domain , wwwRoot + , myHakyllReaderOptions + , myHakyllWriterOptions ) where import Prolog import Hakyll import System.Process +import Text.Pandoc.Options -- | mathematicaster.org @@ -34,3 +37,11 @@ baseConfig p = defaultConfiguration baseHakyll :: MonadIO m => FilePath -> Rules a -> m () baseHakyll p = liftIO . hakyllWith (baseConfig p) + +myHakyllReaderOptions :: ReaderOptions +myHakyllReaderOptions = defaultHakyllReaderOptions + +myHakyllWriterOptions :: WriterOptions +myHakyllWriterOptions = defaultHakyllWriterOptions + { writerHTMLMathMethod = MathJax mempty + } diff --git a/src/WWW/HW.hs b/src/WWW/HW.hs index 1ce601f..9387961 100644 --- a/src/WWW/HW.hs +++ b/src/WWW/HW.hs @@ -1,6 +1,8 @@ module WWW.HW ( removeEnv , removeSolutions + , setDocLocation + , setDocLocation_ -- * LaTeX utils , LaTeX (..) , texmap @@ -9,13 +11,28 @@ module WWW.HW , module Hakyll.TeX.LaTeX ) where --- import Prolog +import Prolog +import Hakyll import Hakyll.TeX.HaTeX import Hakyll.TeX.LaTeX +import Network.URI import Text.LaTeX.Base.Syntax +import Text.LaTeX.Packages.Hyperref removeEnv :: (String -> Bool) -> LaTeX -> LaTeX removeEnv p = texmap (\case { TeXEnv s _ _ -> p s; _ -> False }) $ pure mempty removeSolutions :: LaTeX -> LaTeX removeSolutions = removeEnv (== "solution") + +setDocLocation :: URI -> (String -> [TeXArg] -> Bool) -> Item LaTeX -> Compiler (Item LaTeX) +setDocLocation u p (Item i l) = Item i <$> texmapM (\case { TeXComm _ _ -> True; _ -> False }) mapper l + where + mapper = \case + TeXComm s args | p s args -> do + relpath <- getRoute i >>= maybe (fail $ show i <> " has no route") pure >>= maybe (fail $ "Cannot parse " <> show i <> " as a relative URI") pure . parseRelativeReference + pure $ TeXComm s [ FixArg $ url $ toSL $ relpath `relativeTo` u ] + x -> pure x + +setDocLocation_ :: URI -> Item LaTeX -> Compiler (Item LaTeX) +setDocLocation_ u = setDocLocation u $ \s _ -> s == "doclink" diff --git a/src/WWW/Templates.hs b/src/WWW/Templates.hs index 0068a07..f73236e 100644 --- a/src/WWW/Templates.hs +++ b/src/WWW/Templates.hs @@ -13,6 +13,7 @@ import Prolog import Hakyll import Hakyll.TeX.TikZ (tikzTemplate) +import Hakyll.Web.Template.Util (slug) defaultTemplate :: Template @@ -29,5 +30,6 @@ myContext :: Context String myContext = fold [ constField "personalEmail" "chris@mathematicaster.org" , constField "workEmail" "coc0014@auburn.edu" + , slug , defaultContext ] |
