added extended feeds. Custom build of yesod-newsfeed is needed.

This commit is contained in:
nek0 2015-09-30 04:07:08 +02:00
parent 3bbd29bb8a
commit a967f6d033
2 changed files with 20 additions and 0 deletions

View file

@ -25,6 +25,9 @@ import Text.Shakespeare.Text (stext)
import Yesod.Feed import Yesod.Feed
import Yesod.RssFeed import Yesod.RssFeed
import Yesod.AtomFeed import Yesod.AtomFeed
import System.FilePath
import qualified System.Posix as P
import System.IO.Unsafe
getCommentFeedRssR :: MediumId -> Handler RepRss getCommentFeedRssR :: MediumId -> Handler RepRss
getCommentFeedRssR mId = do getCommentFeedRssR mId = do
@ -56,6 +59,7 @@ commentFeedBuilder mId = do
|] |]
, feedLanguage = "en" , feedLanguage = "en"
, feedUpdated = time , feedUpdated = time
, feedLogo = Just (StaticR $ StaticRoute (drop 2 $ map T.pack $ splitDirectories $ mediumThumb medium) [], unTextarea $ fromMaybe (Textarea "") $ mediumDescription medium)
, feedEntries = es , feedEntries = es
} }
@ -66,6 +70,7 @@ commentToEntry c =
, feedEntryUpdated = (commentTime $ entityVal c) , feedEntryUpdated = (commentTime $ entityVal c)
, feedEntryTitle = L.toStrict $ [stext|#{commentAuthorSlug $ entityVal c} wrote:|] , feedEntryTitle = L.toStrict $ [stext|#{commentAuthorSlug $ entityVal c} wrote:|]
, feedEntryContent = [shamlet|#{commentContent $ entityVal c}|] , feedEntryContent = [shamlet|#{commentContent $ entityVal c}|]
, feedEntryEnclosure = Nothing
} }
getAlbumFeedRssR :: AlbumId -> Handler RepRss getAlbumFeedRssR :: AlbumId -> Handler RepRss
@ -98,6 +103,7 @@ albumFeedBuilder aId = do
|] |]
, feedLanguage = "en" , feedLanguage = "en"
, feedUpdated = time , feedUpdated = time
, feedLogo = Just (StaticR $ StaticRoute (drop 2 $ map T.pack $ splitDirectories $ fromMaybe "/static/img/album.jpg" $ albumSamplePic album) [], "")
, feedEntries = es , feedEntries = es
} }
@ -140,6 +146,7 @@ userFeedBuilder uId = do
|] |]
, feedLanguage = "en" , feedLanguage = "en"
, feedUpdated = time , feedUpdated = time
, feedLogo = Nothing
, feedEntries = es , feedEntries = es
} }
@ -171,6 +178,7 @@ rootFeedBuilder = do
|] |]
, feedLanguage = "en" , feedLanguage = "en"
, feedUpdated = time , feedUpdated = time
, feedLogo = Nothing
, feedEntries = es , feedEntries = es
} }
@ -181,4 +189,15 @@ mediumToEntry ent =
, feedEntryUpdated = mediumTime (entityVal ent) , feedEntryUpdated = mediumTime (entityVal ent)
, feedEntryTitle = mediumTitle (entityVal ent) , feedEntryTitle = mediumTitle (entityVal ent)
, feedEntryContent = toHtml (fromMaybe (Textarea "") $ mediumDescription $ entityVal ent) , feedEntryContent = toHtml (fromMaybe (Textarea "") $ mediumDescription $ entityVal ent)
, feedEntryEnclosure = Just
( StaticR $ StaticRoute (drop 2 $ map T.pack $ splitDirectories $ mediumPreview $ entityVal ent) []
, unsafePerformIO $ getSize $ mediumPreview $ entityVal ent
, "image/jpeg"
)
} }
getSize :: FilePath -> IO Int
getSize path = do
stat <- P.getFileStatus path
P.COff raw <- return $ P.fileSize stat
return $ (fromIntegral raw :: Int)

View file

@ -113,6 +113,7 @@ library
, blaze-markup >= 0.7 , blaze-markup >= 0.7
, wai >= 3.0 , wai >= 3.0
, yesod-newsfeed >= 1.4 , yesod-newsfeed >= 1.4
, unix >= 2.7
-- for Migrations -- for Migrations
, HDBC , HDBC
, HDBC-postgresql , HDBC-postgresql