--------------------------------------------------------- -- -- Module : Web.Restful.Response.AtomFeed -- Copyright : Michael Snoyman -- License : BSD3 -- -- Maintainer : Michael Snoyman -- Stability : Stable -- Portability : portable -- -- Generating atom news feeds. -- --------------------------------------------------------- module Web.Restful.Response.AtomFeed ( AtomFeed (..) , AtomFeedEntry (..) ) where import Web.Restful.Response import Web.Restful.Utils import Data.Time.Clock import Web.Encodings import Data.ByteString.Class data AtomFeed = AtomFeed { atomTitle :: String , atomLinkSelf :: String , atomLinkHome :: String , atomUpdated :: UTCTime , atomEntries :: [AtomFeedEntry] } instance HasReps AtomFeed where reps e = [ ("application/atom+xml", toLazyByteString $ show e) ] data AtomFeedEntry = AtomFeedEntry { atomEntryLink :: String , atomEntryUpdated :: UTCTime , atomEntryTitle :: String , atomEntryContent :: String } instance Show AtomFeed where show f = concat [ "\n" , "" , "" , encodeHtml $ atomTitle f , "" , "" , "" , "" , formatW3 $ atomUpdated f , "" , "" , encodeHtml $ atomLinkHome f , "" , concatMap show $ atomEntries f , "" ] instance Show AtomFeedEntry where show e = concat [ "" , "" , encodeHtml $ atomEntryLink e , "" , "" , "" , formatW3 $ atomEntryUpdated e , "" , "" , encodeHtml $ atomEntryTitle e , "" , "" , "" ]