Add support for social profiles on the h-card, which become rel="me" links

This commit is contained in:
Danielle McLean 2017-10-03 12:53:13 +11:00
parent c5fd0fd326
commit e81a44d122
Signed by: 00dani
GPG key ID: 3844A6973C6058F1
5 changed files with 21 additions and 4 deletions

View file

@ -10,5 +10,5 @@ import Widget.Hcard (hcard)
getHomeR :: Handler Html
getHomeR = do
(Entity _ user) <- runDB . getBy404 $ UniqueUser "dani"
user <- runDB . getBy404 $ UniqueUser "dani"
defaultLayout $(widgetFile "home")

View file

@ -6,7 +6,11 @@ module Widget.Hcard (hcard) where
import Import
import qualified Network.Libravatar as L
hcard :: User -> Widget
hcard user = do
hcard :: Entity User -> Widget
hcard (Entity userId user) = do
maybeAvatar <- liftIO $ L.avatarUrl (L.Email $ userEmail user) def { L.optSecure = True, L.optSize = L.Size 512 }
userProfiles <- handlerToWidget . runDB $ do
profiles <- map entityVal <$> selectList [ProfileUserId ==. userId] []
sites <- belongsToJust profileSiteId `mapM` profiles
return . sortBy (comparing $ siteIcon . fst) $ zip sites profiles
$(widgetFile "hcard")