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
|
User
|
||||||
ident Text sqltype=varchar(255)
|
ident Text sqltype=varchar(255)
|
||||||
fullName Text sqltype=varchar(500)
|
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
|
password Text Maybe sqltype=varchar(255) default=NULL
|
||||||
UniqueUser ident
|
UniqueUser ident
|
||||||
deriving Typeable
|
deriving Typeable
|
||||||
|
|
|
@ -46,6 +46,7 @@ dependencies:
|
||||||
- time
|
- time
|
||||||
- case-insensitive
|
- case-insensitive
|
||||||
- wai
|
- wai
|
||||||
|
- libravatar >=0.4 && <0.5
|
||||||
|
|
||||||
# The library contains all of our application code. The executable
|
# The library contains all of our application code. The executable
|
||||||
# defined below is just a thin wrapper.
|
# defined below is just a thin wrapper.
|
||||||
|
|
|
@ -217,9 +217,9 @@ instance YesodAuth App where
|
||||||
case x of
|
case x of
|
||||||
Just (Entity uid _) -> return $ Authenticated uid
|
Just (Entity uid _) -> return $ Authenticated uid
|
||||||
Nothing -> Authenticated <$> insert User
|
Nothing -> Authenticated <$> insert User
|
||||||
{ userAvatar = Nothing
|
{ userIdent = credsIdent creds
|
||||||
, userIdent = credsIdent creds
|
|
||||||
, userFullName = ""
|
, userFullName = ""
|
||||||
|
, userEmail = ""
|
||||||
, userPassword = Nothing
|
, userPassword = Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
module Widget.Hcard (hcard) where
|
module Widget.Hcard (hcard) where
|
||||||
|
|
||||||
import Import
|
import Import
|
||||||
|
import qualified Network.Libravatar as L
|
||||||
img :: Text -> Route App
|
|
||||||
img file = StaticR . flip StaticRoute [] $ ["img", file]
|
|
||||||
|
|
||||||
hcard :: User -> Widget
|
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
|
# Dependency packages to be pulled from upstream that are not in the resolver
|
||||||
# (e.g., acme-missiles-0.3)
|
# (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
|
# Override default flag values for local packages and extra-deps
|
||||||
flags: {}
|
flags: {}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<div .card.h-card>
|
<div .card.h-card>
|
||||||
$maybe avatar <- userAvatar user
|
$maybe avatar <- maybeAvatar
|
||||||
<img .card-img-top.u-photo src=@{img avatar} alt="Avatar for #{userFullName user}">
|
<img .card-img-top.u-photo src=#{avatar} alt="Avatar for #{userFullName user}">
|
||||||
<div .card-body>
|
<div .card-body>
|
||||||
<h4 .card-title.p-name>#{userFullName user}
|
<h4 .card-title.p-name>#{userFullName user}
|
||||||
|
|
Loading…
Reference in a new issue