From 6c6319c3ecfb9606c32b3c6c9b487da33911f8b6 Mon Sep 17 00:00:00 2001
From: cel 🌸 <cel@blos.sm>
Date: Thu, 18 Jul 2024 01:37:00 +0100
Subject: add resources dir

---
 site.hs                         | 42 +++++++++++++++++++++++++++++++++------
 style.css                       | 26 +++++++++++++++++++++++-
 templates/article-resource.html | 44 -----------------------------------------
 templates/article.html          | 34 -------------------------------
 templates/base.html             |  3 ++-
 templates/post.html             | 37 ++++++++++++++++++++++++++++++++--
 templates/resource.html         | 36 +++++++++++++++++++++++++++++++--
 templates/resources.html        | 25 +++++++++++++++++++++++
 templates/thumbs.html           |  2 +-
 todo.md                         |  8 ++++----
 10 files changed, 162 insertions(+), 95 deletions(-)
 delete mode 100644 templates/article-resource.html
 delete mode 100644 templates/article.html
 create mode 100644 templates/resources.html

diff --git a/site.hs b/site.hs
index 8284c2f..a25c79c 100644
--- a/site.hs
+++ b/site.hs
@@ -69,18 +69,46 @@ main = hakyll $ do
         route   idRoute
         compile getResourceBody
 
+    match "resources/*" $ do
+        route $ setExtension "html" `composeRoutes`
+                appendIndex
+        compile $ pandocCompiler
+            >>= saveSnapshot "article-text"
+            >>= loadAndApplyTemplate "templates/resource.html" postCtx
+            >>= saveSnapshot "content"
+            >>= loadAndApplyTemplate "templates/base.html" postCtx
+            >>= relativizeUrls
+
+    match "resources/*" $ version "raw" $ do
+        route   idRoute
+        compile getResourceBody
+
+    create ["resources.html"] $ do
+        route appendIndex
+        compile $ do
+            resources <- loadAll ("resources/*" .&&. hasNoVersion)
+            let resourcesCtx =
+                    listField "resources" postCtx (return resources) `mappend`
+                    constField "title" "resources" `mappend`
+                    defaultContext
+
+            makeItem ""
+                >>= loadAndApplyTemplate "templates/resources.html" resourcesCtx
+                >>= loadAndApplyTemplate "templates/base.html" resourcesCtx
+                >>= relativizeUrls
+
     create ["archives.html"] $ do
         route appendIndex
         compile $ do
             posts <- recentFirst =<< loadAll ("posts/*" .&&. hasNoVersion)
-            let archiveCtx =
+            let archivesCtx =
                     listField "posts" postCtx (return posts) `mappend`
                     constField "title" "archives"            `mappend`
                     defaultContext
 
             makeItem ""
-                >>= loadAndApplyTemplate "templates/archives.html" archiveCtx
-                >>= loadAndApplyTemplate "templates/base.html" archiveCtx
+                >>= loadAndApplyTemplate "templates/archives.html" archivesCtx
+                >>= loadAndApplyTemplate "templates/base.html" archivesCtx
                 >>= relativizeUrls
 
 
@@ -104,7 +132,8 @@ main = hakyll $ do
         compile $ do
             let feedCtx = postCtx `mappend` bodyField "description"
             posts <- fmap (take 10) . recentFirst =<<
-                loadAllSnapshots ("posts/*" .&&. hasNoVersion) "content"
+                loadAllSnapshots (("resources/*" .&&. hasNoVersion) .||. ("posts/*" .&&. hasNoVersion)) "content"
+
             renderAtom feedConfig feedCtx posts
 
     create ["sitemap.xml"] $ do
@@ -112,12 +141,13 @@ main = hakyll $ do
         compile $ do
             -- load and sort the posts
             posts <- recentFirst =<< loadAll "posts/*"
+            resources <- recentFirst =<< loadAll "resources/*"
 
             -- load individual pages from a list (globs DO NOT work here)
-            singlePages <- loadAll (fromList ["about.md", "contact.md", "archives.html", "feed.xml"])
+            singlePages <- loadAll (fromList ["about.md", "contact.md", "archives.html", "resources.html", "feed.xml"])
 
                            -- mappend the posts and singlePages together
-            let pages = posts <> singlePages
+            let pages = posts <> resources <> singlePages
 
                            -- create the `pages` field with the postCtx
                            -- and return the `pages` value for it
