? yelp-shaunm-030816-0.diff Index: src/yelp-cache.c =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-cache.c,v retrieving revision 1.2 diff -u -r1.2 yelp-cache.c --- src/yelp-cache.c 13 Jun 2003 17:15:00 -0000 1.2 +++ src/yelp-cache.c 16 Aug 2003 22:04:15 -0000 @@ -30,11 +30,17 @@ GHashTable *cache_table; GMutex *cache_mutex; +GHashTable *links_table; +GMutex *links_mutex; + void yelp_cache_init (void) { cache_mutex = g_mutex_new (); cache_table = g_hash_table_new (g_str_hash, g_str_equal); + + links_mutex = g_mutex_new (); + links_table = g_hash_table_new (g_str_hash, g_str_equal); } const gchar * @@ -51,6 +57,20 @@ return ret_val; } +YelpNavLinks * +yelp_cache_lookup_links (const gchar *path) +{ + YelpNavLinks *ret_val; + + g_mutex_lock (links_mutex); + + ret_val = (YelpNavLinks *) g_hash_table_lookup (links_table, path); + + g_mutex_unlock (links_mutex); + + return ret_val; +} + void yelp_cache_add (const gchar *path, const gchar *html) { @@ -59,4 +79,16 @@ g_hash_table_insert (cache_table, (gchar *) path, g_strdup (html)); g_mutex_unlock (cache_mutex); +} + +void +yelp_cache_add_links (const gchar *path, const YelpNavLinks *links) +{ + YelpNavLinks *new_links; + + g_mutex_lock (links_mutex); + + g_hash_table_insert (links_table, (gchar *) path, links); + + g_mutex_unlock (links_mutex); } Index: src/yelp-cache.h =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-cache.h,v retrieving revision 1.2 diff -u -r1.2 yelp-cache.h --- src/yelp-cache.h 13 Jun 2003 17:15:00 -0000 1.2 +++ src/yelp-cache.h 16 Aug 2003 22:04:15 -0000 @@ -27,10 +27,31 @@ #include "yelp-uri.h" +typedef struct _YelpNavLinks YelpNavLinks; + +#define YELP_NAV_LINKS(x) ((YelpNavLinks *) x) + +struct _YelpNavLinks { + gchar *prev_link_uri; + gchar *next_link_uri; + gchar *prev_link_title; + gchar *next_link_title; + gchar *prev_link_text; + gchar *next_link_text; + gchar *up_link_uri; + gchar *up_link_title; +}; + void yelp_cache_init (void); const gchar * yelp_cache_lookup (const gchar *path); void yelp_cache_add (const gchar *path, const gchar *html); + +YelpNavLinks * yelp_cache_lookup_links (const gchar *path); + +void yelp_cache_add_links (const gchar *path, + const YelpNavLinks *links); + #endif /* __YELP_CACHE_H__ */ Index: src/yelp-db2html.c =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-db2html.c,v retrieving revision 1.27 diff -u -r1.27 yelp-db2html.c --- src/yelp-db2html.c 24 Jul 2003 06:18:35 -0000 1.27 +++ src/yelp-db2html.c 16 Aug 2003 22:04:15 -0000 @@ -66,16 +66,28 @@ const gchar *params[16 + 1]; gchar *pathname; gchar *docpath; + gboolean gen_links; db_doc = NULL; putenv ("XML_CATALOG_FILES=" DATADIR "/yelp/catalog"); if (argc < 2) { - g_print ("Usage 'yelp-db2html url'\n"); + g_print ("Usage 'yelp-db2html [-n] url'\n"); exit (1); } - docpath = argv[1]; + if (!strcmp (argv[1], "-n")) { + if (argc < 3) { + g_print ("Usage 'yelp-db2html [-n] url'\n"); + exit (1); + } + + docpath = argv[2]; + gen_links = FALSE; + } else { + docpath = argv[1]; + gen_links = TRUE; + } if (!g_file_test (docpath, G_FILE_TEST_EXISTS)) { g_warning ("'%s' doesn't exist.", docpath); @@ -126,7 +138,7 @@ params[6] = "yelp_max_chunk_depth"; params[7] = "2"; params[8] = "yelp_generate_navbar"; - params[9] = "1"; + params[9] = (gen_links ? "1" : "0"); params[10] = "yelp_chunk_method"; params[11] = "'yelp'"; params[12] = NULL; Index: src/yelp-reader.c =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-reader.c,v retrieving revision 1.28 diff -u -r1.28 yelp-reader.c --- src/yelp-reader.c 8 Jul 2003 12:05:49 -0000 1.28 +++ src/yelp-reader.c 16 Aug 2003 22:04:17 -0000 @@ -94,7 +94,7 @@ static void reader_th_data_free (ReaderThreadData *th_data); #endif static gchar * reader_get_chunk (const gchar *document, - const gchar *section); + YelpURI *uri); static gchar * reader_look_for_cached_help_file (const gchar *url); @@ -261,9 +261,15 @@ break; case YELP_URI_TYPE_DOCBOOK_XML: case YELP_URI_TYPE_DOCBOOK_SGML: - command_line = g_strdup_printf ("%s/yelp-db2html %s", - SERVERDIR, - yelp_uri_get_path (uri)); + if (yelp_cache_lookup_links (yelp_uri_to_string (uri))) { + command_line = g_strdup_printf ("%s/yelp-db2html -n %s", + SERVERDIR, + yelp_uri_get_path (uri)); + } else { + command_line = g_strdup_printf ("%s/yelp-db2html %s", + SERVERDIR, + yelp_uri_get_path (uri)); + } break; default: /* Set error */ @@ -312,14 +318,7 @@ yelp_uri_get_type (uri) == YELP_URI_TYPE_DOCBOOK_SGML) { gchar *chunk; - if (yelp_uri_get_section (uri) && - strcmp (yelp_uri_get_section (uri), "")) { - chunk = reader_get_chunk (q_data->data, - yelp_uri_get_section (uri)); - } else { - chunk = reader_get_chunk (q_data->data, - "toc"); - } + chunk = reader_get_chunk (q_data->data, uri); g_free (q_data->data); q_data->data = chunk; @@ -634,25 +633,30 @@ #endif static gchar * -reader_get_chunk (const gchar *document, const gchar *section) +reader_get_chunk (const gchar *document, YelpURI *uri) { - gchar *header; - gchar *chunk; - const gchar *footer; - gchar *ret_val; - const gchar *start; - const gchar *end; - gchar *tag; - GTimer *timer; - -/* g_print ("%s\n", document); */ - - timer = g_timer_new (); + const gchar *section; + gchar *header; + gchar *chunk; + const gchar *footer; + gchar *ret_val; + const gchar *start; + const gchar *end; + gchar *tag; + GTimer *timer; + YelpNavLinks *links; + const gchar *nav_top; + const gchar *nav_bottom; + + // timer = g_timer_new (); + + section = yelp_uri_get_section (uri); + if (!section || !strcmp (section, "")) + section = "toc"; end = strstr (document, ""); if (!end) { -/* g_warning ("Wrong type of document\n"); */ return g_strdup (document); } @@ -663,7 +667,6 @@ g_free (tag); if (!start) { -/* g_warning ("Document doesn't include section: '%s'", section); */ g_free (header); return g_strdup (document); @@ -672,8 +675,6 @@ end = strstr (start, ""); if (!end) { -/* g_warning ("Document is doesn't contain end tag for section: %s", */ -/* section); */ g_free (header); return g_strdup (document); @@ -684,15 +685,59 @@ footer = strstr (document, ""); if (!footer) { -/* g_warning ("Couldn't find footer in document"); */ g_free (header); g_free (chunk); return g_strdup (document); } - - ret_val = g_strconcat (header, chunk, footer, NULL); - + + links = yelp_cache_lookup_links (yelp_uri_to_string (uri)); + + if (!links) { + nav_top = ""; + nav_bottom = ""; + } else { + nav_top = g_strconcat ("
", + "", + links->prev_link_title, + " | ", + "", + "", + links->next_link_title, + " | ", + "
",
+ "",
+ links->prev_link_title,
+ " ", + links->prev_link_text, + " | ",
+ "", + "", + links->up_link_title, + " | ", + "",
+ "",
+ links->next_link_title,
+ " ", + links->next_link_text, + " | ",
+ "