[prev in list] [next in list] [prev in thread] [next in thread] 

List:       forrest-dev
Subject:    svn commit: rev 10429 - in xml/forrest/trunk: . src/core/context src/core/context/resources/styleshe
From:       cheche () apache ! org
Date:       2004-04-29 19:58:09
Message-ID: 20040429195809.98815.qmail () minotaur ! apache ! org
[Download RAW message or body]

Author: cheche
Date: Thu Apr 29 12:58:07 2004
New Revision: 10429

Added:
   xml/forrest/trunk/src/core/context/resources/stylesheets/search/
   xml/forrest/trunk/src/core/context/resources/stylesheets/search/book2cinclude-lucene.xsl
  xml/forrest/trunk/src/core/context/resources/stylesheets/search/document2lucene.xsl
   xml/forrest/trunk/src/core/context/resources/stylesheets/search/lucene-update2document.xsl
  xml/forrest/trunk/src/core/context/resources/stylesheets/search/search2document.xsl
   xml/forrest/trunk/src/core/context/search.xmap
Modified:
   xml/forrest/trunk/src/core/context/sitemap.xmap
   xml/forrest/trunk/src/core/context/skins/common/xslt/html/site2xhtml.xsl
   xml/forrest/trunk/src/core/context/skins/forrest-site/xslt/html/site2xhtml.xsl
   xml/forrest/trunk/src/core/targets/context.xml
   xml/forrest/trunk/src/core/targets/webapp.xml
   xml/forrest/trunk/status.xml
Log:
Completely rewritten Lucene-based index and search functionality.
Thanks to Florian G. Haas


Added: xml/forrest/trunk/src/core/context/resources/stylesheets/search/book2cinclude-lucene.xsl
 ==============================================================================
--- (empty file)
+++ xml/forrest/trunk/src/core/context/resources/stylesheets/search/book2cinclude-lucene.xsl	Thu \
Apr 29 12:58:07 2004 @@ -0,0 +1,80 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 2002-2004 The Apache Software Foundation
+                                                                                     \
 +  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+                                                                                     \
 +      http://www.apache.org/licenses/LICENSE-2.0
+                                                                                     \
 +  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!--
+Generates a lucene:index for the whole site with CInclude elements where \
lucene:documents should be pulled in. +Input is expected to be in standard book.xml \
format. @hrefs should be normalized, although unnormalized hrefs can be +handled by \
uncommenting the relevant section. +
+f.g.haas@gmx.net (stealing shamelessly from jefft@apache.org)
+-->
+<xsl:stylesheet version="1.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:cinclude="http://apache.org/cocoon/include/1.0"
+  xmlns:lucene="http://apache.org/cocoon/lucene/1.0">
+
+  <!-- Java class name of the Lucene analyzer to be used -->
+  <xsl:param name="analyzer"/>
+
+  <!-- Directory where the lucene index will be created (relative to
+  Forrest working directory as determined by servlet engine) -->
+  <xsl:param name="directory"/>
+ 
+  <!-- Should the index be updated if it already exists? If false and
+  the index already exists, the index is re-created, and the original
+  index is discarded. -->
+  <xsl:param name="update-index"/>
+  
+  <!-- Index merge factor (see Lucene documentation) -->
+  <xsl:param name="merge-factor"/>  
+
+  <!-- The extension of the lucene index fragments. -->
+  <xsl:param name="extension" select="'.lucene'"/>
+
+
+  <!-- Creates the lucene:index root element from the Forrest
+  book. -->
+  <xsl:template match="book">
+    <lucene:index analyzer="{$analyzer}"
+      directory="{$directory}"
+      create="{not(boolean($update-index))}"
+      merge-factor="{$merge-factor}">
+      <xsl:apply-templates select="menu|menu-item"/>
+    </lucene:index>
+  </xsl:template>
+
+  <!-- Recursively processes menu elements. -->
+  <xsl:template match="menu">
+    <xsl:apply-templates/>
+  </xsl:template>
+
+  <xsl:template match="menu-item[@type='hidden']"/>  <!-- Ignore hidden items -->
+  <xsl:template match="menu-item[contains(@href, '#')]"/>  <!-- Ignore #frag-id \
items --> +  <xsl:template match="menu-item[starts-with(@href, 'http:')]"/>  <!-- \
Ignore absolute http urls --> +  <xsl:template match="menu-item[starts-with(@href, \
'https:')]"/>  <!-- Ignore absolute https urls --> +
+  <!-- Inserts a cinclude:include element for document referenced by
+  menu item. -->
+  <xsl:template match="menu-item">
+    <cinclude:include>
+      <xsl:attribute name="src">
+        <xsl:text>cocoon://</xsl:text>
+        <xsl:value-of select="concat(substring-before(@href, '.'), $extension)"/>
+      </xsl:attribute>
+    </cinclude:include>
+  </xsl:template>
+
+</xsl:stylesheet>

