Merge branch 'master' of gitea.esy.fun:yogsototh/her.esy.fun
This commit is contained in:
commit
594434aa7b
1 changed files with 32 additions and 2 deletions
34
Shakefile.hs
34
Shakefile.hs
|
@ -154,10 +154,11 @@ buildRules = do
|
||||||
then copyFileChanged (srcDir </> asset) out
|
then copyFileChanged (srcDir </> asset) out
|
||||||
else genPdfAction getPost out
|
else genPdfAction getPost out
|
||||||
".txt" -> do
|
".txt" -> do
|
||||||
txtExists <- doesFileExist (srcDir </> asset)
|
fileExists <- doesFileExist (srcDir </> asset)
|
||||||
if txtExists
|
if fileExists
|
||||||
then copyFileChanged (srcDir </> asset) out
|
then copyFileChanged (srcDir </> asset) out
|
||||||
else genAsciiAction getPost out
|
else genAsciiAction getPost out
|
||||||
|
".gmi" -> genGeminiAction getPost out
|
||||||
".jpg" -> compressImage asset
|
".jpg" -> compressImage asset
|
||||||
".jpeg" -> compressImage asset
|
".jpeg" -> compressImage asset
|
||||||
".gif" -> compressImage asset
|
".gif" -> compressImage asset
|
||||||
|
@ -353,6 +354,28 @@ genPdfAction _getPost out = do
|
||||||
, "-V", "monofontoptions:Scale=0.7"
|
, "-V", "monofontoptions:Scale=0.7"
|
||||||
, "-o", out ]
|
, "-o", out ]
|
||||||
|
|
||||||
|
|
||||||
|
genGemini :: (MonadIO m, MonadFail m) => BlogPost -> m Text
|
||||||
|
genGemini bp = do
|
||||||
|
eitherMd <- liftIO $ Pandoc.runIO $ Writers.writeMarkdown def (postBody bp)
|
||||||
|
case eitherMd of
|
||||||
|
Left _ -> fail "BAD"
|
||||||
|
Right innerMd -> return innerMd
|
||||||
|
|
||||||
|
genGeminiAction
|
||||||
|
:: (FilePath -> Action BlogPost)
|
||||||
|
-> [Char] -> Action ()
|
||||||
|
genGeminiAction getPost out = do
|
||||||
|
let srcFile = srcDir </> (dropDirectory1 (dropDirectory1 (out -<.> "org")))
|
||||||
|
need [srcFile]
|
||||||
|
bp <- getPost srcFile
|
||||||
|
innerGemini <- genGemini bp
|
||||||
|
let preamble = "# " <> postTitle bp <> "\n"
|
||||||
|
<> postAuthor bp <> "\n"
|
||||||
|
<> postDate bp <> "\n"
|
||||||
|
<> toS origin <> toS (postUrl bp) <> "\n\n"
|
||||||
|
writeFile' out (toS (preamble <> toS innerGemini))
|
||||||
|
|
||||||
allHtmlAction :: Action ()
|
allHtmlAction :: Action ()
|
||||||
allHtmlAction = do
|
allHtmlAction = do
|
||||||
allOrgFiles <- getDirectoryFiles srcDir ["//*.org"]
|
allOrgFiles <- getDirectoryFiles srcDir ["//*.org"]
|
||||||
|
@ -371,6 +394,12 @@ allAsciiAction = do
|
||||||
let allAsciiFiles = map (-<.> "txt") allOrgFiles
|
let allAsciiFiles = map (-<.> "txt") allOrgFiles
|
||||||
need (map build allAsciiFiles)
|
need (map build allAsciiFiles)
|
||||||
|
|
||||||
|
allGeminiAction :: Action ()
|
||||||
|
allGeminiAction = do
|
||||||
|
allOrgFiles <- getDirectoryFiles srcDir ["//*.org"]
|
||||||
|
let allGeminiFiles = map (("gemini" </>) . (-<.> "gmi")) allOrgFiles
|
||||||
|
need (map build allGeminiFiles)
|
||||||
|
|
||||||
compressImage :: FilePath -> Action ()
|
compressImage :: FilePath -> Action ()
|
||||||
compressImage img = do
|
compressImage img = do
|
||||||
let src = srcDir </> img
|
let src = srcDir </> img
|
||||||
|
@ -408,6 +437,7 @@ needAll = do
|
||||||
needFast
|
needFast
|
||||||
allAsciiAction
|
allAsciiAction
|
||||||
allPdfAction
|
allPdfAction
|
||||||
|
allGeminiAction
|
||||||
|
|
||||||
allRule :: Rules ()
|
allRule :: Rules ()
|
||||||
allRule =
|
allRule =
|
||||||
|
|
Loading…
Reference in a new issue