Commit Diff


commit - 1ba2bcf97d8ea671f4139b51f92c578d45b360bc
commit + 9707cd8712535a5835b97d140bccec565a11fd59
blob - 48635e02627b02f1ac58dbe242aa8df0ffe3adc9
blob + 11cdc0f91414165b5e7f6a99f0310fcaea4e98e6
--- fragments.tmpl
+++ fragments.tmpl
@@ -22,6 +22,7 @@
 #include <arpa/inet.h>
 
 #include <event.h>
+#include <libgen.h>
 #include <limits.h>
 #include <stdint.h>
 #include <stdio.h>
@@ -30,6 +31,8 @@
 #include "galileo.h"
 #include "tmpl.h"
 
+static int tp_navigation(struct template *);
+
 !}
 
 {{ define tp_head(struct template *tp, const char *lang,
@@ -61,6 +64,9 @@
 		</title>
 	</head>
 	<body>
+		{{ if path }}
+			{{ render tp_navigation(tp) }}
+		{{ end }}
 {{ end }}
 
 {{ define tp_foot(struct template *tp) }}
@@ -86,6 +92,44 @@ gemini://{{ pc->proxy_name }}{{ path }}
 </html>
 {{ end }}
 
+{{ define tp_navigation(struct template *tp) }}
+{!
+	struct client	*clt = tp->tp_arg;
+	const char	*prfx = clt->clt_script_name;
+	char		*path = clt->clt_path_info;
+	char		*tilde, *t, home[GEMINI_MAXLEN], up[GEMINI_MAXLEN];
+	char		*dname;
+	char		 c;
+
+	*home = '\0';
+	if ((tilde = strstr(path, "/~")) != NULL &&
+	    (t = strchr(tilde + 1, '/')) != NULL) {
+		c = *++t;
+		*t = '\0';
+		(void) strlcpy(home, path + 1, sizeof(home));
+		*t = c;
+	}
+
+	(void) strlcpy(up, path + 1, sizeof(up));
+	dname = dirname(up);
+!}
+<header>
+	<nav>
+		<ul>
+			<li><a href="{{ prfx }}">Root</a></li>
+
+			{{ if *home != '\0' }}
+			<li><a href="{{ prfx }}{{ home }}">Home</a></li>
+			{{ end }}
+
+			{{ if strcmp(dname, ".") != 0 }}
+			<li><a href="{{ prfx }}{{ dname }}/">Up</a></li>
+			{{ end }}
+		</ul>
+	</nav>
+</header>
+{{ end }}
+
 {{ define tp_figure(struct template *tp, const char *url, const char *label) }}
 <figure>
 	<a href="{{ url | urlescape }}">
blob - ae6573b58a5bd26245f063ad047b1f2b410176d9
blob + 96dbfdb5d2939c67958ceeda7d59c2ec88c12ecb
--- galileo.css
+++ galileo.css
@@ -8,6 +8,17 @@ body {
 	padding: 1rem;
 }
 
+header nav ul {
+    list-style: none;
+    padding: 0;
+    margin: 0;
+}
+
+header nav ul li {
+    display: inline-block;
+    margin-right: 10px;
+}
+
 h1, h2, h3 {
 	margin: 2rem 0 1rem;
 }