Added: xml/forrest/trunk/src/core/context/resources/stylesheets/search/document2lucene.xsl
 ==============================================================================
--- (empty file)
+++ xml/forrest/trunk/src/core/context/resources/stylesheets/search/document2lucene.xsl	Thu \
Apr 29 12:58:07 2004 @@ -0,0 +1,82 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 2002-2004 The Apache Software Foundation
+                                                                                     \
 +  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+                                                                                     \
 +      http://www.apache.org/licenses/LICENSE-2.0
+                                                                                     \
 +  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- Transforms a Forrest document into a result tree fragment
+     suitable for use by the LuceneIndexTransformer. 
+
+     Note: the result document generated by this stylesheet CANNOT be
+     transformed by the LuceneIndexTransformer directly. Aggregation is
+     required to assemble several of the lucene:document elements
+     (which this stylesheet generates) into one lucene:index root
+     element. -->
+<xsl:stylesheet
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:lucene="http://apache.org/cocoon/lucene/1.0"
+  version="1.0">
+
+  <!-- The URL of the document which the indexing information stems
+  from -->
+  <xsl:param name="document-url"/>
+
+  <!-- Creates a lucene:document element, and assigns the url
+  attribute as passed in via top-level param -->
+  <xsl:template match="/">
+    <lucene:document url="{$document-url}">
+      <xsl:apply-templates select="document/header" mode="store"/>
+      <contents>
+        <xsl:apply-templates/>
+      </contents>
+    </lucene:document>
+  </xsl:template>
+
+  <!-- Copies document header, title, and version, and instructs
+  Lucene to store the contents of these elements (in addition to
+  indexing them) -->
+  <xsl:template match="/document/header/title |
+                       /document/header/subtitle |
+                       /document/header/abstract |
+                       /document/header/version"
+                mode="store">
+    <xsl:element name="{name(.)}">
+      <xsl:attribute name="lucene:store">true</xsl:attribute>
+      <xsl:apply-templates/>
+    </xsl:element>
+  </xsl:template>
+
+  <!-- Copies authors/person, and instructs
+  Lucene to store the contents of the person element and to index the
+  email and name attributes -->
+  <xsl:template match="/document/header/authors/person"
+                mode="store">
+    <author>
+      <xsl:attribute name="lucene:store">true</xsl:attribute>
+      <xsl:value-of select="@name"/>
+    </author>
+  </xsl:template>
+
+  <!-- Everything else from document/header should be ignored -->
+  <xsl:template match="/document/header/notice |
+                       /document/header/type"
+                mode="store">
+  </xsl:template>
+
+  <!-- Copies an element and its attributes (text content is handled
+  by implicit default template) -->
+  <xsl:template match="*">
+    <xsl:apply-templates/>
+  </xsl:template>
+  
+</xsl:stylesheet>

Added: xml/forrest/trunk/src/core/context/resources/stylesheets/search/lucene-update2document.xsl
 ==============================================================================
--- (empty file)
+++ xml/forrest/trunk/src/core/context/resources/stylesheets/search/lucene-update2document.xsl	Thu \
Apr 29 12:58:07 2004 @@ -0,0 +1,77 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 2002-2004 The Apache Software Foundation
+                                                                                     \
 +  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+                                                                                     \
 +      http://www.apache.org/licenses/LICENSE-2.0
+                                                                                     \
 +  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- Creates a Forrest document containing status information from a
+     Lucene index creation or update. -->
+<xsl:stylesheet
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:lucene="http://apache.org/cocoon/lucene/1.0"
+  version="1.0">
+
+  <xsl:template match="/">
+    <xsl:apply-templates/>
+  </xsl:template>
+
+  <xsl:template match="lucene:index">
+    <document>
+      <header>
+        <title>Lucene Index Creation Report</title>
+      </header>
+      <body>
+        <p>
+          <xsl:text>Lucene has created an index in a directory named </xsl:text>
+          <code>
+            <xsl:value-of select="@directory"/>
+          </code>
+          <xsl:text> below your servlet container's context
+          root. </xsl:text>
+          <xsl:text>It used the analyzer class </xsl:text>
+          <code>
+            <xsl:value-of select="@analyzer"/>
+          </code>
+          <xsl:text> for this purpose.</xsl:text>
+        </p>
+        <p>
+          <xsl:value-of select="count(lucene:document)"/>
+          <xsl:text> documents were indexed. </xsl:text>
+          <xsl:text>The index was created with a merge factor
+          of </xsl:text>
+          <xsl:value-of select="@merge-factor"/>
+          <xsl:text>, just in case you're interested.</xsl:text>
+        </p>
+        <section>
+          <title>Index creation time breakdown</title>
+          <xsl:apply-templates/>
+        </section>
+      </body>
+    </document>
+  </xsl:template>
+
+  <xsl:template match="lucene:document">
+    <p>
+      <xsl:text>The document </xsl:text>
+      <strong>
+        <xsl:value-of select="@url"/>
+      </strong>
+      <xsl:text> was indexed in </xsl:text>
+      <strong>
+        <xsl:value-of select="@elapsed-time"/>
+        <xsl:text>ms</xsl:text>
+      </strong>
+      <xsl:text>.</xsl:text>
+    </p>
+  </xsl:template>
+</xsl:stylesheet>

