Subject: Re: file
To: None <rpaulo@NetBSD.org, hubert@feyrer.de>
From: Hiroki Sato <hrs@NetBSD.org>
List: netbsd-docs
Date: 07/04/2005 15:00:28
----Security_Multipart(Mon_Jul__4_15_00_28_2005_143)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hubert Feyrer <hubert@feyrer.de> wrote
  in <Pine.LNX.4.61.0507031638000.10771@m24s24.vlinux.de>:

hu> On Sun, 3 Jul 2005, Rui Paulo wrote:
hu> > <cvsweb dir="src">build.sh</cvsweb>
hu> > <cvsweb dir="src" rev="1.1">build.sh</cvsweb>
hu> 
hu> Wasn't the idea not to add new tags but to add identifiers to things like 
hu> the <ulink> tag here, e.g.
hu> 
hu>  	<ulink class="cvsweb" dir="src">build.sh</ulink>
hu>  	<ulink class="cvsweb" dir="src" rev="1.1">build.sh</ulink>

 I think <filename> is suitable for this purpose.  The attached patch
 allows to use role attribute to make a link to cvsweb.NetBSD.org like
 the following:

 <filename role="cvsweb">src/build.sh</filename>
 <filename role="cvsweb" revision="1.1">src/build.sh</filename>
 <filename role="cvsweb" path="src">build.sh</filename>
 <filename role="cvsweb" path="src" revision="1.1">build.sh</filename>

 The results will be:

 <a href="http://cvsweb.NetBSD.org/bsdweb.cgi/src/build.sh?rev=HEAD&amp;content-type=text/x-cvsweb-markup" target="_top"><code class="filename">src/build.sh</code></a>

 <a href="http://cvsweb.NetBSD.org/bsdweb.cgi/src/build.sh?rev=1.1&amp;content-type=text/x-cvsweb-markup" target="_top"><code class="filename">src/build.sh</code></a>

 <a href="http://cvsweb.NetBSD.org/bsdweb.cgi/src/build.sh?rev=HEAD&amp;content-type=text/x-cvsweb-markup" target="_top"><code class="filename">build.sh</code></a>

 <a href="http://cvsweb.NetBSD.org/bsdweb.cgi/src/build.sh?rev=1.1&amp;content-type=text/x-cvsweb-markup" target="_top"><code class="filename">build.sh</code></a>

-- 
| Hiroki SATO

Index: xml/misc.ent
===================================================================
RCS file: /cvsroot/htdocs/share/xml/misc.ent,v
retrieving revision 1.7
diff -d -u -I\$FreeBSD:.*\$ -I\$NetBSD:.*\$ -I\$OpenBSD:.*\$ -I\$DragonFly:.*\$ -I\$Id:.*\$ -I\$hrs:.*\$ -r1.7 misc.ent
--- xml/misc.ent	25 Jun 2005 13:59:18 -0000	1.7
+++ xml/misc.ent	4 Jul 2005 05:45:40 -0000
@@ -48,3 +48,6 @@
 
 <!ENTITY pkgsrc.branch.latest		"pkgsrc-2005Q2">
 <!ENTITY pkgsrc.branch.previous		"pkgsrc-2005Q1">
+
+<!-- URL -->
+<!ENTITY url.cvsweb "http://cvsweb.NetBSD.org/bsdweb.cgi">
Index: xsl/netbsd.xsl
===================================================================
RCS file: /cvsroot/htdocs/share/xsl/netbsd.xsl,v
retrieving revision 1.7
diff -d -u -I\$FreeBSD:.*\$ -I\$NetBSD:.*\$ -I\$OpenBSD:.*\$ -I\$DragonFly:.*\$ -I\$Id:.*\$ -I\$hrs:.*\$ -r1.7 netbsd.xsl
--- xsl/netbsd.xsl	12 Apr 2005 13:57:15 -0000	1.7
+++ xsl/netbsd.xsl	4 Jul 2005 05:53:05 -0000
@@ -1,10 +1,15 @@
 <?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- html -*- -->
-<!DOCTYPE xsl:stylesheet [<!ENTITY nbsp "&#160;">]>
+<!DOCTYPE xsl:stylesheet
+  PUBLIC "-//NetBSD//DTD NetBSD XSLT 1.0 DTD//EN"
+         "http://www.NetBSD.org/XML/htdocs/share/xml/xslt10-netbsd.dtd">
 
 <!-- $NetBSD: netbsd.xsl,v 1.7 2005/04/12 13:57:15 hrs Exp $ -->
 
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 		xmlns:html="http://www.w3.org/1999/xhtml"
+                xmlns:suwl="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.UnwrapLinks"
+                xmlns:exsl="http://exslt.org/common"
+                exclude-result-prefixes="suwl exsl"
 		version="1.0">
 
   <!-- beautify blocks of code -->
@@ -50,5 +55,59 @@
     </a>
   </xsl:template>
 
-</xsl:stylesheet>
+  <xsl:template match="filename">
+    <xsl:variable name="filename.label" select="." />
+
+    <xsl:variable name="ulink.url">
+      <xsl:if test="@role != '' and @role = 'cvsweb'">
+	<xsl:value-of select="concat('&url.cvsweb;', '/')" />
+	<xsl:if test="@path">
+	  <xsl:value-of select="concat(@path, '/')" />
+	</xsl:if>
+	<xsl:value-of select="concat('', $filename.label)" />
+	<xsl:choose>
+	  <xsl:when test="@revision != ''">
+	    <xsl:value-of select="concat('?', 'rev=', @revision)" />
+	  </xsl:when>
+	  <xsl:otherwise>
+	    <xsl:value-of select="concat('?', 'rev=', 'HEAD')" />
+	  </xsl:otherwise>
+	</xsl:choose>
+	<xsl:value-of select="concat('&amp;', 'content-type=text/x-cvsweb-markup')" />
+      </xsl:if>
+    </xsl:variable>
 
+    <xsl:variable name="link">
+      <xsl:choose>
+	<xsl:when test="@role != '' and @role = 'cvsweb'">
+	  <a>
+	    <xsl:if test="@id">
+	      <xsl:attribute name="name">
+		<xsl:value-of select="@id"/>
+	      </xsl:attribute>
+	    </xsl:if>
+	    <xsl:attribute name="href"><xsl:value-of select="$ulink.url"/></xsl:attribute>
+	    <xsl:if test="$ulink.target != ''">
+	      <xsl:attribute name="target">
+		<xsl:value-of select="$ulink.target"/>
+	      </xsl:attribute>
+	    </xsl:if>
+	    <xsl:call-template name="inline.monoseq" />
+	  </a>
+	</xsl:when>
+	<xsl:otherwise>
+	  <xsl:call-template name="inline.monoseq" />
+	</xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+
+    <xsl:choose>
+      <xsl:when test="function-available('suwl:unwrapLinks')">
+	<xsl:copy-of select="suwl:unwrapLinks($link)"/>
+      </xsl:when>
+      <xsl:otherwise>
+	<xsl:copy-of select="$link"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+</xsl:stylesheet>


----Security_Multipart(Mon_Jul__4_15_00_28_2005_143)--
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (FreeBSD)

iD8DBQBCyNB+TyzT2CeTzy0RAk4KAKDHAE+d6uvTAwJ68OoDb2gfRSlegACfeUE9
D6ri33/8f61Ymys3Lw+6uLc=
=T+1N
-----END PGP SIGNATURE-----

----Security_Multipart(Mon_Jul__4_15_00_28_2005_143)----