Use Libravatar rather than tracking avatars internally
This commit is contained in:
parent
2fa69f9883
commit
64c4aab14b
6 changed files with 12 additions and 10 deletions
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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: {}
|
||||
|
|
|
@ -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}
|
||||
|
|
Loading…
Reference in a new issue