Added: xml/forrest/trunk/src/core/context/resources/stylesheets/search/search2document.xsl
 ==============================================================================
--- (empty file)
+++ xml/forrest/trunk/src/core/context/resources/stylesheets/search/search2document.xsl	Thu \
Apr 29 12:58:07 2004 @@ -0,0 +1,228 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 2002-2004 The Apache Software Foundation
+                                                                                     \
 +  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+                                                                                     \
 +      http://www.apache.org/licenses/LICENSE-2.0
+                                                                                     \
 +  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- Generates a Forrest document from a Lucene search result. -->
+<xsl:stylesheet
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:search="http://apache.org/cocoon/search/1.0" 
+  xmlns:xlink="http://www.w3.org/1999/xlink"
+  version="1.0">
+
+  <!-- The HTTP request parameter to pass in the query string -->
+  <xsl:param name="query-string-param" select="'queryString'"/>
+
+  <!-- The HTTP request parameter to pass in the page length (number
+  of hits displayed per search result page) -->
+  <xsl:param name="page-length-param" select="'pageLength'"/>
+
+  <!-- The HTTP request parameter to pass in the start index (the
+  index of the first item in a hit list that is actually being
+  displayed) -->
+  <xsl:param name="start-index-param" select="'startIndex'"/>
+
+  <!-- The URL of the search page. -->
+  <xsl:param name="search-url" select="'lucene-search.html'"/>
+
+  <xsl:template match="/">
+    <xsl:apply-templates/>
+  </xsl:template>
+
+  <xsl:template match="search:results">
+    <document>
+      <header>
+        <!-- FIXME: i18n stuff here -->
+        <title>Search Results</title>
+      </header>
+      <body>
+        <xsl:if test="not(search:hits)">
+          <note>
+            <xsl:text>Your search for </xsl:text>
+            <code>
+              <xsl:value-of select="@query-string"/>
+            </code>
+            <xsl:text> returned no results. Check that you spelled your
+            search terms correctly, or choose more generic terms to
+            broaden your search.</xsl:text>
+          </note>
+        </xsl:if>
+        <xsl:apply-templates/>
+      </body>
+    </document>
+    
+  </xsl:template>
+  
+  <xsl:template match="search:hits">
+    <xsl:apply-templates/>
+  </xsl:template>
+
+  <!-- Displays the search hit as a paragraph. -->
+  <xsl:template match="search:hit">
+    <p>
+      <!-- FIXME: Score should be displayed in some graphical manner
+      (stars, color codes, whatever) -->
+      <strong>
+        <xsl:text>Score </xsl:text>
+        <xsl:value-of select="@score"/>
+        <xsl:text>: </xsl:text>
+      </strong>
+      <xsl:apply-templates select="." mode="create-link"/>
+      <xsl:apply-templates select="search:field[@name= 'author']"/>
+      <xsl:apply-templates select="search:field[@name= 'abstract']"/>
+    </p>
+  </xsl:template>
+  
+  <!-- Renders the url attribute of a search hit as a Forrest
+  link. -->
+  <xsl:template match="search:hit" mode="create-link">
+    <xsl:variable name="mangledlink">
+      <xsl:value-of select="concat(substring-before(@uri, '.'), '.html')"/>
+      <!--
+      <xsl:choose>
+        <xsl:when test="substring(@uri,string-length(@uri)-3) = '.xml'">
+          <xsl:text>site:</xsl:text>
+          <xsl:value-of select="substring(@uri, 1, string-length(@uri)-4)"/>
+        </xsl:when>
+        <xsl:when test="substring(@uri,string-length(@uri)-5) = '.ehtml'">
+          <xsl:text>site:</xsl:text>
+          <xsl:value-of select="substring(@uri, 1, string-length(@uri)-6)"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:value-of select="@uri"/>
+        </xsl:otherwise>
+      </xsl:choose>
+      -->
+    </xsl:variable>
+
+    <xsl:variable name="linktext">
+      <xsl:choose>
+        <!-- If a field for the document title exists, use its
+        contents as the link text. -->
+        <xsl:when test="search:field[@name = 'title']">
+          <xsl:value-of select="search:field[@name = 'title']"/>
+        </xsl:when>
+        <!-- Otherwise, use the mangled link as determined above -->
+        <xsl:otherwise>
+          <xsl:value-of select="$mangledlink"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+
+    <!-- Create the link -->
+    <link>
+      <xsl:attribute name="href">
+        <xsl:value-of select="$mangledlink"/>
+      </xsl:attribute>
+      <xsl:value-of select="$linktext"/>
+    </link>
+  </xsl:template>
+
+  <!-- If a document's author is known, displays the author's name in
+  parentheses -->
+  <xsl:template match="search:field[@name = 'author' and text() != '']">
+    <xsl:text> (</xsl:text>
+    <xsl:apply-templates/>
+    <xsl:text>) </xsl:text>
+  </xsl:template>
+
+  <!-- If a abstract exists for a document, displays it with emphasis -->
+  <xsl:template match="search:field[@name = 'abstract' and text() != '']">
+    <em>
+      <xsl:apply-templates/>
+    </em>
+  </xsl:template>
+
+  <!-- Creates a document footer, to be used for navigation -->
+  <xsl:template match="search:navigation">
+    <xsl:variable name="startindex" select="../@start-index"/>
+    <xsl:variable name="hitcount" select="count(../search:hits/search:hit)"/>
+    <xsl:variable name="endindex" select="$startindex + $hitcount - 1"/>
+    <xsl:variable name="totalhitcount" select="@total-count"/>
+
+    <footer>
+      <xsl:if test="$totalhitcount != 0">
+        <xsl:choose>
+          <xsl:when test="../@page-length = 1">
+            <xsl:text>Displaying hit </xsl:text>
+            <!-- A zero-based index might be confusing to users, so we
+            simply add 1 to the real index values -->
+            <xsl:value-of select="$startindex + 1"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:text>Displaying hits </xsl:text>
+            <!-- A zero-based index might be confusing to users, so we
+            simply add 1 to the real index values -->
+            <xsl:value-of select="$startindex + 1"/>
+            <xsl:text> to </xsl:text>
+            <xsl:value-of select="$endindex + 1"/>
+          </xsl:otherwise>
+        </xsl:choose>
+        <xsl:text> of </xsl:text>
+        <xsl:value-of select="$totalhitcount"/>
+        <xsl:text> total hits for query </xsl:text>
+        <code>
+          <xsl:value-of select="../@query-string"/>
+        </code>
+        <xsl:text>.</xsl:text>
+
+        <!-- Display "previous page" link, if appropriate -->
+        <xsl:if test="@has-previous = 'true'">
+          <xsl:text>&#160;</xsl:text>
+          <xsl:call-template name="nav-link">
+            <xsl:with-param name="linktext">Previous page</xsl:with-param>
+            <xsl:with-param name="start-index" select="@previous-index"/>
+          </xsl:call-template>
+        </xsl:if>
+
+        <!-- Display "next page" link, if appropriate -->
+        <xsl:if test="@has-next = 'true'">
+          <xsl:text>&#160;</xsl:text>
+          <xsl:call-template name="nav-link">
+            <xsl:with-param name="linktext">Next page</xsl:with-param>
+            <xsl:with-param name="startindex" select="@next-index"/>
+          </xsl:call-template>
+        </xsl:if>
+      </xsl:if>
+    </footer>
+  </xsl:template>
+
+  <!-- Convenience template, constructs a link to jump to a specific
+  item in the hit list. -->
+  <xsl:template name="nav-link">
+    <xsl:param name="context" select="."/>
+    <xsl:param name="linktext"/>
+    <xsl:param name="startindex"/>
+
+    <link>
+      <xsl:attribute name="href">
+        <xsl:value-of select="$search-url"/>
+        <xsl:text>?</xsl:text>
+        <xsl:value-of select="$query-string-param"/>
+        <xsl:text>=</xsl:text>
+        <xsl:value-of select="$context/../@query-string"/>
+        <xsl:text>&amp;</xsl:text>
+        <xsl:value-of select="$start-index-param"/>
+        <xsl:text>=</xsl:text>
+        <xsl:value-of select="$startindex"/>
+        <xsl:text>&amp;</xsl:text>
+        <xsl:value-of select="$page-length-param"/>
+        <xsl:text>=</xsl:text>
+        <xsl:value-of select="$context/../@page-length"/>
+      </xsl:attribute>
+      <xsl:value-of select="$linktext"/>
+    </link>
+
+  </xsl:template>
+</xsl:stylesheet>

