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

@ -32,3 +32,8 @@ Entry
published UTCTime
updated UTCTime
authorId UserId
Syndication
entryId EntryId
profileId ProfileId
url Text sqltype=varchar(255)

View file

@ -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

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")

View file

@ -17,3 +17,7 @@
<time .dt-updated datetime=#{timeUnfriendly updated} :published == updated:hidden>
<i .fa.fa-pencil>
#{timeFriendly updated}
$forall (E.Value url, E.Value icon, E.Value name) <- posses
<a .u-syndication href=#{url}>
<i .fa.fa-#{icon}>
#{name}