lynx-dev
[Top][All Lists]
Advanced

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

lynx-dev 2.8.2dev.17 patch 1 - L-page


From: Klaus Weide
Subject: lynx-dev 2.8.2dev.17 patch 1 - L-page
Date: Tue, 23 Feb 1999 08:05:19 -0600 (CST)

Patch to avoid the confusing titles set by <LINK REL="next"> etc.

This change is conservative: Only LINK tags with certain REL
attributes are affected, LINK tags with explicit TITLE attribute
are not, handling of A not changed.  Could be extended to more
REL values, or otherwise changed according to better taste.

   Klaus


* Changed the effect of some LINK tags with REL attribute of a very
  relative character (Up, Next, Prev, ...) on titles as they appear
  e.g. on the LIST page:  the title of the target HTParentAnchor isn't
  being set when such a LINK tag is parsed, but the relation is now
  stored as a property of the link itself rather than its destination.
  The LIST page shows the relation as additional info, not superseding
  a URL or title string obtained otherwise.
  
--- lynx2-8-2.old/src/HTML.c    Wed Feb 17 08:29:32 1999
+++ lynx2-8-2/src/HTML.c        Tue Feb 23 07:48:06 1999
@@ -656,6 +656,7 @@
     char *alt_string = NULL;
     char *id_string = NULL;
     char *newtitle = NULL;
+    char **pdoctitle = NULL;
     char *href = NULL;
     char *map_href = NULL;
     char *title = NULL;
@@ -1005,10 +1006,6 @@
                    !strcasecomp(value[HTML_LINK_REL], "Index") ||
                    !strcasecomp(value[HTML_LINK_REL], "Glossary") ||
                    !strcasecomp(value[HTML_LINK_REL], "Copyright") ||
-                   !strcasecomp(value[HTML_LINK_REL], "Up") ||
-                   !strcasecomp(value[HTML_LINK_REL], "Next") ||
-                   !strcasecomp(value[HTML_LINK_REL], "Previous") ||
-                   !strcasecomp(value[HTML_LINK_REL], "Prev") ||
                    !strcasecomp(value[HTML_LINK_REL], "Help") ||
                    !strcasecomp(value[HTML_LINK_REL], "Search") ||
                    !strcasecomp(value[HTML_LINK_REL], "Bookmark") ||
@@ -1016,29 +1013,46 @@
                    !strcasecomp(value[HTML_LINK_REL], "Top") ||
                    !strcasecomp(value[HTML_LINK_REL], "Origin") ||
                    !strcasecomp(value[HTML_LINK_REL], "Navigator") ||
-                   !strcasecomp(value[HTML_LINK_REL], "Child") ||
                    !strcasecomp(value[HTML_LINK_REL], "Disclaimer") ||
-                   !strcasecomp(value[HTML_LINK_REL], "Sibling") ||
-                   !strcasecomp(value[HTML_LINK_REL], "Parent") ||
                    !strcasecomp(value[HTML_LINK_REL], "Author") ||
                    !strcasecomp(value[HTML_LINK_REL], "Editor") ||
                    !strcasecomp(value[HTML_LINK_REL], "Publisher") ||
                    !strcasecomp(value[HTML_LINK_REL], "Trademark") ||
-                   !strcasecomp(value[HTML_LINK_REL], "Meta") ||
-                   !strcasecomp(value[HTML_LINK_REL], "URC") ||
                    !strcasecomp(value[HTML_LINK_REL], "Hotlist") ||
                    !strcasecomp(value[HTML_LINK_REL], "Begin") ||
                    !strcasecomp(value[HTML_LINK_REL], "First") ||
                    !strcasecomp(value[HTML_LINK_REL], "End") ||
                    !strcasecomp(value[HTML_LINK_REL], "Last") ||
