* Fixes to wiki view to handle "short" links.
authorArt Cancro <ajc@citadel.org>
Tue, 24 Jan 2006 18:56:57 +0000 (18:56 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 24 Jan 2006 18:56:57 +0000 (18:56 +0000)
webcit/ChangeLog
webcit/html2html.c
webcit/messages.c
webcit/rss.c
webcit/webcit.h

index da81745bd689db45ae97d8cb073b01d4b038bd93..cfe173af9369bc37f3bd297c09aceb5b3c96f25d 100644 (file)
@@ -1,5 +1,8 @@
 $Id$
 
+Tue Jan 24 13:56:03 EST 2006 ajc
+* Fixes to wiki view to handle "short" links.
+
 Tue Jan 24 11:07:04 EST 2006 ajc
 * client_getln() now fails if the client attempts to transmit non printable
   characters.   This is for fast bailout if someone tries to do HTTPS to a
index 794f69165c15eb302f1a9cfc92722434bcb504e9..6992c406272c77e90c4811a2174e48462c61503c 100644 (file)
@@ -17,7 +17,7 @@
  * Also convert weird character sets to UTF-8 if necessary.
  * \param charset the input charset
  */
-void output_html(char *charset) {
+void output_html(char *charset, int treat_as_wiki) {
        char buf[SIZ];
        char *msg;
        char *ptr;
@@ -151,14 +151,32 @@ void output_html(char *charset) {
                        ptr = &ptr[16];
                        ++alevel;
                }
-               /** Make links open in a separate window */
+               /** Make external links open in a separate window */
                else if (!strncasecmp(ptr, "<a href=", 8)) {
-                       content_length += 64;
-                       converted_msg = realloc(converted_msg, content_length);
-                       sprintf(&converted_msg[output_length], new_window);
-                       output_length += strlen(new_window);
-                       ptr = &ptr[8];
                        ++alevel;
+                       if ( ((strchr(ptr, ':') < strchr(ptr, '/')))
+                            &&  ((strchr(ptr, '/') < strchr(ptr, '>'))) 
+                            ) {
+                               /* open external links to new window */
+                               content_length += 64;
+                               converted_msg = realloc(converted_msg, content_length);
+                               sprintf(&converted_msg[output_length], new_window);
+                               output_length += strlen(new_window);
+                               ptr = &ptr[8];
+                       }
+                       else if ( (treat_as_wiki) && (strncasecmp(ptr, "<a href=\"wiki?", 14)) ) {
+                               lprintf(9, "converting wiki link\n");
+                               content_length += 64;
+                               converted_msg = realloc(converted_msg, content_length);
+                               sprintf(&converted_msg[output_length], "<a href=\"wiki?page=");
+                               output_length += 19;
+                               ptr = &ptr[9];
+                       }
+                       else {
+                               sprintf(&converted_msg[output_length], "<a href=");
+                               output_length += 8;
+                               ptr = &ptr[8];
+                       }
                }
                /**
                 * Turn anything that looks like a URL into a real link, as long
index 9dc54cfcd6afa6f7727cda8aa410715e9c7c3939..84689122c86bc7ff9a4d55d3f5c818b5be32e089 100644 (file)
@@ -942,7 +942,7 @@ void read_message(long msgnum, int printable_view, char *section) {
 
        else /** HTML is fun, but we've got to strip it first */
        if (!strcasecmp(mime_content_type, "text/html")) {
-               output_html(mime_charset);
+               output_html(mime_charset, (WC->wc_view == VIEW_WIKI ? 1 : 0));
        }
 
        /** Unknown weirdness */
index ba1116432db90c338a5a35dac9638e4803a73f30..48a7ad9a46a1331a52fd39c888d34db5c4242e79 100644 (file)
@@ -328,7 +328,7 @@ void display_rss(char *roomname, char *request_method)
                /** HTML is fun, but we've got to strip it first */
                else if (!strcasecmp(content_type, "text/html")) {
                        wprintf("      <description><![CDATA[");
-                       output_html(charset);
+                       output_html(charset, 0);
                        wprintf("]]></description>\n");
                }
 
index 93ec4e3d20643533da1e3700fce31c4c13b0b530..22ec3a3cfe626f2604d0a8ddc09ddec96f949312 100644 (file)
@@ -477,6 +477,7 @@ void embed_main_menu(void);
 void serv_read(char *buf, int bytes);
 int haschar(char *, char);
 void readloop(char *oper);
+void read_message(long msgnum, int printable_view, char *section);
 void embed_message(char *msgnum_as_string);
 void print_message(char *msgnum_as_string);
 void display_headers(char *msgnum_as_string);
@@ -586,7 +587,7 @@ void display_addressbook(long msgnum, char alpha);
 void offer_start_page(void);
 void convenience_page(char *titlebarcolor, char *titlebarmsg, char *messagetext);
 void change_start_page(void);
-void output_html(char *);
+void output_html(char *, int);
 void display_floorconfig(char *);
 void delete_floor(void);
 void create_floor(void);