feed 0.3.10.4 → 0.3.11.0
raw patch · 21 files changed
+330/−48 lines, 21 files
Files
- CHANGELOG.md +5/−0
- feed.cabal +1/−1
- src/Text/Atom/Feed.hs +25/−1
- src/Text/Atom/Feed/Export.hs +39/−1
- src/Text/Atom/Feed/Import.hs +24/−1
- src/Text/Atom/Feed/Link.hs +4/−5
- src/Text/Atom/Feed/Validate.hs +31/−2
- src/Text/Atom/Pub.hs +7/−1
- src/Text/Atom/Pub/Export.hs +14/−1
- src/Text/DublinCore/Types.hs +6/−1
- src/Text/Feed/Translate.hs +3/−4
- src/Text/Feed/Types.hs +9/−6
- src/Text/Feed/Util.hs +31/−8
- src/Text/RSS/Export.hs +19/−1
- src/Text/RSS/Import.hs +27/−2
- src/Text/RSS/Syntax.hs +25/−2
- src/Text/RSS1/Export.hs +2/−4
- src/Text/RSS1/Import.hs +1/−3
- src/Text/RSS1/Syntax.hs +21/−2
- src/Text/RSS1/Utils.hs +34/−2
- tests/Main.hs +2/−0
CHANGELOG.md view
@@ -1,3 +1,8 @@+#### 0.3.11.0++* Add `toFeedDateStringUTC` which uses UTCTime rather than ClockTime (thanks to Emanuel Borsboom)+* Now with explicit export lists!+ #### 0.3.10.4 * Fix toFeedDateString time format, It used %s (seconds since epoch) instead of %S (seconds of minute), and %m (month) instead of %M (minute) (thanks to Emanuel Borsboom)
feed.cabal view
@@ -1,5 +1,5 @@ name: feed-version: 0.3.10.4+version: 0.3.11.0 license: BSD3 license-file: LICENSE category: Text
src/Text/Atom/Feed.hs view
@@ -11,7 +11,31 @@ -- -------------------------------------------------------------------- -module Text.Atom.Feed where+module Text.Atom.Feed+ ( URI+ , NCName+ , Date+ , MediaType+ , Feed (..)+ , Entry (..)+ , EntryContent (..)+ , Category (..)+ , Generator (..)+ , Link (..)+ , TextContent (..)+ , txtToString+ , Source (..)+ , Person (..)+ , InReplyTo (..)+ , InReplyTotal (..)+ , newCategory+ , nullFeed+ , nullEntry+ , nullGenerator+ , nullLink+ , nullSource+ , nullPerson+ ) where import qualified Text.XML.Light as XML
src/Text/Atom/Feed/Export.hs view
@@ -15,7 +15,45 @@ -------------------------------------------------------------------- -module Text.Atom.Feed.Export where+module Text.Atom.Feed.Export+ ( atom_prefix+ , atom_thr_prefix+ , atomNS+ , atomThreadNS+ , xmlns_atom+ , xmlns_atom_thread+ , atomName+ , atomAttr+ , atomNode+ , atomLeaf+ , atomThreadName+ , atomThreadAttr+ , atomThreadNode+ , atomThreadLeaf+ , xmlFeed+ , xmlEntry+ , xmlContent+ , xmlCategory+ , xmlLink+ , xmlSource+ , xmlGenerator+ , xmlAuthor+ , xmlContributor+ , xmlPerson+ , xmlInReplyTo+ , xmlInReplyTotal+ , xmlId+ , xmlIcon+ , xmlLogo+ , xmlUpdated+ , xmlPublished+ , xmlRights+ , xmlTitle+ , xmlSubtitle+ , xmlSummary+ , xmlTextContent+ , mb+ ) where import Text.XML.Light as XML import Text.Atom.Feed
src/Text/Atom/Feed/Import.hs view
@@ -14,7 +14,30 @@ -- -------------------------------------------------------------------- -module Text.Atom.Feed.Import where+module Text.Atom.Feed.Import+ ( pNodes+ , pQNodes+ , pNode+ , pQNode+ , pLeaf+ , pQLeaf+ , pAttr+ , pAttrs+ , pQAttr+ , pMany+ , children+ , elementFeed+ , pTextContent+ , pPerson+ , pCategory+ , pGenerator+ , pSource+ , pLink+ , pEntry+ , pContent+ , pInReplyTotal+ , pInReplyTo+ ) where import Data.Maybe (listToMaybe, mapMaybe, isJust) import Data.List (find)
src/Text/Atom/Feed/Link.hs view
@@ -12,10 +12,10 @@ -------------------------------------------------------------------- module Text.Atom.Feed.Link- ( LinkRelation(..)- , showLinkRelation- , showLinkAttr- ) where+ ( LinkRelation(..)+ , showLinkRelation+ , showLinkAttr+ ) where -- | Atom feeds uses typed IRI links to represent -- information \/ metadata that is of interest to the@@ -78,4 +78,3 @@ where escQ '"' = "&dquot;" escQ x = [x]-
src/Text/Atom/Feed/Validate.hs view
@@ -10,12 +10,41 @@ -- Portability: portable -- ---------------------------------------------------------------------module Text.Atom.Feed.Validate where+module Text.Atom.Feed.Validate+ ( VTree (..)+ , ValidatorResult+ , advice+ , demand+ , valid+ , mkTree+ , flattenT+ , validateEntry+ , checkEntryAuthor+ , checkCats+ , checkContents+ , checkContributor+ , checkContentLink+ , checkLinks+ , checkId+ , checkPublished+ , checkRights+ , checkSource+ , checkSummary+ , checkTitle+ , checkUpdated+ , checkCat+ , checkContent+ , checkTerm+ , checkAuthor+ , checkPerson+ , checkName+ , checkEmail+ , checkUri+ ) where import Text.Atom.Feed.Import import Text.XML.Light.Types import Text.XML.Light.Proc- import Data.List import Data.Maybe
src/Text/Atom/Pub.hs view
@@ -12,7 +12,13 @@ -- Types for the Atom Publishing Protocol (APP) -- ---------------------------------------------------------------------module Text.Atom.Pub where+module Text.Atom.Pub+ ( Service (..)+ , Workspace (..)+ , Collection (..)+ , Categories (..)+ , Accept (..)+ ) where import Text.XML.Light.Types as XML import Text.Atom.Feed ( TextContent, Category, URI )
src/Text/Atom/Pub/Export.hs view
@@ -13,7 +13,20 @@ -- Serializing Atom Publishing Protocol types as XML. -- ---------------------------------------------------------------------module Text.Atom.Pub.Export where+module Text.Atom.Pub.Export+ ( showServiceDoc+ , mkQName+ , mkElem+ , mkLeaf+ , mkAttr+ , xmlns_app+ , appNS+ , xmlService+ , xmlWorkspace+ , xmlCollection+ , xmlCategories+ , xmlAccept+ ) where import Text.XML.Light import Text.Atom.Pub
src/Text/DublinCore/Types.hs view
@@ -12,7 +12,12 @@ -- For information on the Dublin Core Metadata Element Set, -- see: <http://dublincore.org/> ---module Text.DublinCore.Types where+module Text.DublinCore.Types+ ( DCItem (..)+ , DCInfo (..)+ , infoToTag+ , dc_element_names+ ) where -- | A DCItem pairs a specific element with its (string) value. data DCItem
src/Text/Feed/Translate.hs view
@@ -18,14 +18,13 @@ , withRSS1Item -- :: (RSS1.Item -> RSS1.Item) -> Item -> Item ) where -import Text.Feed.Types as Feed+import Text.Atom.Feed as Atom import Text.Feed.Constructor-+import Text.Feed.Types as Feed import Text.RSS.Syntax as RSS import qualified Text.RSS1.Syntax as RSS1-import Text.Atom.Feed as Atom -import Data.Maybe ( fromMaybe )+import Data.Maybe (fromMaybe) -- functions for performing format-specific transformations. -- If the item isn't in the of-interest format, no transformation
src/Text/Feed/Types.hs view
@@ -11,12 +11,16 @@ -- -------------------------------------------------------------------- -module Text.Feed.Types where+module Text.Feed.Types+ ( Feed (..)+ , Item (..)+ , FeedKind (..)+ ) where -import Text.RSS.Syntax as RSS-import Text.Atom.Feed as Atom-import Text.RSS1.Syntax as RSS1-import Text.XML.Light as XML+import qualified Text.RSS.Syntax as RSS+import qualified Text.Atom.Feed as Atom+import qualified Text.RSS1.Syntax as RSS1+import qualified Text.XML.Light as XML -- | The abstract type of feed documents. The internal representation -- is as whatever feed variant type the document was either imported or@@ -46,4 +50,3 @@ | RSSKind (Maybe String) -- Nothing => default version (2.0) | RDFKind (Maybe String) -- Nothing => default version (1.0) deriving (Eq, Show)-
src/Text/Feed/Util.hs view
@@ -10,17 +10,40 @@ -- Portability: portable -- ---------------------------------------------------------------------module Text.Feed.Util where+module Text.Feed.Util+ ( toFeedDateString+ , toFeedDateStringUTC+ ) where import Text.Feed.Types-import System.Time-import System.Locale+import Data.Time (UTCTime, formatTime)+import qualified Data.Time.Locale.Compat+import qualified System.Locale+import System.Time (ClockTime, formatCalendarTime, toUTCTime) --- | 'toFeedDate' translates a calendar time into+-- | 'toFeedDateString' translates a calendar time into -- the format expected by the feed kind. toFeedDateString :: FeedKind -> ClockTime -> {-Date-}String toFeedDateString fk ct =- case fk of- AtomKind{} -> formatCalendarTime defaultTimeLocale "%Y-%m-%dT%H:%M:%SZ" (toUTCTime ct)- RSSKind{} -> formatCalendarTime defaultTimeLocale "%a, %d %b %Y %H:%M:%S GMT" (toUTCTime ct)- RDFKind{} -> formatCalendarTime defaultTimeLocale "%Y-%m-%dT%H:%M:%SZ" (toUTCTime ct)+ formatCalendarTime System.Locale.defaultTimeLocale fmt ut+ where+ fmt = feedKindTimeFormat fk+ ut = toUTCTime ct++-- | 'toFeedDateStringUTC' translates a UTC time into+-- the format expected by the feed kind.+toFeedDateStringUTC :: FeedKind -> UTCTime -> {-Date-}String+toFeedDateStringUTC fk =+ formatTime Data.Time.Locale.Compat.defaultTimeLocale fmt+ where+ fmt = feedKindTimeFormat fk++-- | Time format expected by the feed kind.+feedKindTimeFormat :: FeedKind -> String+feedKindTimeFormat fk =+ case fk of+ AtomKind{} -> atomRdfTimeFormat+ RSSKind{} -> "%a, %d %b %Y %H:%M:%S GMT"+ RDFKind{} -> atomRdfTimeFormat+ where+ atomRdfTimeFormat = "%Y-%m-%dT%H:%M:%SZ"
src/Text/RSS/Export.hs view
@@ -12,7 +12,25 @@ -------------------------------------------------------------------- -module Text.RSS.Export where+module Text.RSS.Export+ ( qualNode+ , qualName+ , xmlRSS+ , xmlChannel+ , xmlItem+ , xmlSource+ , xmlEnclosure+ , xmlCategory+ , xmlGuid+ , xmlImage+ , xmlCloud+ , xmlTextInput+ , xmlSkipHours+ , xmlSkipDays+ , xmlAttr+ , xmlLeaf+ , mb+ ) where import Text.XML.Light as XML import Text.RSS.Syntax
src/Text/RSS/Import.hs view
@@ -12,7 +12,33 @@ -- -------------------------------------------------------------------- -module Text.RSS.Import where+module Text.RSS.Import+ ( pNodes+ , pQNodes+ , pNode+ , pQNode+ , pLeaf+ , pQLeaf+ , pAttr+ , pMany+ , children+ , qualName+ , dcName+ , elementToRSS+ , elementToChannel+ , elementToImage+ , elementToCategory+ , elementToCloud+ , elementToItem+ , elementToSource+ , elementToEnclosure+ , elementToGuid+ , elementToTextInput+ , elementToSkipHours+ , elementToSkipDays+ , readInt+ , readBool+ ) where import Text.RSS.Syntax import Text.RSS1.Utils ( dcNS, dcPrefix )@@ -274,4 +300,3 @@ 't':'r':'u':'e':_ -> Just True 'f':'a':'l':'s':'e':_ -> Just False _ -> Nothing-
src/Text/RSS/Syntax.hs view
@@ -16,7 +16,31 @@ -------------------------------------------------------------------- -module Text.RSS.Syntax where+module Text.RSS.Syntax+ ( RSS (..)+ , URLString+ , DateString+ , RSSChannel (..)+ , RSSItem (..)+ , RSSSource (..)+ , RSSEnclosure (..)+ , RSSCategory (..)+ , RSSGuid (..)+ , RSSImage (..)+ , RSSCloud (..)+ , RSSTextInput (..)+ , nullRSS+ , nullChannel+ , nullItem+ , nullSource+ , nullEnclosure+ , newCategory+ , nullGuid+ , nullPermaGuid+ , nullImage+ , nullCloud+ , nullTextInput+ ) where import Text.XML.Light as XML @@ -290,4 +314,3 @@ , rssTextInputAttrs = [] , rssTextInputOther = [] }-
src/Text/RSS1/Export.hs view
@@ -11,9 +11,7 @@ -- -------------------------------------------------------------------- -module Text.RSS1.Export- ( xmlFeed- ) where+module Text.RSS1.Export (xmlFeed) where import Text.XML.Light as XML import Text.RSS1.Syntax@@ -43,7 +41,7 @@ ] )) -- should we expect these to be derived by the XML pretty printer..? { elAttribs = nub $- Attr (qualName (Nothing,Nothing) "xmlns") (fromJust rss10NS) :+ Attr (qualName (Nothing,Nothing) "xmlns") (fromJust rss10NS) : Attr (qualName (Nothing,Just "xmlns") (fromJust rdfPrefix)) (fromJust rdfNS) : Attr (qualName (Nothing,Just "xmlns") (fromJust synPrefix)) (fromJust synNS) : Attr (qualName (Nothing,Just "xmlns") (fromJust taxPrefix)) (fromJust taxNS) :
src/Text/RSS1/Import.hs view
@@ -11,9 +11,7 @@ -- -------------------------------------------------------------------- -module Text.RSS1.Import- ( elementToFeed- ) where+module Text.RSS1.Import (elementToFeed) where import Text.RSS1.Syntax import Text.RSS1.Utils
src/Text/RSS1/Syntax.hs view
@@ -11,7 +11,27 @@ -- -------------------------------------------------------------------- -module Text.RSS1.Syntax where+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 Text.XML.Light.Types as XML import Text.DublinCore.Types@@ -216,4 +236,3 @@ , contentEncoding = Nothing , contentValue = Nothing }-
src/Text/RSS1/Utils.hs view
@@ -11,9 +11,41 @@ -- -------------------------------------------------------------------- -module Text.RSS1.Utils where+module Text.RSS1.Utils+ ( pQNodes+ , pNode+ , pQNode+ , pLeaf+ , pQLeaf+ , pAttr+ , pMany+ , children+ , qualName+ , rssPrefix+ , rss10NS+ , rdfPrefix+ , rdfNS+ , synPrefix+ , synNS+ , taxPrefix+ , taxNS+ , conPrefix+ , conNS+ , dcPrefix+ , dcNS+ , rdfName+ , rssName+ , synName+ , known_rss_elts+ , known_syn_elts+ , known_dc_elts+ , known_tax_elts+ , known_con_elts+ , removeKnownElts+ , removeKnownAttrs+ ) where -import Text.XML.Light as XML+import Text.XML.Light as XML import Text.DublinCore.Types import Data.Maybe (listToMaybe, mapMaybe)
tests/Main.hs view
@@ -3,9 +3,11 @@ import Test.Framework (defaultMain) import Text.RSS.Tests (rssTests) import Text.Atom.Tests (atomTests)+import Text.Feed.Util.Tests (feedUtilTests) main :: IO () main = defaultMain [ rssTests , atomTests+ , feedUtilTests ]