replace txt by gmi
This commit is contained in:
parent
67112b0974
commit
8bf91ba875
2 changed files with 6 additions and 37 deletions
41
Shakefile.hs
41
Shakefile.hs
|
@ -153,15 +153,13 @@ buildRules = do
|
||||||
if txtExists
|
if txtExists
|
||||||
then copyFileChanged (srcDir </> asset) out
|
then copyFileChanged (srcDir </> asset) out
|
||||||
else genPdfAction getPost out
|
else genPdfAction getPost out
|
||||||
".txt" -> do
|
".gmi" -> do
|
||||||
fileExists <- doesFileExist (srcDir </> asset)
|
fileExists <- doesFileExist (srcDir </> asset)
|
||||||
if fileExists
|
if fileExists
|
||||||
then copyFileChanged (srcDir </> asset) out
|
then copyFileChanged (srcDir </> asset) out
|
||||||
else genAsciiAction getPost out
|
else if out == siteDir </> "archive.gmi"
|
||||||
".gmi" ->
|
then buildGeminiArchive getPosts out
|
||||||
if out == siteDir </> "archive.gmi"
|
else genGeminiAction out
|
||||||
then buildGeminiArchive getPosts out
|
|
||||||
else genGeminiAction out
|
|
||||||
".jpg" -> compressImage asset
|
".jpg" -> compressImage asset
|
||||||
".jpeg" -> compressImage asset
|
".jpeg" -> compressImage asset
|
||||||
".gif" -> compressImage asset
|
".gif" -> compressImage asset
|
||||||
|
@ -333,35 +331,12 @@ genHtmlAction getPost getTemplate out = do
|
||||||
, "description" .= postDescr bp
|
, "description" .= postDescr bp
|
||||||
, "body" .= innerHtml
|
, "body" .= innerHtml
|
||||||
, "orgsource" .= T.pack (postUrl bp -<.> "org")
|
, "orgsource" .= T.pack (postUrl bp -<.> "org")
|
||||||
, "txtsource" .= T.pack (postUrl bp -<.> "txt")
|
, "txtsource" .= T.pack (postUrl bp -<.> "gmi")
|
||||||
, "pdf" .= T.pack (postUrl bp -<.> "pdf")
|
, "pdf" .= T.pack (postUrl bp -<.> "pdf")
|
||||||
, "permalink" .= T.pack (toS origin <> postUrl bp -<.> "html")
|
, "permalink" .= T.pack (toS origin <> postUrl bp -<.> "html")
|
||||||
]
|
]
|
||||||
writeFile' out (toS htmlContent)
|
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 :: p -> [Char] -> Action ()
|
||||||
genPdfAction _getPost out = do
|
genPdfAction _getPost out = do
|
||||||
let srcFile = srcDir </> (dropDirectory1 (out -<.> "org"))
|
let srcFile = srcDir </> (dropDirectory1 (out -<.> "org"))
|
||||||
|
@ -402,11 +377,6 @@ allPdfAction = do
|
||||||
let allHtmlFiles = map (-<.> "pdf") allOrgFiles
|
let allHtmlFiles = map (-<.> "pdf") allOrgFiles
|
||||||
need (map build allHtmlFiles)
|
need (map build allHtmlFiles)
|
||||||
|
|
||||||
allAsciiAction :: Action ()
|
|
||||||
allAsciiAction = do
|
|
||||||
allOrgFiles <- getDirectoryFiles srcDir ["//*.org"]
|
|
||||||
let allAsciiFiles = map (-<.> "txt") allOrgFiles
|
|
||||||
need (map build allAsciiFiles)
|
|
||||||
|
|
||||||
allGeminiAction :: Action ()
|
allGeminiAction :: Action ()
|
||||||
allGeminiAction = do
|
allGeminiAction = do
|
||||||
|
@ -449,7 +419,6 @@ fastRule =
|
||||||
needAll :: Action ()
|
needAll :: Action ()
|
||||||
needAll = do
|
needAll = do
|
||||||
needFast
|
needFast
|
||||||
allAsciiAction
|
|
||||||
allPdfAction
|
allPdfAction
|
||||||
allGeminiAction
|
allGeminiAction
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<a href="https://her.esy.fun">
|
<a href="https://her.esy.fun">
|
||||||
<span class="author">{{author}}</span>'s blog</a> -
|
<span class="author">{{author}}</span>'s blog</a> -
|
||||||
<a href="{{orgsource}}">source</a> -
|
<a href="{{orgsource}}">source</a> -
|
||||||
<a href="{{txtsource}}">txt</a> -
|
<a href="{{txtsource}}">gmi</a> -
|
||||||
<a href="{{pdf}}">pdf</a> -
|
<a href="{{pdf}}">pdf</a> -
|
||||||
<a class="permalink" href="{{permalink}}">§permalink</a>
|
<a class="permalink" href="{{permalink}}">§permalink</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue