module Text.Atom.Feed
( URI
, NCName
, Date
, MediaType
, Attr
, Feed(..)
, Entry(..)
, EntryContent(..)
, Category(..)
, Generator(..)
, Link(..)
, TextContent(..)
, txtToString
, Source(..)
, Person(..)
, InReplyTo(..)
, InReplyTotal(..)
, newCategory
, nullFeed
, nullEntry
, nullGenerator
, nullLink
, nullSource
, nullPerson
) where
import Prelude.Compat
import Data.Text (Text, unpack)
import Data.XML.Compat
import Data.XML.Types as XML
type URI = Text
type NCName = Text
type Date = Text
type MediaType = Text
data Feed =
Feed
{ Feed -> Text
feedId :: URI
, Feed -> TextContent
feedTitle :: TextContent
, Feed -> Text
feedUpdated :: Date
, Feed -> [Person]
feedAuthors :: [Person]
, Feed -> [Category]
feedCategories :: [Category]
, Feed -> [Person]
feedContributors :: [Person]
, Feed -> Maybe Generator
feedGenerator :: Maybe Generator
, Feed -> Maybe Text
feedIcon :: Maybe URI
, Feed -> [Link]
feedLinks :: [Link]
, Feed -> Maybe Text
feedLogo :: Maybe URI
, Feed -> Maybe TextContent
feedRights :: Maybe TextContent
, Feed -> Maybe TextContent
feedSubtitle :: Maybe TextContent
, Feed -> [Entry]
feedEntries :: [Entry]
, Feed -> [Attr]
feedAttrs :: [Attr]
, Feed -> [Element]
feedOther :: [XML.Element]
}
deriving (Int -> Feed -> ShowS
[Feed] -> ShowS
Feed -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Feed] -> ShowS
$cshowList :: [Feed] -> ShowS
show :: Feed -> String
$cshow :: Feed -> String
showsPrec :: Int -> Feed -> ShowS
$cshowsPrec :: Int -> Feed -> ShowS
Show)
data Entry =
Entry
{ Entry -> Text
entryId :: URI
, Entry -> TextContent
entryTitle :: TextContent
, Entry -> Text
entryUpdated :: Date
, Entry -> [Person]
entryAuthors :: [Person]
, Entry -> [Category]
entryCategories :: [Category]
, Entry -> Maybe EntryContent
entryContent :: Maybe EntryContent
, Entry -> [Person]
entryContributor :: [Person]
, Entry -> [Link]
entryLinks :: [Link]
, Entry -> Maybe Text
entryPublished :: Maybe Date
, Entry -> Maybe TextContent
entryRights :: Maybe TextContent
, Entry -> Maybe Source
entrySource :: Maybe Source
, Entry -> Maybe TextContent
entrySummary :: Maybe TextContent
, Entry -> Maybe InReplyTo
entryInReplyTo :: Maybe InReplyTo
, Entry -> Maybe InReplyTotal
entryInReplyTotal :: Maybe InReplyTotal
, Entry -> [Attr]
entryAttrs :: [Attr]
, Entry -> [Element]
entryOther :: [XML.Element]
}
deriving (Int -> Entry -> ShowS
[Entry] -> ShowS
Entry -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Entry] -> ShowS
$cshowList :: [Entry] -> ShowS
show :: Entry -> String
$cshow :: Entry -> String
showsPrec :: Int -> Entry -> ShowS
$cshowsPrec :: Int -> Entry -> ShowS
Show)
data EntryContent
= TextContent Text
| HTMLContent Text
| XHTMLContent XML.Element
| MixedContent (Maybe Text) [XML.Node]
| ExternalContent (Maybe MediaType) URI
deriving (Int -> EntryContent -> ShowS
[EntryContent] -> ShowS
EntryContent -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EntryContent] -> ShowS
$cshowList :: [EntryContent] -> ShowS
show :: EntryContent -> String
$cshow :: EntryContent -> String
showsPrec :: Int -> EntryContent -> ShowS
$cshowsPrec :: Int -> EntryContent -> ShowS
Show)
data Category =
Category
{ Category -> Text
catTerm :: Text
, Category -> Maybe Text
catScheme :: Maybe URI
, Category -> Maybe Text
catLabel :: Maybe Text
, Category -> [Element]
catOther :: [XML.Element]
}
deriving (Int -> Category -> ShowS
[Category] -> ShowS
Category -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Category] -> ShowS
$cshowList :: [Category] -> ShowS
show :: Category -> String
$cshow :: Category -> String
showsPrec :: Int -> Category -> ShowS
$cshowsPrec :: Int -> Category -> ShowS
Show)
data Generator =
Generator
{ Generator -> Maybe Text
genURI :: Maybe URI
, Generator -> Maybe Text
genVersion :: Maybe Text
, Generator -> Text
genText :: Text
}
deriving (Generator -> Generator -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Generator -> Generator -> Bool
$c/= :: Generator -> Generator -> Bool
== :: Generator -> Generator -> Bool
$c== :: Generator -> Generator -> Bool
Eq, Int -> Generator -> ShowS
[Generator] -> ShowS
Generator -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Generator] -> ShowS
$cshowList :: [Generator] -> ShowS
show :: Generator -> String
$cshow :: Generator -> String
showsPrec :: Int -> Generator -> ShowS
$cshowsPrec :: Int -> Generator -> ShowS
Show)
data Link =
Link
{ Link -> Text
linkHref :: URI
, Link -> Maybe (Either Text Text)
linkRel :: Maybe (Either NCName URI)
, Link -> Maybe Text
linkType :: Maybe MediaType
, Link -> Maybe Text
linkHrefLang :: Maybe Text
, Link -> Maybe Text
linkTitle :: Maybe Text
, Link -> Maybe Text
linkLength :: Maybe Text
, Link -> [Attr]
linkAttrs :: [Attr]
, Link -> [Element]
linkOther :: [XML.Element]
}
deriving (Int -> Link -> ShowS
[Link] -> ShowS
Link -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Link] -> ShowS
$cshowList :: [Link] -> ShowS
show :: Link -> String
$cshow :: Link -> String
showsPrec :: Int -> Link -> ShowS
$cshowsPrec :: Int -> Link -> ShowS
Show)
data TextContent
= TextString Text
| HTMLString Text
| XHTMLString XML.Element
deriving (Int -> TextContent -> ShowS
[TextContent] -> ShowS
TextContent -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TextContent] -> ShowS
$cshowList :: [TextContent] -> ShowS
show :: TextContent -> String
$cshow :: TextContent -> String
showsPrec :: Int -> TextContent -> ShowS
$cshowsPrec :: Int -> TextContent -> ShowS
Show)
txtToString :: TextContent -> String
txtToString :: TextContent -> String
txtToString (TextString Text
s) = Text -> String
unpack Text
s
txtToString (HTMLString Text
s) = Text -> String
unpack Text
s
txtToString (XHTMLString Element
x) = forall a. Show a => a -> String
show Element
x
data Source =
Source
{ Source -> [Person]
sourceAuthors :: [Person]
, Source -> [Category]
sourceCategories :: [Category]
, Source -> Maybe Generator
sourceGenerator :: Maybe Generator
, Source -> Maybe Text
sourceIcon :: Maybe URI
, Source -> Maybe Text
sourceId :: Maybe URI
, Source -> [Link]
sourceLinks :: [Link]
, Source -> Maybe Text
sourceLogo :: Maybe URI
, Source -> Maybe TextContent
sourceRights :: Maybe TextContent
, Source -> Maybe TextContent
sourceSubtitle :: Maybe TextContent
, Source -> Maybe TextContent
sourceTitle :: Maybe TextContent
, Source -> Maybe Text
sourceUpdated :: Maybe Date
, Source -> [Element]
sourceOther :: [XML.Element]
}
deriving (Int -> Source -> ShowS
[Source] -> ShowS
Source -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Source] -> ShowS
$cshowList :: [Source] -> ShowS
show :: Source -> String
$cshow :: Source -> String
showsPrec :: Int -> Source -> ShowS
$cshowsPrec :: Int -> Source -> ShowS
Show)
data Person =
Person
{ Person -> Text
personName :: Text
, Person -> Maybe Text
personURI :: Maybe URI
, Person -> Maybe Text
personEmail :: Maybe Text
, Person -> [Element]
personOther :: [XML.Element]
}
deriving (Int -> Person -> ShowS
[Person] -> ShowS
Person -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Person] -> ShowS
$cshowList :: [Person] -> ShowS
show :: Person -> String
$cshow :: Person -> String
showsPrec :: Int -> Person -> ShowS
$cshowsPrec :: Int -> Person -> ShowS
Show)
data InReplyTo =
InReplyTo
{ InReplyTo -> Text
replyToRef :: URI
, InReplyTo -> Maybe Text
replyToHRef :: Maybe URI
, InReplyTo -> Maybe Text
replyToType :: Maybe MediaType
, InReplyTo -> Maybe Text
replyToSource :: Maybe URI
, InReplyTo -> [Attr]
replyToOther :: [Attr]
, InReplyTo -> [Node]
replyToContent :: [Node]
}
deriving (Int -> InReplyTo -> ShowS
[InReplyTo] -> ShowS
InReplyTo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InReplyTo] -> ShowS
$cshowList :: [InReplyTo] -> ShowS
show :: InReplyTo -> String
$cshow :: InReplyTo -> String
showsPrec :: Int -> InReplyTo -> ShowS
$cshowsPrec :: Int -> InReplyTo -> ShowS
Show)
data InReplyTotal =
InReplyTotal
{ InReplyTotal -> Integer
replyToTotal :: Integer
, InReplyTotal -> [Attr]
replyToTotalOther :: [Attr]
}
deriving (Int -> InReplyTotal -> ShowS
[InReplyTotal] -> ShowS
InReplyTotal -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InReplyTotal] -> ShowS
$cshowList :: [InReplyTotal] -> ShowS
show :: InReplyTotal -> String
$cshow :: InReplyTotal -> String
showsPrec :: Int -> InReplyTotal -> ShowS
$cshowsPrec :: Int -> InReplyTotal -> ShowS
Show)
newCategory ::
Text
-> Category
newCategory :: Text -> Category
newCategory Text
t = Category {catTerm :: Text
catTerm = Text
t, catScheme :: Maybe Text
catScheme = forall a. Maybe a
Nothing, catLabel :: Maybe Text
catLabel = forall a. a -> Maybe a
Just Text
t, catOther :: [Element]
catOther = []}
nullFeed ::
URI
-> TextContent
-> Date
-> Feed
nullFeed :: Text -> TextContent -> Text -> Feed
nullFeed Text
i TextContent
t Text
u =
Feed
{ feedId :: Text
feedId = Text
i
, feedTitle :: TextContent
feedTitle = TextContent
t
, feedUpdated :: Text
feedUpdated = Text
u
, feedAuthors :: [Person]
feedAuthors = []
, feedCategories :: [Category]
feedCategories = []
, feedContributors :: [Person]
feedContributors = []
, feedGenerator :: Maybe Generator
feedGenerator = forall a. Maybe a
Nothing
, feedIcon :: Maybe Text
feedIcon = forall a. Maybe a
Nothing
, feedLinks :: [Link]
feedLinks = []
, feedLogo :: Maybe Text
feedLogo = forall a. Maybe a
Nothing
, feedRights :: Maybe TextContent
feedRights = forall a. Maybe a
Nothing
, feedSubtitle :: Maybe TextContent
feedSubtitle = forall a. Maybe a
Nothing
, feedEntries :: [Entry]
feedEntries = []
, feedAttrs :: [Attr]
feedAttrs = []
, feedOther :: [Element]
feedOther = []
}
nullEntry ::
URI
-> TextContent
-> Date
-> Entry
nullEntry :: Text -> TextContent -> Text -> Entry
nullEntry Text
i TextContent
t Text
u =
Entry
{ entryId :: Text
entryId = Text
i
, entryTitle :: TextContent
entryTitle = TextContent
t
, entryUpdated :: Text
entryUpdated = Text
u
, entryAuthors :: [Person]
entryAuthors = []
, entryCategories :: [Category]
entryCategories = []
, entryContent :: Maybe EntryContent
entryContent = forall a. Maybe a
Nothing
, entryContributor :: [Person]
entryContributor = []
, entryLinks :: [Link]
entryLinks = []
, entryPublished :: Maybe Text
entryPublished = forall a. Maybe a
Nothing
, entryRights :: Maybe TextContent
entryRights = forall a. Maybe a
Nothing
, entrySource :: Maybe Source
entrySource = forall a. Maybe a
Nothing
, entrySummary :: Maybe TextContent
entrySummary = forall a. Maybe a
Nothing
, entryInReplyTo :: Maybe InReplyTo
entryInReplyTo = forall a. Maybe a
Nothing
, entryInReplyTotal :: Maybe InReplyTotal
entryInReplyTotal = forall a. Maybe a
Nothing
, entryAttrs :: [Attr]
entryAttrs = []
, entryOther :: [Element]
entryOther = []
}
nullGenerator ::
Text
-> Generator
nullGenerator :: Text -> Generator
nullGenerator Text
t = Generator {genURI :: Maybe Text
genURI = forall a. Maybe a
Nothing, genVersion :: Maybe Text
genVersion = forall a. Maybe a
Nothing, genText :: Text
genText = Text
t}
nullLink ::
URI
-> Link
nullLink :: Text -> Link
nullLink Text
uri =
Link
{ linkHref :: Text
linkHref = Text
uri
, linkRel :: Maybe (Either Text Text)
linkRel = forall a. Maybe a
Nothing
, linkType :: Maybe Text
linkType = forall a. Maybe a
Nothing
, linkHrefLang :: Maybe Text
linkHrefLang = forall a. Maybe a
Nothing
, linkTitle :: Maybe Text
linkTitle = forall a. Maybe a
Nothing
, linkLength :: Maybe Text
linkLength = forall a. Maybe a
Nothing
, linkAttrs :: [Attr]
linkAttrs = []
, linkOther :: [Element]
linkOther = []
}
nullSource :: Source
nullSource :: Source
nullSource =
Source
{ sourceAuthors :: [Person]
sourceAuthors = []
, sourceCategories :: [Category]
sourceCategories = []
, sourceGenerator :: Maybe Generator
sourceGenerator = forall a. Maybe a
Nothing
, sourceIcon :: Maybe Text
sourceIcon = forall a. Maybe a
Nothing
, sourceId :: Maybe Text
sourceId = forall a. Maybe a
Nothing
, sourceLinks :: [Link]
sourceLinks = []
, sourceLogo :: Maybe Text
sourceLogo = forall a. Maybe a
Nothing
, sourceRights :: Maybe TextContent
sourceRights = forall a. Maybe a
Nothing
, sourceSubtitle :: Maybe TextContent
sourceSubtitle = forall a. Maybe a
Nothing
, sourceTitle :: Maybe TextContent
sourceTitle = forall a. Maybe a
Nothing
, sourceUpdated :: Maybe Text
sourceUpdated = forall a. Maybe a
Nothing
, sourceOther :: [Element]
sourceOther = []
}
nullPerson :: Person
nullPerson :: Person
nullPerson = Person {personName :: Text
personName = Text
"", personURI :: Maybe Text
personURI = forall a. Maybe a
Nothing, personEmail :: Maybe Text
personEmail = forall a. Maybe a
Nothing, personOther :: [Element]
personOther = []}