aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2020-01-24 13:15:34 -0300
committerEuAndreh <eu@euandre.org>2020-01-24 13:15:34 -0300
commit1a08821a024cd09b361937b32d0498f21583d7e5 (patch)
tree86b9f08144fcf4e763f2e816919c9421aff360bd
parentutils.nix: Revert change (diff)
downloadeuandre.org-1a08821a024cd09b361937b32d0498f21583d7e5.tar.gz
euandre.org-1a08821a024cd09b361937b32d0498f21583d7e5.tar.xz
Add pastebins.html listing page
-rw-r--r--default.nix6
-rw-r--r--hakyll/Main.hs27
-rw-r--r--site/pastebins.html5
-rw-r--r--site/templates/pastebin-list.html7
-rw-r--r--site/templates/pastebin.html8
-rw-r--r--site/templates/post.html3
6 files changed, 45 insertions, 11 deletions
diff --git a/default.nix b/default.nix
index 4ff2220..414e233 100644
--- a/default.nix
+++ b/default.nix
@@ -65,15 +65,11 @@ in rec {
docs = utils.baseTask.overrideAttrs (baseAttrs: {
name = "${baseAttrs.name}-docs";
src = ./site;
- buildInputs = [ websiteBuilder pkgs.pandoc ];
+ buildInputs = [ websiteBuilder ];
buildPhase = ''
export LOCALE_ARCHIVE="${pkgs.glibcLocales}/lib/locale/locale-archive";
export LANG=en_US.UTF-8
-
- ls pastebin/*.org | awk -F. '{print $1}' | xargs -I{} pandoc -o {}.html {}.org --standalone
-
build-site build
-
mkdir $out
cp -r _site/* $out
'';
diff --git a/hakyll/Main.hs b/hakyll/Main.hs
index 6d27c66..139b607 100644
--- a/hakyll/Main.hs
+++ b/hakyll/Main.hs
@@ -20,13 +20,18 @@ main = hakyll $ do
match "fonts/*" $ do
route idRoute
compile copyFileCompiler
- match "pastebin/*.html" $ do
- route idRoute
- compile copyFileCompiler
match "root/*" $ do
route $ dropPrefix "root/"
compile copyFileCompiler
+ match "pastebin/*" $ do
+ route $ setExtension "html"
+ compile $ pandocCompiler
+ >>= loadAndApplyTemplate "templates/pastebin.html" pastebinCtx
+ >>= saveSnapshot "content"
+ >>= loadAndApplyTemplate "templates/default.html" pastebinCtx
+ >>= relativizeUrls
+
match "posts/*" $ do
route $ setExtension "html"
`composeRoutes` dropPrefix "posts/"
@@ -44,6 +49,19 @@ main = hakyll $ do
>>= loadAndApplyTemplate "templates/default.html" defaultContext
>>= relativizeUrls
+ match "pastebins.html" $ do
+ route idRoute
+ compile $ do
+ pastebins <- recentFirst =<< loadAll "pastebin/*"
+ let pastebinCtx =
+ listField "pastebins" pastebinCtx (return pastebins) `mappend`
+ defaultContext
+
+ getResourceBody
+ >>= applyAsTemplate pastebinCtx
+ >>= loadAndApplyTemplate "templates/default.html" pastebinCtx
+ >>= relativizeUrls
+
match "index.html" $ do
route idRoute
compile $ do
@@ -96,6 +114,9 @@ postCtx =
dateField "date" "%B %e, %Y" `mappend`
defaultContext
+pastebinCtx :: Context String
+pastebinCtx = postCtx
+
feedCtx :: Context String
feedCtx =
bodyField "description" `mappend`
diff --git a/site/pastebins.html b/site/pastebins.html
new file mode 100644
index 0000000..0afa928
--- /dev/null
+++ b/site/pastebins.html
@@ -0,0 +1,5 @@
+---
+title: Pastebins listing
+---
+
+$partial("templates/pastebin-list.html")$
diff --git a/site/templates/pastebin-list.html b/site/templates/pastebin-list.html
new file mode 100644
index 0000000..4c98c80
--- /dev/null
+++ b/site/templates/pastebin-list.html
@@ -0,0 +1,7 @@
+<ul>
+ $for(pastebins)$
+ <li>
+ <a href="$url$">$title$</a> - $date$
+ </li>
+ $endfor$
+</ul>
diff --git a/site/templates/pastebin.html b/site/templates/pastebin.html
new file mode 100644
index 0000000..7aa2775
--- /dev/null
+++ b/site/templates/pastebin.html
@@ -0,0 +1,8 @@
+<article>
+ <section class="header">
+ Posted on $date$
+ </section>
+ <section>
+ $body$
+ </section>
+</article>
diff --git a/site/templates/post.html b/site/templates/post.html
index 428ebff..7aa2775 100644
--- a/site/templates/post.html
+++ b/site/templates/post.html
@@ -1,9 +1,6 @@
<article>
<section class="header">
Posted on $date$
- $if(author)$
- by $author$
- $endif$
</section>
<section>
$body$