Add support for u-syndication of each entry, tracking where else it's been posted

This commit is contained in:
Danielle McLean 2017-10-10 19:45:31 +11:00
parent 716769d24e
commit 401c544ef1
Signed by: 00dani
GPG key ID: 5A5D2D1AFF12EEC5
4 changed files with 18 additions and 0 deletions

View file

@ -5,6 +5,8 @@ module Widget.Entry ( entryR, hEntry ) where
import Import
import Database.Esqueleto ( (^.) )
import qualified Database.Esqueleto as E
import Data.Time.Format ( defaultTimeLocale, formatTime, iso8601DateFormat )
import Data.Time.Format.Human ( humanReadableTime )
@ -25,5 +27,11 @@ hEntry :: Entity Entry -> Widget
hEntry (Entity entryId entry) = do
published <- toFormattedTime . entryPublished $ entry
updated <- toFormattedTime . entryUpdated $ entry
posses <- handlerToWidget . runDB . E.select . E.from $ \(syndication `E.InnerJoin` profile `E.InnerJoin` site) -> do
E.on $ profile ^. ProfileSiteId E.==. site ^. SiteId
E.on $ syndication ^. SyndicationProfileId E.==. profile ^. ProfileId
E.where_ $ syndication ^. SyndicationEntryId E.==. E.val entryId
E.orderBy [E.asc $ site ^. SiteIcon]
return (syndication ^. SyndicationUrl, site ^. SiteIcon, E.coalesceDefault [profile ^. ProfileDisplayName] (profile ^. ProfileUsername))
maybeAuthor <- handlerToWidget . runDB . get . entryAuthorId $ entry
$(widgetFile "mf2/h-entry")