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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
|
--------------------------------------------------------------------
-- |
-- Module : Text.RSS1.Syntax
-- Copyright : (c) Galois, Inc. 2008
-- License : BSD3
--
-- Maintainer: Sigbjorn Finne <sof@galois.com>
-- Stability : provisional
-- Portability:
--
--------------------------------------------------------------------
module Text.RSS1.Syntax where
import Text.XML.Light.Types as XML
import Text.DublinCore.Types
type URIString = String
type TitleString = String
type TimeString = String
type TextString = String
data Feed
= Feed { feedVersion :: String
, feedChannel :: Channel
, feedImage :: Maybe Image
, feedItems :: [Item]
, feedTextInput :: Maybe TextInputInfo
, feedTopics :: [TaxonomyTopic]
, feedOther :: [XML.Element]
, feedAttrs :: [XML.Attr]
}
deriving (Show)
data Channel
= Channel
{ channelURI :: URIString
, channelTitle :: TitleString
, channelLink :: URIString
, channelDesc :: TextString
-- these are indirect RDF associations to elements declared
-- outside the channel element in the RDF \/ feed document.
, channelImageURI :: Maybe URIString
, channelItemURIs :: [URIString]
, channelTextInputURI :: Maybe URIString
, channelDC :: [DCItem]
, channelUpdatePeriod :: Maybe UpdatePeriod
, channelUpdateFreq :: Maybe Integer
, channelUpdateBase :: Maybe TimeString -- format is yyyy-mm-ddThh:mm
, channelContent :: [ContentInfo]
, channelTopics :: [URIString]
, channelOther :: [XML.Element]
, channelAttrs :: [XML.Attr]
}
deriving (Show)
data Image
= Image
{ imageURI :: URIString -- the image resource, most likely.
, imageTitle :: TextString -- the "alt"ernative text.
, imageURL :: URIString
, imageLink :: URIString -- the href of the rendered img resource.
, imageDC :: [DCItem]
, imageOther :: [XML.Element]
, imageAttrs :: [XML.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 :: [XML.Attr]
}
deriving (Show)
data TextInputInfo
= TextInputInfo
{ textInputURI :: URIString
, textInputTitle :: TextString
, textInputDesc :: TextString
, textInputName :: TextString
, textInputLink :: URIString
, textInputDC :: [DCItem]
, textInputOther :: [XML.Element]
, textInputAttrs :: [XML.Attr]
}
deriving (Show)
data TaxonomyTopic
= TaxonomyTopic
{ taxonomyURI :: URIString
, taxonomyLink :: URIString
, taxonomyTitle :: Maybe String
, taxonomyDesc :: Maybe String
, 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 String -- should be: RDFValue
}
deriving (Eq, Show)
--default constructors:
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 -> String -> 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
}
|