[yelp] [info2html] Link trails in info documents



commit 7ac0dfbc56a86a23db41181b19ccb60981377a0c
Author: Shaun McCance <shaunm gnome org>
Date:   Tue Apr 27 14:11:03 2010 -0500

    [info2html] Link trails in info documents

 libyelp/yelp-info-parser.c   |   13 +++++++++++--
 stylesheets/info2html.xsl.in |   24 +++++++++++++++++++++++-
 2 files changed, 34 insertions(+), 3 deletions(-)
---
diff --git a/libyelp/yelp-info-parser.c b/libyelp/yelp-info-parser.c
index e6f58df..cbca0e4 100644
--- a/libyelp/yelp-info-parser.c
+++ b/libyelp/yelp-info-parser.c
@@ -567,7 +567,7 @@ process_page (GtkTreeStore *tree, GHashTable *nodes2offsets,
 	  }
 	
 	/* by this point our parent and older sibling should be processed */
-	if (!up || !g_ascii_strcasecmp (up, "(dir)") || !strcmp (up, "Top"))
+	if (!up || !g_ascii_strcasecmp (up, "(dir)"))
 	{
 	  debug_print (DB_DEBUG, "\t> no parent\n");
 		if (!prev || !g_ascii_strcasecmp (prev, "(dir)"))
@@ -817,7 +817,7 @@ GtkTreeStore
 static void
 parse_tree_level (GtkTreeStore *tree, xmlNodePtr *node, GtkTreeIter iter)
 {
-	GtkTreeIter children;
+    GtkTreeIter children, parent;
 	xmlNodePtr newnode;
 
 	char *page_no = NULL;
@@ -857,6 +857,15 @@ parse_tree_level (GtkTreeStore *tree, xmlNodePtr *node, GtkTreeIter iter)
 		g_free (page_content);
 		page_content = NULL;
 
+                if (gtk_tree_model_iter_parent (GTK_TREE_MODEL (tree), &parent, &iter)) {
+                    gchar *parent_id;
+                    gtk_tree_model_get (GTK_TREE_MODEL (tree), &parent,
+                                        INFO_PARSER_COLUMN_PAGE_NO, &parent_id,
+                                        -1);
+                    xmlNewProp (newnode, BAD_CAST "up", BAD_CAST parent_id);
+                    g_free (parent_id);
+                }
+
 		xmlNewProp (newnode, BAD_CAST "id", 
 			    BAD_CAST page_no);
 		xmlNewProp (newnode, BAD_CAST "name", 
diff --git a/stylesheets/info2html.xsl.in b/stylesheets/info2html.xsl.in
index fb5619f..00704c7 100644
--- a/stylesheets/info2html.xsl.in
+++ b/stylesheets/info2html.xsl.in
@@ -12,6 +12,20 @@
 <xsl:import href="@XSL_THEME_HTML@"/>
 <xsl:include href="yelp-common.xsl"/>
 
+<xsl:template name="linktrails">
+  <xsl:param name="up" select="@up"/>
+  <xsl:variable name="upnode" select="/Info//Section[ id = $up]"/>
+  <xsl:if test="$upnode/@up">
+    <xsl:call-template name="linktrails">
+      <xsl:with-param name="up" select="$upnode/@up"/>
+    </xsl:call-template>
+  </xsl:if>
+  <a href="xref:{$upnode/@id}">
+    <xsl:value-of select="$upnode/@name"/>
+  </a>
+  <xsl:text>&#x00A0;» </xsl:text>
+</xsl:template>
+
 <xsl:template match="/Info">
   <xsl:apply-templates select="Section"/>
 </xsl:template>
@@ -28,7 +42,15 @@
         </style>
       </head>
       <body>
-        <div class="head"/>
+        <div class="head">
+          <xsl:if test="@up">
+            <div class="trails">
+              <div class="trail">
+                <xsl:call-template name="linktrails"/>
+              </div>
+            </div>
+          </xsl:if>
+        </div>
         <div class="body">
           <xsl:apply-templates select="node()[not(self::Section)]"/>
         </div>



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