diff options
| -rw-r--r-- | src/Hakyll/Alias.hs | 42 | ||||
| -rw-r--r-- | src/Prolog.hs | 3 | ||||
| -rw-r--r-- | templates/default.html | 21 | ||||
| -rw-r--r-- | www/templates/paper.html | 34 | ||||
| -rw-r--r-- | www/templates/prints.html | 15 |
5 files changed, 108 insertions, 7 deletions
diff --git a/src/Hakyll/Alias.hs b/src/Hakyll/Alias.hs new file mode 100644 index 0000000..b127a05 --- /dev/null +++ b/src/Hakyll/Alias.hs @@ -0,0 +1,42 @@ +module Hakyll.Alias where + +import Prolog +import Data.HashSet qualified as HS + + +newtype Aliased a x = Aliased { unAliased :: Either a x } + deriving newtype (Binary, Eq, Foldable, Functor, Generic, Generic1, Hashable, Ord, Show, Traversable) + +class (Eq a, Hashable a) => ToAliases x a where + toAliases :: x -> HashSet a + +instance Hashable a => ToAliases a a where + toAliases = HM.singleton + +instance (Eq a, Hashable a) => ToAliases (HashSet a) a where + toAliases = id + +instance ToAliases x a => ToAliases [x] a where + toAliases = foldMap toAliases + + +class FromAlias a x where + fromAlias :: MonadThrow m => a -> m x + +instance FromAlias a a where + fromAlias = pure + +instance (FromAlias a x, FromAlias b x) => FromAlias (Either a b) x where + fromAlias = either fromAlias fromAlias + +instance FromAlias a x => FromAlias (Aliased a x) x where + fromAlias = fromAlias . unAliased + +newtype NoAlias a =NoAlias a + deriving (Eq, Show) + +instance Show a => Exception (NoAlias a) where + displayException (NoAlias a) = show a <> " is not an alias" + +missingAlias :: MonadThrow m => a -> m b +missingAlias = throwM . NoAlias diff --git a/src/Prolog.hs b/src/Prolog.hs index a6ac1b5..bb464f5 100644 --- a/src/Prolog.hs +++ b/src/Prolog.hs @@ -216,3 +216,6 @@ instance ToMarkup URI where instance ToValue URI where toValue = toValue . show preEscapedToValue = preEscapedToValue . show + +instance MonadThrow Compiler where + throwM = throwError . pure . displayException diff --git a/templates/default.html b/templates/default.html index 124a2f2..4aeffd6 100644 --- a/templates/default.html +++ b/templates/default.html @@ -2,11 +2,7 @@ <html lang="en" color-mode="light"> <head> <title>$title$</title> - $if(author)$ - <meta name="author" content="$author$"> - $else$ - <meta name="author" content="Chris Wells"> - $endif$ + <meta name="author" content="$if(author)$author$$else$Chris Wells$endif$"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" > <meta name="viewport" content="width=device-width, initial-scale=1" > @@ -17,7 +13,10 @@ <script type="text/javascript" src="/js/toggle.js"></script> $endif$ $if(math)$ - $partial("templates/math.html")$ + <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css" integrity="sha384-zB1R0rpPzHqg7Kpt0Aljp8JPLqbXI3bhnPWROx27a9N0Ll6ZP/+DiW/UqRcLbRjq" crossorigin="anonymous"> + <script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.js" integrity="sha384-y23I5Q6l+B6vatafAwxRu/0oK/79VlbSz7Q9aiSZUvyWYIYsd+qj+o24G5ZU2zJz" crossorigin="anonymous"></script> + <script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"></script> + <script type="text/javascript" src="/js/katex.js"></script> $endif$ <!-- <script src="https://kit.fontawesome.com/cd6957df2d.js" crossorigin="anonymous"></script> --> @@ -34,7 +33,15 @@ </head> <body> <header> - $partial("templates/nav.html")$ + <div id="menu"> + <a href="/"><i class="fa fa-home"></i> Chris Wells</a> + <span class="pull-right"> + <a href="/research"><i class="fa fa-book"></i> Research</a> + <a href="/teaching"><i class="fa fa-chalkboard-teacher"></i> Teaching</a> + <a href="/contact.html"><i class="fa fa-address-book"></i> Contact</a> + <a href="/doc/cv.pdf"><i class="fa fa-file-alt"></i> CV</a> + </span> + </div> </header> <div id="main"> diff --git a/www/templates/paper.html b/www/templates/paper.html new file mode 100644 index 0000000..0a19137 --- /dev/null +++ b/www/templates/paper.html @@ -0,0 +1,34 @@ +<div class="paper"> + <div class="paper-title"> + $title$ + </div> + <div class="paper-author"> + <ul> + $for(authors)$ + <li>$alias(author)$</li> + $endfor$ + </ul> + </div> + $if(abstract)$ + <div class="paper-abstract"> + <div id="$slug(title)$-abstract" style="display:none;"> + $abstract$ + </div> + </div> + $endif$ + <div class="paper-foot"> + <ul> + $if(submitted)$ + <li>Submitted</li> + $endif$ + $if(accepted)$ + <li>$journal$ (Accepted)</li> + $endif$ + $if(published)$ + <li>$journal$</li> + <li>$pubdate$</li> + $endif$ + $if(abstract)$<button class="abstract-button" style="float:right" onclick="toggle('$slug(title)$-abstract');">Abstract</button>$endif$ + </ul> + </div> +</div> diff --git a/www/templates/prints.html b/www/templates/prints.html new file mode 100644 index 0000000..4fae26d --- /dev/null +++ b/www/templates/prints.html @@ -0,0 +1,15 @@ +<div class="paper-prints"> + <ul> + $if(doi)$ + <li href="$doi$">doi</li> + $endif$ + + $if(arxiv)$ + <li href="$arxiv$">arXiv</li> + $endif$ + + $if(pdf)$ + <li href="$pdf$">pdf</li> + $endif$ + </ul> +</div> |
