From db32b02811f4b3218bd8bae9ddf132ac14adfd95 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Mon, 16 Oct 2017 22:40:35 +1100 Subject: [PATCH] Properly set p-name on h-feeds, rather than trying to infer it and getting awful names --- src/Handler/Categories.hs | 5 ++++- src/Handler/Entries.hs | 5 +++-- src/Widget/Feed.hs | 8 ++++++-- templates/home.cassius | 4 ++-- templates/home.hamlet | 2 +- templates/mf2/h-feed.cassius | 7 ++----- templates/mf2/h-feed.hamlet | 10 +++++++--- 7 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/Handler/Categories.hs b/src/Handler/Categories.hs index 5799a1c..630484d 100644 --- a/src/Handler/Categories.hs +++ b/src/Handler/Categories.hs @@ -8,12 +8,15 @@ import Database.Esqueleto import Widget.Feed ( hFeed ) import Model.Category ( Category, asTag ) +import qualified Data.Text as T + getCategoryR :: Category -> Handler Html getCategoryR tag = do + title <- asks $ siteTitle . appSettings entries <- runDB . select . from $ \(entry `InnerJoin` category) -> do on $ entry ^. EntryId ==. category ^. EntryCategoryEntryId where_ $ category ^. EntryCategoryCategory ==. val tag return entry defaultLayout $ do setTitle . toHtml . asTag $ tag - hFeed entries + T.concat [asTag tag, " ~ ", title] `hFeed` entries diff --git a/src/Handler/Entries.hs b/src/Handler/Entries.hs index bd73934..0929f44 100644 --- a/src/Handler/Entries.hs +++ b/src/Handler/Entries.hs @@ -20,10 +20,11 @@ getEntriesR :: K.EntryKind -> Handler Html getEntriesR kind = do entries <- runDB $ selectList [EntryKind ==. kind] [Desc EntryPublished] title <- asks $ siteTitle . appSettings + let myTitle = T.concat [K.pluralise kind, " ~ ", title] defaultLayout $ do setTitle . toHtml . K.pluralise $ kind - atomLink (FeedKindR kind) $ T.concat [K.pluralise kind, " ~ ", title] - hFeed entries + FeedKindR kind `atomLink` myTitle + hFeed myTitle entries getEntryR :: a -> EntryId -> Handler Html getEntryR _ = renderEntry <=< getCached diff --git a/src/Widget/Feed.hs b/src/Widget/Feed.hs index b707dd8..ae61b03 100644 --- a/src/Widget/Feed.hs +++ b/src/Widget/Feed.hs @@ -4,5 +4,9 @@ module Widget.Feed ( hFeed ) where import Import import Widget.Entry ( hEntry ) -hFeed :: [Entity Entry] -> Widget -hFeed entries = $(widgetFile "mf2/h-feed") +import qualified Data.Text as T + +hFeed :: T.Text -> [Entity Entry] -> Widget +hFeed name entries = do + mroute <- getCurrentRoute + $(widgetFile "mf2/h-feed") diff --git a/templates/home.cassius b/templates/home.cassius index 9e1ab09..dc6b00d 100644 --- a/templates/home.cassius +++ b/templates/home.cassius @@ -2,7 +2,7 @@ body > main display: flex flex-direction: column align-items: center - > ol.h-feed + > div.h-feed flex: 1 margin-bottom: 0 > aside.author @@ -16,7 +16,7 @@ body > main body > main flex-direction: row-reverse align-items: unset - > ol.h-feed + > div.h-feed margin-right: 2em > aside.author margin-bottom: 0 diff --git a/templates/home.hamlet b/templates/home.hamlet index 23ca377..6681528 100644 --- a/templates/home.hamlet +++ b/templates/home.hamlet @@ -1,2 +1,2 @@