From c10a3ab34015892566bf76f954d4fa87ae3f54e7 Mon Sep 17 00:00:00 2001 From: Rhiannon Morris Date: Sun, 19 Jul 2020 17:58:19 +0200 Subject: [PATCH] make title mandatory --- make-pages/GalleryPage.hs | 10 ++-------- make-pages/Info.hs | 4 ++-- make-pages/SinglePage.hs | 10 +++------- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/make-pages/GalleryPage.hs b/make-pages/GalleryPage.hs index d17f275..0bac20e 100644 --- a/make-pages/GalleryPage.hs +++ b/make-pages/GalleryPage.hs @@ -63,23 +63,17 @@ makeYearItems nsfw year infos = [b|@4 where items = map (uncurry $ makeItem nsfw) infos makeItem :: Bool -> FilePath -> Info -> Builder -makeItem nsfw file info = [b|@4 +makeItem nsfw file info@(Info {title}) = [b|@4
  • - $title +
    $*title
    |] where dir = takeDirectory file thumb = maybe (throw $ NoThumb dir) (\t -> dir thumbFile t) $ #thumb info - title = maybe mempty mkTitle $ #title info - mkTitle t = [b|@8 -
    - $*t -
    - |] cls | nsfw && #anyNsfw info = [b|class="item nsfw"|] | otherwise = [b|class=item|] diff --git a/make-pages/Info.hs b/make-pages/Info.hs index 694f919..84dfdef 100644 --- a/make-pages/Info.hs +++ b/make-pages/Info.hs @@ -28,7 +28,7 @@ import Text.Read (readMaybe) data Info = Info { date :: !Day, - title :: !(Maybe Text), + title :: !Text, artist :: !(Maybe Artist), -- nothing = me, obv tags :: ![Text], nsfwTags :: ![Text], @@ -95,7 +95,7 @@ instance Ord Info where instance FromYAML Info where parseYAML = YAML.withMap "info" \m -> Info <$> m .: "date" - <*> m .:? "title" + <*> m .: "title" <*> m .:? "artist" <*> m .:? "tags" .!= [] <*> m .:? "nsfw-tags" .!= [] diff --git a/make-pages/SinglePage.hs b/make-pages/SinglePage.hs index a5e1627..a26645a 100644 --- a/make-pages/SinglePage.hs +++ b/make-pages/SinglePage.hs @@ -9,7 +9,6 @@ import Control.Exception import qualified Data.Text as Strict import qualified Data.Text.Lazy as Lazy import Data.Time (formatTime, defaultTimeLocale) -import Data.Maybe (fromMaybe) import qualified Data.Char as Char import qualified Data.List as List @@ -36,10 +35,10 @@ make' nsfw (Info {date, title, artist, tags, nsfwTags, - $titleTag + $*title
    - $titleHeader +

    $*title

    $artistTag

    $formattedDate

    $buttonBar @@ -71,14 +70,11 @@ make' nsfw (Info {date, title, artist, tags, nsfwTags, |] where - titleTag = ifJust title \t -> [b|$*t|] - titleHeader = ifJust title \t -> [b|

    $*t

    |] - artistTag = ifJust artist makeArtist formattedDate = formatDate date - buttonBar = makeButtonBar (fromMaybe (Strict.pack path0) title) nsfw images + buttonBar = makeButtonBar title nsfw images image0 = head images path0 = #path image0 path0' = pageFile path0