replace txt by gmi

This commit is contained in:
Yann Esposito (Yogsototh) 2020-11-09 18:14:04 +01:00
parent 67112b0974
commit 8bf91ba875
Signed by untrusted user who does not match committer: yogsototh
GPG Key ID: 7B19A4C650D59646
2 changed files with 6 additions and 37 deletions

View File

@ -153,15 +153,13 @@ buildRules = do
if txtExists
then copyFileChanged (srcDir </> asset) out
else genPdfAction getPost out
".txt" -> do
".gmi" -> do
fileExists <- doesFileExist (srcDir </> asset)
if fileExists
then copyFileChanged (srcDir </> asset) out
else genAsciiAction getPost out
".gmi" ->
if out == siteDir </> "archive.gmi"
then buildGeminiArchive getPosts out
else genGeminiAction out
else if out == siteDir </> "archive.gmi"
then buildGeminiArchive getPosts out
else genGeminiAction out
".jpg" -> compressImage asset
".jpeg" -> compressImage asset
".gif" -> compressImage asset
@ -333,35 +331,12 @@ genHtmlAction getPost getTemplate out = do
, "description" .= postDescr bp
, "body" .= innerHtml
, "orgsource" .= T.pack (postUrl bp -<.> "org")
, "txtsource" .= T.pack (postUrl bp -<.> "txt")
, "txtsource" .= T.pack (postUrl bp -<.> "gmi")
, "pdf" .= T.pack (postUrl bp -<.> "pdf")
, "permalink" .= T.pack (toS origin <> postUrl bp -<.> "html")
]
writeFile' out (toS htmlContent)
genAscii :: (MonadIO m, MonadFail m) => BlogPost -> m Text
genAscii bp = do
eitherAscii <- liftIO $ Pandoc.runIO $ Writers.writePlain def (postBody bp)
case eitherAscii of
Left _ -> fail "BAD"
Right innerAscii -> return innerAscii
genAsciiAction
:: (FilePath -> Action BlogPost)
-> [Char] -> Action ()
genAsciiAction getPost out = do
let srcFile = srcDir </> (dropDirectory1 (out -<.> "org"))
need [srcFile]
bp <- getPost srcFile
innerAscii <- genAscii bp
let preamble = postTitle bp <> "\n"
<> T.replicate (T.length (postTitle bp)) "=" <> "\n\n"
<> postAuthor bp <> "\n"
<> postDate bp <> "\n"
<> toS origin <> toS (postUrl bp) <> "\n\n"
writeFile' out (toS (preamble <> toS innerAscii))
genPdfAction :: p -> [Char] -> Action ()
genPdfAction _getPost out = do
let srcFile = srcDir </> (dropDirectory1 (out -<.> "org"))
@ -402,11 +377,6 @@ allPdfAction = do
let allHtmlFiles = map (-<.> "pdf") allOrgFiles
need (map build allHtmlFiles)
allAsciiAction :: Action ()
allAsciiAction = do
allOrgFiles <- getDirectoryFiles srcDir ["//*.org"]
let allAsciiFiles = map (-<.> "txt") allOrgFiles
need (map build allAsciiFiles)
allGeminiAction :: Action ()
allGeminiAction = do
@ -449,7 +419,6 @@ fastRule =
needAll :: Action ()
needAll = do
needFast
allAsciiAction
allPdfAction
allGeminiAction

View File

@ -22,7 +22,7 @@
<a href="https://her.esy.fun">
<span class="author">{{author}}</span>'s blog</a> -
<a href="{{orgsource}}">source</a> -
<a href="{{txtsource}}">txt</a> -
<a href="{{txtsource}}">gmi</a> -
<a href="{{pdf}}">pdf</a> -
<a class="permalink" href="{{permalink}}">§permalink</a>
</div>