From 5c6ff281320235373f6288ce35edc32c783fff6d Mon Sep 17 00:00:00 2001 From: neko Date: Tue, 18 Aug 2015 23:57:50 +0200 Subject: [PATCH] added visible links to feeds --- Foundation.hs | 1 + Handler/RootFeed.hs | 18 ++++++++++++++++++ config/routes | 2 ++ templates/default-layout.hamlet | 28 ++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/Foundation.hs b/Foundation.hs index 4d7c3f0..00b119a 100644 --- a/Foundation.hs +++ b/Foundation.hs @@ -66,6 +66,7 @@ type Form x = Html -> MForm (HandlerT App IO) (FormResult x, Widget) renderLayout :: Widget -> Handler Html renderLayout widget = do master <- getYesod + route <- getCurrentRoute mmsg <- getMessage msu <- lookupSession "userId" username <- case msu of diff --git a/Handler/RootFeed.hs b/Handler/RootFeed.hs index be055c1..e8fa45d 100644 --- a/Handler/RootFeed.hs +++ b/Handler/RootFeed.hs @@ -214,6 +214,24 @@ getUserFeedAtomR = getUserFeedR getUserFeedRssR :: UserId -> Handler RepRss getUserFeedRssR = getUserFeedR +getNameFeedAtomR :: Text -> Handler RepAtom +getNameFeedAtomR name = do + muser <- runDB $ getBy $ UniqueUser name + case muser of + Just (Entity uId _) -> + getUserFeedR uId + Nothing -> + notFound + +getNameFeedRssR :: Text -> Handler RepRss +getNameFeedRssR name = do + muser <- runDB $ getBy $ UniqueUser name + case muser of + Just (Entity uId _) -> + getUserFeedR uId + Nothing -> + notFound + getUserFeedR :: RepFeed a => UserId -> Handler a getUserFeedR userId = do user <- runDB $ get404 userId diff --git a/config/routes b/config/routes index a631b15..4a15a38 100644 --- a/config/routes +++ b/config/routes @@ -68,3 +68,5 @@ /feed/medium/#MediumId/rss.xml CommentFeedRssR GET /feed/user/#UserId/atom.xml UserFeedAtomR GET /feed/user/#UserId/rss.xml UserFeedRssR GET +!/feed/user/#Text/atom.xml NameFeedAtomR GET +!/feed/user/#Text/rss.xml NameFeedRssR GET diff --git a/templates/default-layout.hamlet b/templates/default-layout.hamlet index 8c3b14c..f427bea 100644 --- a/templates/default-layout.hamlet +++ b/templates/default-layout.hamlet @@ -29,3 +29,31 @@ $maybe msg <- mmsg