Skip to content
Snippets Groups Projects
Verified Commit 7303234a authored by Nicolas Lenz's avatar Nicolas Lenz :snowflake:
Browse files

refactor: reformat some stuff in Feed.hs

parent df416370
No related branches found
No related tags found
No related merge requests found
......@@ -20,27 +20,28 @@ import Control.Concurrent.Async
-- See also https://validator.w3.org/feed/docs/atom.html
toEntry :: PandocMonad m => Text -> Page -> m Atom.Entry
toEntry baseUrl page@Page{..} = let Pandoc meta _ = pageDoc in do
toEntry baseUrl page@Page{..} = do
html <- renderPageContent page
let link :: Text = baseUrl <> fromMaybe "" (lookupMetaPlain "link" meta)
let entry = Atom.nullEntry
link
(Atom.TextString $ fromMaybe "Untitled" (lookupMetaPlain "title" meta))
timestamp
let
Pandoc meta _ = pageDoc
link :: Text = baseUrl <> fromMaybe "" (lookupMetaPlain "link" meta)
timestamp :: Atom.Date = toText . iso8601Show $ getUpdated page
entry :: Atom.Entry = Atom.nullEntry
link
(Atom.TextString $ fromMaybe "Untitled" (lookupMetaPlain "title" meta))
timestamp
return entry
{ Atom.entryContent = Just $ Atom.HTMLContent html
, Atom.entrySummary = Atom.TextString <$> lookupMetaPlain "description" meta
, Atom.entryLinks = [ Atom.nullLink link ]
}
where
timestamp :: Atom.Date
timestamp = toText . iso8601Show $ getUpdated page
getUpdated :: Page -> ZonedTime
getUpdated Page{..} = case (pageDate, pageUpdated) of
(_, Just updated) -> updated
(Just date, _) -> date
_ -> placeholderTime
(_, Just updated) -> updated
(Just date, _) -> date
_ -> placeholderTime
placeholderTime :: ZonedTime
placeholderTime = ZonedTime (LocalTime (fromOrdinalDate 1980 1) midnight) utc
......@@ -59,7 +60,7 @@ toFeed baseUrl feed@Feed{..} = do
(toText . iso8601Show $ latestUpdate feed)
return entry
{ Atom.feedEntries = entries
, Atom.feedLinks = [Atom.nullLink baseUrl]
, Atom.feedLinks = [ Atom.nullLink baseUrl ]
}
{-renderFeed :: Atom.Feed -> Text
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment