diff options
Diffstat (limited to 'src/yelp-reader.c')
-rw-r--r-- | src/yelp-reader.c | 121 |
1 files changed, 41 insertions, 80 deletions
diff --git a/src/yelp-reader.c b/src/yelp-reader.c index 6eac8e80..b018fd7b 100644 --- a/src/yelp-reader.c +++ b/src/yelp-reader.c @@ -94,7 +94,7 @@ static void reader_q_data_free (ReaderQueueData *q_data); static void reader_th_data_free (ReaderThreadData *th_data); #endif static gchar * reader_get_chunk (const gchar *document, - YelpURI *uri); + const gchar *section); static gchar * reader_look_for_cached_help_file (const gchar *url); @@ -261,15 +261,9 @@ reader_convert_start (ReaderThreadData *th_data) break; case YELP_URI_TYPE_DOCBOOK_XML: case YELP_URI_TYPE_DOCBOOK_SGML: - 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)); - } + command_line = g_strdup_printf ("%s/yelp-db2html %s", + SERVERDIR, + yelp_uri_get_path (uri)); break; default: /* Set error */ @@ -318,7 +312,14 @@ reader_convert_start (ReaderThreadData *th_data) yelp_uri_get_type (uri) == YELP_URI_TYPE_DOCBOOK_SGML) { gchar *chunk; - chunk = reader_get_chunk (q_data->data, uri); + 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"); + } g_free (q_data->data); q_data->data = chunk; @@ -633,30 +634,25 @@ reader_th_data_free (ReaderThreadData *th_data) #endif static gchar * -reader_get_chunk (const gchar *document, YelpURI *uri) +reader_get_chunk (const gchar *document, const gchar *section) { - 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"; + 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 (); end = strstr (document, "<!-- End of header -->"); if (!end) { +/* g_warning ("Wrong type of document\n"); */ return g_strdup (document); } @@ -667,6 +663,7 @@ reader_get_chunk (const gchar *document, YelpURI *uri) g_free (tag); if (!start) { +/* g_warning ("Document doesn't include section: '%s'", section); */ g_free (header); return g_strdup (document); @@ -675,6 +672,8 @@ reader_get_chunk (const gchar *document, YelpURI *uri) end = strstr (start, "<!-- End of chunk -->"); if (!end) { +/* g_warning ("Document is doesn't contain end tag for section: %s", */ +/* section); */ g_free (header); return g_strdup (document); @@ -685,59 +684,15 @@ reader_get_chunk (const gchar *document, YelpURI *uri) footer = strstr (document, "<!-- Start of footer -->"); if (!footer) { +/* g_warning ("Couldn't find footer in document"); */ g_free (header); g_free (chunk); return g_strdup (document); } - - links = yelp_cache_lookup_links (yelp_uri_to_string (uri)); - - if (!links) { - nav_top = ""; - nav_bottom = ""; - } else { - nav_top = g_strconcat ("<table width='100%'><tr>", - "<td width='40%' align='left'>", - "<a accesskey='p' href='", - links->prev_link_uri, "'>", - links->prev_link_title, - "</a></td>", - "<td width='40%' align='right'>", - "<a accesskey='n' href='", - links->next_link_uri, "'>", - links->next_link_title, - "</a></td>", - "</tr></table>", - "<hr>", - NULL); - nav_bottom = g_strconcat ("<hr class='bottom'>", - "<table width='100%'><tr>", - "<td width='40%' align='left'>", - "<a accesskey='p' href='", - links->prev_link_uri, "'>", - links->prev_link_title, - "</a><br>", - links->prev_link_text, - "</td>", - "<td width='20%' align='center'>", - "<a accesskey='u' href='", - links->up_link_uri, "'>", - links->up_link_title, - "</a></td>", - "<td width='40%' align='right'>", - "<a accesskey='n' href='", - links->next_link_uri, "'>", - links->next_link_title, - "</a><br>", - links->next_link_text, - "</td>", - "</tr></table>", - NULL); - } - - ret_val = g_strconcat (header, nav_top, chunk, nav_bottom, footer, NULL); - + + ret_val = g_strconcat (header, chunk, footer, NULL); + g_free (header); g_free (chunk); @@ -947,8 +902,14 @@ yelp_reader_start (YelpReader *reader, YelpURI *uri) } else { document = read_document; } - - chunk = reader_get_chunk (document, new_uri); + + if (yelp_uri_get_section (new_uri) && + strcmp (yelp_uri_get_section (new_uri), "")) { + chunk = reader_get_chunk (document, + yelp_uri_get_section (new_uri)); + } else { + chunk = reader_get_chunk (document, "toc"); + } g_free (read_document); yelp_uri_unref (new_uri); |