src: format

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2023-08-26 20:45:10 +05:30
parent 7cb266782d
commit ba247f88d4

View File

@@ -6,11 +6,13 @@ import Data.Maybe (isJust)
import Data.Text (Text) import Data.Text (Text)
import qualified Data.Text as T import qualified Data.Text as T
import Hakyll import Hakyll
import System.Environment (getEnv)
import System.FilePath (replaceDirectory, replaceExtension, takeDirectory) import System.FilePath (replaceDirectory, replaceExtension, takeDirectory)
import System.IO.Unsafe (unsafePerformIO)
import qualified System.Process as Process import qualified System.Process as Process
import Text.Pandoc import Text.Pandoc (
( WriterOptions WriterOptions (
( writerHighlightStyle, writerHighlightStyle,
writerNumberSections, writerNumberSections,
writerTOCDepth, writerTOCDepth,
writerTableOfContents, writerTableOfContents,
@@ -19,8 +21,6 @@ import Text.Pandoc
) )
import qualified Text.Pandoc as Pandoc import qualified Text.Pandoc as Pandoc
import Text.Pandoc.Templates (Template, compileTemplate) import Text.Pandoc.Templates (Template, compileTemplate)
import System.Environment (getEnv)
import System.IO.Unsafe (unsafePerformIO)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@@ -162,13 +162,13 @@ main = hakyllWith config $ do
_ <- _ <-
Process.system $ Process.system $
unwords unwords
[ "xelatex", [ "xelatex"
"-halt-on-error", , "-halt-on-error"
"-output-directory", , "-output-directory"
tmpDir, , tmpDir
texPath, , texPath
">/dev/null", , ">/dev/null"
"2>&1" , "2>&1"
] ]
return () return ()
@@ -177,23 +177,23 @@ main = hakyllWith config $ do
rssFeedConfiguration :: FeedConfiguration rssFeedConfiguration :: FeedConfiguration
rssFeedConfiguration = rssFeedConfiguration =
FeedConfiguration FeedConfiguration
{ feedTitle = "nattopages", { feedTitle = "nattopages"
feedDescription = "Pages by natto", , feedDescription = "Pages by natto"
feedAuthorName = "Amneesh Singh", , feedAuthorName = "Amneesh Singh"
feedAuthorEmail = "natto@weirdnatto.in", , feedAuthorEmail = "natto@weirdnatto.in"
feedRoot = "https://weirdnatto.in" , feedRoot = "https://weirdnatto.in"
} }
config :: Configuration config :: Configuration
config = config =
defaultConfiguration defaultConfiguration
{ deployCommand = "rsync --checksum -ave 'ssh -p" ++ sshTargetPort ++"' _site/* " ++ sshTarget, { deployCommand = "rsync --checksum -ave 'ssh -p" ++ sshTargetPort ++ "' _site/* " ++ sshTarget
previewPort = 3333 , previewPort = 3333
} }
where where
{-# NOINLINE sshTarget#-} {-# NOINLINE sshTarget #-}
sshTarget = unsafePerformIO $ getEnv "SSHTARGET" sshTarget = unsafePerformIO $ getEnv "SSHTARGET"
{-# NOINLINE sshTargetPort#-} {-# NOINLINE sshTargetPort #-}
sshTargetPort = unsafePerformIO $ getEnv "SSHTARGETPORT" sshTargetPort = unsafePerformIO $ getEnv "SSHTARGETPORT"
postCtx :: Tags -> Context String postCtx :: Tags -> Context String
@@ -223,23 +223,23 @@ defaultCtx =
subdomains = map mkItem ["git", "radio", "f"] subdomains = map mkItem ["git", "radio", "f"]
where where
mkItem :: a -> Item a mkItem :: a -> Item a
mkItem a = Item {itemIdentifier = "subdomain", itemBody = a} mkItem a = Item{itemIdentifier = "subdomain", itemBody = a}
writerOptions :: Bool -> WriterOptions writerOptions :: Bool -> WriterOptions
writerOptions withNumbering = writerOptions withNumbering =
defaultHakyllWriterOptions defaultHakyllWriterOptions
{ writerNumberSections = withNumbering, { writerNumberSections = withNumbering
writerTableOfContents = True, , writerTableOfContents = True
writerTOCDepth = 2, , writerTOCDepth = 2
writerTemplate = Just tocTemplate , writerTemplate = Just tocTemplate
} }
tocTemplate :: Text.Pandoc.Templates.Template Text tocTemplate :: Text.Pandoc.Templates.Template Text
tocTemplate = tocTemplate =
either error id . runIdentity . compileTemplate "" $ either error id . runIdentity . compileTemplate "" $
T.unlines T.unlines
[ "<div class=\"toc\"><div class=\"toc-header\">Table of Contents</div>", [ "<div class=\"toc\"><div class=\"toc-header\">Table of Contents</div>"
"$toc$", , "$toc$"
"</div>", , "</div>"
"$body$" , "$body$"
] ]