Improved gemini gen added gemini link
This commit is contained in:
parent
f1dc320648
commit
c5d591564e
3 changed files with 17 additions and 10 deletions
23
Shakefile.hs
23
Shakefile.hs
|
@ -181,8 +181,9 @@ buildArchive getPosts getTemplate out = do
|
||||||
let
|
let
|
||||||
title :: Text
|
title :: Text
|
||||||
title = "#+title: Yann Esposito's blog"
|
title = "#+title: Yann Esposito's blog"
|
||||||
|
menu = "@@html:<a href=\"/index.html\">Home</a> | <a href=\"/slides.html\">Slides</a> | <a href=\"/about-me.html\">About</a>@@"
|
||||||
articleList = toS $ T.intercalate "\n" $ map postInfo posts
|
articleList = toS $ T.intercalate "\n" $ map postInfo posts
|
||||||
fileContent = title <> "\n\n" <> welcomeTxt <> "\n\n" <> articleList
|
fileContent = title <> "\n\n" <> menu <> "\n\n" <> welcomeTxt <> "\n\n" <> articleList
|
||||||
eitherResult <- liftIO $ Pandoc.runIO $ Readers.readOrg (def { readerStandalone = True }) (toS fileContent)
|
eitherResult <- liftIO $ Pandoc.runIO $ Readers.readOrg (def { readerStandalone = True }) (toS fileContent)
|
||||||
bp <- case eitherResult of
|
bp <- case eitherResult of
|
||||||
Left _ -> fail "BAD"
|
Left _ -> fail "BAD"
|
||||||
|
@ -205,11 +206,7 @@ geminiMenu = T.intercalate "\n"
|
||||||
[ "=> /index.gmi Home"
|
[ "=> /index.gmi Home"
|
||||||
, "=> /gem-atom.xml Feed"
|
, "=> /gem-atom.xml Feed"
|
||||||
, "=> /slides.gmi Slides"
|
, "=> /slides.gmi Slides"
|
||||||
, "=> /about-me.gmi About"
|
, "=> /about-me.gmi About me"
|
||||||
, ""
|
|
||||||
, "=> https://gitea.esy.fun code"
|
|
||||||
, "=> https://espial.esy.fun/u:yogsototh bookmarks"
|
|
||||||
, "=> https://espial.esy.fun/u:yogsototh/notes notes"
|
|
||||||
]
|
]
|
||||||
|
|
||||||
buildGeminiArchive
|
buildGeminiArchive
|
||||||
|
@ -224,8 +221,9 @@ buildGeminiArchive getPosts out = do
|
||||||
articleList = toS $ T.intercalate "\n" $ map postGeminiInfo posts
|
articleList = toS $ T.intercalate "\n" $ map postGeminiInfo posts
|
||||||
fileContent = title
|
fileContent = title
|
||||||
<> "\n\n" <> welcomeTxt
|
<> "\n\n" <> welcomeTxt
|
||||||
<> "\n\n" <> articleList
|
|
||||||
<> "\n\n" <> geminiMenu
|
<> "\n\n" <> geminiMenu
|
||||||
|
<> "\n\n" <> "## Articles"
|
||||||
|
<> "\n\n" <> articleList
|
||||||
writeFile' out (toS fileContent)
|
writeFile' out (toS fileContent)
|
||||||
|
|
||||||
postGeminiInfo :: BlogPost -> Text
|
postGeminiInfo :: BlogPost -> Text
|
||||||
|
@ -325,6 +323,9 @@ genHtml bp = do
|
||||||
origin :: Text
|
origin :: Text
|
||||||
origin = "https://her.esy.fun"
|
origin = "https://her.esy.fun"
|
||||||
|
|
||||||
|
geminiOrigin :: Text
|
||||||
|
geminiOrigin = "gemini://her.esy.fun"
|
||||||
|
|
||||||
genHtmlAction
|
genHtmlAction
|
||||||
:: (FilePath -> Action BlogPost)
|
:: (FilePath -> Action BlogPost)
|
||||||
-> (FilePath -> Action Template) -> [Char] -> Action ()
|
-> (FilePath -> Action Template) -> [Char] -> Action ()
|
||||||
|
@ -334,10 +335,11 @@ genHtmlAction getPost getTemplate out = do
|
||||||
"slides" -> "slide.mustache"
|
"slides" -> "slide.mustache"
|
||||||
"drafts" -> "post.mustache"
|
"drafts" -> "post.mustache"
|
||||||
_ -> "main.mustache"
|
_ -> "main.mustache"
|
||||||
template <- getTemplate ("templates" </> tplname)
|
let templateFile = "templates" </> tplname
|
||||||
|
template <- getTemplate templateFile
|
||||||
let srcFile = srcDir </> (dropDirectory1 (out -<.> "org"))
|
let srcFile = srcDir </> (dropDirectory1 (out -<.> "org"))
|
||||||
liftIO $ putText $ "need: " <> (toS srcFile) <> " -> " <> (toS out)
|
liftIO $ putText $ "need: " <> (toS srcFile) <> " -> " <> (toS out)
|
||||||
need [srcFile]
|
need [srcFile,templateFile,"templates" </> "menu.mustache","Shakefile.hs"]
|
||||||
bp <- getPost srcFile
|
bp <- getPost srcFile
|
||||||
innerHtml <- genHtml bp
|
innerHtml <- genHtml bp
|
||||||
let htmlContent =
|
let htmlContent =
|
||||||
|
@ -350,6 +352,7 @@ genHtmlAction getPost getTemplate out = do
|
||||||
, "body" .= innerHtml
|
, "body" .= innerHtml
|
||||||
, "orgsource" .= T.pack (postUrl bp -<.> "org")
|
, "orgsource" .= T.pack (postUrl bp -<.> "org")
|
||||||
, "txtsource" .= T.pack (postUrl bp -<.> "gmi")
|
, "txtsource" .= T.pack (postUrl bp -<.> "gmi")
|
||||||
|
, "geminiurl" .= T.pack (toS geminiOrigin <> 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")
|
||||||
]
|
]
|
||||||
|
@ -358,7 +361,7 @@ genHtmlAction getPost getTemplate out = do
|
||||||
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"))
|
||||||
need [srcFile]
|
need [srcFile,"Shakefile.hs"]
|
||||||
command_ [] "pandoc"
|
command_ [] "pandoc"
|
||||||
["--pdf-engine=xelatex"
|
["--pdf-engine=xelatex"
|
||||||
, "--resource-path=" <> takeDirectory srcFile
|
, "--resource-path=" <> takeDirectory srcFile
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="content">
|
<div id="content">
|
||||||
{{{body}}}
|
{{{body}}}
|
||||||
|
<br/>
|
||||||
|
<a href="{{geminiurl}}"><code>=> This article is also available on gemini</code></a>
|
||||||
</div>
|
</div>
|
||||||
<div id="postamble" class="status">
|
<div id="postamble" class="status">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
|
|
|
@ -32,6 +32,8 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="content">
|
<div id="content">
|
||||||
{{{body}}}
|
{{{body}}}
|
||||||
|
<br/>
|
||||||
|
<a href="{{geminiurl}}"><code>=> This article is also available on gemini</code></a>
|
||||||
</div>
|
</div>
|
||||||
<div id="postamble" class="status">
|
<div id="postamble" class="status">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
|
|
Loading…
Reference in a new issue