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