commit 9707cd8712535a5835b97d140bccec565a11fd59 from: Omar Polo date: Thu Mar 02 14:42:19 2023 UTC add a navigation bar This adds a simple navigation bar since web browser are apparently dumbler than most Gemini browsers. The "Root" link points to the capsule' root, "Home" to the current home directory and "Up" to the parent directory. Users home are discovered using a simple heuristics: ~user path components. commit - 1ba2bcf97d8ea671f4139b51f92c578d45b360bc commit + 9707cd8712535a5835b97d140bccec565a11fd59 blob - 48635e02627b02f1ac58dbe242aa8df0ffe3adc9 blob + 11cdc0f91414165b5e7f6a99f0310fcaea4e98e6 --- fragments.tmpl +++ fragments.tmpl @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -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 @@ + {{ if path }} + {{ render tp_navigation(tp) }} + {{ end }} {{ end }} {{ define tp_foot(struct template *tp) }} @@ -86,6 +92,44 @@ gemini://{{ pc->proxy_name }}{{ path }} {{ 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); +!} +
+ +
+{{ end }} + {{ define tp_figure(struct template *tp, const char *url, const char *label) }}
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; }