Create a 'URL' type to document the use of type 'String' in Blog.URL module
This commit is contained in:
parent
7e7d7e0804
commit
b42fac59c4
5 changed files with 17 additions and 16 deletions
|
@ -6,7 +6,7 @@ module Blog (
|
|||
, Path(..)
|
||||
, Renderer
|
||||
, Skin(..)
|
||||
, URL(..)
|
||||
, URLs(..)
|
||||
, Wording
|
||||
, build
|
||||
, template
|
||||
|
@ -22,7 +22,7 @@ import Blog.Template (Environment, Templates, render)
|
|||
import qualified Blog.Template as Template (build)
|
||||
import Blog.Skin (Skin(..))
|
||||
import qualified Blog.Skin as Skin (build)
|
||||
import Blog.URL (URL(..))
|
||||
import Blog.URL (URLs(..))
|
||||
import qualified Blog.URL as URL (build)
|
||||
import Blog.Wording (Wording)
|
||||
import qualified Blog.Wording as Wording (build)
|
||||
|
@ -57,7 +57,7 @@ data Blog = Blog {
|
|||
, skin :: Skin
|
||||
, tags :: Collection (Set String)
|
||||
, templates :: Templates
|
||||
, urls :: URL
|
||||
, urls :: URLs
|
||||
, wording :: Wording
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
{-# LANGUAGE NamedFieldPuns #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
module Blog.URL (
|
||||
URL(..)
|
||||
URLs(..)
|
||||
, build
|
||||
) where
|
||||
|
||||
|
@ -14,23 +14,24 @@ import System.Exit (die)
|
|||
import System.IO (hPutStrLn, stderr)
|
||||
import Text.Printf (printf)
|
||||
|
||||
data URL = URL {
|
||||
cards :: Maybe String
|
||||
, comments :: Maybe String
|
||||
, rss :: Maybe String
|
||||
type URL = String
|
||||
data URLs = URLs {
|
||||
cards :: Maybe URL
|
||||
, comments :: Maybe URL
|
||||
, rss :: Maybe URL
|
||||
} deriving Generic
|
||||
|
||||
instance ToJSON URL where
|
||||
toEncoding (URL {comments}) = pairs (
|
||||
instance ToJSON URLs where
|
||||
toEncoding (URLs {comments}) = pairs (
|
||||
"comments" .= comments
|
||||
)
|
||||
|
||||
build :: Arguments -> IO URL
|
||||
build :: Arguments -> IO URLs
|
||||
build arguments = do
|
||||
cards <- getSiteURL argOGCards "Open Graph cards"
|
||||
rss <- getSiteURL argRSS "RSS feeds"
|
||||
checksUsed (argOGCards || argRSS) siteURL
|
||||
return $ URL {cards, comments, rss}
|
||||
return $ URLs {cards, comments, rss}
|
||||
where
|
||||
comments = Arguments.commentsURL arguments
|
||||
siteURL = Arguments.siteURL arguments
|
||||
|
|
|
@ -10,7 +10,7 @@ import qualified Article (preview)
|
|||
import ArticlesList (
|
||||
ArticlesList(..), description, getArticles, otherURL, rssLinkTexts
|
||||
)
|
||||
import Blog (Blog(..), Skin(..), URL(..), template)
|
||||
import Blog (Blog(..), Skin(..), URLs(..), template)
|
||||
import Control.Monad.Reader (ReaderT, asks)
|
||||
import Data.Map as Map (Map, toList)
|
||||
import Data.Text (Text, pack, empty)
|
||||
|
|
|
@ -4,7 +4,7 @@ module JSON (
|
|||
exportBlog
|
||||
) where
|
||||
|
||||
import Blog (Blog, Path, Skin, URL, Wording)
|
||||
import Blog (Blog, Path, Skin, URLs, Wording)
|
||||
import qualified Blog (Blog(..))
|
||||
import Data.Aeson (Options(..), ToJSON(..), genericToEncoding, defaultOptions)
|
||||
import Data.Map (Map, mapWithKey)
|
||||
|
@ -39,7 +39,7 @@ data BlogExport = BlogExport {
|
|||
, pages :: Map String MarkdownExport
|
||||
, skin :: Skin
|
||||
, tags :: Map String [String]
|
||||
, urls :: URL
|
||||
, urls :: URLs
|
||||
, wording :: Wording
|
||||
} deriving (Generic)
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ module RSS (
|
|||
import Article (Article(..))
|
||||
import ArticlesList (ArticlesList(..), getArticles)
|
||||
import qualified ArticlesList (description)
|
||||
import Blog (Blog(urls), Renderer, URL(..))
|
||||
import Blog (Blog(urls), Renderer, URLs(..))
|
||||
import Collection (Collection(..), getAll)
|
||||
import qualified Collection (title)
|
||||
import Control.Monad.IO.Class (MonadIO(..))
|
||||
|
|
Loading…
Reference in a new issue