Added: xml/forrest/trunk/src/core/context/search.xmap
==============================================================================
--- (empty file)
+++ xml/forrest/trunk/src/core/context/search.xmap	Thu Apr 29 12:58:07 2004
@@ -0,0 +1,157 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 2002-2004 The Apache Software Foundation
+                                                                                     \
 +  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+                                                                                     \
 +      http://www.apache.org/licenses/LICENSE-2.0
+                                                                                     \
 +  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- ===============================================
+Pipelines relevant to Lucene index creation and searching.
+
+Creates lucene:documents from Forrest documents, to be used for indexing
+by the LuceneIndexTransformer.
+
+Aggregates all lucene:documents from a site into a single lucene:index
+document.
+
+Uses the LuceneIndexTransformer to create a Lucene index from this
+lucene:index document.
+
+Allows searching the Lucene index using the Cocoon SearchGenerator.
+
+Generates   :  Lucene lucene:index documents, search results 
+Example URLs:  http://localhost/lucene-update.html (Index creation)
+               http://localhost/**.html (use the search box after setting
+               <search provider="lucene"/> in skinconf.xml)
+Uses        :  content/xdocs/**.xml, context/xdocs/**.ehtml,
+               resources/stylesheets/*2lucene*.xsl
+
+$Revision$
+==================================================== -->
+
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+  <map:components>
+
+    <!-- Lucene search generator: Creates a hit list from a query and
+    an existing index. -->
+    <map:generators default="file">
+      <map:generator name="search" 
+        logger="sitemap.generator.searchgenerator"
+        src="org.apache.cocoon.generation.SearchGenerator" />
+    </map:generators>
+
+    <!-- Lucene index transformer: Creates a new Lucene index. -->
+    <map:transformers default="xslt">
+      <map:transformer name="index" 
+        logger="sitemap.transformer.luceneindextransformer" 
+        src="org.apache.cocoon.transformation.LuceneIndexTransformer"/>      
+    </map:transformers>
+
+    <map:readers default="resource"/>
+    <map:serializers default="html"/>
+    <map:matchers default="wildcard"/>
+
+  </map:components>
+  <!-- =========================== Pipelines ================================= -->
+  <map:pipelines>
+
+    <map:pipeline internal-only="false">
+      
+      <!-- ===== INDEX CREATION ===== -->
+
+      <!-- Creates or updates the Lucene index -->
+      <map:match pattern="lucene-update.xml">
+        <map:generate src="cocoon:/site.lucene"/>
+        <map:transform type="index"/>
+        <map:transform \
src="{forrest:stylesheets}/search/lucene-update2document.xsl"/> +        \
<map:serialize type="xml"/> +      </map:match>
+
+
+      <!-- ===== INDEX QUERYING ===== -->
+
+      <!-- Searches the Lucene index using the search expression given
+      in the request param named "queryString" -->
+      <map:match pattern="lucene-search.xml">
+        <map:generate type="search">
+          <!-- Important: This value must match that of the
+          "directory" parameter passed to book2include-lucene.xsl (see
+          below) -->
+          <map:parameter name="index" value="lucene-index"/>
+          <map:parameter name="query-string" value="queryString"/>
+        </map:generate>
+
+        <map:transform
+        src="{forrest:stylesheets}/search/search2document.xsl"/>
+
+        <map:serialize type="xml"/>
+      </map:match>
+
+
+      <!-- ===== DOCUMENTS FOR LUCENE INDEX TRANSFORMER ===== -->
+
+      <!-- Generates a document suitable for processing by the
+      LuceneIndexTransformer, using sources across the whole site -->
+      <map:match pattern="site.lucene">
+        <map:generate src="cocoon://abs-linkmap"/>
+        <map:transform src="{forrest:stylesheets}/site2book.xsl" />
+        <map:transform src="{forrest:stylesheets}/search/book2cinclude-lucene.xsl">
+          <map:parameter name="analyzer" \
value="org.apache.lucene.analysis.standard.StandardAnalyzer"/> +          \
<map:parameter name="merge-factor" value="20"/> +          <map:parameter \
name="update-index" value="true"/> +          <!-- Important: This value must match \
that of the +          "index" parameter passed to the search generator (see
+          above) -->
+          <map:parameter name="directory" value="lucene-index"/>
+        </map:transform>
+        <map:transform type="cinclude"/>
+        <map:serialize type="xml"/>
+      </map:match>
+
+      <!-- Creates a lucene:document from a Forrest document body -->
+      <map:match pattern="**body-*.lucene">
+        <map:select type="exists">
+          <map:when test="{project:content.xdocs}{1}{2}.ehtml">
+            <map:generate src="{project:content.xdocs}{1}{2}.ehtml" />
+            <map:transform src="{forrest:stylesheets}/html2htmlbody.xsl" />
+          </map:when>
+          <map:when test="cocoon://{1}{2}.xml">
+            <map:generate src="cocoon://{1}{2}.xml"/>
+          </map:when>
+        </map:select>
+        <map:transform src="{forrest:stylesheets}/search/document2lucene.xsl">
+          <map:parameter name="document-url" value="{1}{2}.xml"/>
+        </map:transform>
+        <map:serialize type="xml"/>
+      </map:match>
+
+      <!-- Creates a lucene:document from a Forrest document (same as
+      above, as search-relevent information is only contained in the
+      body) -->
+      <map:match pattern="*.lucene">
+        <map:generate src="cocoon:/body-{0}"/>
+        <map:serialize type="xml"/>
+      </map:match>         
+      <map:match pattern="**/*.lucene">
+        <map:generate src="cocoon:/{1}/body-{2}.lucene"/>
+        <map:serialize type="xml"/>
+      </map:match>
+
+      <!-- ===== TODO: ERROR HANDLING ===== -->
+
+      <!-- Must do something about malformed (unparseable) queries or
+      a non-existant index. -->
+
+    </map:pipeline>
+
+  </map:pipelines>
+</map:sitemap>

