Links
Imports
For Atom feeds:
import qualified Text.Feed.Types as Feed
import qualified Text.Feed.Util as Feed
import qualified Text.Atom.Feed as Atom
import qualified Text.Atom.Feed.Export as Atom
-- from the “xml” package
import qualified Text.XML.Light.Output as XML
Creating an Atom feed
There are several types that you would need:
Each of these (apart from EntryContent
and TextContent
) is a record with lots of fields. You would almost never need all of those fields, so there are some helper functions available that make initialising them easier. For instance, to create a Link
, use nullLink
:
-- URI = String
nullLink :: URI -> Link
And then you can customise some of the fields:
nullLink "http://foo.bar" {
linkTitle = Just "Foo Bar" }
Same with nullEntry
and nullFeed
; a complete example can be found here. Note that:
-
The example uses String
s as dates. If you want to convert UTCTime
to the string format expected by the library, use toFeedDateStringUTC AtomKind
(from Text.Feed.Util
and Text.Feed.Types
respectively).
-
The newest entry should be the 1st in the list.
-
The feed ID (i.e. the 1st parameter to nullFeed
) doesn't have to be a link – for instance, for Github feeds it's something like
tag:github.com,2008:/bergmark/feed/commits/master
Entry IDs, contrary to what the example says, don't have to be links either.