I've just whipped up some magic to make sections in man pages collapse/expand when you click on their headers. I've attached a patch and two PNG files to this email. Apply the patch and put the images in the data/icons directory. I'll probably end up putting this in, but I figured I'd get some feedback first. The arrow images are kind of rough. We all know that Shaun should not be allowed to draw things. -- Shaun
? title.diff ? yelp-collapsable.patch ? yelp-search-xslt1.patch ? data/info.xml ? data/icons/yelp-icon-arrow-down.png ? data/icons/yelp-icon-arrow-right.png ? m4/intltool.m4 ? po/.intltool-merge-cache ? po/report ? src/yelp-transform.c ? src/yelp-transform.h Index: data/yelp.js =================================================================== RCS file: /cvs/gnome/yelp/data/yelp.js,v retrieving revision 1.4 diff -u -r1.4 yelp.js --- data/yelp.js 21 Nov 2005 20:56:22 -0000 1.4 +++ data/yelp.js 9 Jan 2006 22:41:54 -0000 @@ -93,3 +93,37 @@ window.location = "x-yelp-search:" + document.getElementById ('search-entry').value; return false; } + +function toggleDiv (divID) +{ + el = document.getElementById ('-x-div-'+divID); + im = document.getElementById ('-x-img-'+divID); + cl = el.className.split (' '); + p = -1; + for (var i=0; i < cl.length; i++) { + if (cl[i] == 'Collapsed') { + p = i; + break; + }} + if (p < 0) { + cl = cl.concat ('Collapsed'); + m = document.getElementsByTagName ('meta'); + for (var i=0; i < m.length; i++) { + if (m[i].getAttribute ('name') == 'yelp-icon-arrow-right') { + im.src = m[i].getAttribute ('content'); + break; + } + } + } else { + cl.splice (p, 1); + m = document.getElementsByTagName ('meta'); + for (var i=0; i < m.length; i++) { + if (m[i].getAttribute ('name') == 'yelp-icon-arrow-down') { + im.src = m[i].getAttribute ('content'); + break; + } + } + } + + el.className = cl.join (' '); +} Index: data/icons/Makefile.am =================================================================== RCS file: /cvs/gnome/yelp/data/icons/Makefile.am,v retrieving revision 1.4 diff -u -r1.4 Makefile.am --- data/icons/Makefile.am 1 Feb 2005 21:45:05 -0000 1.4 +++ data/icons/Makefile.am 9 Jan 2006 22:41:54 -0000 @@ -5,6 +5,8 @@ icondir = $(datadir)/yelp/icons icon_DATA = \ + yelp-icon-arrow-down.png \ + yelp-icon-arrow-right.png \ yelp-icon-caution.png \ yelp-icon-important.png \ yelp-icon-note.png \ Index: src/yelp-html.cpp =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-html.cpp,v retrieving revision 1.5 diff -u -r1.5 yelp-html.cpp --- src/yelp-html.cpp 7 Jan 2006 23:12:02 -0000 1.5 +++ src/yelp-html.cpp 9 Jan 2006 22:41:54 -0000 @@ -104,10 +104,14 @@ d (g_print ("embed_open_uri_cb uri=%s\n", uri)); d (g_print (" uri = \"%s\"\n", uri)); - if (!html->priv->frames_enabled) { + if (g_str_has_prefix (uri, "javascript:")) { + block_load = FALSE; + } + else if (!html->priv->frames_enabled) { g_signal_emit (html, signals[URI_SELECTED], 0, uri, FALSE); block_load = TRUE; - } else { + } + else { g_signal_emit (html, signals[FRAME_SELECTED], 0, uri, FALSE, &block_load); } return block_load; Index: src/yelp-settings.c =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-settings.c,v retrieving revision 1.14 diff -u -r1.14 yelp-settings.c --- src/yelp-settings.c 8 Jan 2006 20:56:04 -0000 1.14 +++ src/yelp-settings.c 9 Jan 2006 22:41:54 -0000 @@ -73,6 +73,8 @@ }; static const gchar * const icon_params[YELP_NUM_ICONS] = { + "yelp.icon.arrow-down", + "yelp.icon.arrow-right", "yelp.icon.blockquote", "yelp.icon.caution", "yelp.icon.important", @@ -131,6 +133,12 @@ for (i = 0; i < YELP_NUM_ICONS; i++) { switch (i) { + case YELP_ICON_ARROW_DOWN: + icon_names[i] = "yelp-icon-arrow-down"; + break; + case YELP_ICON_ARROW_RIGHT: + icon_names[i] = "yelp-icon-arrow-right"; + break; case YELP_ICON_BLOCKQUOTE: /* TRANSLATORS: This is an image of the opening quote character used to watermark Index: src/yelp-settings.h =================================================================== RCS file: /cvs/gnome/yelp/src/yelp-settings.h,v retrieving revision 1.9 diff -u -r1.9 yelp-settings.h --- src/yelp-settings.h 16 May 2005 21:02:33 -0000 1.9 +++ src/yelp-settings.h 9 Jan 2006 22:41:54 -0000 @@ -74,7 +74,9 @@ } YelpColorType; typedef enum { - YELP_ICON_BLOCKQUOTE = 0, + YELP_ICON_ARROW_DOWN = 0, + YELP_ICON_ARROW_RIGHT, + YELP_ICON_BLOCKQUOTE, YELP_ICON_CAUTION, YELP_ICON_IMPORTANT, YELP_ICON_NOTE, Index: stylesheets/db2html.xsl.in =================================================================== RCS file: /cvs/gnome/yelp/stylesheets/db2html.xsl.in,v retrieving revision 1.19 diff -u -r1.19 db2html.xsl.in --- stylesheets/db2html.xsl.in 19 May 2005 22:41:16 -0000 1.19 +++ stylesheets/db2html.xsl.in 9 Jan 2006 22:41:54 -0000 @@ -153,39 +153,6 @@ background-image: url("</xsl:text> <xsl:value-of select="$yelp.icon.warning"/><xsl:text>"); } - - div[class~="navbar"] { - -moz-box-sizing: border-box; - position: absolute; - bottom: 0px; - left: 0px; - width: 100%; - font-size: 0.8em; - margin: 0px; - padding: 3px; - padding-left: 12px; - padding-right: 12px; - background-color: </xsl:text> - <xsl:value-of select="$yelp.color.gray.bg"/><xsl:text>; - border: none; - border: solid 1px </xsl:text> - <xsl:value-of select="$yelp.color.gray.bg.dark1"/><xsl:text>; - } - div[class~="navbar"] span { white-space: nowrap; } - div[class~="navbar"] a { text-decoration: none; } - div[class~="navbar"] a:hover { text-decoration: underline; } - span[class~="navbar-prev"]:before { - content: '◀ '; - color: </xsl:text> - <xsl:value-of select="$yelp.color.gray.fg"/><xsl:text>; - text-decoration: none; - } - span[class~="navbar-next"]:after { - content: ' ▶'; - color: </xsl:text> - <xsl:value-of select="$yelp.color.gray.fg"/><xsl:text>; - text-decoration: none; - } </xsl:text> </xsl:template> Index: stylesheets/man2html.xsl =================================================================== RCS file: /cvs/gnome/yelp/stylesheets/man2html.xsl,v retrieving revision 1.12 diff -u -r1.12 man2html.xsl --- stylesheets/man2html.xsl 9 Jan 2006 05:01:01 -0000 1.12 +++ stylesheets/man2html.xsl 9 Jan 2006 22:41:54 -0000 @@ -15,6 +15,8 @@ <xsl:param name="yelp.javascript"/> +<xsl:param name="yelp.icon.arrow-down"/> +<xsl:param name="yelp.icon.arrow-right"/> <xsl:param name="yelp.icon.blockquote"/> <xsl:param name="yelp.icon.caution"/> <xsl:param name="yelp.icon.important"/> @@ -70,6 +72,8 @@ <xsl:value-of select="concat('file://', $yelp.javascript)"/> </xsl:attribute> </script> + <meta name="yelp-icon-arrow-down" content="{$yelp.icon.arrow-down}"/> + <meta name="yelp-icon-arrow-right" content="{$yelp.icon.arrow-right}"/> </head> <body> <xsl:call-template name="html.linktrail"/> @@ -85,7 +89,18 @@ <xsl:call-template name="yelp.common.css"/> <xsl:text> div[class~="SH"] { margin-left: 1.2em; } - div[class~="SS"] { margin-left: 1.6em; } + div[class~="SS"] { margin-left: 1.44em; } + div[class~="Collapsed"] { display: none; } + + h2 a, h3 a { color: </xsl:text> + <xsl:value-of select="$yelp.color.gray.fg"/><xsl:text>; + text-decoration: none; + } + img[class~="Arrow"] { + border: none; + vertical-align: center; + padding-right: 0.2em; + } span[class~="R"] { font-family: serif; } span[class~="Section"] { margin-left: 0.4em; } @@ -219,8 +234,14 @@ <xsl:variable name="nextSS" select="following-sibling::SS[not($nextSH) or following-sibling::SH[1] = $nextSH][1]"/> - <h3><xsl:apply-templates/></h3> - <div class="SS"> + <xsl:variable name="id" select="generate-id(.)"/> + <h3> + <a href="javascript:toggleDiv('{$id}')"> + <img src="{$yelp.icon.arrow-down}" class="Arrow" id="-x-img-{$id}"/> + <xsl:apply-templates/> + </a> + </h3> + <div class="SS" id="-x-div-{$id}"> <xsl:choose> <xsl:when test="$nextSS"> <xsl:apply-templates @@ -244,8 +265,14 @@ <xsl:variable name="nextSS" select="following-sibling::SS[not($nextSH) or following-sibling::SH[1] = $nextSH]"/> - <h2><xsl:apply-templates/></h2> - <div class="SH"> + <xsl:variable name="id" select="generate-id(.)"/> + <h2> + <a href="javascript:toggleDiv('{$id}')"> + <img src="{$yelp.icon.arrow-down}" class="Arrow" id="-x-img-{$id}"/> + <xsl:apply-templates/> + </a> + </h2> + <div class="SH" id="-x-div-{$id}"> <xsl:choose> <xsl:when test="$nextSS"> <xsl:apply-templates Index: stylesheets/yelp-common.xsl =================================================================== RCS file: /cvs/gnome/yelp/stylesheets/yelp-common.xsl,v retrieving revision 1.2 diff -u -r1.2 yelp-common.xsl --- stylesheets/yelp-common.xsl 19 May 2005 22:41:16 -0000 1.2 +++ stylesheets/yelp-common.xsl 9 Jan 2006 22:41:54 -0000 @@ -43,9 +43,22 @@ padding-bottom: 3em; } - h1 { font-size: 1.4em; } - h2 { font-size: 1.2em; } - h1 + div h2[class~="title"] { margin-top: 2em; } + h1 { font-size: 1.72em; margin-top: 0em; } + h2 { font-size: 1.44em; } + h2[class~="title"] { margin-top: 1.72em; border-bottom: solid 1px; } + + h3 { font-size: 1.2em; } + h3[class~="title"] { margin-top: 1.72em; } + h3 span[class~="title"] { border-bottom: solid 1px; } + + h4 { font-size: 1.0em; } + h4[class~="title"] { margin-top: 1.44em; } + h4 span[class~="title"] { border-bottom: solid 1px; } + + h5 { font-size: 1em; margin-top: 1em; } + h6 { font-size: 1em; margin-top: 1em; } + h7 { font-size: 1em; margin-top: 1em; } + h1, h2, h3, h4, h5, h6, h7 { color: </xsl:text> <xsl:value-of select="$yelp.color.gray.fg"/><xsl:text>; } h3 span[class~="title"] { border-bottom: none; } @@ -83,6 +96,45 @@ } a[class~="linktrail"] { text-decoration: none; } a[class~="linktrail"]:hover { text-decoration: underline; } + + div[class~="navbar"] { + -moz-box-sizing: border-box; + position: absolute; + bottom: 0px; + left: 0px; + width: 100%; + font-size: 0.8em; + margin: 0px; + padding: 3px; + padding-left: 12px; + padding-right: 12px; + background-color: </xsl:text> + <xsl:value-of select="$yelp.color.gray.bg"/><xsl:text>; + border: none; + border: solid 1px </xsl:text> + <xsl:value-of select="$yelp.color.gray.bg.dark1"/><xsl:text>; + } + div[class~="navbar"] span { white-space: nowrap; } + div[class~="navbar"] a { text-decoration: none; } + div[class~="navbar"] a:hover { text-decoration: underline; } + span[class~="navbar-prev"]:before { + content: '◀ '; + color: </xsl:text> + <xsl:value-of select="$yelp.color.gray.fg"/><xsl:text>; + text-decoration: none; + } + span[class~="navbar-next"]:after { + content: ' ▶'; + color: </xsl:text> + <xsl:value-of select="$yelp.color.gray.fg"/><xsl:text>; + text-decoration: none; + } + + @media print { + div[class~="linktrail"] { display: none; } + div[class~="navbar"] { display: none; } + h1, h2, h3, h4, h5, h6, h7 { font-family: sans-serif; } + } </xsl:text> </xsl:template>
Attachment:
yelp-icon-arrow-down.png
Description: PNG image
Attachment:
yelp-icon-arrow-right.png
Description: PNG image