Modified: xml/forrest/trunk/src/core/context/sitemap.xmap
==============================================================================
--- xml/forrest/trunk/src/core/context/sitemap.xmap	(original)
+++ xml/forrest/trunk/src/core/context/sitemap.xmap	Thu Apr 29 12:58:07 2004
@@ -257,7 +257,12 @@
         <map:match pattern="site.xml">
           <map:mount uri-prefix="" src="aggregate.xmap" check-reload="yes" />
         </map:match>
-     
+
+        <!-- Lucene index update and search -->
+        <map:match pattern="lucene-*.xml">
+          <map:mount uri-prefix="" src="search.xmap" check-reload="yes"/>
+        </map:match>
+
         <!-- Default source types -->
         <map:mount uri-prefix="" src="forrest.xmap" check-reload="yes" />
 
@@ -478,6 +483,9 @@
       </map:match>
      <map:match pattern="**.ico">
         <map:mount uri-prefix="" src="resources.xmap" check-reload="yes" />
+      </map:match> 
+      <map:match pattern="**.lucene">
+        <map:mount uri-prefix="" src="search.xmap" check-reload="yes" />
       </map:match> 
     </map:pipeline>
 

Modified: xml/forrest/trunk/src/core/context/skins/common/xslt/html/site2xhtml.xsl
==============================================================================
--- xml/forrest/trunk/src/core/context/skins/common/xslt/html/site2xhtml.xsl	(original)
                
