Support for Open Graph on the homepage - again it's gross but consuming sites understand it

This commit is contained in:
Danielle McLean 2017-10-14 16:51:01 +11:00
parent 44288b419c
commit 47fe00a8b8
Signed by: 00dani
GPG key ID: 5A5D2D1AFF12EEC5
5 changed files with 23 additions and 13 deletions

View file

@ -25,6 +25,7 @@ profileUrl site = substitute $ T.unpack (siteName site) `compileMustache` siteTe
hCard :: Entity User -> Widget
hCard (Entity userId user) = do
let (firstName:lastName) = T.words $ userFullName user
mcurrentRoute <- getCurrentRoute
userProfiles <- handlerToWidget . runDB . E.select . E.from $ \(profile `E.InnerJoin` site) -> do
E.on $ profile ^. ProfileSiteId E.==. site ^. SiteId
@ -32,8 +33,21 @@ hCard (Entity userId user) = do
E.orderBy [E.asc $ site ^. SiteName]
return (site, profile)
pgpKeys <- handlerToWidget . runDB $ map entityVal <$> selectList [PgpKeyUserId ==. userId] []
let maybeFb = find (\(Entity _ site, _) -> "Facebook" == siteName site) userProfiles
toWidgetHead [hamlet|
<meta name="author" content=#{userFullName user}>
<link rel="author" href=@{HomeR}>
<meta property="og:type" content="profile">
<meta property="og:description" content=#{userNote user}>
<meta property="og:image" content=@{staticR ["img", userAvatar user]}>
<meta property="profile:first_name" content=#{firstName}>
<meta property="profile:last_name" content=#{T.unwords lastName}>
<meta property="profile:username" content=#{userUsername user}>
$maybe (_, Entity _ fb) <- maybeFb
<meta property="fb:profile_id" content=#{profileUsername fb}>
$forall key <- pgpKeys
<link rel="pgpkey" type="application/pgp-keys" href=@{routeFromPgp key}>
|]
$(widgetFile "mf2/h-card")