From b62586b4ad89babc56a976568c6696c72a537942 Mon Sep 17 00:00:00 2001 From: Rhiannon Morris Date: Thu, 23 Jul 2020 19:51:53 +0200 Subject: [PATCH] put link to index in footer of gallery pages --- make-pages/Depend.hs | 3 ++- make-pages/GalleryPage.hs | 14 ++++++++++---- make-pages/Main.hs | 4 ++-- make-pages/Options.hs | 11 ++++++----- style/shiny/gallery.css | 7 +++++++ 5 files changed, 27 insertions(+), 12 deletions(-) diff --git a/make-pages/Depend.hs b/make-pages/Depend.hs index 0e6b483..00efeee 100644 --- a/make-pages/Depend.hs +++ b/make-pages/Depend.hs @@ -65,7 +65,8 @@ dependGallery' (GalleryInfo {title, description, prefix, filters}) $@path: $@pages' $@files' $@rss $$(MAKEPAGES) echo "[gallery] "$$@ mkdir -p $$(dir $$@) - $$(MAKEPAGES) $$(MPFLAGS) gallery -t "$*title" $flags -o "$$@" \ + $$(MAKEPAGES) $$(MPFLAGS) gallery \ + -p "$@prefix" -t "$*title" $flags -o "$$@" \ $$(filter $$(DATADIR)/%/$$(INFONAME),$$^) $@rss: $@files' $$(MAKEPAGES) diff --git a/make-pages/GalleryPage.hs b/make-pages/GalleryPage.hs index 6af4154..ac2a9de 100644 --- a/make-pages/GalleryPage.hs +++ b/make-pages/GalleryPage.hs @@ -5,7 +5,7 @@ import Control.Exception import Data.Function (on, (&)) import Data.List (sortOn, groupBy) import qualified Data.Text.Lazy as Lazy -import System.FilePath ((), takeDirectory) +import System.FilePath ((), takeDirectory, joinPath, splitPath) import GHC.Exts (Down (..), the) import BuilderQQ @@ -17,13 +17,14 @@ newtype NoThumb = NoThumb FilePath instance Show NoThumb where show (NoThumb dir) = "no thumbnail for " ++ dir make :: Text -- ^ title + -> FilePath -- ^ gallery url prefix -> Bool -- ^ nsfw is included? -> [(FilePath, Info)] -> Lazy.Text -make title nsfw infos = toLazyText $ make' title nsfw infos +make title prefix nsfw infos = toLazyText $ make' title prefix nsfw infos -make' :: Text -> Bool -> [(FilePath, Info)] -> Builder -make' title nsfw infos = [b|@0 +make' :: Text -> FilePath -> Bool -> [(FilePath, Info)] -> Builder +make' title prefix nsfw infos = [b|@0 @@ -45,6 +46,10 @@ make' title nsfw infos = [b|@0 $4.items + + |] where items = map (uncurry $ makeYearItems nsfw) infosByYear @@ -55,6 +60,7 @@ make' title nsfw infos = [b|@0 let year = #year info, then group by Down year using groupBy'] groupBy' f = groupBy ((==) `on` f) + undir = joinPath (replicate (length (splitPath prefix)) "..") makeYearItems :: Bool -- ^ nsfw -> Integer -- ^ year diff --git a/make-pages/Main.hs b/make-pages/Main.hs index 77b64c5..bac61f4 100644 --- a/make-pages/Main.hs +++ b/make-pages/Main.hs @@ -51,10 +51,10 @@ main2 (SinglePage {file, dataDir, nsfw, output}) = do let page = SinglePage.make nsfw dir info writeOutput output page -main2 (GalleryPage {title, files, nsfw, output, dataDir}) = do +main2 (GalleryPage {title, prefix, files, nsfw, output, dataDir}) = do infos <- mapM (infoYAML dataDir) files printV $ "infos" := infos - let page = GalleryPage.make title nsfw infos + let page = GalleryPage.make title prefix nsfw infos writeOutput output page main2 (IndexPage {file, output}) = do diff --git a/make-pages/Options.hs b/make-pages/Options.hs index 22d5d66..28bdbd7 100644 --- a/make-pages/Options.hs +++ b/make-pages/Options.hs @@ -19,6 +19,7 @@ data ModeOptions = } | GalleryPage { files :: [FilePath], + prefix :: FilePath, nsfw :: Bool, title :: Text, output :: Maybe FilePath, @@ -84,7 +85,11 @@ optionsParser = globalOpts `info` mainInfo where gallery = command "gallery" $ galleryOpts `info` galleryInfo galleryOpts = - GalleryPage <$> files <*> nsfwG <*> title <*> output <*> dataDir + GalleryPage <$> files <*> prefix <*> nsfwG <*> title <*> output <*> dataDir + prefix = strOption $ + short 'p' <> long "prefix" <> metavar "DIR" <> + value "" <> + help "output directory prefix" files = many $ strArgument $ metavar "FILE..." <> help "yaml files to read" nsfwG = switch $ @@ -110,10 +115,6 @@ optionsParser = globalOpts `info` mainInfo where dsOpts = DependSingle <$> file <*> nsfwS <*> output <*> prefix <*> buildDir <*> dataDir - prefix = strOption $ - short 'p' <> long "prefix" <> metavar "DIR" <> - value "" <> - help "output directory prefix" buildDir = strOption $ short 'B' <> long "build-dir" <> metavar "DIR" <> value "_build" <> help "build directory (default: _build)" diff --git a/style/shiny/gallery.css b/style/shiny/gallery.css index eb096ba..84f0012 100644 --- a/style/shiny/gallery.css +++ b/style/shiny/gallery.css @@ -89,6 +89,13 @@ figcaption { mix-blend-mode: multiply; } +footer { + font-size: 90%; + text-align: center; + margin-top: 1em; +} + + @media (hover) { .item:hover figcaption { opacity: 20%;