Add support for u-syndication of each entry, tracking where else it's been posted
This commit is contained in:
parent
716769d24e
commit
401c544ef1
4 changed files with 18 additions and 0 deletions
|
@ -32,3 +32,8 @@ Entry
|
||||||
published UTCTime
|
published UTCTime
|
||||||
updated UTCTime
|
updated UTCTime
|
||||||
authorId UserId
|
authorId UserId
|
||||||
|
|
||||||
|
Syndication
|
||||||
|
entryId EntryId
|
||||||
|
profileId ProfileId
|
||||||
|
url Text sqltype=varchar(255)
|
||||||
|
|
|
@ -49,6 +49,7 @@ dependencies:
|
||||||
|
|
||||||
- blaze-markup >=0.8 && <0.9
|
- blaze-markup >=0.8 && <0.9
|
||||||
- conduit-combinators >= 1.1 && <1.2
|
- conduit-combinators >= 1.1 && <1.2
|
||||||
|
- esqueleto >=2.5 && <2.6
|
||||||
- friendly-time >=0.4 && <0.5
|
- friendly-time >=0.4 && <0.5
|
||||||
- foreign-store >=0.2 && <0.3
|
- foreign-store >=0.2 && <0.3
|
||||||
- mustache >=2.2 && <2.3
|
- mustache >=2.2 && <2.3
|
||||||
|
|
|
@ -5,6 +5,8 @@ module Widget.Entry ( entryR, hEntry ) where
|
||||||
|
|
||||||
import Import
|
import Import
|
||||||
|
|
||||||
|
import Database.Esqueleto ( (^.) )
|
||||||
|
import qualified Database.Esqueleto as E
|
||||||
import Data.Time.Format ( defaultTimeLocale, formatTime, iso8601DateFormat )
|
import Data.Time.Format ( defaultTimeLocale, formatTime, iso8601DateFormat )
|
||||||
import Data.Time.Format.Human ( humanReadableTime )
|
import Data.Time.Format.Human ( humanReadableTime )
|
||||||
|
|
||||||
|
@ -25,5 +27,11 @@ hEntry :: Entity Entry -> Widget
|
||||||
hEntry (Entity entryId entry) = do
|
hEntry (Entity entryId entry) = do
|
||||||
published <- toFormattedTime . entryPublished $ entry
|
published <- toFormattedTime . entryPublished $ entry
|
||||||
updated <- toFormattedTime . entryUpdated $ 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
|
maybeAuthor <- handlerToWidget . runDB . get . entryAuthorId $ entry
|
||||||
$(widgetFile "mf2/h-entry")
|
$(widgetFile "mf2/h-entry")
|
||||||
|
|
|
@ -17,3 +17,7 @@
|
||||||
<time .dt-updated datetime=#{timeUnfriendly updated} :published == updated:hidden>
|
<time .dt-updated datetime=#{timeUnfriendly updated} :published == updated:hidden>
|
||||||
<i .fa.fa-pencil>
|
<i .fa.fa-pencil>
|
||||||
#{timeFriendly updated}
|
#{timeFriendly updated}
|
||||||
|
$forall (E.Value url, E.Value icon, E.Value name) <- posses
|
||||||
|
<a .u-syndication href=#{url}>
|
||||||
|
<i .fa.fa-#{icon}>
|
||||||
|
#{name}
|
||||||
|
|
Loading…
Reference in a new issue