diff options
author | Don Scorgie <dscorgie@src.gnome.org> | 2007-04-26 20:31:41 +0000 |
---|---|---|
committer | Don Scorgie <dscorgie@src.gnome.org> | 2007-04-26 20:31:41 +0000 |
commit | cf917f0033bcf2f3715ce07b60f72eda6470118a (patch) | |
tree | e27a39fe70ba6ce63ca876c91d98f17b4eefabfc | |
parent | f422e9a667cd7e1d37a97d77dbc980d374471666 (diff) | |
download | yelp-cf917f0033bcf2f3715ce07b60f72eda6470118a.tar.gz |
Make TOC work properly with new document structure
* stylesheets/toc2html.xsl:
* src/test-document.c:
* src/yelp-toc.c:
Make TOC work properly with new document structure
* src/yelp-page.c:
* src/yelp-docbook.c:
Various misc. changes to make docbook work properly
Add TODO's
svn path=/branches/yelp-spoon/; revision=2810
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | src/test-document.c | 16 | ||||
-rw-r--r-- | src/yelp-docbook.c | 9 | ||||
-rw-r--r-- | src/yelp-page.c | 2 | ||||
-rw-r--r-- | src/yelp-toc.c | 18 | ||||
-rw-r--r-- | stylesheets/toc2html.xsl | 4 |
6 files changed, 41 insertions, 20 deletions
@@ -1,3 +1,15 @@ +2007-04-26 Don Scorgie <dscorgie@cvs.gnome.org> + + * stylesheets/toc2html.xsl: + * src/test-document.c: + * src/yelp-toc.c: + Make TOC work properly with new document structure + + * src/yelp-page.c: + * src/yelp-docbook.c: + Various misc. changes to make docbook work properly + Add TODO's + 2007-04-24 Don Scorgie <dscorgie@cvs.gnome.org> * src/yelp-toc.c: diff --git a/src/test-document.c b/src/test-document.c index 1cf1cc9e..e83d0990 100644 --- a/src/test-document.c +++ b/src/test-document.c @@ -27,6 +27,7 @@ #include "yelp-error.h" #include "yelp-docbook.h" #include "yelp-man.h" +#include "yelp-toc.h" static gchar *mode = NULL; static gchar **files = NULL; @@ -34,7 +35,7 @@ static const GOptionEntry options[] = { { "mode", 'm', 0, G_OPTION_ARG_STRING, &mode, - "One of man or docbook", "MODE" }, + "One of man, docbook or toc", "MODE" }, { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &files, NULL, NULL }, @@ -125,12 +126,19 @@ main (gint argc, gchar **argv) return 3; } - if (files == NULL || files[1] == NULL) + if ((files == NULL || files[1] == NULL) && (!g_str_equal (mode, "toc"))) yelp_document_get_page (document, "x-yelp-index", (YelpDocumentFunc) document_func, NULL); - else + else if (!g_str_equal (mode, "toc")) { for (i = 1; files[i]; i++) yelp_document_get_page (document, files[i], (YelpDocumentFunc) document_func, NULL); - + } else { + if (files) { + for (i = 0; files[i]; i++) + yelp_document_get_page (document, files[i], (YelpDocumentFunc) document_func, NULL); + } else { + yelp_document_get_page (document, "index", (YelpDocumentFunc) document_func, NULL); + } + } loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (loop); diff --git a/src/yelp-docbook.c b/src/yelp-docbook.c index 384c6a40..ed33ccb7 100644 --- a/src/yelp-docbook.c +++ b/src/yelp-docbook.c @@ -240,11 +240,11 @@ docbook_request (YelpDocument *document, debug_print (DB_FUNCTION, "entering\n"); debug_print (DB_ARG, " req_id = %i\n", req_id); debug_print (DB_ARG, " page_id = \"%s\"\n", page_id); - g_assert (document != NULL && YELP_IS_DOCBOOK (document)); - if (handled) + if (handled) { return; + } docbook = YELP_DOCBOOK (document); priv = docbook->priv; @@ -282,7 +282,6 @@ transform_func (YelpTransform *transform, YelpDocbook *docbook) { YelpDocbookPriv *priv; - debug_print (DB_FUNCTION, "entering\n"); g_assert (docbook != NULL && YELP_IS_DOCBOOK (docbook)); @@ -338,7 +337,6 @@ transform_page_func (YelpTransform *transform, g_mutex_lock (priv->mutex); content = yelp_transform_eat_chunk (transform, page_id); - yelp_document_add_page (YELP_DOCUMENT (docbook), page_id, content); g_free (page_id); @@ -461,6 +459,7 @@ docbook_process (YelpDocbook *docbook) g_mutex_unlock (priv->mutex); goto done; } + g_mutex_unlock (priv->mutex); docbook_walk (docbook); @@ -469,7 +468,6 @@ docbook_process (YelpDocbook *docbook) g_mutex_unlock (priv->mutex); goto done; } - priv->transform = yelp_transform_new (STYLESHEET, (YelpTransformFunc) transform_func, docbook); @@ -583,7 +581,6 @@ docbook_walk (YelpDocbook *docbook) docbook_walk (docbook); } } - priv->cur_depth--; priv->xmlcur = old_cur; diff --git a/src/yelp-page.c b/src/yelp-page.c index 1a3e6b9b..00fce62d 100644 --- a/src/yelp-page.c +++ b/src/yelp-page.c @@ -86,7 +86,9 @@ page_read_string (YelpPage *page, { g_return_val_if_fail (page != NULL, G_IO_STATUS_ERROR); + if (page->content_offset == page->content_len) { + /* FIXME: set the error */ return G_IO_STATUS_EOF; } else if (page->content_offset > page->content_len) { diff --git a/src/yelp-toc.c b/src/yelp-toc.c index 5d8656cf..8f80481a 100644 --- a/src/yelp-toc.c +++ b/src/yelp-toc.c @@ -307,7 +307,6 @@ transform_page_func (YelpTransform *transform, { YelpTocPriv *priv; gchar *content; - debug_print (DB_FUNCTION, "entering\n"); priv = toc->priv; @@ -357,13 +356,12 @@ spoon_add_document (void *reg, void * user_data) xmlNodePtr node = (xmlNodePtr) user_data; SpoonReg *r = (SpoonReg *) reg; xmlNodePtr new; - gchar tmp[10]; - + gchar *tmp; new = xmlNewChild (node, NULL, BAD_CAST "doc", NULL); xmlNewNsProp (new, NULL, BAD_CAST "href", BAD_CAST r->uri); xmlNewTextChild (new, NULL, BAD_CAST "title", BAD_CAST r->name); xmlNewTextChild (new, NULL, BAD_CAST "description", BAD_CAST r->comment); - g_sprintf (&tmp, "%d", r->weight); + tmp = g_strdup_printf ("%d", r->weight); xmlNewNsProp (new, NULL, BAD_CAST "weight", BAD_CAST tmp); return FALSE; } @@ -381,7 +379,6 @@ toc_process (YelpToc *toc) xmlXPathContextPtr xpath; xmlXPathObjectPtr obj; gint i, ret; - debug_print (DB_FUNCTION, "entering\n"); g_assert (toc != NULL && YELP_IS_TOC (toc)); @@ -414,7 +411,10 @@ toc_process (YelpToc *toc) xml_trim_titles (node, BAD_CAST "title"); xml_trim_titles (node, BAD_CAST "description"); - icon = xmlGetProp (node, BAD_CAST "icon"); + /* FIXME: Once hooked up properly into yelp, uncomment + * to make the nice shiny icon appear + */ + /*icon = xmlGetProp (node, BAD_CAST "icon");*/ if (icon) { GtkIconInfo *info; GtkIconTheme *theme = @@ -444,12 +444,15 @@ toc_process (YelpToc *toc) xmlChar *id = xmlTextReaderGetAttribute (reader, BAD_CAST "id"); xmlNodePtr node; gchar *xpath_s; - if (!id) { ret = xmlTextReaderRead (reader); continue; } + g_mutex_lock (priv->mutex); + + yelp_document_add_page_id (YELP_DOCUMENT (toc), (gchar *) id, (gchar *) id); + g_mutex_unlock (priv->mutex); xpath_s = g_strdup_printf ("//toc[@id = '%s']", id); obj = xmlXPathEvalExpression (BAD_CAST xpath_s, xpath); g_free (xpath_s); @@ -496,6 +499,7 @@ toc_process (YelpToc *toc) toc); priv->transform_running = TRUE; /* FIXME: we probably need to set our own params */ + yelp_transform_start (priv->transform, priv->xmldoc, NULL); diff --git a/stylesheets/toc2html.xsl b/stylesheets/toc2html.xsl index 0fa28cd7..4aa7711a 100644 --- a/stylesheets/toc2html.xsl +++ b/stylesheets/toc2html.xsl @@ -28,8 +28,6 @@ <xsl:param name="yelp.color.admon.bg.dark2"/> <xsl:param name="yelp.color.admon.bg.dark3"/> -<xsl:param name="yelp.toc.id" select="'Man-man6'"/> - <xsl:template match="toc"> <yelp:document href="{@id}"> <html> @@ -262,7 +260,7 @@ </xsl:template> <xsl:template match="/"> - <xsl:apply-templates select="//toc[@id = $yelp.toc.id]" /> + <xsl:apply-templates select="//toc" /> </xsl:template> </xsl:stylesheet> |