+++ xml/forrest/trunk/src/core/context/skins/common/xslt/html/site2xhtml.xsl	Thu Apr \
29 12:58:07 2004 @@ -58,6 +58,9 @@
     </xsl:call-template>
   </xsl:variable>
 
+  <!-- Path of Lucene search results page (relative to $root) -->
+  <xsl:param name="lucene-search" select="'lucene-search.html'"/>
+
   <xsl:variable name="skin-img-dir" select="concat(string($root), 'skin/images')"/>
   <xsl:variable name="spacer" select="concat($root, 'skin/images/spacer.gif')"/>
 

Modified: xml/forrest/trunk/src/core/context/skins/forrest-site/xslt/html/site2xhtml.xsl
 ==============================================================================
--- xml/forrest/trunk/src/core/context/skins/forrest-site/xslt/html/site2xhtml.xsl	(original)
                
+++ xml/forrest/trunk/src/core/context/skins/forrest-site/xslt/html/site2xhtml.xsl	Thu \
Apr 29 12:58:07 2004 @@ -107,39 +107,73 @@
         <xsl:comment>================= start Search ==================</xsl:comment>
         <td bgcolor="{$header-color}" rowspan="2" valign="top">
           <xsl:if test="$config/search">
-            <form method="get" action="http://www.google.com/search" \
                target="_blank">
-              <table bgcolor="{$menu-border}" cellpadding="0" cellspacing="0" \
                border="0" summary="search">
-                <tr>
-                  <td colspan="3"><img class="spacer" src="{$spacer}" alt="" \
                width="1" height="10" /></td>
-                </tr>
-                <tr>
-                  <td><img class="spacer" src="{$spacer}" alt="" width="1" \
                height="1" /></td>
