User: better show user card
This commit is contained in:
parent
35b12761d0
commit
968de846a7
|
@ -22,8 +22,8 @@ instance FromRow User where
|
||||||
render :: User -> H.Html
|
render :: User -> H.Html
|
||||||
render user = do
|
render user = do
|
||||||
H.div ! A.class_ "card blue-grey darken-3" $ do
|
H.div ! A.class_ "card blue-grey darken-3" $ do
|
||||||
H.div ! A.class_ "card-content white-text" $ do
|
H.div ! A.class_ "card-content white-text center" $ do
|
||||||
H.span ! A.class_ "card-title" $ H.toHtml $ unpack (name user)
|
H.span ! A.class_ "card-title" $ H.toHtml $ unpack (name user)
|
||||||
H.br
|
H.br
|
||||||
H.a ! A.href (H.toValue ("https://derpibooru.org/profiles/" ++ unpack (oID user))) $ do
|
H.a ! A.href (H.toValue ("https://derpibooru.org/profiles/" ++ unpack (oID user))) $ do
|
||||||
H.img ! A.src (H.toValue $ unpack $ avatar user)
|
H.img ! A.src (H.toValue $ unpack $ avatar user) ! A.width "125"
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
|
||||||
|
module Within.DBMemorial.Views.Thread where
|
||||||
|
|
||||||
|
import Control.Monad (forM_)
|
||||||
|
import Data.Map (Map)
|
||||||
|
import qualified Data.Map as Map
|
||||||
|
import Data.Text (Text)
|
||||||
|
import Text.Blaze.Html
|
||||||
|
import Text.Blaze.Html5 as H hiding (map)
|
||||||
|
import Text.Blaze.Html5.Attributes as A
|
||||||
|
import qualified Within.DBMemorial.Post as Post
|
||||||
|
import qualified Within.DBMemorial.User as User
|
||||||
|
|
||||||
|
render :: Int -> [Post.Post] -> (Map Text User.User) -> Html
|
||||||
|
render pageNumber posts users = do
|
||||||
|
H.h1 ! A.class_ "center text-orange" $ H.toHtml ("Page " ++ (show pageNumber))
|
||||||
|
|
||||||
|
H.div ! A.class_ "row" $ do
|
||||||
|
forM_ posts $ \post -> do
|
||||||
|
let user = case (Post.author post) `Map.lookup` users of
|
||||||
|
Just u -> u
|
||||||
|
Nothing -> error "Can't find user? Impossible state."
|
||||||
|
|
||||||
|
Post.render post (User.render user)
|
Loading…
Reference in New Issue