diff --git a/config/routes b/config/routes index 0fd5278..5bab231 100644 --- a/config/routes +++ b/config/routes @@ -7,6 +7,7 @@ /sitemap.xml SitemapR GET / HomeR GET +/avatars/#UserId AvatarR GET /feed FeedR GET !/#EntryKind/feed FeedKindR GET diff --git a/src/Application.hs b/src/Application.hs index a1e82c5..a9bcf5e 100644 --- a/src/Application.hs +++ b/src/Application.hs @@ -48,6 +48,7 @@ import System.Log.FastLogger (defaultBufSize, newStdoutLoggerSet, -- Import all relevant handler modules here. -- Don't forget to add new modules to your cabal file! +import Handler.Avatars import Handler.Common import Handler.Entries import Handler.Feed diff --git a/src/Handler/Avatars.hs b/src/Handler/Avatars.hs new file mode 100644 index 0000000..2bc2e17 --- /dev/null +++ b/src/Handler/Avatars.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE OverloadedStrings #-} +module Handler.Avatars where + +import Import + +import Model.Cache ( getCached ) +import Settings.StaticR ( staticR ) + +getAvatarR :: UserId -> Handler () +getAvatarR = redirect <=< fmap (avatarR . entityVal) . getCached + where avatarR user = staticR ["img", userAvatar user] diff --git a/templates/mf2/h-card.hamlet b/templates/mf2/h-card.hamlet index 2034e1b..e5d8937 100644 --- a/templates/mf2/h-card.hamlet +++ b/templates/mf2/h-card.hamlet @@ -2,7 +2,7 @@ $maybe route <- mcurrentRoute