[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [gopher] Proposal for a gopher++ TITLE resource



Kim Holviala <kim@holviala.com> writes:

> A proposal for a method to include titles in gopher++ menus
> ===========================================================
[...]
> 3. Conforming client requirements
>
> Conforming clients will use the first info resource with the word
> "TITLE" in the selector as the title of the menu. All following TITLE
> resources should be ignored.
>
> Non-conforming clients will see a normal info resource and present it
> as normal informational text. This provides near-perfect backwards
> compatibility.
[...]
> 6. Example code
>
> The Gophernicus Server version 0.5-beta (and later) automatically
> inserts TITLE resources for all menus where a gophermap doesn't
> exist. There is also a patch for the NSCA Mosaic 2.7ck8 gopher client
> which adds support for parsing & rendering the TITLE resources.
>
> gopher://gophernicus.org/1/software/gophernicus/server/
> gopher://gophernicus.org/1/software/patches/gopher++/

I'm attaching a patch for lynx 2.8.7 which, if the first item in the
menu is a TITLE info selector, uses its text as the menu title.

(Looking for TITLE on other lines looks harder - lynx generates html as
it reads the menu, so using *any* TITLE 'i' selector will require
caching the entire document body so the header can be written last.)

It is working with your (gophernicus.org) server, and works as expected
in servers which don't provide TITLEs.

diff -ur lynx2-8-7/WWW/Library/Implementation/HTGopher.c lynx2-8-7.gopher/WWW/Library/Implementation/HTGopher.c
--- lynx2-8-7/WWW/Library/Implementation/HTGopher.c	2008-04-28 01:10:25.000000000 +0100
+++ lynx2-8-7.gopher/WWW/Library/Implementation/HTGopher.c	2010-04-10 00:09:22.000000000 +0100
@@ -219,6 +219,7 @@
     int bytes = 0;
     int BytesReported = 0;
     char buffer[128];
+    int firstline = 1;
 
 #define TAB		'\t'
 #define HEX_ESCAPE	'%'
@@ -227,27 +228,6 @@
     PUTC('\n');
     START(HTML_HEAD);
     PUTC('\n');
-    START(HTML_TITLE);
-    if ((title = HTAnchor_title(anAnchor)))
-	PUTS(title);
-    else
-	PUTS(GOPHER_MENU_TITLE);
-    END(HTML_TITLE);
-    PUTC('\n');
-    END(HTML_HEAD);
-    PUTC('\n');
-
-    START(HTML_BODY);
-    PUTC('\n');
-    START(HTML_H1);
-    if ((title = HTAnchor_title(anAnchor)))
-	PUTS(title);
-    else
-	PUTS(GOPHER_MENU_TITLE);
-    END(HTML_H1);
-    PUTC('\n');
-    START(HTML_PRE);
-    PUTC('\n');			/* newline after HTML_PRE forces split-line */
     while ((ich = NEXT_CHAR) != EOF) {
 
 	if (interrupted_in_htgetcharacter) {
@@ -311,6 +291,56 @@
 		}		/* selector ok */
 	    }
 	    /* gtype and name ok */
+
+	    /* This is a basic implementation for gopher menu title as
+	       proposed in gmane.network.gopher.general by Kim
+	       Holviala (message-id:
+	       <[🔎] 4BB486C6.9040308@holviala.com>). 
+
+	       As lynx writes the HTML while reading from the stream,
+	       reading TITLEs somewhere other than the first line
+	       would require bigger changes, so this works only if it
+	       is the first line of the menu. 
+
+	       The generation of the first lines of a menu (title and
+	       header) is delayed until the first LF, so that a TITLE
+	       can be detected and used.  */
+	    if (firstline) {
+	      firstline--;
+
+	      START(HTML_TITLE);
+	      if  ((gtype == GOPHER_INFO) && (strcmp(selector, "TITLE") == 0))
+		PUTS(name);
+	      else if ((title = HTAnchor_title(anAnchor)))
+		PUTS(title);
+	      else 
+		PUTS(GOPHER_MENU_TITLE);
+	      END(HTML_TITLE);
+	      PUTC('\n');
+	      END(HTML_HEAD);
+	      PUTC('\n');
+	      
+	      START(HTML_BODY);
+	      PUTC('\n');
+	      START(HTML_H1);
+	      if  ((gtype == GOPHER_INFO) && (strcmp(selector, "TITLE") == 0))
+		PUTS(name);
+	      else if ((title = HTAnchor_title(anAnchor)))
+		PUTS(title);
+	      else
+		PUTS(GOPHER_MENU_TITLE);
+	      END(HTML_H1);
+	      PUTC('\n');
+	      START(HTML_PRE);
+	      PUTC('\n');			/* newline after HTML_PRE forces split-line */
+
+	      if  ((gtype == GOPHER_INFO) && (strcmp(selector, "TITLE") == 0)) {
+		p = line;		/* Start again at beginning of line */
+		continue;
+	      }
+
+	    }
+
 	    /* Nameless files are a separator line */
 	    if (gtype == GOPHER_TEXT) {
 		int i = strlen(name) - 1;
-- 
Nuno J. Silva
gopher://sdf-eu.org/1/users/njsg
_______________________________________________
Gopher-Project mailing list
Gopher-Project@lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/gopher-project

Reply to: