diff --git a/src/Foundation.hs b/src/Foundation.hs index 90e09c8..2dc9fbc 100644 --- a/src/Foundation.hs +++ b/src/Foundation.hs @@ -118,7 +118,9 @@ instance Yesod App where -- you to use normal widget features in default-layout. pc <- widgetToPageContent $(widgetFile "default-layout") - let hasPageTitle = not . B.null . pageTitle $ pc + let globalTitle = toHtml . siteTitle . appSettings $ master + hasPageTitle = not . B.null $ pageTitle pc + fullTitle = if hasPageTitle then mconcat [pageTitle pc, " ~ ", globalTitle] else globalTitle withUrlRenderer $(hamletFile "templates/default-layout-wrapper.hamlet") -- The page to be redirected to when authentication is required. diff --git a/src/Handler/Home.hs b/src/Handler/Home.hs index 5e2ad57..c89d67e 100644 --- a/src/Handler/Home.hs +++ b/src/Handler/Home.hs @@ -15,14 +15,9 @@ import Widget.Feed ( hFeed ) getHomeR :: Handler Html getHomeR = do settings <- asks appSettings - userE@(Entity userId user) <- runDB . getBy404 . UniqueUser . siteUsername $ settings + user <- runDB . getBy404 . UniqueUser . siteUsername $ settings let title = siteTitle settings - entries <- runDB $ selectList [EntryAuthorId ==. userId] [Desc EntryPublished] + entries <- runDB $ selectList [EntryAuthorId ==. entityKey user] [Desc EntryPublished] defaultLayout $ do atomLink FeedR title - toWidgetHead - [hamlet| - - - |] $(widgetFile "home") diff --git a/src/Widget/Card.hs b/src/Widget/Card.hs index fcb705b..c9ceddf 100644 --- a/src/Widget/Card.hs +++ b/src/Widget/Card.hs @@ -25,6 +25,7 @@ profileUrl site = substitute $ T.unpack (siteName site) `compileMustache` siteTe hCard :: Entity User -> Widget hCard (Entity userId user) = do + let (firstName:lastName) = T.words $ userFullName user mcurrentRoute <- getCurrentRoute userProfiles <- handlerToWidget . runDB . E.select . E.from $ \(profile `E.InnerJoin` site) -> do E.on $ profile ^. ProfileSiteId E.==. site ^. SiteId @@ -32,8 +33,21 @@ hCard (Entity userId user) = do E.orderBy [E.asc $ site ^. SiteName] return (site, profile) pgpKeys <- handlerToWidget . runDB $ map entityVal <$> selectList [PgpKeyUserId ==. userId] [] + let maybeFb = find (\(Entity _ site, _) -> "Facebook" == siteName site) userProfiles + toWidgetHead [hamlet| + + + + + + + + + $maybe (_, Entity _ fb) <- maybeFb + $forall key <- pgpKeys |] + $(widgetFile "mf2/h-card") diff --git a/templates/default-layout-wrapper.hamlet b/templates/default-layout-wrapper.hamlet index a3836c5..a4c2d3a 100644 --- a/templates/default-layout-wrapper.hamlet +++ b/templates/default-layout-wrapper.hamlet @@ -5,12 +5,11 @@ $doctype 5 - - $if hasPageTitle - #{pageTitle pc} ~ # - #{siteTitle $ appSettings master} + <title>#{fullTitle} + <meta property="og:title" content=#{fullTitle}> $maybe route <- mcurrentRoute <link rel="canonical" href=@{route}> + <meta property="og:url" content=@{route}> <link rel="sitemap" href=@{SitemapR}> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous"> diff --git a/templates/home.hamlet b/templates/home.hamlet index 26b5e93..ac9a0f5 100644 --- a/templates/home.hamlet +++ b/templates/home.hamlet @@ -1,2 +1,2 @@ -<div .author>^{hCard userE} +<div .author>^{hCard user} ^{hFeed entries}