render images inline - gopherproxy-c - Gopher HTTP proxy in C (CGI)
(HTM) git clone git://git.codemadness.org/gopherproxy-c
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 4c9fcc17502735ad031ee12215fb441c2c27a42f
(DIR) parent e96ccc93928250ede30995cff7bf0e11758b2602
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Wed, 9 Jul 2025 19:34:43 +0200
render images inline
Patch by kroovy <me@kroovy.de>:
gopher://kroovy.de/1/phlog/inline-images-patch.gph
With some modifications.
Diffstat:
M gopherproxy.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
---
(DIR) diff --git a/gopherproxy.c b/gopherproxy.c
@@ -388,6 +388,18 @@ servedir(const char *server, const char *port, const char *path, const char *que
xmlencode(v.username);
fputs("</a>", stdout);
break;
+ case 'I': /* image: show inline */
+ fputs(typestr(v._type), stdout);
+ fputs(" <a href=\"?q=", stdout);
+ encodeparam(uri);
+ fputs("\">", stdout);
+
+ fputs("<img src=\"?q=", stdout);
+ encodeparam(uri);
+ fputs("\" width=\"400\">", stdout);
+
+ fputs("</a>", stdout);
+ break;
default: /* other */
fputs(typestr(v._type), stdout);
fputs(" <a href=\"", stdout);
@@ -731,7 +743,7 @@ main(void)
fputs(
"Gopher HTTP proxy</title>\n"
"<style type=\"text/css\">\n"
- "a { text-decoration: none; } a:hover { text-decoration: underline; }\n"
+ "a { text-decoration: none; } a:hover { text-decoration: underline; } img { vertical-align: middle; }\n"
"@media (prefers-color-scheme: dark) { body { background-color: #000; color: #bdbdbd; color-scheme: dark; } a { color: #56c8ff; } }\n"
"</style>\n"
"<meta name=\"robots\" content=\"noindex, nofollow\" />\n"