From 844cc5a638e73b343ac00d15a34568565c296e30 Mon Sep 17 00:00:00 2001 From: Tissevert Date: Mon, 4 Feb 2019 22:50:41 +0100 Subject: [PATCH] Fix signature that was too general in class + add the actual module that was supposedly added three commits ago (38846e) --- src/ArticlesList.hs | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/Dom.hs | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 src/ArticlesList.hs diff --git a/src/ArticlesList.hs b/src/ArticlesList.hs new file mode 100644 index 0000000..d260640 --- /dev/null +++ b/src/ArticlesList.hs @@ -0,0 +1,44 @@ +{-# LANGUAGE NamedFieldPuns #-} +module ArticlesList ( + ArticlesList(..) + , otherLink + , otherUrl + , pageTitle + ) where + +import Article (Article) +import Data.Text (Text, pack) +import System.FilePath.Posix (()) + +data ArticlesList = ArticlesList { + tagged :: Maybe String + , full :: Bool + , featured :: [Article] + } + +otherUrl :: ArticlesList -> Text +otherUrl (ArticlesList {full, tagged}) = + if full + then pack $ url tagged + else pack $ url tagged "all.html" + where + url = maybe "/" ("/" ) + +otherLink :: ArticlesList -> Text +otherLink (ArticlesList {full}) = pack $ + if full + then "See only latest" + else "See all" + +pageTitle :: ArticlesList -> Text +pageTitle (ArticlesList {full, tagged}) = pack $ + (if full then "All" else "Latest") ++ " articles" ++ maybe "" (" tagged " ++) tagged + +{- + pageTitle = + (if full then "All" else "Latest") ++ " articles" ++ maybe "" (" tagged " ++) category + + p_ $ if full + then a_ [href_ . pack $ url category] "See only latest" + else a_ [href_ . pack $ url category "all.html"] "See all" +-} diff --git a/src/Dom.hs b/src/Dom.hs index dfc996a..b05bbfb 100644 --- a/src/Dom.hs +++ b/src/Dom.hs @@ -17,7 +17,7 @@ import System.FilePath.Posix ((), (<.>)) type HtmlGenerator = HtmlT (ReaderT Blog IO) class Page a where - content :: Monad m => a -> HtmlT m () + content :: a -> HtmlGenerator () instance Page Article where content (Article {fullContents, urlPath}) =