You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cr...@apache.org on 2002/07/11 07:14:35 UTC
cvs commit: xml-cocoon2/src/webapp/samples/linkstatus linkalarm-1.xsl linkalarm-2.xsl linkalarm-3.xsl linkalarm2html.xsl samples.xml sitemap.xmap
crossley 2002/07/10 22:14:35
Modified: src/webapp/samples/linkstatus sitemap.xmap
Added: src/webapp/samples/linkstatus linkalarm-1.xsl
linkalarm-2.xsl linkalarm-3.xsl linkalarm2html.xsl
samples.xml
Log:
Linkstatus now has a samples.xml front page, with various samples to assist
with link mending. Added a new sample which retrieves the current LinkAlarm
summary list and pretty-print it.
Revision Changes Path
1.3 +34 -1 xml-cocoon2/src/webapp/samples/linkstatus/sitemap.xmap
Index: sitemap.xmap
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/webapp/samples/linkstatus/sitemap.xmap,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- sitemap.xmap 30 Jun 2002 16:29:55 -0000 1.2
+++ sitemap.xmap 11 Jul 2002 05:14:35 -0000 1.3
@@ -27,8 +27,18 @@
<map:pipelines>
<map:pipeline>
-
+
<map:match pattern="">
+ <map:redirect-to uri="welcome"/>
+ </map:match>
+
+ <map:match pattern="welcome">
+ <map:generate src="samples.xml"/>
+ <map:transform src="context://samples/stylesheets/simple-samples2html.xsl"/>
+ <map:serialize/>
+ </map:match>
+
+ <map:match pattern="linkstatus">
<map:redirect-to uri="linkstatus/http/localhost/8080/cocoon/documents/index.html"/>
</map:match>
@@ -36,6 +46,29 @@
<map:generate type="linkstatus" src="{1}://{2}:{3}/{4}"/>
<map:transform src="linkstatus.xsl"/>
<map:serialize/>
+ </map:match>
+
+ <map:match pattern="linkalarm">
+ <!-- Get the current linkalarm broken list and wrap it in a <body>
+ This report is tab-delimited with the following fields:
+ broken-url,referer-url,response-code,text-reason
+ -->
+ <map:generate src="http://reports.linkalarm.com/373104199608/links.broken.txt" type="html"/>
+ <!-- clean out any <a> tags -->
+ <map:transform src="linkalarm-1.xsl"/>
+ <!-- split it into tokens based on whitespace -->
+ <map:transform src="linkalarm-2.xsl"/>
+ <!-- structure it into items -->
+ <map:transform src="linkalarm-3.xsl"/>
+ <!-- produce the html page -->
+ <map:transform src="linkalarm2html.xsl"/>
+ <map:serialize type="html"/>
+ </map:match>
+
+ <!-- ========================= Resources ================================ -->
+
+ <map:match pattern="images/**.gif">
+ <map:read src="context://samples/resources/images/{1}.gif" mime-type="image/gif"/>
</map:match>
</map:pipeline>
1.1 xml-cocoon2/src/webapp/samples/linkstatus/linkalarm-1.xsl
Index: linkalarm-1.xsl
===================================================================
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version='1.0'>
<xsl:template match="body">
<body>
<xsl:apply-templates/>
</body>
</xsl:template>
<xsl:template match="a">
<!-- massage link for 301 redirect, it messes up the url detection later -->
<xsl:value-of select="substring-before(.,'/')"/>
<xsl:text> </xsl:text>
<xsl:value-of select="substring-after(.,':')"/>
</xsl:template>
</xsl:stylesheet>
1.1 xml-cocoon2/src/webapp/samples/linkstatus/linkalarm-2.xsl
Index: linkalarm-2.xsl
===================================================================
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version='1.0'>
<xsl:template match="body">
<linkalarm-report><xsl:text>
</xsl:text>
<xsl:call-template name="split-it">
<xsl:with-param name="list" select="."/>
</xsl:call-template>
</linkalarm-report>
</xsl:template>
<xsl:template name="split-it">
<!-- split the list based on whitespace -->
<xsl:param name="list"/>
<xsl:variable name="nlist"
select="concat(normalize-space($list),' ')"/>
<xsl:variable name="token" select="substring-before($nlist, ' ')"/>
<xsl:variable name="rest" select="substring-after($nlist, ' ')"/>
<xsl:choose>
<!-- server response code -->
<xsl:when test="string(number($token))!='NaN'">
<response-code>
<xsl:value-of select="$token"/>
</response-code><xsl:text>
</xsl:text>
</xsl:when>
<!-- broken-url or referer-url -->
<xsl:when test="contains($token,'://')">
<url>
<xsl:value-of select="$token"/>
</url><xsl:text>
</xsl:text>
</xsl:when>
<!-- text reason-->
<xsl:otherwise>
<reason-word>
<xsl:value-of select="$token"/>
</reason-word><xsl:text>
</xsl:text>
</xsl:otherwise>
</xsl:choose>
<!-- if any text remains then split it too -->
<xsl:if test="$rest">
<xsl:call-template name="split-it">
<xsl:with-param name="list" select="$rest"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
1.1 xml-cocoon2/src/webapp/samples/linkstatus/linkalarm-3.xsl
Index: linkalarm-3.xsl
===================================================================
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version='1.0'>
<!-- FIXME: Under development.
* Not sure how it will cope with a big links.broken.txt list (currently small).
* Should be able to produce more structure with <item> so that we can display
as table. Seems to be a tricky process.
-->
<xsl:template match="linkalarm-report">
<linkalarm-report><xsl:text>
</xsl:text>
<xsl:apply-templates/>
</linkalarm-report>
</xsl:template>
<xsl:template match="url">
<!-- process each url and decide which link type and whether new item -->
<xsl:variable name="url-num"><xsl:number/></xsl:variable>
<xsl:variable name="item-num">
<xsl:value-of select="round($url-num div 2)"/>
</xsl:variable>
<!-- DEBUG: URL-NUM=<xsl:value-of select="$url-num"/> -->
<xsl:choose>
<!-- odd-number <url> is the beginning of <item> and is the broken url -->
<xsl:when test="$url-num mod 2 != 0">
<item-num><xsl:value-of select="$item-num"/></item-num>
<broken-url><xsl:value-of select="."/></broken-url>
</xsl:when>
<!-- even-number <url> is the referer url -->
<xsl:otherwise>
<referer-url><xsl:value-of select="."/></referer-url>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="response-code">
<response-code><xsl:value-of select="."/></response-code>
</xsl:template>
<xsl:template match="reason-word">
<reason-word><xsl:value-of select="."/></reason-word>
</xsl:template>
</xsl:stylesheet>
1.1 xml-cocoon2/src/webapp/samples/linkstatus/linkalarm2html.xsl
Index: linkalarm2html.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="linkalarm-report">
<html>
<head><title>LinkAlarm summary for current Cocoon website</title></head>
<body>
<h1>LinkAlarm summary for current Cocoon website</h1>
<p>The LinkAlarm service traverses the Cocoon website occasionally. The full
set of reports are at
<a href="http://reports.linkalarm.com/373104199608/">http://reports.linkalarm.com/373104199608/</a>
</p>
<p>This Cocoon Sample retrieves the summary report
<code>links.broken.txt</code> and processes the tab-delimited file through
a sequence of transformations to pretty-print the data.
</p>
<p>Please help to
<a href="../../documents/plan/linkstatus.html">mend the broken links</a>.
</p>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="item-num">
<h3>Item number:
<xsl:value-of select="."/>
</h3>
</xsl:template>
<xsl:template match="broken-url">
<p>Broken URL:
<a href="{.}">
<xsl:value-of select="."/>
</a>
</p>
</xsl:template>
<xsl:template match="referer-url">
<p>Referer page:
<a href="{.}">
<xsl:value-of select="."/>
</a>
</p>
</xsl:template>
<xsl:template match="response-code">
<p>Server response code:
<xsl:value-of select="."/>
</p>
</xsl:template>
<xsl:template match="reason-word">
<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>
1.1 xml-cocoon2/src/webapp/samples/linkstatus/samples.xml
Index: samples.xml
===================================================================
<?xml version="1.0" encoding="iso-8859-1"?>
<samples xmlns:xlink="http://www.w3.org/1999/xlink">
<group name="Main examples page">
<sample name="Back" href="..">to Cocoon examples main page</sample>
</group>
<group name="Core tools">
<sample name="LinkStatus Generator" href="linkstatus">
Verify that there are no broken hyperlinks in the local Cocoon
documentation. This sample will start at the home page of the local
documentation webapp and traverse each internal link, reporting its status
in a colour-coded table.
</sample>
<sample name="Documentation" href="../../documents/plan/index.html">Please
help to fix broken links. Keep the documentation set and website robust.
</sample>
</group>
<group name="External tools">
<sample name="Linkalarm for Cocoon" href="linkalarm">Retrieve and display
the summary list of broken links in the current Cocoon website.
The LinkAlarm service interrogates the xml.apache.org/cocoon/ site roughly
once per month and produces a set of reports. This sample simply retrieves
the current summary from the main report at
http://reports.linkalarm.com/373104199608/
The file is tab-delimited with 4 fields
(broken-url,referer-url,response-code,text-reason).
</sample>
</group>
</samples>
----------------------------------------------------------------------
In case of troubles, e-mail: webmaster@xml.apache.org
To unsubscribe, e-mail: cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org