about summary refs log tree commit diff
path: root/web/homepage
diff options
context:
space:
mode:
Diffstat (limited to 'web/homepage')
-rw-r--r--web/homepage/default.nix51
-rw-r--r--web/homepage/entries.nix1
-rw-r--r--web/homepage/footer.html2
-rw-r--r--web/homepage/header.html33
4 files changed, 86 insertions, 1 deletions
diff --git a/web/homepage/default.nix b/web/homepage/default.nix
index 94dfaf3dc6f1..f6892576f5fe 100644
--- a/web/homepage/default.nix
+++ b/web/homepage/default.nix
@@ -10,6 +10,55 @@
 with pkgs;
 with nix.yants;
 
-third_party.callPackage ./nginx.nix {
+let
+  inherit (builtins) readFile replaceStrings sort;
+  inherit (third_party) writeFile runCommandNoCC;
+
+  # The different types of entries on the homepage.
+  entryClass = enum "entryClass" [ "blog" "project" "misc" ];
+
+  # The definition of a single entry.
+  entry = struct "entry" {
+    class = entryClass;
+    title = string;
+    url = string;
+    date = int; # epoch
+    description = option string;
+  };
+
+  escape = replaceStrings [ "<" ">" "&" "'" ] [ "&lt;" "&gt;" "&amp;" "&#39;" ];
+
+  postToEntry = defun [ web.blog.post entry ] (post: {
+    class = "blog";
+    title = "Blog: " + post.title;
+    url = "/blog/${post.key}";
+    date = post.date;
+  });
+
+  # TODO(tazjin): add date formatting function
+  entryToDiv = defun [ entry string ] (entry: ''
+    <div class="entry ${entry.class}">
+      <p class="entry-title">${escape entry.title}</p>
+      ${
+        lib.optionalString ((entry ? description) && (entry.description != null))
+        "<p class=\"entry-description\">${escape entry.description}</p>"
+      }
+    </div>
+  '');
+
+  index = entries: third_party.writeText "index.html" (lib.concatStrings (
+    [ (builtins.readFile ./header.html) ]
+    ++ (map entryToDiv (sort (a: b: a.date < b.date) entries))
+    ++ [ (builtins.readFile ./footer.html) ]
+  ));
+
+  homepage = index ((map postToEntry web.blog.posts) ++ (import ./entries.nix));
+  website = runCommandNoCC "website" {} ''
+    mkdir $out
+    cp ${homepage} $out/index.html
+    cp -r ${./static} $out/static
+  '';
+in third_party.callPackage ./nginx.nix {
+  inherit website;
   blog = web.blog;
 }
diff --git a/web/homepage/entries.nix b/web/homepage/entries.nix
new file mode 100644
index 000000000000..fe51488c7066
--- /dev/null
+++ b/web/homepage/entries.nix
@@ -0,0 +1 @@
+[]
diff --git a/web/homepage/footer.html b/web/homepage/footer.html
new file mode 100644
index 000000000000..2f17135066e8
--- /dev/null
+++ b/web/homepage/footer.html
@@ -0,0 +1,2 @@
+  </div>
+</body>
diff --git a/web/homepage/header.html b/web/homepage/header.html
new file mode 100644
index 000000000000..832306fae3a4
--- /dev/null
+++ b/web/homepage/header.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<head><meta charset="utf-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1">
+  <meta name="description" content="tazjin&#39;s blog">
+  <link rel="stylesheet" type="text/css" href="static/tazjin.css" media="all">
+  <link rel="alternate" type="application/rss+xml" title="RSS-Feed" href="/rss.xml">
+  <title>tazjin&#39;s interblag</title>
+</head>
+<body class="dark">
+  <header>
+    <h1>
+      <a class="unstyled-link" href="/">tazjin&#39;s interblag</a>
+    </h1>
+    <hr>
+  </header>
+  <div class="introduction">
+    <p>Hello, illuminated visitor.</p>
+    <p>
+      I'm tazjin. Usually you can find
+      me <a href="https://git.tazj.in/about">programming computers</a>
+      using tools such as <a href="https://nixos.org/nix">Nix</a>
+      and <a href="https://www.gnu.org/software/emacs/">Emacs</a>,
+      cuddling <a href="https://twitter.com/edefic">people I love</a>
+      or posting nonsense <a href="https://twitter.com/tazjin">on the
+      internet</a>.
+    </p>
+    <p>
+      Below you can find a collection of my projects and blog posts.
+      If you'd like to get in touch about anything, send me a mail at
+      mail@[this domain] or ping me on IRC or Twitter.
+    </p>
+  </div>
+  <div class="entry-container">