-                  <td nowrap="nowrap">
-                    <input type="hidden" name="sitesearch" \
                value="{$config/search/attribute::domain}"/>
-                    <input type="text" id="query" name="q" size="15"/>
-                    <img class="spacer" src="{$spacer}" alt="" width="5" height="1" \
                />
-                    <input type="submit" value="Search" name="Search"/>
-                    <br />
-                    <font color="white" size="2" face="Arial, Helvetica, \
                Sans-serif">
-                      the <xsl:value-of select="$config/search/attribute::name"/> \
                site
-                      <!-- setting search options off for the moment -->
-                      <!--
-                      <input type="radio" name="web" value="web"/>web \
                site&#160;&#160;<input type="radio" name="mail" value="mail"/>mail \
                lists
-                      -->
-                    </font>
-                  </td>
-                  <td><img class="spacer" src="{$spacer}" alt="" width="1" \
                height="1" /></td>
-                </tr>
-                <tr>
-                  <td><img src="{$skin-img-dir}/search-left.gif" width="9" \
                height="10" border="0" alt="" /></td>
-                  <td><img class="spacer" src="{$spacer}" alt="" width="1" \
                height="1" /></td>
-                  <td><img src="{$skin-img-dir}/search-right.gif" width="9" \
                height="10" border="0" alt="" /></td>
-                </tr>
-              </table>
-            </form>
+           <xsl:choose>
+              <xsl:when test="$config/search/@provider = 'lucene'">
+                <!-- Lucene search -->
+                <form method="get" action="{$root}{$lucene-search}">
+                  <table bgcolor="{$menu-border}" cellpadding="0" cellspacing="0" \
border="0" summary="search"> +                    <tr>
+                      <td colspan="3"><img class="spacer" src="{$spacer}" alt="" \
width="1" height="10" /></td> +                    </tr>
+                    <tr>
+                      <td><img class="spacer" src="{$spacer}" alt="" width="1" \
height="1" /></td> +                      <td nowrap="nowrap">
+                        <input type="text" id="query" name="queryString" size="15"/>
+                        <img class="spacer" src="{$spacer}" alt="" width="5" \
height="1" /> +                        <input type="submit" value="Search" \
name="Search"/> +                        <br />
+                        <font color="white" size="2" face="Arial, Helvetica, \
Sans-serif"> +                          the <xsl:value-of \
select="$config/search/attribute::name"/> site +                        </font>
+                      </td>
+                      <td><img class="spacer" src="{$spacer}" alt="" width="1" \
height="1" /></td> +                    </tr>
+                    <tr>
+                      <td><img src="{$skin-img-dir}/search-left.gif" width="9" \
height="10" border="0" alt="" /></td> +                      <td><img class="spacer" \
src="{$spacer}" alt="" width="1" height="1" /></td> +                      <td><img \
src="{$skin-img-dir}/search-right.gif" width="9" height="10" border="0" alt="" \
/></td> +                    </tr>
+                  </table>
+                </form>
+              </xsl:when>
+              <xsl:otherwise>
+                <!-- Google search -->
+                <form method="get" action="http://www.google.com/search" \
target="_blank"> +                  <table bgcolor="{$menu-border}" cellpadding="0" \
cellspacing="0" border="0" summary="search"> +                    <tr>
+                      <td colspan="3"><img class="spacer" src="{$spacer}" alt="" \
width="1" height="10" /></td> +                    </tr>
+                    <tr>
+                      <td><img class="spacer" src="{$spacer}" alt="" width="1" \
height="1" /></td> +                      <td nowrap="nowrap">
+                        <input type="hidden" name="sitesearch" \
value="{$config/search/attribute::domain}"/> +                        <input \
type="text" id="query" name="q" size="15"/> +                        <img \
class="spacer" src="{$spacer}" alt="" width="5" height="1" /> +                       \
<input type="submit" value="Search" name="Search"/> +                        <br />
+                        <font color="white" size="2" face="Arial, Helvetica, \
Sans-serif"> +                          the <xsl:value-of \
select="$config/search/attribute::name"/> site +                          <!-- \
setting search options off for the moment --> +                          <!--
+                          <input type="radio" name="web" value="web"/>web \
site&#160;&#160;<input type="radio" name="mail" value="mail"/>mail lists +            \
--> +                        </font>
+                      </td>
+                      <td><img class="spacer" src="{$spacer}" alt="" width="1" \
height="1" /></td> +                    </tr>
+                    <tr>
+                      <td><img src="{$skin-img-dir}/search-left.gif" width="9" \
height="10" border="0" alt="" /></td> +                      <td><img class="spacer" \
src="{$spacer}" alt="" width="1" height="1" /></td> +                      <td><img \
src="{$skin-img-dir}/search-right.gif" width="9" height="10" border="0" alt="" \
/></td> +                    </tr>
+                  </table>
+                </form>
+              </xsl:otherwise>
+            </xsl:choose>
           </xsl:if>
