diff --git a/config/models b/config/models index 76a545b..6998622 100644 --- a/config/models +++ b/config/models @@ -32,3 +32,8 @@ Entry published UTCTime updated UTCTime authorId UserId + +Syndication + entryId EntryId + profileId ProfileId + url Text sqltype=varchar(255) diff --git a/package.yaml b/package.yaml index 683923a..773a9f1 100644 --- a/package.yaml +++ b/package.yaml @@ -49,6 +49,7 @@ dependencies: - blaze-markup >=0.8 && <0.9 - conduit-combinators >= 1.1 && <1.2 +- esqueleto >=2.5 && <2.6 - friendly-time >=0.4 && <0.5 - foreign-store >=0.2 && <0.3 - mustache >=2.2 && <2.3 diff --git a/src/Widget/Entry.hs b/src/Widget/Entry.hs index 392b92f..a67a527 100644 --- a/src/Widget/Entry.hs +++ b/src/Widget/Entry.hs @@ -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") diff --git a/templates/mf2/h-entry.hamlet b/templates/mf2/h-entry.hamlet index 45ca638..e8cd937 100644 --- a/templates/mf2/h-entry.hamlet +++ b/templates/mf2/h-entry.hamlet @@ -17,3 +17,7 @@