Commit 553ffc7b authored by Shaun McCance's avatar Shaun McCance

- Get titles from the db.titleabbrev XSLT template

* configure.in:
* src/yelp-db-pager.c:
* stylesheets/Makefile.am:
* stylesheets/db-title.xsl.in:
- Get titles from the db.titleabbrev XSLT template

* data/toc.xml.in:
- Changed 'Sound & Video' to be 'Multimedia', for upstream compliance

* src/yelp-info-pager.c:
* src/yelp-man-pager.c:
* src/yelp-toc-pager.c:
- Some #define naming changes
parent e46f7c0b
2005-01-17 Shaun McCance <shaunm@gnome.org>
* configure.in:
* src/yelp-db-pager.c:
* stylesheets/Makefile.am:
* stylesheets/db-title.xsl.in:
- Get titles from the db.titleabbrev XSLT template
* data/toc.xml.in:
- Changed 'Sound & Video' to be 'Multimedia', for upstream compliance
* src/yelp-info-pager.c:
* src/yelp-man-pager.c:
* src/yelp-toc-pager.c:
- Some #define naming changes
2005-01-13 Shaun McCance <shaunm@gnome.org>
* NEWS:
......
......@@ -62,6 +62,10 @@ AC_PATH_PROGS(SED, gsed sed)
YELP_IDL_INCLUDES="`echo ${idl_dirs} | ${SED} -e 's/^/ /' -e 's/ *$//' -e 's/ */ -I /g' -e 's/^ *//'`"
AC_SUBST(YELP_IDL_INCLUDES)
XSLT_PATH="`$PKG_CONFIG --variable=xsltdir gnome-doc-utils`"
DB_TITLE="$XSLT_PATH""/docbook/common/db-title.xsl"
AC_SUBST(DB_TITLE)
DB2HTML="`$PKG_CONFIG --variable=db2html gnome-doc-utils`"
AC_SUBST(DB2HTML)
......@@ -179,6 +183,7 @@ Makefile
src/Makefile
stylesheets/Makefile
stylesheets/db2html.xsl
stylesheets/db-title.xsl
data/Makefile
data/icons/Makefile
data/ui/Makefile
......
......@@ -35,7 +35,7 @@
<_title>Internet</_title>
</toc>
<toc id="ApplicationsMultimedia" icon="gnome-multimedia">
<_title>Sound &amp; Video</_title>
<_title>Multimedia</_title>
</toc>
<toc id="ApplicationsOffice" icon="gnome-applications">
<_title>Office</_title>
......
......@@ -47,8 +47,9 @@
#define d(x)
#endif
#define DB_STYLESHEET_PATH DATADIR"/sgml/docbook/yelp/"
#define DB_STYLESHEET DB_STYLESHEET_PATH"db2html.xsl"
#define STYLESHEET_PATH DATADIR"/yelp/xslt/"
#define DB_STYLESHEET STYLESHEET_PATH"db2html.xsl"
#define DB_TITLE STYLESHEET_PATH"db-title.xsl"
#define BOOK_CHUNK_DEPTH 2
#define ARTICLE_CHUNK_DEPTH 1
......@@ -77,6 +78,8 @@ struct _DBWalker {
gint depth;
gint max_depth;
xsltStylesheetPtr titleStylesheet;
};
static void db_pager_class_init (YelpDBPagerClass *klass);
......@@ -92,10 +95,10 @@ static const gchar * db_pager_resolve_frag (YelpPager *pager,
static GtkTreeModel * db_pager_get_sections (YelpPager *pager);
static void walker_walk_xml (DBWalker *walker);
static gboolean walker_is_chunk (DBWalker *walker);
static gboolean xml_is_division (xmlNodePtr node);
static gchar * xml_get_title (xmlNodePtr node);
static gboolean node_is_chunk (DBWalker *walker);
static gboolean node_is_division (DBWalker *walker);
static gchar * node_get_title (DBWalker *walker);
static YelpPagerClass *parent_class;
......@@ -251,6 +254,8 @@ db_pager_parse (YelpPager *pager)
walker->doc = doc;
walker->cur = xmlDocGetRootElement (walker->doc);
walker->titleStylesheet = xsltParseStylesheetFile (DB_TITLE);
if (!xmlStrcmp (xmlDocGetRootElement (doc)->name, BAD_CAST "book"))
walker->max_depth = BOOK_CHUNK_DEPTH;
else
......@@ -268,6 +273,8 @@ db_pager_parse (YelpPager *pager)
walker_walk_xml (walker);
done:
xsltFreeStylesheet (walker->titleStylesheet);
g_free (filename);
g_free (walker);
......@@ -399,8 +406,8 @@ walker_walk_xml (DBWalker *walker)
id = xmlStrdup ("__yelp_toc");
}
if (walker_is_chunk (walker)) {
title = xml_get_title (walker->cur);
if (node_is_chunk (walker)) {
title = node_get_title (walker);
if (id) {
gtk_tree_store_append (GTK_TREE_STORE (priv->sects),
......@@ -447,7 +454,7 @@ walker_walk_xml (DBWalker *walker)
walker->depth--;
walker->cur = old_cur;
if (walker_is_chunk (walker) && id) {
if (node_is_chunk (walker) && id) {
walker->iter = old_iter;
walker->page_id = old_id;
......@@ -459,52 +466,49 @@ walker_walk_xml (DBWalker *walker)
xmlFree (title);
}
gchar *
xml_get_title (xmlNodePtr node)
static gchar *
node_get_title (DBWalker *walker)
{
gchar *title = NULL;
gchar *ret = NULL;
xmlNodePtr cur;
/* FIXME: this needs so much work */
for (cur = node->children; cur; cur = cur->next) {
if (!xmlStrcmp (cur->name, (xmlChar *) "title")) {
if (title)
g_free (title);
title = xmlNodeGetContent (cur);
}
else if (!xmlStrcmp (cur->name, (xmlChar *) "titleabbrev")) {
if (title)
g_free (title);
title = xmlNodeGetContent (cur);
break;
}
gchar *title;
xmlDocPtr doc;
xmlChar *params[3];
xmlChar *outstr;
int outlen;
params[0] = "node";
params[1] = xmlGetNodePath (walker->cur);
params[2] = NULL;
doc = xsltApplyStylesheet (walker->titleStylesheet,
walker->doc,
params);
if (xsltSaveResultToString (&outstr, &outlen, doc, walker->titleStylesheet) < 0)
title = _("Unknown Section");
else {
title = g_strdup (outstr);
xmlFree (outstr);
}
if (!title)
title = g_strdup (_("Unknown"));
// This really isn't adequate for what we want.
ret = g_strdup (g_strstrip (title));
g_free (title);
xmlFreeDoc (doc);
xmlFree (params[1]);
return ret;
return title;
}
gboolean
walker_is_chunk (DBWalker *walker)
static gboolean
node_is_chunk (DBWalker *walker)
{
if (walker->depth <= walker->max_depth) {
if (xml_is_division (walker->cur))
if (node_is_division (walker))
return TRUE;
}
return FALSE;
}
gboolean
xml_is_division (xmlNodePtr node)
static gboolean
node_is_division (DBWalker *walker)
{
xmlNodePtr node = walker->cur;
return (!xmlStrcmp (node->name, (const xmlChar *) "appendix") ||
!xmlStrcmp (node->name, (const xmlChar *) "article") ||
!xmlStrcmp (node->name, (const xmlChar *) "book") ||
......
......@@ -41,8 +41,8 @@
#include "yelp-info-parser.h"
#include "yelp-settings.h"
#define INFO_STYLESHEET_PATH DATADIR"/sgml/docbook/yelp/"
#define INFO_STYLESHEET INFO_STYLESHEET_PATH"info2html.xsl"
#define STYLESHEET_PATH DATADIR"/yelp/xslt/"
#define INFO_STYLESHEET STYLESHEET_PATH"info2html.xsl"
struct _YelpInfoPagerPriv {
GtkTreeStore *tree;
......
......@@ -40,8 +40,8 @@
#include "yelp-man-parser.h"
#include "yelp-settings.h"
#define MAN_STYLESHEET_PATH DATADIR"/sgml/docbook/yelp/"
#define MAN_STYLESHEET MAN_STYLESHEET_PATH"man2html.xsl"
#define STYLESHEET_PATH DATADIR"/yelp/xslt/"
#define MAN_STYLESHEET STYLESHEET_PATH"man2html.xsl"
struct _YelpManPagerPriv {
gpointer unused;
......
......@@ -54,8 +54,8 @@
#define YELP_NAMESPACE "http://www.gnome.org/yelp/ns"
#define TOC_STYLESHEET_PATH DATADIR"/sgml/docbook/yelp/"
#define TOC_STYLESHEET TOC_STYLESHEET_PATH"toc2html.xsl"
#define STYLESHEET_PATH DATADIR"/yelp/xslt/"
#define TOC_STYLESHEET STYLESHEET_PATH"toc2html.xsl"
typedef gboolean (*ProcessFunction) (YelpTocPager *pager);
......
@INTLTOOL_XML_RULE@
xsldir=$(datadir)/sgml/docbook/yelp
xsldir=$(datadir)/yelp/xslt
xsl_DATA = db2html.xsl info2html.xsl man2html.xsl toc2html.xsl
xsl_DATA = db2html.xsl db-title.xsl info2html.xsl man2html.xsl toc2html.xsl
EXTRA_DIST=$(xsl_DATA)
<?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:yelp="http://www.gnome.org/yelp/ns"
xmlns="http://www.w3.org/1999/xhtml"
extension-element-prefixes="yelp"
version="1.0">
<xsl:import href="@DB_TITLE@"/>
<xsl:template name="node"/>
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:variable name="title">
<xsl:call-template name="db.titleabbrev">
<xsl:with-param name="node" select="$node"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="normalize-space($title)"/>
</xsl:template>
</xsl:stylesheet>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment