Serve avatar locally rather than through Libravatar, it'll perform better and doesn't require the image's size to be messed with
This commit is contained in:
parent
20470aa852
commit
c517baac1c
6 changed files with 3 additions and 11 deletions
|
@ -3,6 +3,7 @@ User
|
||||||
password Text maxlen=79
|
password Text maxlen=79
|
||||||
fullName Text maxlen=500
|
fullName Text maxlen=500
|
||||||
email Text maxlen=190
|
email Text maxlen=190
|
||||||
|
avatar Text maxlen=190
|
||||||
note Text sqltype=mediumtext
|
note Text sqltype=mediumtext
|
||||||
UniqueUser username
|
UniqueUser username
|
||||||
UniqueEmail email
|
UniqueEmail email
|
||||||
|
|
|
@ -51,7 +51,6 @@ dependencies:
|
||||||
- conduit-combinators >= 1.1 && <1.2
|
- conduit-combinators >= 1.1 && <1.2
|
||||||
- friendly-time >=0.4 && <0.5
|
- friendly-time >=0.4 && <0.5
|
||||||
- foreign-store >=0.2 && <0.3
|
- foreign-store >=0.2 && <0.3
|
||||||
- libravatar >=0.4 && <0.5
|
|
||||||
- slug >=0.1 && <0.2
|
- slug >=0.1 && <0.2
|
||||||
- split >=0.2 && <0.3
|
- split >=0.2 && <0.3
|
||||||
- yesod-auth-hashdb >=1.6.2 && <1.7
|
- yesod-auth-hashdb >=1.6.2 && <1.7
|
||||||
|
|
|
@ -7,11 +7,6 @@ import Import
|
||||||
import Data.Maybe (fromJust)
|
import Data.Maybe (fromJust)
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import qualified Network.Libravatar as L
|
|
||||||
|
|
||||||
libravatar :: (MonadIO m) => User -> m (Maybe Text)
|
|
||||||
libravatar = liftIO . flip L.avatarUrl opts . L.Email . userEmail
|
|
||||||
where opts = def { L.optSecure = True, L.optSize = L.Size 512, L.optTryGravatar = False }
|
|
||||||
|
|
||||||
entityToTuple :: Entity t -> (Key t, t)
|
entityToTuple :: Entity t -> (Key t, t)
|
||||||
entityToTuple (Entity key value) = (key, value)
|
entityToTuple (Entity key value) = (key, value)
|
||||||
|
@ -30,7 +25,6 @@ routeFromPgp PgpKey { pgpKeyFingerprint = f } = staticR ["pgp", T.takeEnd 8 f ++
|
||||||
|
|
||||||
hCard :: Entity User -> Widget
|
hCard :: Entity User -> Widget
|
||||||
hCard (Entity userId user) = do
|
hCard (Entity userId user) = do
|
||||||
maybeAvatar <- libravatar user
|
|
||||||
mcurrentRoute <- getCurrentRoute
|
mcurrentRoute <- getCurrentRoute
|
||||||
userProfiles <- handlerToWidget . runDB $ do
|
userProfiles <- handlerToWidget . runDB $ do
|
||||||
profiles <- map entityVal <$> selectList [ProfileUserId ==. userId] []
|
profiles <- map entityVal <$> selectList [ProfileUserId ==. userId] []
|
||||||
|
|
|
@ -39,8 +39,7 @@ 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: {}
|
||||||
|
|
BIN
static/img/dewdrop wink.png
Normal file
BIN
static/img/dewdrop wink.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 47 KiB |
|
@ -2,8 +2,7 @@
|
||||||
$maybe route <- mcurrentRoute
|
$maybe route <- mcurrentRoute
|
||||||
<a .u-uid.u-url itemprop="url" href=@{route} hidden>
|
<a .u-uid.u-url itemprop="url" href=@{route} hidden>
|
||||||
|
|
||||||
$maybe avatar <- maybeAvatar
|
<img .card-img-top.u-photo itemprop="image" src=@{staticR ["img", userAvatar user]} alt="Avatar for #{userFullName user}">
|
||||||
<img .card-img-top.u-photo itemprop="image" src=#{avatar} alt="Avatar for #{userFullName user}">
|
|
||||||
|
|
||||||
<div .card-body>
|
<div .card-body>
|
||||||
<h4 .card-title.p-name itemprop="name">#{userFullName user}
|
<h4 .card-title.p-name itemprop="name">#{userFullName user}
|
||||||
|
|
Loading…
Reference in a new issue