From 08bd3560f45b225c8fd411d2726487853f4f76e8 Mon Sep 17 00:00:00 2001 From: Chris Wells Date: Thu, 10 Apr 2025 20:59:07 -0500 Subject: bit of work --- src/Hakyll/Paper.hs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src/Hakyll/Paper.hs') diff --git a/src/Hakyll/Paper.hs b/src/Hakyll/Paper.hs index 8db50cd..0c997eb 100644 --- a/src/Hakyll/Paper.hs +++ b/src/Hakyll/Paper.hs @@ -6,6 +6,7 @@ import Data.Paper import Data.Name import Data.Time.Format import Hakyll.Util (transformContext_) +import Hakyll.Core.Identifier.Pattorn import System.FilePath @@ -55,9 +56,12 @@ statusCtxt = fold $ , field "doi" $ \i -> case itemBody i of Published _ _ d -> pure $ show (doiLink d) _ -> fail "No DOI" - , boolField "published" $ \i -> case itemBody i of - Published _ _ _ -> True - _ -> False + , boolField "published" $ \case + Item _ (Published {..}) -> True + _ -> False + -- \i -> case itemBody i of + -- Published _ _ _ -> True + -- _ -> False , boolField "accepted" $ \i -> case itemBody i of Accepted _ _ -> True _ -> False @@ -91,10 +95,15 @@ eprintCtxt = fold $ ] findLocal :: (StringConv a String, StringConv String a) => Item (Paper a) -> Compiler [Eprint a] -findLocal paper = do - let k = sluggedKey $ itemBody paper - ident = toFilePath $ itemIdentifier paper - getMatches (fromString (ident <> ".pdf") .||. fromString (ident <> "/" <> k <> ".pdf")) >>= witherM (fmap (>>= parseRelativeReference) . getRoute) >>= pure . fmap (OtherEprint (toSL ".pdf")) +findLocal (Item ident paper) = getMatches (getPattern potentialPdfs) >>= witherM (fmap (>>= parseRelativeReference) . getRoute) >>= pure . fmap (OtherEprint (toSL ".pdf")) + where + fp :: FilePath + fp = toFilePath ident + potentialPdfs :: Pattorn + potentialPdfs = foldMap (fromString . (fp <>)) $ + [ ".pdf" + , "/" <> sluggedKey paper <> ".pdf" + ] sluggedKey :: StringConv a String => Paper a -> String @@ -105,7 +114,7 @@ compilePapers :: StringConv s String => Item s -> Compiler (Item [Paper String]) compilePapers = compileBibtex >=> traverse (mapM mkPaper) papersCompiler :: Compiler (Item [Paper String]) -papersCompiler = getResourceBody >>= compilerPapers +papersCompiler = getResourceBody >>= compilePapers -- paperListCompiler :: Compiler [Paper String] -- paperListCompiler = bibtexCompiler -- cgit v1.2.3