summaryrefslogtreecommitdiff
path: root/src/Hakyll/Paper.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Hakyll/Paper.hs')
-rw-r--r--src/Hakyll/Paper.hs25
1 files changed, 17 insertions, 8 deletions
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