implement tag aliases, replacements, warnings
warnings are printed by `list-tags`
This commit is contained in:
parent
cae6400ec9
commit
67f0c3ded7
9 changed files with 319 additions and 118 deletions
|
@ -4,21 +4,21 @@ module SinglePage (make) where
|
|||
import Date
|
||||
import Info
|
||||
import BuilderQQ
|
||||
import qualified NsfwWarning
|
||||
import NsfwWarning qualified
|
||||
import TagTransforms
|
||||
|
||||
import Control.Exception
|
||||
import Control.Monad
|
||||
import Data.Char (isSpace)
|
||||
import Data.Foldable
|
||||
import Data.HashSet qualified as HashSet
|
||||
import Data.List (sort, intersperse)
|
||||
import Data.Maybe (fromMaybe, isJust)
|
||||
import qualified Data.Text as Strict
|
||||
import qualified Data.Text.Lazy as Lazy
|
||||
import System.FilePath (joinPath, splitPath)
|
||||
import Data.HashSet (HashSet)
|
||||
import qualified Data.HashSet as HashSet
|
||||
import Data.Traversable
|
||||
import Data.Semigroup
|
||||
import Data.List.NonEmpty (toList)
|
||||
import Data.Char (isSpace)
|
||||
import Data.Text qualified as Strict
|
||||
import Data.Text.Lazy qualified as Lazy
|
||||
import Data.Traversable
|
||||
import System.FilePath (joinPath, splitPath)
|
||||
|
||||
|
||||
-- | e.g. only nsfw images are present for a non-nsfw page
|
||||
|
@ -32,22 +32,25 @@ instance Show NoEligibleImages where
|
|||
|
||||
|
||||
make :: Text -- ^ website root
|
||||
-> Text -- ^ website name
|
||||
-> IndexInfo
|
||||
-> FilePath -- ^ gallery prefix
|
||||
-> Bool -- ^ nsfw?
|
||||
-> FilePath -- ^ data dir
|
||||
-> FilePath -- ^ subdir of datadir containing this @info.yaml@
|
||||
-> Info -> IO Lazy.Text
|
||||
make root siteName prefix nsfw dataDir dir info =
|
||||
toLazyText <$> make' root siteName prefix nsfw dataDir dir info
|
||||
make root iinfo prefix nsfw dataDir dir info =
|
||||
fmap toLazyText $
|
||||
make' root iinfo prefix nsfw dataDir dir $
|
||||
transformInfoTags iinfo.tags info
|
||||
|
||||
make' :: Text -> Text -> FilePath -> Bool -> FilePath -> FilePath -> Info
|
||||
make' :: Text -> IndexInfo -> FilePath -> Bool -> FilePath -> FilePath -> Info
|
||||
-> IO Builder
|
||||
make' root siteName prefix nsfw _dataDir dir
|
||||
make' root iinfo prefix nsfw _dataDir dir
|
||||
info@(Info {date, title, artist, bg}) = do
|
||||
images <- maybe (throw $ NoEligibleImages title) pure $ imagesFor nsfw info
|
||||
|
||||
let undir = joinPath (replicate (length (splitPath dir)) "..")
|
||||
let siteName = iinfo.title
|
||||
|
||||
let formattedDate = formatLong date
|
||||
|
||||
|
@ -59,7 +62,8 @@ make' root siteName prefix nsfw _dataDir dir
|
|||
|
||||
let artistSection = makeArtist artist
|
||||
let descSection = makeDesc $ descFor nsfw info
|
||||
let tagsList = makeTags undir $ tagsFor nsfw info
|
||||
let tags = tagsFor nsfw info
|
||||
let tagsList = makeTags undir tags
|
||||
let linksList = extLinks $ linksFor nsfw info
|
||||
let updates = sort $ updatesFor nsfw info
|
||||
let updatesList = makeUpdates updates
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue