From 485b90fb46664e803e7528d49908aad02781271e Mon Sep 17 00:00:00 2001 From: rhiannon morris Date: Wed, 21 Jun 2023 19:58:01 +0200 Subject: [PATCH] style & layout updates --- make-pages/Date.hs | 13 +++- make-pages/GalleryPage.hs | 34 ++++------- make-pages/Info.hs | 7 ++- make-pages/SinglePage.hs | 5 +- script/gallery.js | 8 ++- style/shiny/base.css | 9 ++- style/shiny/gallery.css | 124 +++++++------------------------------- style/shiny/index.css | 6 +- style/shiny/single.css | 18 ------ 9 files changed, 65 insertions(+), 159 deletions(-) diff --git a/make-pages/Date.hs b/make-pages/Date.hs index 3c22927..7a5bb33 100644 --- a/make-pages/Date.hs +++ b/make-pages/Date.hs @@ -1,7 +1,7 @@ module Date (Date (..), Day (..), dayNum, exact, - formatLong, formatShort, formatRSS, formatSlash, + formatLong, formatShort, formatRSS, formatSlash, formatTooltip, parseP, parseS, parseA) where @@ -9,7 +9,7 @@ import Control.Applicative import qualified Text.ParserCombinators.ReadP as ReadP import Text.ParserCombinators.ReadP (ReadP, readS_to_P, readP_to_S, (<++)) import Data.Time hiding (Day) -import Data.Char (isSpace) +import Data.Char (isSpace, toLower) import BuilderQQ import Data.Function (on) import Data.Maybe (fromMaybe) @@ -60,6 +60,15 @@ formatShort (Date {month, day}) = [b|$day'$month'|] where Unknown -> "" month' = formatTime defaultTimeLocale "%b" $ fromGregorian 1 month 1 +formatTooltip :: Date -> Builder +formatTooltip (Date {year, month, day}) = [b|$day'$month' $year|] where + day' = case day of + Exact d -> [b|$d $&|] + Approx d -> [b|$d? $&|] + Unknown -> "" + month' = map toLower $ + formatTime defaultTimeLocale "%b" $ fromGregorian 1 month 1 + formatRSS :: Date -> Builder formatRSS = fromString . format . toTime where format = formatTime defaultTimeLocale "%a, %d %b %_Y %T GMT" diff --git a/make-pages/GalleryPage.hs b/make-pages/GalleryPage.hs index 93a1708..80e6345 100644 --- a/make-pages/GalleryPage.hs +++ b/make-pages/GalleryPage.hs @@ -12,7 +12,7 @@ import Data.Function (on, (&)) import qualified Data.HashMap.Strict as HashMap import Data.HashSet (HashSet) import qualified Data.HashSet as HashSet -import Data.List (intersperse, groupBy, sortBy, sortOn) +import Data.List (intersperse, groupBy, sortBy, sort) import Data.Maybe import qualified Data.Text.Lazy as Lazy import System.FilePath (takeDirectory, joinPath, splitPath) @@ -52,9 +52,8 @@ make' root (GalleryInfo {title, desc, prefix, filters, hidden}) infos = [b|@0

$title

-

- rss -

+ rss + back
|] where @@ -110,7 +105,7 @@ make' root (GalleryInfo {title, desc, prefix, filters, hidden}) infos = [b|@0 allTags = infos & concatMap (map (,1) . tagsFor nsfw . #second) & HashMap.fromListWith (+) & HashMap.toList - & sortOn (\(tag, count) -> (Down count, tag)) + & sort requireFilters = map (uncurry $ makeFilter "require" mempty) allTags excludeFilters = map (uncurry $ makeFilter "exclude" hidden) allTags @@ -153,18 +148,12 @@ makeYearItems nsfw year infos = [b|@0 makeItem :: Bool -> FilePath -> Info -> Builder makeItem nsfw file info@(Info {bg}) = [b|@0 -
  • -
    - - - -
    - $date' - $title -
    -
    + + + |] where title = fromMaybe (#title info) $ #galleryTitle info @@ -173,7 +162,10 @@ makeItem nsfw file info@(Info {bg}) = [b|@0 nsfw' = if nsfw && #anyNsfw info then [b| nsfw|] else "" tags' = fold $ intersperse ";" $ map fromText $ tagsFor nsfw info date = #latestDate info nsfw - date' = formatShort date + date' = formatTooltip date year' = #year date updated' = if #updated info nsfw then [b|true|] else [b|false|] bgStyle = case bg of Other col -> [b| style="background: $col"|]; _ -> "" + tooltip = + let upd = if #updated info nsfw then "updated " else "" :: Builder in + [b|$title ($upd$date')|] diff --git a/make-pages/Info.hs b/make-pages/Info.hs index 093dc3c..10d6632 100644 --- a/make-pages/Info.hs +++ b/make-pages/Info.hs @@ -3,7 +3,8 @@ {-# OPTIONS_GHC -Wno-orphans #-} module Info (Info (..), - tagsFor, descFor, imagesFor, linksFor, updatesFor, compareFor, sortFor, + tagsFor, descFor, imagesFor, linksFor, updatesFor, lastUpdate, + compareFor, sortFor, Artist (..), Images' (..), Images, Image (..), Desc (..), DescField (..), Link (..), Update (..), Bg (..), GalleryInfo (..), GalleryFilters (..), ArtistFilter (..), NsfwFilter (..), @@ -219,6 +220,10 @@ linksFor nsfw = if nsfw then #links else #sfwLinks updatesFor :: Bool -> Info -> [(Date, [Update])] updatesFor nsfw = if nsfw then #updates else #sfwUpdates +lastUpdate :: Bool -> Info -> Maybe Date +lastUpdate nsfw info = + case updatesFor nsfw info of [] -> Nothing; us -> Just $ fst $ last us + compareFor :: Bool -> Info -> Info -> Ordering compareFor nsfw = comparing \i -> (#latestDate i nsfw, #sortEx i, #title i) diff --git a/make-pages/SinglePage.hs b/make-pages/SinglePage.hs index 75dad28..5e483be 100644 --- a/make-pages/SinglePage.hs +++ b/make-pages/SinglePage.hs @@ -158,6 +158,7 @@ make' root siteName prefix nsfw _dataDir dir

    $formattedDate $updateDate

    + back to gallery $2.buttonBar @@ -180,10 +181,6 @@ make' root siteName prefix nsfw _dataDir dir $6.tagsList - -