+
         </td>
-        <xsl:comment>================= start Search ==================</xsl:comment>
+        <xsl:comment>================= end Search ==================</xsl:comment>
 
         <td bgcolor="{$header-color}"><img class="spacer" src="{$spacer}" alt="" \
width="10" height="10" /></td>  </tr>

Modified: xml/forrest/trunk/src/core/targets/context.xml
==============================================================================
--- xml/forrest/trunk/src/core/targets/context.xml	(original)
+++ xml/forrest/trunk/src/core/targets/context.xml	Thu Apr 29 12:58:07 2004
@@ -161,23 +161,29 @@
 
  
   <!-- ===============================================================
-       Prepares the Lucene context indexing the site. [RPR]
+       Prepares the Lucene context indexing the site. 
        =============================================================== -->
-  <target name="lucene-index" depends="init, -prepare-classpath" \
                if="use-lucene-indexer">
-    <java classname="org.apache.forrest.search.ForrestIndexer"
-      dir="${project.webapp}"
-      fork="true"
-      failonerror="true"
-      maxmemory="${forrest.maxmemory}">
-      <jvmarg line="${forrest.jvmargs}"/>
-      <jvmarg line="${forrest.basic.jvmargs}"/>
-      <jvmarg value="-Djava.endorsed.dirs=${forrest.home}/lib/endorsed${path.separator}${java.endorsed.dirs}"/>
                
-      <arg line="-index ${project.index-dir}"/>
-      <arg value="${xdocs-dir}"/>
-      <classpath>
-        <path refid="forrest.cp"/>
-      </classpath>
-    </java>
-  </target>
+  <target name="lucene-index">
+   <java classname="org.apache.cocoon.Main"
+        fork="true"
+        dir="${project.webapp}"
+        failonerror="true"
+        maxmemory="${forrest.maxmemory}">
+        <jvmarg line="${forrest.jvmargs}"/>
+        <jvmarg line="${forrest.basic.jvmargs}"/>
+        <jvmarg value="-Djava.endorsed.dirs=${forrest.home}/lib/endorsed${path.separator}${java.endorsed.dirs}"/>
 +        <arg value="--logLevel=${project.debuglevel}"/>
+        <arg value="--Logger=${project.logger}"/>
+        <arg value="--logKitconfig=${project.logkitfile}"/>
+        <arg value="--destDir=${project.temp-dir}"/>
+        <arg value="--xconf=${project.configfile}"/>
+        <arg value="--followLinks=false"/>
+        <arg value="-w${project.cocoon-work-dir}"/>
+        <arg value="lucene-update.html"/>
+        <classpath>
+          <path refid="forrest.cp"/>
+        </classpath>
+      </java>
+</target>
 
 </project>

Modified: xml/forrest/trunk/src/core/targets/webapp.xml
==============================================================================
--- xml/forrest/trunk/src/core/targets/webapp.xml	(original)
+++ xml/forrest/trunk/src/core/targets/webapp.xml	Thu Apr 29 12:58:07 2004
@@ -50,16 +50,13 @@
          Is this really a concern of the skinconf?
          The indexer must be off by default. If the optional skinconf parameter
          "disable-lucene" is missing or false, then off. 
-    -->
     <condition property="use-lucene-indexer">
-      <!-- sorry for the convolution -->
-      <and>
-        <isset property="skinconfig.disable-lucene"/>
-        <isfalse value="${skinconfig.disable-lucene}"/>
-      </and>
+        <isset property="skinconfig.search(provider)"/>
+        <equals arg1="${skinconfig.search(provider)}" arg2="lucene"/>
     </condition>
     <antcall target="lucene-index"/>
-    
+    -->
+
     <available file="${content-dir}/jettyconf.xml" 
       property="custom_jetty_config"/>
 

Modified: xml/forrest/trunk/status.xml
==============================================================================
--- xml/forrest/trunk/status.xml	(original)
+++ xml/forrest/trunk/status.xml	Thu Apr 29 12:58:07 2004
@@ -44,6 +44,9 @@
 
   <changes>
     <release version="0.6-dev" date="unreleased">
+      <action dev="JJP" type="update" context="core" due-to="Florian G. Haas" \
fixes-bug="FOR-9"> +        Completely rewritten Lucene-based index and search \
functionality +      </action>
       <action dev="JJP" type="fix" context="core" fixes-bug="FOR-139">
         skinconf was ignore for the svg and fo formats.
       </action>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic