Use Libravatar rather than tracking avatars internally

This commit is contained in:
Danielle McLean 2017-10-03 11:48:44 +11:00
parent 2fa69f9883
commit 64c4aab14b
Signed by: 00dani
GPG key ID: 3844A6973C6058F1
6 changed files with 12 additions and 10 deletions

View file

@ -1,7 +1,7 @@
User
ident Text sqltype=varchar(255)
fullName Text sqltype=varchar(500)
avatar Text Maybe sqltype=varchar(255) default=NULL
email Text sqltype=varchar(255)
password Text Maybe sqltype=varchar(255) default=NULL
UniqueUser ident
deriving Typeable

View file

@ -46,6 +46,7 @@ dependencies:
- time
- case-insensitive
- wai
- libravatar >=0.4 && <0.5
# The library contains all of our application code. The executable
# defined below is just a thin wrapper.

View file

@ -217,9 +217,9 @@ instance YesodAuth App where
case x of
Just (Entity uid _) -> return $ Authenticated uid
Nothing -> Authenticated <$> insert User
{ userAvatar = Nothing
, userIdent = credsIdent creds
{ userIdent = credsIdent creds
, userFullName = ""
, userEmail = ""
, userPassword = Nothing
}

View file

@ -4,9 +4,9 @@
module Widget.Hcard (hcard) where
import Import
img :: Text -> Route App
img file = StaticR . flip StaticRoute [] $ ["img", file]
import qualified Network.Libravatar as L
hcard :: User -> Widget
hcard user = $(widgetFile "hcard")
hcard user = do
maybeAvatar <- liftIO $ L.avatarUrl (L.Email $ userEmail user) def { L.optSecure = True, L.optSize = L.Size 512 }
$(widgetFile "hcard")

View file

@ -39,7 +39,8 @@ packages:
- .
# Dependency packages to be pulled from upstream that are not in the resolver
# (e.g., acme-missiles-0.3)
extra-deps: []
extra-deps:
- libravatar-0.4.0.1
# Override default flag values for local packages and extra-deps
flags: {}

View file

@ -1,5 +1,5 @@
<div .card.h-card>
$maybe avatar <- userAvatar user
<img .card-img-top.u-photo src=@{img avatar} alt="Avatar for #{userFullName user}">
$maybe avatar <- maybeAvatar
<img .card-img-top.u-photo src=#{avatar} alt="Avatar for #{userFullName user}">
<div .card-body>
<h4 .card-title.p-name>#{userFullName user}