-                   !strcasecomp(value[HTML_LINK_REL], "Pointer") ||
-                   !strcasecomp(value[HTML_LINK_REL], "Translation") ||
-                   !strcasecomp(value[HTML_LINK_REL], "Definition") ||
-                   !strcasecomp(value[HTML_LINK_REL], "Chapter") ||
                    !strcasecomp(value[HTML_LINK_REL], "Documentation") ||
                    !strcasecomp(value[HTML_LINK_REL], "Biblioentry") ||
                    !strcasecomp(value[HTML_LINK_REL], "Bibliography")) {
                    StrAllocCopy(title, value[HTML_LINK_REL]);
+                   pdoctitle = &title; /* for setting HTAnchor's title */
+               } else
+               if (!strcasecomp(value[HTML_LINK_REL], "Up") ||
+                   !strcasecomp(value[HTML_LINK_REL], "Next") ||
+                   !strcasecomp(value[HTML_LINK_REL], "Previous") ||
+                   !strcasecomp(value[HTML_LINK_REL], "Prev") ||
+                   !strcasecomp(value[HTML_LINK_REL], "Child") ||
+                   !strcasecomp(value[HTML_LINK_REL], "Sibling") ||
+                   !strcasecomp(value[HTML_LINK_REL], "Parent") ||
+                   !strcasecomp(value[HTML_LINK_REL], "Meta") ||
+                   !strcasecomp(value[HTML_LINK_REL], "URC") ||
+                   !strcasecomp(value[HTML_LINK_REL], "Pointer") ||
+                   !strcasecomp(value[HTML_LINK_REL], "Translation") ||
+                   !strcasecomp(value[HTML_LINK_REL], "Definition") ||
+                   !strcasecomp(value[HTML_LINK_REL], "Chapter")) {
+                   StrAllocCopy(title, value[HTML_LINK_REL]);
+                   /* not setting target HTAnchor's title, for these
+                      link of highly relative character.  Instead,
+                      try to remember the REL attribute as a property
+                      of the link (but not the destination), in the
+                      (otherwise underused) link type in a special format;
+                      the LIST page generation code may later use it. - kw */
+                   if (!intern_flag) {
+                       StrAllocCopy(temp, "RelTitle: ");
+                       StrAllocCat(temp, value[HTML_LINK_REL]);
+                   }
                } else {
                    CTRACE(tfp, "HTML: LINK with REL=\"%s\" ignored.\n",
                                 value[HTML_LINK_REL]);
@@ -1064,6 +1078,7 @@
                break;
            }
            StrAllocCopy(title, value[HTML_LINK_REL]);
+           pdoctitle = &title;
        }
        if (href) {
            /*
@@ -1077,6 +1092,8 @@
                TRANSLATE_AND_UNESCAPE_ENTITIES(&title, TRUE, FALSE);
                LYTrimHead(title);
                LYTrimTail(title);
+               pdoctitle = &title;
+               FREE(temp); /* forget about recording RelTitle - kw */
            }
            if (!(title && *title)) {
                FREE(href);
@@ -1103,12 +1120,14 @@
                                me->node_anchor,        /* Parent */
                                NULL,                   /* Tag */
                                href,                   /* Addresss */
-                               INTERN_LT);             /* Type */
+                               temp ?
+       (HTLinkType*)HTAtom_for(temp) : INTERN_LT);     /* Type */
+           FREE(temp);
            if ((dest = HTAnchor_parent(
                            HTAnchor_followMainLink((HTAnchor*)me->CurrentA)
                                      )) != NULL) {
-               if (!HTAnchor_title(dest))
-                   HTAnchor_setTitle(dest, title);
+               if (pdoctitle && !HTAnchor_title(dest))
+                   HTAnchor_setTitle(dest, *pdoctitle);
                dest = NULL;
                if (present[HTML_LINK_CHARSET] &&
                    value[HTML_LINK_CHARSET] && *value[HTML_LINK_CHARSET] != 
'\0') {
--- lynx2-8-2.old/WWW/Library/Implementation/HTAnchor.c Mon Feb  8 04:32:58 1999
+++ lynx2-8-2/WWW/Library/Implementation/HTAnchor.c     Tue Feb 16 00:20:41 1999
@@ -901,11 +901,21 @@
     int i;
 
     if (me) {
-       StrAllocCopy(me->title, title);
-       for (i = 0; me->title[i]; i++) {
-           if ((unsigned char)me->title[i] == 1 ||
-               (unsigned char)me->title[i] == 2) {
-               me->title[i] = ' ';
+       if (title) {
+           StrAllocCopy(me->title, title);
+           for (i = 0; me->title[i]; i++) {
+               if ((unsigned char)me->title[i] == 1 ||
+                   (unsigned char)me->title[i] == 2) {
+                   me->title[i] = ' ';
+               }
+           }
+       } else {
+           CTRACE(tfp,"HTAnchor_setTitle: New title is NULL! ");
+           if (me->title) {
+               CTRACE(tfp,"Old title was \"%s\".\n", me->title);
+               FREE(me->title);
+           } else {
+               CTRACE(tfp,"Old title was NULL.\n");
            }
        }
     }

reply via email to

[Prev in Thread] Current Thread [Next in Thread]