aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFélix Sipma <felix.sipma@no-log.org>2016-09-01 16:40:27 +0200
committerFélix Sipma <felix.sipma@no-log.org>2016-09-01 16:40:27 +0200
commit8217b9d703663d86a96d3ca04e6a604b3254a725 (patch)
treefc915cef599b46fcd0ad33c55d69ec5c3c730915
parent5236263961ddd9144ab328cf8becef1ddffbe0a2 (diff)
RSS: minor refactoring
-rw-r--r--src/RSS.hs11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/RSS.hs b/src/RSS.hs
index c66e2ce..131b640 100644
--- a/src/RSS.hs
+++ b/src/RSS.hs
@@ -20,16 +20,19 @@ import Parse
localNameFilter :: T.Text -> Axis
localNameFilter ln = checkName (\name -> nameLocalName name == ln)
+parseFieldContent :: T.Text -> Cursor -> [T.Text]
+parseFieldContent field c = c $/ localNameFilter field &// content
+
parseId :: Cursor -> T.Text
-parseId c = mconcat $ c $/ localNameFilter "guid" &// content
+parseId = mconcat . parseFieldContent "guid"
parseTitle :: Cursor -> T.Text
parseTitle c =
- mconcat (c $/ localNameFilter "title" &// content)
+ mconcat (parseFieldContent "title" c)
`mappend` mconcat (c $/ element "{http://purl.org/dc/elements/1.1/}subject" &// content)
parseUpdated :: MonadLogger m => [Entry] -> Cursor -> m (Maybe UTCTime)
-parseUpdated e c = case mconcat $ c $/ localNameFilter "lastBuildDate" &// content of
+parseUpdated e c = case mconcat $ parseFieldContent "lastBuildDate" c of
"" -> case e of
[] -> return (Just $ read "1970-01-01 00:00:00 UTC")
_ -> case map entryUpdated e of
@@ -39,7 +42,7 @@ parseUpdated e c = case mconcat $ c $/ localNameFilter "lastBuildDate" &// conte
parseEntryUpdated :: MonadLogger m => Cursor -> m (Maybe UTCTime)
parseEntryUpdated c = parseW3Rfc822 $
- mconcat (c $/ localNameFilter "pubDate" &// content)
+ mconcat (parseFieldContent "pubDate" c)
`mappend` mconcat (c $/ element "{http://purl.org/dc/elements/1.1/}date" &// content)
parseLink :: Cursor -> Link