From: <bi...@us...> - 2008-10-11 01:45:12
|
Revision: 2603 http://archive-access.svn.sourceforge.net/archive-access/?rev=2603&view=rev Author: binzino Date: 2008-10-11 01:45:00 +0000 (Sat, 11 Oct 2008) Log Message: ----------- Added page links template, some comments and other various tweaks. Modified Paths: -------------- trunk/archive-access/projects/nutchwax/archive/src/web/style/search.xsl Modified: trunk/archive-access/projects/nutchwax/archive/src/web/style/search.xsl =================================================================== --- trunk/archive-access/projects/nutchwax/archive/src/web/style/search.xsl 2008-10-10 03:00:53 UTC (rev 2602) +++ trunk/archive-access/projects/nutchwax/archive/src/web/style/search.xsl 2008-10-11 01:45:00 UTC (rev 2603) @@ -122,13 +122,37 @@ <div style="font-size: 8pt; margin:0; padding:0 0 0.5em 0;">Results <xsl:value-of select="opensearch:startIndex + 1" />-<xsl:value-of select="opensearch:startIndex + opensearch:itemsPerPage" /> of about <xsl:value-of select="opensearch:totalResults" /> <span style="margin-left: 1em;"><a href="{nutch:nextPage}">Next</a></span></div> <!-- Search results --> <ol start="{opensearch:startIndex + 1}"> - <xsl:apply-templates select="item" /> + <xsl:apply-templates select="item" /> </ol> - <a href="{nutch:nextPage}">Next</a> + <!-- Generate list of page links --> + <center> + <xsl:if test="(floor(opensearch:startIndex div opensearch:itemsPerPage) + 1) != 1"> + <a href="search?query={nutch:query}&start={(floor(opensearch:startIndex div opensearch:itemsPerPage) - 1) * opensearch:itemsPerPage}">«</a><xsl:text> </xsl:text> + </xsl:if> + <xsl:choose> + <xsl:when test="(floor(opensearch:startIndex div opensearch:itemsPerPage) + 1) < 11"> + <xsl:call-template name="pageLinks" > + <xsl:with-param name="begin" select="1" /> + <xsl:with-param name="end" select="21" /> + <xsl:with-param name="current" select="floor(opensearch:startIndex div opensearch:itemsPerPage) + 1" /> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="pageLinks" > + <xsl:with-param name="begin" select="floor(opensearch:startIndex div opensearch:itemsPerPage) + 1 - 10" /> + <xsl:with-param name="end" select="floor(opensearch:startIndex div opensearch:itemsPerPage) + 1 + 11" /> + <xsl:with-param name="current" select="floor(opensearch:startIndex div opensearch:itemsPerPage) + 1" /> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + <a href="{nutch:nextPage}">»</a> + </center> </body> </html> </xsl:template> +<!-- Template to emit a search result as an HTML list item (<li/>). + --> <xsl:template match="item"> <li> <div class="searchResult"> @@ -146,8 +170,38 @@ </li> </xsl:template> +<!-- Template to emit a date in YYYY/MM/DD format + --> <xsl:template match="nutch:date" > <xsl:value-of select="substring(.,1,4)" /><xsl:text>-</xsl:text><xsl:value-of select="substring(.,5,2)" /><xsl:text>-</xsl:text><xsl:value-of select="substring(.,7,2)" /><xsl:text> </xsl:text> </xsl:template> +<!-- Template to generate a list of numbered links to results pages. + Parameters: + begin starting # inclusive + end ending # exclusive + current the current page, don't emit a link + --> +<xsl:template name="pageLinks"> + <xsl:param name="begin" /> + <xsl:param name="end" /> + <xsl:param name="current" /> + <xsl:if test="$begin < $end"> + <xsl:choose> + <xsl:when test="$begin = $current" > + <xsl:value-of select="$current" /> + </xsl:when> + <xsl:otherwise> + <a href="?query={nutch:query}&start={($begin -1) * opensearch:itemsPerPage}&hitsPerPage={opensearch:itemsPerPage}"><xsl:value-of select="$begin" /></a> + </xsl:otherwise> + </xsl:choose> + <xsl:text> </xsl:text> + <xsl:call-template name="pageLinks"> + <xsl:with-param name="begin" select="$begin + 1" /> + <xsl:with-param name="end" select="$end" /> + <xsl:with-param name="current" select="$current" /> + </xsl:call-template> + </xsl:if> +</xsl:template> + </xsl:stylesheet> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |