aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFélix Sipma <felix.sipma@no-log.org>2020-12-08 19:49:52 +0100
committerFélix Sipma <felix.sipma@no-log.org>2020-12-08 19:49:52 +0100
commit287a8d0d99b68b90970a5e4484c87532cfb38e4c (patch)
treee8115b8ef3f0abef7d70c37410f96c2cd4f49d7c
parent955c86b7e7558d20ab7adb79b71ef9cb44ced1f0 (diff)
atom: use 'source > updated' instead of 'updated' if available
-rw-r--r--src/Atom.hs17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/Atom.hs b/src/Atom.hs
index d5dcdad..3f2f652 100644
--- a/src/Atom.hs
+++ b/src/Atom.hs
@@ -36,10 +36,25 @@ parseUpdated :: MonadLogger m => Cursor -> m (Maybe UTCTime)
parseUpdated c = parseW3Rfc822 $ mconcat $ parseFieldContent "updated" c
parseEntryUpdated :: MonadLogger m => Cursor -> m (Maybe UTCTime)
-parseEntryUpdated c = case parseFieldContent "updated" c of
+parseEntryUpdated c = do
+ mu <- parseEntrySourceUpdated c
+ case mu of
+ Nothing -> parseEntryUpdated' c
+ Just u -> return $ Just u
+-- parseEntryUpdated = parseEntryUpdated'
+
+parseEntryUpdated' :: MonadLogger m => Cursor -> m (Maybe UTCTime)
+parseEntryUpdated' c = case parseFieldContent "updated" c of
[] -> parseW3Rfc822 $ mconcat $ parseFieldContent "published" c
us -> parseW3Rfc822 $ mconcat us
+-- | "source > updated" is useful for "planet" feeds, it is often more accurate
+-- than "updated"
+parseEntrySourceUpdated :: MonadLogger m => Cursor -> m (Maybe UTCTime)
+parseEntrySourceUpdated c = case (c $/ localNameFilter "source" &/ localNameFilter "updated" &// content) of
+ [] -> return Nothing
+ us -> parseW3Rfc822 $ mconcat us
+
parseLink :: Cursor -> Link
parseLink c = do
let href = case mconcat $ c $| attribute "href" of