diff --git a/style.css b/style.css
index f384e6f..60329e7 100644
--- a/style.css
+++ b/style.css
@@ -75,6 +75,28 @@ pre {
   filter: drop-shadow(0px 0px 1px #e3b69b);
 }
 
+.resource-list {
+  display: flex;
+  flex-wrap: wrap;
+  font-family: 'Syne Mono';
+  /* text-shadow: 0px 0px 2px #e3b69b; */
+  filter: drop-shadow(0px 0px 2px #e3b69b);
+  padding: 0;
+}
+
+.resource-list .panel {
+  padding: 2vw;
+}
+
+.resource-list li {
+  display: inline;
+}
+
+.resource-list a:hover {
+  /* text-shadow: 0px 0px 4px #e3b69b; */
+  filter: drop-shadow(0px 0px 1px #e3b69b);
+}
+
 #public-license:hover {
   position: relative;
 }
@@ -207,6 +229,8 @@ article {
 
 .thumb .thumbnail {
   height: 20vh;
+  display: block;
+  margin: 0 auto 1em;
 }
 
 article .thumbnail {
@@ -685,4 +709,4 @@ code span.wa {
   font-weight: bold;
   font-style: normal;
   font-display: block;
-}
+}
\ No newline at end of file
diff --git a/templates/article-resource.html b/templates/article-resource.html
deleted file mode 100644
index e3d9cac..0000000
--- a/templates/article-resource.html
+++ /dev/null
@@ -1,44 +0,0 @@
-<article>
-  $if(thumbnail)$
-  <div class="thumbnail" style="height: 30vh;">$thumbnail$</div>
-  $endif$
-  $if(torrent)$
-  <div>
-    <video controls class="thumbnail" id="media-$id$" style="height: 30vh;"></video>
-    <script type='module'>
-      const torrentId = '$torrent$';
-      const player = document.querySelector('#media-$id$');
-      window.torrentClient.add(torrentId, torrent => {
-        const file = torrent.files.find(file => file.name.endsWith('.mp4'));
-        file.streamTo(player);
-      });
-    </script>
-  </div>
-  $endif$
-  <div class="panel">
-    <section class="header">
-      <div class="title">
-        <h1>$title$</h1>
-        <a href="https://infoculture.pub$url$">permalink</a>
-        <a href="/$path$">raw</a>
-        $if(torrent)$
-        <a href="$torrent$">magnet link</a>
-        $endif$
-      </div>
-      <div class="meta">
-        $if(author)$
-        <h2 class="author">$author$</h2>
-        $endif$
-        <h3 class="date">$date$</h3>
-        $if(tags)$
-        <h3 class="tags">$tags$</h3>
-        $endif$
-      </div>
-    </section>
-    <br>
-    <br>
-    <section>
-      $body$
-    </section>
-  </div>
-</article>
\ No newline at end of file
diff --git a/templates/article.html b/templates/article.html
deleted file mode 100644
index 2aa24f2..0000000
--- a/templates/article.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<article>
-  $if(thumbnail)$
-  <div class="thumbnail" style="height: 30vh;">$thumbnail$</div>
-  $endif$
-  $if(torrent)$
-  $partial("templates/video-player.html")$
-  $endif$
-  <div class="panel">
-    <section class="header">
-      <div class="title">
-        <h1>$title$</h1>
-        <a href="https://infoculture.pub$url$">permalink</a>
-        <a href="/$path$">raw</a>
-        $if(torrent)$
-        <a href="$torrent$">magnet link</a>
-        $endif$
-      </div>
-      <div class="meta">
-        $if(author)$
-        <h2 class="author">$author$</h2>
-        $endif$
-        <h3 class="date">$date$</h3>
-        $if(tags)$
-        <h3 class="tags">$tags$</h3>
-        $endif$
-      </div>
-    </section>
-    <br>
-    <br>
-    <section>
-      $body$
-    </section>
-  </div>
-</article>
\ No newline at end of file
diff --git a/templates/base.html b/templates/base.html
index 1875345..1d5c74c 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -22,9 +22,10 @@
   <nav>
     <ul>
       <li><a href="/">home</a></li>
+      <li><a href="/resources">resources</a></li>
+      <li><a href="/archives">archives</a></li>
       <li><a href="/about">about</a></li>
       <li><a href="/contact">contact</a></li>
-      <li><a href="/archives">archives</a></li>
       <li class="nav-badges">
         <a href="/feed.xml"><img src="/assets/atom.png"></a>
         <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/"><img src="/assets/cc-by-nc-sa-80x15.png"></a>
diff --git a/templates/post.html b/templates/post.html
index 5815e91..b9bbbe0 100644
--- a/templates/post.html
+++ b/templates/post.html
@@ -2,5 +2,38 @@
   $if(torrent)$
   $partial("templates/load-webtorrent.html")$
   $endif$
-  $partial("templates/article.html")$
-</main>
+  <article>
+    $if(thumbnail)$
+    <div class="thumbnail" style="height: 30vh;">$thumbnail$</div>
+    $endif$
+    $if(torrent)$
+    $partial("templates/video-player.html")$
+    $endif$
+    <div class="panel">
+      <section class="header">
+        <div class="title">
+          <h1>$title$</h1>
+          <a href="https://infoculture.pub$url$">permalink</a>
+          <a href="/$path$">raw</a>
+          $if(torrent)$
+          <a href="$torrent$">magnet link</a>
+          $endif$
+        </div>
+        <div class="meta">
+          $if(author)$
+          <h2 class="author">$author$</h2>
+          $endif$
+          <h3 class="date">$date$</h3>
+          $if(tags)$
+          <h3 class="tags">$tags$</h3>
+          $endif$
+        </div>
+      </section>
+      <br>
+      <br>
+      <section>
+        $body$
+      </section>
+    </div>
+  </article>
+</main>
\ No newline at end of file
diff --git a/templates/resource.html b/templates/resource.html
index b93984a..20b9716 100644
--- a/templates/resource.html
+++ b/templates/resource.html
@@ -2,5 +2,37 @@
   $if(torrent)$
   $partial("templates/load-webtorrent.html")$
   $endif$
-  $partial("templates/article.html")$
-</main>
\ No newline at end of file
+  <article>
+    $if(thumbnail)$
+    <div class="thumbnail" style="height: 30vh;">$thumbnail$</div>
+    $endif$
+    $if(torrent)$
+    $partial("templates/video-player.html")$
+    $endif$
+    <div class="panel">
+      <section class="header">
+        <div class="title">
+          <h1>$title$</h1>
+          <a href="https://infoculture.pub$url$">permalink</a>
+          <a href="/$path$">raw</a>
+          $if(torrent)$
+          <a href="$torrent$">magnet link</a>
+          $endif$
+        </div>
+        <div class="meta">
+          $if(author)$
+          <h2 class="author">$author$</h2>
+          $endif$
+          $if(tags)$
+          <h3 class="tags">$tags$</h3>
+          $endif$
+        </div>
+      </section>
+      <br>
+      <br>
+      <section>
+        $body$
+      </section>
+    </div>
+  </article>
+</main>
diff --git a/templates/resources.html b/templates/resources.html
new file mode 100644
index 0000000..ab8f066
--- /dev/null
+++ b/templates/resources.html
@@ -0,0 +1,25 @@
+<main role="main">
+  <ul class="resource-list">
+    $for(resources)$
+    <li class="panel">
+      $if(thumbnail)$
+      <div class="thumbnail" style="height: 25vh">$thumbnail$</div>
+      $endif$
+      $if(torrent)$
+      $partial("templates/video-player.html")$
+      $endif$
+      <a href="$url$">$title$</a>
+      $if(subtitle)$
+      <div class="thumb-subtitle">
+        $subtitle$
+      </div>
+      $endif$
+      $if(teaser)$
+      <div class="thumb-teaser">
+        $teaser$<a href="$url$">read more...</a>
+      </div>
+      $endif$
+    </li>
+    $endfor$
+  </ul>
+</main>
\ No newline at end of file
diff --git a/templates/thumbs.html b/templates/thumbs.html
index cadbbc7..72b2853 100644
--- a/templates/thumbs.html
+++ b/templates/thumbs.html
@@ -32,4 +32,4 @@
     $endif$
   </div>
   $endfor$
-</div>
+</div>
\ No newline at end of file
diff --git a/todo.md b/todo.md
index 775239c..4ccd109 100644
--- a/todo.md
+++ b/todo.md
@@ -10,13 +10,13 @@
 [x] sitemap.xml
 [x] teasers
 [x] webtorrent
-[ ] resources directory
-[ ] move posts to articles
+[x] resources directory
+[x] move posts to articles
 [x] edit about
 [ ] remove placeholders
 
 later:
 [ ] fun homepage design
-[ ] author pages
-[ ] tags filter
+[ ] author pages?
+[ ] tags filter/page
 [ ] add tags to sitemap?
-- 
cgit