lebd/src/Widget/Hcard.hs

17 lines
664 B
Haskell
Raw Normal View History

{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
module Widget.Hcard (hcard) where
import Import
import qualified Network.Libravatar as L
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")