From e323135f5f857a731657601c23cd4dfb3cb5d7d7 Mon Sep 17 00:00:00 2001 From: Chris Wells Date: Thu, 20 Aug 2026 08:53:59 -0400 Subject: Fixed the extra links in papers --- src/Data/Paper.hs | 5 ++++- src/Hakyll/Paper.hs | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Data/Paper.hs b/src/Data/Paper.hs index b86b2f0..38994de 100644 --- a/src/Data/Paper.hs +++ b/src/Data/Paper.hs @@ -135,7 +135,7 @@ mkPaper bib = do -- doi <- find' "doi" >>= fmap DOI . puri -- date <- getDate -- pure $ Published {..} - extraLink <- traverse puri $ M.lookup "extralink" fields + extraLink <- traverse pauri $ M.lookup "extralink" fields eprints <- case toLower <<$>> M.lookup "eprinttype" fields of Just "arxiv" -> do _identifier <- find' "eprint" >>= puri @@ -155,5 +155,8 @@ mkPaper bib = do puri :: MonadFail m => String -> m URI puri u = maybe (fail $ show u <> " cannot be understood as a uri") pure $ parseRelativeReference u +pauri :: MonadFail m => String -> m URI +pauri u = maybe (fail $ show u <> " cannot be understood as a uri") pure $ parseURIReference u + findit :: (Show a, Ord a, MonadFail m) => a -> M.Map a x -> m x findit k = maybe (fail $ "Field " <> show k <> " does not exist") pure . M.lookup k diff --git a/src/Hakyll/Paper.hs b/src/Hakyll/Paper.hs index 06c45d0..5cc9620 100644 --- a/src/Hakyll/Paper.hs +++ b/src/Hakyll/Paper.hs @@ -43,7 +43,7 @@ paperCtxt fctxt = fold $ let k = sluggedKey $ itemBody i ident = toFilePath $ itemIdentifier i getMatches (fromString $ ident <> "/index.*") >>= witherM (fmap (>>= parseRelativeReference) . getRoute) >>= \case - (x:_) -> pure $ show x + (x:_) -> pure $ "/" <> show x _ -> fail $ "No extra for " <> k ] @@ -106,7 +106,7 @@ eprintCtxt = fold $ ] findLocal :: (StringConv a String, StringConv String a) => Item (Paper a) -> Compiler [Eprint a] -findLocal (Item ident paper) = getMatches (getPattern potentialPdfs) >>= 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 -- cgit v1.3.1