]> git.ekhem.eu.org Git - website.git/commitdiff
Put home page's content in a separate file and serve it through SSI.
authorJakub Czajka <jczajka@google.com>
Sat, 11 May 2024 22:55:44 +0000 (00:55 +0200)
committerJakub Czajka <jczajka@google.com>
Sat, 11 May 2024 23:03:49 +0000 (01:03 +0200)
home.html [new file with mode: 0644]
index.html
website.conf

diff --git a/home.html b/home.html
new file mode 100644 (file)
index 0000000..c23a9c0
--- /dev/null
+++ b/home.html
@@ -0,0 +1,42 @@
+<!-- Copyright (c) 2023-2024 Jakub Czajka <jakub@ekhem.eu.org> -->
+<!-- License: GPL-3.0 or later. -->
+<!-- ðŸ’ª (1F4AA) ðŸ˜Ž (1F60E) -->
+<h2>Jakub Czajka's website &#x1F4AA;&#x1F60E;</h2>
+<h3 style="margin-bottom: 0px;">About</h3>
+<hr/>
+<ul style="list-style-type: none; padding-left: 15px;">
+  <li>
+    <!-- ðŸ“„ (1F4C4) -->
+    &#x1F4C4; <a href="https://ekhem.eu.org/cv">CV</a>
+  </li>
+</ul>
+<h3 style="margin-bottom: 0px;">Contact</h3>
+<hr/>
+<ul style="list-style-type: none; padding-left: 15px;">
+  <li>
+    <!-- ðŸ“« (1F4EC) -->
+    &#x1F4EC; <a href="mailto:jakub@ekhem.eu.org">jakub@ekhem.eu.org</a>
+  </li>
+  <li>
+    <!-- ðŸ”‘ (1F511) -->
+    &#x1F511;
+      <a href="https://keys.openpgp.org/vks/v1/by-fingerprint/CB552A2D05AE8FE44503E5C71F81DE6C733FE873">
+        GPG key</a>
+  </li>
+</ul>
+<h3 style="margin-bottom: 0px;">Links</h3>
+<hr/>
+<ul style="list-style-type: none; padding-left: 15px;">
+  <li>
+    <img src="media/git.png" alt="git" style="height: 1em;">
+    <a href="https://git.ekhem.eu.org">Projects</a>
+  </li>
+</ul>
+<h3 style="margin-bottom: 0px;">Articles</h3>
+<hr/>
+<ul style="list-style-type: none; padding-left: 15px;">
+  <li>
+    <a href="articles/web">article1</a>
+  </li>
+</ul>
+<br/>
index 97e6320c8893168c9624acab848a7ebeb61280cc..d5264d0bfd003e372897418fd6a47974c2f4c52a 100644 (file)
       border-style: double;
       padding: 5px;
     }
-    h3 {
-      margin-bottom: 0px;
-    }
-    p {
-      margin: auto 10px;
-    }
-    ul {
-      list-style-type: none;
-      padding-left: 15px;
-    }
-    li img {
-      height: 1em;
-    }
     .bottom-container {
       display: grid;
       grid-template-columns: 1fr 1fr 1fr 1fr;
 </head>
 <body>
   <div class="top-container">
-    <!-- ðŸ’ª (1F4AA) ðŸ˜Ž (1F60E) -->
-    <h2>Jakub Czajka's website &#x1F4AA;&#x1F60E;</h2>
-    <h3>About</h3>
-    <hr/>
-    <ul>
-      <li>
-        <!-- ðŸ“„ (1F4C4) -->
-        &#x1F4C4; <a href="https://ekhem.eu.org/cv">CV</a>
-      </li>
-    </ul>
-    <h3>Contact</h3>
-    <hr/>
-    <ul>
-      <li>
-        <!-- ðŸ“« (1F4EC) -->
-        &#x1F4EC; <a href="mailto:jakub@ekhem.eu.org">jakub@ekhem.eu.org</a>
-      </li>
-      <li>
-        <!-- ðŸ”‘ (1F511) -->
-        &#x1F511;
-          <a href="https://keys.openpgp.org/vks/v1/by-fingerprint/CB552A2D05AE8FE44503E5C71F81DE6C733FE873">
-            GPG key</a>
-      </li>
-    </ul>
-    <h3>Links</h3>
-    <hr/>
-    <ul>
-      <li>
-        <img src="media/git.png" alt="git">
-        <a href="https://git.ekhem.eu.org">Projects</a>
-      </li>
-    </ul>
-    <h3>Articles</h3>
-    <hr/>
-    <!-- ðŸ¤” (1F914) -->
-    <p>There's nothing here &#x1F914;</p>
-    <br/>
+    <!--#include file="$content.html" -->
   </div>
   <div class="bottom-container">
     <p>Modified:&nbsp;</p>
index 5f471fa78d0b120c9d9123fb9f30d4ff8b66acec..26c16e99c7dff4a94f8672460bfd7aeb914e0a8e 100644 (file)
@@ -44,8 +44,43 @@ server {
         add_header Content-Disposition 'inline';
     }
 
+    # Dynamic SSI from
+    # https://www.nginx.com/resources/wiki/start/topics/examples/dynamic_ssi.
+    #
+    # If user requests /page.html, nginx should first serve /index.html which
+    # then requests /page.html.
+    #
+    # Simply rewriting /page.html to /index.html causes an infinite loop because
+    # /index.html requests /page.html.
+    #
+    # Instead, if user requests /index.html with /page.html, they should instead
+    # hit /page.
+    # 1. User requests /page.
+    # 2. Nginx serves /index.html.
+    # 3. /index.html requests /page.html.
+    # 4. /page.html serves page.html.
     location / {
-        index index.html;
+        ssi on;
+
+        set ${dollar}content ${dollar}request_uri;
+        if (${dollar}request_uri = "/") {
+            set ${dollar}content "/home";
+        }
+        if (!-f ${dollar}request_filename) {
+            rewrite ^ /index.html last;
+        }
+        if (!-f ${dollar}document_root${dollar}content.html) {
+            return 404;
+        }
+    }
+
+    # /index.html is an edge case.
+    location = /index {
+        return 301 /;
+    }
+
+    # Images should be served as-is.
+    location /media {
     }
 }