Commit Diff


commit - 81c76a9aff80b7ecc421f213ee79f82424bf3e6f
commit + da7b17a31957f5c847acce17e4fa300142655db5
blob - 0a15e33f2954fcf9b6d0bb279c0b0599a680d3bf
blob + 76de0865b8ee3c20dd1d91f4218f57e97ac53a32
--- fragments.tmpl
+++ fragments.tmpl
@@ -43,6 +43,9 @@ static int tp_navigation(struct template *);
 	const char *stylesheet = pc ? pc->stylesheet : "";
 	const char *prfx = clt->clt_script_name;
 	const char *path = clt->clt_path_info;
+	int hidenav;
+
+	hidenav = pc ? pc->flags & PROXY_NO_NAVBAR : 0;
 !}
 <!doctype html>
 <html{{ if *lang != '\0' }}{{ " " }}lang="{{ lang }}"{{ end }}>
@@ -64,7 +67,7 @@ static int tp_navigation(struct template *);
 		</title>
 	</head>
 	<body>
-		{{ if path }}
+		{{ if path && !hidenav }}
 			{{ render tp_navigation(tp) }}
 		{{ end }}
 {{ end }}
@@ -74,8 +77,11 @@ static int tp_navigation(struct template *);
 	struct client *clt = tp->tp_arg;
 	struct proxy_config *pc = clt->clt_pc;
 	const char *path = clt->clt_path_info;
+	int hidefoot;
+
+	hidefoot = pc ? pc->flags & PROXY_NO_FOOTER : 0;
 !}
-	{{ if pc }}
+	{{ if pc && !hidefoot }}
 		<footer>
 			<hr />
 			<dl>
blob - b382968a9db942adec174c443bf06719ff0498d0
blob + 4ed9fdc9e3256eec835ca28442ef1ba1d296a600
--- galileo.conf.5
+++ galileo.conf.5
@@ -79,6 +79,16 @@ Defaults to
 with prepended the URL prefix on which
 .Xr galileo 8
 is served.
+.It Ic no footer
+Do not add a footer with the original link at the bottom of the
+generated page.
+.It Ic no image preview
+Do not generate a preview for links that seem to point to an image.
+.Nm galileo
+uses an heuristic to determine if a link points to an image that may
+be inappropriate and not work in some circumstances.
+.It Ic no navigation bar
+Do no add a navigation bar at the top of the generated page.
 .It Ic no tls
 Do not setup the TLS layer.
 Useful for saving some CPU cycles when connecting to a Gemini server
blob - f1018797e482f4e51f445825c3a78d6136a57f46
blob + 05a8126ae966aec99082f671e6dc52680c168fd9
--- galileo.h
+++ galileo.h
@@ -134,7 +134,12 @@ struct proxy_config {
 	char		 proxy_addr[HOST_NAME_MAX + 1];
 	char		 proxy_name[HOST_NAME_MAX + 1];
 	char		 proxy_port[6];
-	int		 no_tls;
+
+#define PROXY_NO_TLS	0x1
+#define PROXY_NO_NAVBAR	0x2
+#define PROXY_NO_FOOTER	0x4
+#define PROXY_NO_IMGPRV	0x8
+	int		 flags;
 };
 
 struct proxy {
blob - b20e39fe4baee1766139dfc9bf4ba168deea7340
blob + 2a7d767ecfaed1bbea779b8febbf78088d0f821a
--- parse.y
+++ parse.y
@@ -103,7 +103,8 @@ typedef struct {
 %}
 
 %token	INCLUDE ERROR
-%token	CHROOT HOSTNAME NO PORT PREFORK PROXY SOURCE STYLESHEET TLS
+%token	BAR CHROOT FOOTER HOSTNAME IMAGE NAVIGATION NO PORT
+%token	PREFORK PREVIEW PROXY SOURCE STYLESHEET TLS
 %token	<v.number>	NUMBER
 %token	<v.string>	STRING
 %type	<v.number>	port
@@ -245,8 +246,17 @@ proxyoptsl	: SOURCE STRING proxyport {
 				yyerror("stylesheet path too long!");
 			free($2);
 		}
+		| NO FOOTER {
+			pr->pr_conf.flags |= PROXY_NO_FOOTER;
+		}
+		| NO IMAGE PREVIEW {
+			pr->pr_conf.flags |= PROXY_NO_IMGPRV;
+		}
+		| NO NAVIGATION BAR {
+			pr->pr_conf.flags |= PROXY_NO_NAVBAR;
+		}
 		| NO TLS {
-			pr->pr_conf.no_tls = 1;
+			pr->pr_conf.flags |= PROXY_NO_TLS;
 		}
 		;
 
@@ -335,12 +345,17 @@ lookup(char *s)
 {
 	/* this has to be sorted always */
 	static const struct keywords keywords[] = {
+		{ "bar",	BAR },
 		{ "chroot",	CHROOT },
+		{ "footer",	FOOTER },
 		{ "hostname",	HOSTNAME },
+		{ "image",	IMAGE },
 		{ "include",	INCLUDE },
+		{ "navigation",	NAVIGATION },
 		{ "no",		NO },
 		{ "port",	PORT },
 		{ "prefork",	PREFORK },
+		{ "preview",	PREVIEW },
 		{ "proxy",	PROXY },
 		{ "source",	SOURCE },
 		{ "stylesheet",	STYLESHEET},
blob - 1e9c49f9a75a8d2df7623126f0a009fb8e449415
blob + e66f1f0a40e889b1640c55cd0fc138bf246ff1f7
--- proxy.c
+++ proxy.c
@@ -242,6 +242,17 @@ proxy_resurl(struct client *clt, const char *url, char
 	return (0);
 }
 
+static inline int
+match_image_heur(const char *url)
+{
+	return (fnmatch("*.jpg", url, 0) == 0 ||
+	    fnmatch("*.jpeg", url, 0) == 0 ||
+	    fnmatch("*.gif", url, 0) == 0 ||
+	    fnmatch("*.png", url, 0) == 0 ||
+	    fnmatch("*.svg", url, 0) == 0 ||
+	    fnmatch("*.webp", url, 0) == 0);
+}
+
 static int
 gemtext_translate_line(struct client *clt, char *line)
 {
@@ -309,12 +320,8 @@ gemtext_translate_line(struct client *clt, char *line)
 		else
 			url = line; /* leave the URL as it is */
 
-		if (fnmatch("*.jpg", url, 0) == 0 ||
-		    fnmatch("*.jpeg", url, 0) == 0 ||
-		    fnmatch("*.gif", url, 0) == 0 ||
-		    fnmatch("*.png", url, 0) == 0 ||
-		    fnmatch("*.svg", url, 0) == 0 ||
-		    fnmatch("*.webp", url, 0) == 0) {
+		if (!(clt->clt_pc->flags & PROXY_NO_IMGPRV) &&
+		    match_image_heur(url)) {
 			if (clt->clt_translate & TR_NAV) {
 				if (clt_puts(clt, "</ul></nav>") == -1)
 					return (-1);
@@ -590,7 +597,7 @@ done:
 		goto err;
 	}
 
-	if (!clt->clt_pc->no_tls) {
+	if (!(clt->clt_pc->flags & PROXY_NO_TLS)) {
 		/* initialize TLS for Gemini */
 		if ((conf = tls_config_new()) == NULL) {
 			log_warn("tls_config_new failed");