yesod-newsfeed 0.0.0 → 0.0.0.1
raw patch · 5 files changed
+34/−22 lines, 5 filesnew-uploader
Files
- Yesod/Helpers/AtomFeed.hs +6/−3
- Yesod/Helpers/Feed.hs +6/−3
- Yesod/Helpers/FeedTypes.hs +2/−2
- Yesod/Helpers/RssFeed.hs +16/−11
- yesod-newsfeed.cabal +4/−3
Yesod/Helpers/AtomFeed.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE CPP #-} ------------------------------------------------------------+-- | -- Module : Yesod.Helpers.AtomFeed -- Copyright : Michael Snoyman -- License : BSD3@@ -10,11 +10,12 @@ -- Stability : Stable -- Portability : portable ----- Generating atom news feeds.+-- An Atom news feed. --+-- Atom spec: <http://en.wikipedia.org/wiki/Atom_(standard)>+-- --------------------------------------------------------- --- | Generation of Atom newsfeeds. module Yesod.Helpers.AtomFeed ( atomFeed , atomLink@@ -30,10 +31,12 @@ import qualified Data.ByteString.Char8 as S8 import Control.Monad (liftM) +-- | The Atom content type newtype RepAtom = RepAtom Content instance HasReps RepAtom where chooseRep (RepAtom c) _ = return (typeAtom, c) +-- | The feed response itself atomFeed :: Monad mo => Feed (Route master) -> GGHandler sub master mo RepAtom atomFeed = liftM RepAtom . hamletToContent . template
Yesod/Helpers/Feed.hs view
@@ -1,5 +1,5 @@ ----------------------------------------------------------------------------------+-- | -- Module : Yesod.Helpers.Feed -- Copyright : Patrick Brisbin -- License : as-is@@ -8,8 +8,8 @@ -- Stability : Stable -- Portability : Portable ----- Generic Feed and Feed Entry data types that can be used as either an--- Rss feed or an Atom feed (or both, or other).+-- A generic feed that will reply with either Atom or Rss depending on +-- what's requested. -- -- Atom spec: <http://en.wikipedia.org/wiki/Atom_(standard)> -- Rss spec: <http://www.rssboard.org/rss-specification>@@ -27,12 +27,15 @@ import Yesod.Content (HasReps (chooseRep), typeAtom, typeRss) import Yesod.Handler (Route, GGHandler) +-- | The Rss\/Atom content type data RepAtomRss = RepAtomRss RepAtom RepRss instance HasReps RepAtomRss where chooseRep (RepAtomRss (RepAtom a) (RepRss r)) = chooseRep [ (typeAtom, a) , (typeRss, r) ]++-- | The feed itself newsFeed :: Monad mo => Feed (Route master) -> GGHandler sub master mo RepAtomRss newsFeed f = do a <- atomFeed f
Yesod/Helpers/FeedTypes.hs view
@@ -1,3 +1,4 @@+-- | Base data types used in other modules module Yesod.Helpers.FeedTypes ( Feed (..) , FeedEntry (..)@@ -6,12 +7,11 @@ import Text.Hamlet (Html) import Data.Time.Clock (UTCTime) --- | The overal feed+-- | The overall feed data Feed url = Feed { feedTitle :: String , feedLinkSelf :: url , feedLinkHome :: url- -- | note: currently only used for Rss , feedDescription :: Html
Yesod/Helpers/RssFeed.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE CPP #-} ----------------------------------------------------------------------------------+-- | -- Module : Yesod.Helpers.RssFeed -- Copyright : Patrick Brisbin -- License : as-is@@ -10,6 +10,10 @@ -- Stability : Stable -- Portability : Portable --+-- An Rss news feed.+--+-- Rss spec: <http://www.rssboard.org/rss-specification>+-- ------------------------------------------------------------------------------- module Yesod.Helpers.RssFeed ( rssFeed@@ -26,11 +30,12 @@ import qualified Data.ByteString.Char8 as S8 import Control.Monad (liftM) +-- | The Rss content type newtype RepRss = RepRss Content instance HasReps RepRss where chooseRep (RepRss c) _ = return (typeRss, c) --- | Generate the feed+-- | The feed response itself rssFeed :: Monad mo => Feed (Route master) -> GGHandler sub master mo RepRss rssFeed = liftM RepRss . hamletToContent . template @@ -41,15 +46,15 @@ #else [$xhamlet| #endif- \<?xml version="1.0" encoding="utf-8"?> + \<?xml version="1.0" encoding="utf-8"?> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" <channel <atom:link href=@{feedLinkSelf arg} rel="self" type=#{S8.unpack typeRss}- <title> #{feedTitle arg}- <link> @{feedLinkHome arg}- <description> #{feedDescription arg}+ <title>#{feedTitle arg}+ <link>@{feedLinkHome arg}+ <description>#{feedDescription arg} <lastBuildDate>#{formatRFC822 $ feedUpdated arg}- <language> #{feedLanguage arg}+ <language>#{feedLanguage arg} $forall entry <- feedEntries arg ^{entryTemplate entry}@@ -63,10 +68,10 @@ [$xhamlet| #endif <item- <title> #{feedEntryTitle arg}- <link> @{feedEntryLink arg}- <guid> @{feedEntryLink arg}- <pubDate> #{formatRFC822 $ feedEntryUpdated arg}+ <title>#{feedEntryTitle arg}+ <link>@{feedEntryLink arg}+ <guid>@{feedEntryLink arg}+ <pubDate>#{formatRFC822 $ feedEntryUpdated arg} <description>#{feedEntryContent arg} |]
yesod-newsfeed.cabal view
@@ -1,10 +1,11 @@ name: yesod-newsfeed-version: 0.0.0+version: 0.0.0.1 license: BSD3 license-file: LICENSE author: Michael Snoyman, Patrick Brisbin-maintainer: Michael Snoyman <michael@snoyman.com>+maintainer: Patrick Brisbin <pbrisbin@gmail.com> synopsis: Helper functions and data types for producing News feeds.+Description: Helper functions and data types for producing News feeds. category: Web, Yesod stability: Stable cabal-version: >= 1.6@@ -25,4 +26,4 @@ source-repository head type: git- location: git://github.com/snoyberg/yesod-newsfeed.git+ location: git://github.com/pbrisbin/yesod-newsfeed.git