You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by mr...@apache.org on 2007/10/24 15:07:45 UTC
svn commit: r587888 - in
/jackrabbit/trunk/jackrabbit-webapp/src/main/webapp: populate.jsp search.jsp
Author: mreutegg
Date: Wed Oct 24 06:07:44 2007
New Revision: 587888
URL: http://svn.apache.org/viewvc?rev=587888&view=rev
Log:
JCR-1184: Introduce spellchecker functionality based on content in the workspace
- use spell checker if available
Modified:
jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/populate.jsp
jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/search.jsp
Modified: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/populate.jsp
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/populate.jsp?rev=587888&r1=587887&r2=587888&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/populate.jsp (original)
+++ jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/populate.jsp Wed Oct 24 06:07:44 2007
@@ -166,6 +166,9 @@
for (Iterator fn = folderNames.iterator(); fn.hasNext(); ) {
String name = URLDecoder.decode((String) fn.next(), "UTF-8");
name = name.replaceAll(":", "_");
+ if (name.length() == 0) {
+ continue;
+ }
if (!node.hasNode(name)) {
node.addNode(name, "nt:folder");
}
@@ -380,10 +383,10 @@
private void reportProgress(int r) throws IOException {
if (r != -1) {
read += r;
- if (read > nextReport || read == length * 2) {
+ if (read > nextReport || read == length) {
// report every 16k
synchronized (out) {
- double s = 500d * (double) read / (double) length;
+ double s = 1000d * (double) read / (double) length;
out.println("<script>" + varName + ".inform(" +
Math.min((int) Math.ceil(s), 1000) +
", '" + fileName + "')</script>");
Modified: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/search.jsp
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/search.jsp?rev=587888&r1=587887&r2=587888&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/search.jsp (original)
+++ jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/search.jsp Wed Oct 24 06:07:44 2007
@@ -32,7 +32,9 @@
java.text.DateFormat,
java.util.List,
java.util.ArrayList,
- java.util.Iterator"%>
+ java.util.Iterator,
+ javax.jcr.Value,
+ javax.jcr.RepositoryException"%>
<%@ page contentType="text/html;charset=UTF-8" %><%
Repository rep;
Session jcrSession;
@@ -64,6 +66,7 @@
long currentPageIndex = 0;
List indexes = new ArrayList();
RowIterator rows = null;
+ String suggestedQuery = null;
if (q != null && q.length() > 0) {
String stmt;
if (q.startsWith("related:")) {
@@ -109,6 +112,19 @@
for (long i = minPage; i < maxPage; i++) {
indexes.add(new Long(i));
}
+
+ if (total < 10 && !q.startsWith("related:")) {
+ try {
+ Value v = jcrSession.getWorkspace().getQueryManager().createQuery(
+ "/jcr:root[rep:spellcheck('" + q + "')]/(rep:spellcheck())",
+ Query.XPATH).execute().getRows().nextRow().getValue("rep:spellcheck()");
+ if (v != null) {
+ suggestedQuery = v.getString();
+ }
+ } catch (RepositoryException e) {
+ // ignore
+ }
+ }
}
%><html>
<head>
@@ -200,6 +216,11 @@
<table border=0 cellpadding=0 cellspacing=0 width=100% class="t bt">
<tr><td nowrap><span id=sd> Workspace: <%= wspName %> </span></td></tr>
</table>
+ <%
+ if (suggestedQuery != null) {
+ %><p><font class="p" color="#cc0000">Did you mean: </font><a href="search.jsp?q=<%= suggestedQuery %>" class="p"><b><i><%= suggestedQuery %></i></b></a> <br></p><%
+ }
+ %>
<p/>Your search - <b><%= q %></b> - did not match any documents.
<br/><br/>Suggestions:
<ul><li>Make sure all words are spelled correctly.</li><li>Try different keywords.</li><li>Try more general keywords.</li><li>Try fewer keywords.</li></ul>
@@ -209,7 +230,11 @@
<table border=0 cellpadding=0 cellspacing=0 width=100% class="t bt">
<tr><td nowrap><span id=sd> Workspace: <%= wspName %> </span></td><td align=right nowrap><font size=-1>Results <b><%= from + 1 %></b> - <b><%= to %></b> of about <b><%= totalResults %></b> <%= queryTerms %>. (<b><%= executedIn %></b> seconds) </font></td></tr>
</table>
-
+ <%
+ if (suggestedQuery != null) {
+ %><p><font class="p" color="#cc0000">Did you mean: </font><a href="search.jsp?q=<%= suggestedQuery %>" class="p"><b><i><%= suggestedQuery %></i></b></a> <br></p><%
+ }
+ %>
<div id=res>
<%
while (rows.hasNext() && rows.getPosition() < to) {