blob: 35e675af363940a382584a4c5ac4ee50d5682b8f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
module Main where
import Conduit
import Data.Maybe
import Data.XML.Types
import Network.HTTP.Conduit
import Text.Atom.Conduit.Parse
import Text.Atom.Conduit.Render
import Text.XML.Stream.Parse
import Text.XML.Stream.Render
import Text.XML.Unresolved (elementToEvents)
main :: IO ()
main = do
request <- parseRequest "https://code.nomath.org/abuilder/atom"
manager <- newManager tlsManagerSettings
runResourceT do
response <- http request manager
runConduit $
( \feed ->
renderAtomFeed feed
.| renderBytes def
.| printC
)
. fromJust
=<< responseBody response
.| parseBytes def
.| massage
.| atomFeed
massage :: ConduitT Event Event (ResourceT IO) ()
massage = do
await >>= \case
Nothing -> pure ()
Just e -> do
yield e -- BeginDocument
await >>= \case
Nothing -> pure ()
Just e -> do
yield e -- <feed>
yieldMany (elementToEvents idE)
yieldMany (elementToEvents updatedE)
mapC id
where
idE =
-- TODO(id)
Element
"{http://www.w3.org/2005/Atom}id"
[]
[ NodeContent (ContentText "TODO")
]
updatedE =
-- TODO(updated)
Element
"{http://www.w3.org/2005/Atom}updated"
[]
[ NodeContent (ContentText "1970-01-01T00:00:00Z")
]
|