module Text.RSS1.Syntax
( URIString
, TitleString
, TimeString
, TextString
, Feed(..)
, Channel(..)
, Image(..)
, Item(..)
, TextInputInfo(..)
, TaxonomyTopic(..)
, UpdatePeriod(..)
, ContentInfo(..)
, nullFeed
, nullChannel
, nullImage
, nullItem
, nullTextInputInfo
, nullTaxonomyTopic
, nullContentInfo
) where
import Prelude.Compat
import Data.Text
import Data.XML.Compat
import Data.XML.Types as XML
import Text.DublinCore.Types
type URIString = Text
type TitleString = Text
type TimeString = Text
type TextString = Text
data Feed = Feed
{ feedVersion :: Text
, feedChannel :: Channel
, feedImage :: Maybe Image
, feedItems :: [Item]
, feedTextInput :: Maybe TextInputInfo
, feedTopics :: [TaxonomyTopic]
, feedOther :: [XML.Element]
, feedAttrs :: [Attr]
} deriving (Show)
data Channel = Channel
{ channelURI :: URIString
, channelTitle :: TitleString
, channelLink :: URIString
, channelDesc :: TextString
, channelImageURI :: Maybe URIString
, channelItemURIs :: [URIString]
, channelTextInputURI :: Maybe URIString
, channelDC :: [DCItem]
, channelUpdatePeriod :: Maybe UpdatePeriod
, channelUpdateFreq :: Maybe Integer
, channelUpdateBase :: Maybe TimeString
, channelContent :: [ContentInfo]
, channelTopics :: [URIString]
, channelOther :: [XML.Element]
, channelAttrs :: [Attr]
} deriving (Show)
data Image = Image
{ imageURI :: URIString
, imageTitle :: TextString
, imageURL :: URIString
, imageLink :: URIString
, imageDC :: [DCItem]
, imageOther :: [XML.Element]
, imageAttrs :: [Attr]
} deriving (Show)
data Item = Item
{ itemURI :: URIString
, itemTitle :: TextString
, itemLink :: URIString
, itemDesc :: Maybe TextString
, itemDC :: [DCItem]
, itemTopics :: [URIString]
, itemContent :: [ContentInfo]
, itemOther :: [XML.Element]
, itemAttrs :: [Attr]
} deriving (Show)
data TextInputInfo = TextInputInfo
{ textInputURI :: URIString
, textInputTitle :: TextString
, textInputDesc :: TextString
, textInputName :: TextString
, textInputLink :: URIString
, textInputDC :: [DCItem]
, textInputOther :: [XML.Element]
, textInputAttrs :: [Attr]
} deriving (Show)
data TaxonomyTopic = TaxonomyTopic
{ taxonomyURI :: URIString
, taxonomyLink :: URIString
, taxonomyTitle :: Maybe Text
, taxonomyDesc :: Maybe Text
, taxonomyTopics :: [URIString]
, taxonomyDC :: [DCItem]
, taxonomyOther :: [XML.Element]
} deriving (Show)
data UpdatePeriod
= Update_Hourly
| Update_Daily
| Update_Weekly
| Update_Monthly
| Update_Yearly
deriving (Eq, Show)
data ContentInfo = ContentInfo
{ contentURI :: Maybe URIString
, contentFormat :: Maybe URIString
, contentEncoding :: Maybe URIString
, contentValue :: Maybe Text
} deriving (Eq, Show)
nullFeed :: URIString -> TitleString -> Feed
nullFeed uri title =
Feed
{ feedVersion = "1.0"
, feedChannel = nullChannel uri title
, feedImage = Nothing
, feedItems = []
, feedTextInput = Nothing
, feedTopics = []
, feedOther = []
, feedAttrs = []
}
nullChannel :: URIString -> TitleString -> Channel
nullChannel uri title =
Channel
{ channelURI = uri
, channelTitle = title
, channelLink = uri
, channelDesc = title
, channelImageURI = Nothing
, channelItemURIs = []
, channelTextInputURI = Nothing
, channelDC = []
, channelUpdatePeriod = Nothing
, channelUpdateFreq = Nothing
, channelUpdateBase = Nothing
, channelContent = []
, channelTopics = []
, channelOther = []
, channelAttrs = []
}
nullImage :: URIString -> Text -> URIString -> Image
nullImage imguri title link =
Image
{ imageURI = imguri
, imageTitle = title
, imageURL = imguri
, imageLink = link
, imageDC = []
, imageOther = []
, imageAttrs = []
}
nullItem :: URIString -> TextString -> URIString -> Item
nullItem uri title link =
Item
{ itemURI = uri
, itemTitle = title
, itemLink = link
, itemDesc = Nothing
, itemDC = []
, itemTopics = []
, itemContent = []
, itemOther = []
, itemAttrs = []
}
nullTextInputInfo :: URIString -> TextString -> TextString -> URIString -> TextInputInfo
nullTextInputInfo uri title nm link =
TextInputInfo
{ textInputURI = uri
, textInputTitle = title
, textInputDesc = title
, textInputName = nm
, textInputLink = link
, textInputDC = []
, textInputOther = []
, textInputAttrs = []
}
nullTaxonomyTopic :: URIString -> URIString -> TaxonomyTopic
nullTaxonomyTopic uri link =
TaxonomyTopic
{ taxonomyURI = uri
, taxonomyLink = link
, taxonomyTitle = Nothing
, taxonomyDesc = Nothing
, taxonomyTopics = []
, taxonomyDC = []
, taxonomyOther = []
}
nullContentInfo :: ContentInfo
nullContentInfo =
ContentInfo
{ contentURI = Nothing
, contentFormat = Nothing
, contentEncoding = Nothing
, contentValue = Nothing
}