Only use concat

This commit is contained in:
Niels G. W. Serup 2024-10-05 20:28:25 +02:00
parent d96af50943
commit 9240d66c15
No known key found for this signature in database
GPG Key ID: 38EEEBCE67324F19
2 changed files with 15 additions and 17 deletions

View File

@ -107,6 +107,9 @@ instance TokenableTo a (Token a) where
instance TokenableTo [a] [Token a] where instance TokenableTo [a] [Token a] where
toToken = pure . ListToken toToken = pure . ListToken
instance TokenableTo [a] [DepGenM' a] where
toToken = fmap ListToken . sequence
instance TokenableTo a (DepGenM' a) where instance TokenableTo a (DepGenM' a) where
toToken = id toToken = id

View File

@ -17,15 +17,12 @@ thumbnailImageFilename filename = do
makeImageHTML :: Token (FilePath, FilePath) -> DepGenM' Text makeImageHTML :: Token (FilePath, FilePath) -> DepGenM' Text
makeImageHTML t = do makeImageHTML t = do
(thumbnail, actual) <- untupleDepGenM t (thumbnail, actual) <- untupleDepGenM t
appendTexts concatTexts [ inject "<p class=\"image\"><a href=\""
(inject "<p class=\"image\"><a href=\"") , toText actual
(appendTexts , inject "\"><img src=\""
(toText actual) , toText thumbnail
(appendTexts , inject "\"></a></p>"
(inject "\"><img src=\"") ]
(appendTexts
(toText thumbnail)
(inject "\"></a></p>"))))
hasExtension :: (TokenableTo [String] a, TokenableTo FilePath b) => a -> b -> DepGenM' Bool hasExtension :: (TokenableTo [String] a, TokenableTo FilePath b) => a -> b -> DepGenM' Bool
hasExtension exts filename = do hasExtension exts filename = do
@ -53,14 +50,12 @@ handleRecipeDir inputDir outputDir template indexName name = do
mdTemplate <- makeTemplate md ingredienserHeadline mdTemplate <- makeTemplate md ingredienserHeadline
htmlBodyImages <- mapDepGenM makeImageHTML $ zipDepGenM thumbnailImageFilenames imageFilenames htmlBodyImages <- mapDepGenM makeImageHTML $ zipDepGenM thumbnailImageFilenames imageFilenames
imagesHtml <- concatTexts htmlBodyImages imagesHtml <- concatTexts htmlBodyImages
md' <- applyTemplate mdTemplate ( md' <- applyTemplate mdTemplate
appendTexts $ concatTexts [ inject "<p class=\"imagetext\">Opskrift fortsætter efter billedet.</p>\n"
(inject "<p class=\"imagetext\">Opskrift fortsætter efter billedet.</p>\n") , pure imagesHtml
(appendTexts , inject "\n\n"
imagesHtml , pure ingredienserHeadline
(appendTexts ]
(inject "\n\n")
ingredienserHeadline)))
htmlBody <- runPandoc md' htmlBody <- runPandoc md'
html <- applyTemplate template htmlBody html <- applyTemplate template htmlBody
saveFile html $ joinPaths recipeDirOut indexName saveFile html $ joinPaths recipeDirOut indexName