This commit is contained in:
Yann Esposito (Yogsototh) 2020-06-23 08:44:02 +02:00
parent c1a00e1c09
commit d201cf8b1b
Signed by untrusted user who does not match committer: yogsototh
GPG key ID: 7B19A4C650D59646
3 changed files with 12 additions and 17 deletions

View file

@ -22,6 +22,7 @@ import Text.Pandoc.Definition ( Pandoc(..)
, Inline , Inline
, nullMeta , nullMeta
, docTitle , docTitle
, lookupMeta
, docDate , docDate
, docAuthors , docAuthors
) )
@ -59,6 +60,7 @@ data BlogPost =
, postAuthors :: [T.Text] , postAuthors :: [T.Text]
, postUrl :: FilePath , postUrl :: FilePath
, postBody :: Pandoc , postBody :: Pandoc
-- , postToc :: Boolean
} }
inlineToText :: PandocMonad m => [Inline] -> m T.Text inlineToText :: PandocMonad m => [Inline] -> m T.Text
@ -72,7 +74,6 @@ getBlogpostFromMetas path pandoc@(Pandoc meta _) = do
title <- inlineToText $ docTitle meta title <- inlineToText $ docTitle meta
date <- inlineToText $ docDate meta date <- inlineToText $ docDate meta
authors <- mapM inlineToText $ docAuthors meta authors <- mapM inlineToText $ docAuthors meta
-- let url = dropExtension path
return $ BlogPost title date authors path pandoc return $ BlogPost title date authors path pandoc
case eitherBlogpost of case eitherBlogpost of
Left _ -> fail "BAD" Left _ -> fail "BAD"
@ -146,9 +147,17 @@ mkGetTemplate = newCache $ \path -> do
Left _ -> fail "BAD" Left _ -> fail "BAD"
Right template -> return template Right template -> return template
parseOptions :: Text -> [Text] -> Maybe Text
parseOptions fc =
fc & T.lines
& map T.toLower
& filter (T.isPrefixOf (T.pack "#options: "))
& head
mkGetPost :: Rules (FilePath -> Action BlogPost) mkGetPost :: Rules (FilePath -> Action BlogPost)
mkGetPost = newCache $ \path -> do mkGetPost = newCache $ \path -> do
fileContent <- readFile' path fileContent <- readFile' path
let options = parseOptions (toS fileContent)
eitherResult <- liftIO $ Pandoc.runIO $ Readers.readOrg def (toS fileContent) eitherResult <- liftIO $ Pandoc.runIO $ Readers.readOrg def (toS fileContent)
case eitherResult of case eitherResult of
Left _ -> fail "BAD" Left _ -> fail "BAD"

View file

@ -33,22 +33,10 @@
<div class="content"><h1>{{title}}</h1></div> <div class="content"><h1>{{title}}</h1></div>
</div> </div>
<div id="content"> <div id="content">
<p>
<nav>
<a href="/index.html">Home</a> |
<a href="/archive.html">Posts</a> |
<a href="/slides.html">Slides</a> |
<a href="/about-me.html">About</a>
<span class="details">
(<a href="https://gitea.esy.fun/yogsototh">code</a>
<a href="https://espial.esy.fun/u:yogsototh">bookmarks</a>
<a href="https://espial.esy.fun/u:yogsototh/notes">notes</a>)
</span>
</nav>
</p>
{{{ body }}} {{{ body }}}
</div>
<div id="postamble" class="status"> <div id="postamble" class="status">
<div class="content"> <div class="content">
<footer><i>Any comment? Click on my email below and I'll add it.</i> <footer><i>Any comment? Click on my email below and I'll add it.</i>

View file

@ -15,9 +15,7 @@
<input name="t" type="radio" id="d"> <input name="t" type="radio" id="d">
<div id="labels"> <div id="labels">
<div class="content"> <div class="content">
<label for="l">light</label> <label for="l">light</label> | <label for="d">dark</label>
|
<label for="d">dark</label>
</div> </div>
</div> </div>
<div class="main"> <div class="main">