You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nutch.apache.org by si...@apache.org on 2006/05/08 18:26:18 UTC
svn commit: r405088 - in /lucene/nutch/trunk/contrib/web2: ./
src/main/java/org/apache/nutch/webapp/common/
src/main/java/org/apache/nutch/webapp/controller/ src/main/webapp/WEB-INF/
src/main/webapp/WEB-INF/jsp/
Author: siren
Date: Mon May 8 09:25:53 2006
New Revision: 405088
URL: http://svn.apache.org/viewcvs?rev=405088&view=rev
Log:
removed log flooding, removed unneycessaru code from PreferencesController, integrated displaying information of index-more plugin
Added:
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/MoreController.java
Modified:
lucene/nutch/trunk/contrib/web2/README.txt
lucene/nutch/trunk/contrib/web2/build.xml
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/NavigationHelper.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/Search.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/NutchController.java
lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/PreferencesController.java
lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/jsp/more.jsp
lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/jsp/preferences.jsp
lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/jsp/results.jsp
lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/jsp/search.jsp
lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/jsp/template.jsp
lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/tiles-defs.xml
Modified: lucene/nutch/trunk/contrib/web2/README.txt
URL: http://svn.apache.org/viewcvs/lucene/nutch/trunk/contrib/web2/README.txt?rev=405088&r1=405087&r2=405088&view=diff
==============================================================================
--- lucene/nutch/trunk/contrib/web2/README.txt (original)
+++ lucene/nutch/trunk/contrib/web2/README.txt Mon May 8 09:25:53 2006
@@ -9,9 +9,9 @@
(and related) pages. Layout is constructed by using following
tag libraries:
-struts-logic
+jstl-c
+jstl-fmt
struts-tiles
-struts-bean
These tiles blocks can be extended or overridden by plugins
implementing org.apache.nutch.webapp.UIExtensionPoint. A
@@ -36,8 +36,10 @@
Todo:
--Provide some samples of ui plugins
-
+-provide some samples of ui plugins
+-move "more" functionality to plugin
+-remove table structures from html to allow more flexible css layouts
+-add mechanism for adding binary items (ie. images)
Directory contents
Modified: lucene/nutch/trunk/contrib/web2/build.xml
URL: http://svn.apache.org/viewcvs/lucene/nutch/trunk/contrib/web2/build.xml?rev=405088&r1=405087&r2=405088&view=diff
==============================================================================
--- lucene/nutch/trunk/contrib/web2/build.xml (original)
+++ lucene/nutch/trunk/contrib/web2/build.xml Mon May 8 09:25:53 2006
@@ -287,6 +287,7 @@
includes="**/*.html"/>
<replace dir="${docs.dir}" token="help.html" value="help.do" includes="**/*.html"/>
+ <replace dir="${docs.dir}" token="about.html" value="about.do" includes="**/*.html"/>
<replace dir="${docs.dir}" token="search.jsp" value="search.do" includes="**/*.html"/>
<replace dir="${docs.dir}" token="../" value="" includes="**/*.html"/>
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/NavigationHelper.java
URL: http://svn.apache.org/viewcvs/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/NavigationHelper.java?rev=405088&r1=405087&r2=405088&view=diff
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/NavigationHelper.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/NavigationHelper.java Mon May 8 09:25:53 2006
@@ -62,9 +62,6 @@
* @return
*/
protected boolean hasNext() {
- System.out.println("totalIsExact" + totalIsExact);
- System.out.println("end" + end);
- System.out.println("totalHits" + totalHits);
return end < totalHits && (!getShowAllHits());
}
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/Search.java
URL: http://svn.apache.org/viewcvs/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/Search.java?rev=405088&r1=405087&r2=405088&view=diff
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/Search.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/common/Search.java Mon May 8 09:25:53 2006
@@ -89,18 +89,12 @@
hits = new Hits(0, new Hit[0]);
}
- LOG.info("form:");
- LOG.info(locator.getSearchForm().toString());
- LOG.info("performing search");
-
int realEnd = (int) Math.min(hits.getLength(), getStartOffset()
+ getMaxHits());
int endOffset=hits.getLength();
show = hits.getHits(getStartOffset(), realEnd - getStartOffset());
-
-
navigationHelper = new NavigationHelper(startOffset, endOffset, hitsPerPage, hits
.getTotal(), hits.totalIsExact());
Added: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/MoreController.java
URL: http://svn.apache.org/viewcvs/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/MoreController.java?rev=405088&view=auto
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/MoreController.java (added)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/MoreController.java Mon May 8 09:25:53 2006
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2006 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.
+ */
+package org.apache.nutch.webapp.controller;
+
+import java.io.IOException;
+import java.util.Date;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.nutch.webapp.common.SearchResultBean;
+import org.apache.struts.tiles.ComponentContext;
+
+/**
+ * This is the controller used when rendering a hit. Basically what
+ * happens here is that we get some meta data values from HitDetails
+ * and stick them into request object so the jsp can display them.
+ *
+ */
+public class MoreController extends NutchController {
+
+ public void nutchPerform(ComponentContext tileContext,
+ HttpServletRequest request, HttpServletResponse response,
+ ServletContext servletContext) throws ServletException, IOException {
+
+ SearchResultBean hit = (SearchResultBean) request.getAttribute("hit");
+
+ if (hit != null) {
+
+ // Content-Type
+ String primaryType = hit.getDetails().getValue("primaryType");
+ String subType = hit.getDetails().getValue("subType");
+
+ String contentType = subType;
+ if (contentType == null)
+ contentType = primaryType;
+ if (contentType != null) {
+ request.setAttribute("contentType", contentType);
+ }
+ // Content-Length
+ String contentLength = hit.getDetails().getValue("contentLength");
+ if (contentLength != null) {
+ request.setAttribute("contentLength", contentLength);
+ }
+
+ // Last-Modified
+ String lastModified = hit.getDetails().getValue("lastModified");
+ if (lastModified != null) {
+ long millis = new Long(lastModified).longValue();
+ Date date = new Date(millis);
+ request.setAttribute("lastModified", date);
+ }
+ } else {
+ LOG.info("hit was null?");
+ }
+ }
+}
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/NutchController.java
URL: http://svn.apache.org/viewcvs/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/NutchController.java?rev=405088&r1=405087&r2=405088&view=diff
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/NutchController.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/NutchController.java Mon May 8 09:25:53 2006
@@ -55,8 +55,9 @@
LOG.info("Exception occured while executing nutch controller:");
e.printStackTrace(System.err);
}
- LOG.info("request processing time: " + (System.currentTimeMillis() - t)
+/* LOG.info("Controller processing time: " + (System.currentTimeMillis() - t)
+ "ms");
+ */
}
/**
Modified: lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/PreferencesController.java
URL: http://svn.apache.org/viewcvs/lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/PreferencesController.java?rev=405088&r1=405087&r2=405088&view=diff
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/PreferencesController.java (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/java/org/apache/nutch/webapp/controller/PreferencesController.java Mon May 8 09:25:53 2006
@@ -48,12 +48,5 @@
LOG.info("view");
request.setAttribute("preferences", locator.getPreferences());
}
-
- // add List languages (defined in tles-defs)
- request.setAttribute("languages", tileContext.getAttribute("languages"));
-
- // add List hitsPerPages (defined in tles-defs)
- request.setAttribute("hitsPerPage", tileContext.getAttribute("hitsPerPage"));
-
}
}
Modified: lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/jsp/more.jsp
URL: http://svn.apache.org/viewcvs/lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/jsp/more.jsp?rev=405088&r1=405087&r2=405088&view=diff
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/jsp/more.jsp (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/jsp/more.jsp Mon May 8 09:25:53 2006
@@ -1,54 +1,14 @@
-<%@ include file="common.jsp" %>
-<jsp:useBean id="hit" scope="request" type="org.apache.nutch.webapp.SearchResultBean"/>
-<%
- // @author John Xing
- // show meta info (currently type, size, date of last-modified)
- // for each hit. These info are indexed by ./src/plugin/index-more.
-
- // do not show unless we have something
- boolean showMore = false;
-
- // Content-Type
- String primaryType = hit.getDetails().getValue("primaryType");
- String subType = hit.getDetails().getValue("subType");
-
- String contentType = subType;
- if (contentType == null)
- contentType = primaryType;
- if (contentType != null) {
- contentType = "[<span class=\"contentType\">" + contentType + "</span>]";
- showMore = true;
- } else {
- contentType = "";
- }
-
- // Content-Length
- String contentLength = hit.getDetails().getValue("contentLength");
- if (contentLength != null) {
- contentLength = "(" + contentLength + " bytes)";
- showMore = true;
- } else {
- contentLength = "";
- }
-
- // Last-Modified
- String lastModified = hit.getDetails().getValue("lastModified");
- if (lastModified != null) {
- java.util.Calendar cal = new java.util.GregorianCalendar();
- cal.setTimeInMillis(new Long(lastModified).longValue());
- lastModified = cal.get(java.util.Calendar.YEAR)
- + "." + (1+cal.get(java.util.Calendar.MONTH)) // it is 0-based
- + "." + cal.get(java.util.Calendar.DAY_OF_MONTH);
- showMore = true;
- } else {
- lastModified = "";
- }
-%>
-
-<% if (showMore) {
- if ("text".equalsIgnoreCase(primaryType)) { %>
- <br><font size=-1><nobr><%=contentType%> <%=contentLength%> <%=lastModified%></nobr></font>
-<% } else { %>
- <br><font size=-1><nobr><%=contentType%> <%=contentLength%> <%=lastModified%> - <a href="../text.jsp?<jsp:getProperty name="hit" property="id"/>"><i18n:message key="viewAsText"/></a></nobr></font>
-<% }
- } %>
+<%@ include file="common.jsp"%>
+<c:if
+ test="${contentType!=null || contentLength!=null ||lastModified!=null }">
+ <fmt:message key="search.contentType">
+ <fmt:param value="${contentType}" />
+ </fmt:message>
+ <fmt:message key="search.contentLength">
+ <fmt:param value="${contentLength}" />
+ </fmt:message>
+ <fmt:message key="search.lastModified">
+ <fmt:param><fmt:formatDate value="${lastModified}" /></fmt:param>
+ </fmt:message>
+ <br />
+</c:if>
Modified: lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/jsp/preferences.jsp
URL: http://svn.apache.org/viewcvs/lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/jsp/preferences.jsp?rev=405088&r1=405087&r2=405088&view=diff
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/jsp/preferences.jsp (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/jsp/preferences.jsp Mon May 8 09:25:53 2006
@@ -1,4 +1,5 @@
<%@ include file="common.jsp"%>
+<tiles:importAttribute/>
<form action="preferencesSave.do"><fmt:message
key="preferences.ui.language" /> <select name="L">
<c:forEach var="language" items="${languages}">
Modified: lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/jsp/results.jsp
URL: http://svn.apache.org/viewcvs/lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/jsp/results.jsp?rev=405088&r1=405087&r2=405088&view=diff
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/jsp/results.jsp (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/jsp/results.jsp Mon May 8 09:25:53 2006
@@ -1,7 +1,8 @@
<%@ include file="common.jsp" %>
<c:forEach var="hit" items="${nutchSearch.results}">
+ <c:set var="hit" scope="request" value="${hit}"/>
<b><a href="<c:out value="${hit.url}"/>"><c:out value="${hit.title}"/></a></b><br/>
- <tiles:insert name="more" flush="false" beanName="hit"/>
+ <tiles:insert name="more" />
<c:out value="${hit.summary}" escapeXml="false"/>
<br>
<span class="url"><c:out value="${hit.encodedUrl}"/></span>
Modified: lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/jsp/search.jsp
URL: http://svn.apache.org/viewcvs/lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/jsp/search.jsp?rev=405088&r1=405087&r2=405088&view=diff
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/jsp/search.jsp (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/jsp/search.jsp Mon May 8 09:25:53 2006
@@ -15,7 +15,7 @@
<fmt:param value="${resultInfo[3]}" />
</fmt:message>
<br />
- <tiles:insert name="results" />
+ <tiles:insert name="results" flush="true"/>
<tiles:insert name="cluster" />
<tiles:insert name="navigate" />
</c:when>
Modified: lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/jsp/template.jsp
URL: http://svn.apache.org/viewcvs/lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/jsp/template.jsp?rev=405088&r1=405087&r2=405088&view=diff
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/jsp/template.jsp (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/jsp/template.jsp Mon May 8 09:25:53 2006
@@ -2,15 +2,13 @@
<%@ include file="common.jsp"%>
<html lang="<fmt:message key="lang"/>">
<head>
-<tiles:insert name="header">
+<tiles:insert name="header" flush="true">
<tiles:put name="title" beanName="title" />
- <tiles:put name="basePage" content="/include/header.html" />
- <tiles:put name="attrName" content="headerContent" />
</tiles:insert>
</head>
<body onLoad="queryfocus();">
<c:out default="" value="${headerContent}" escapeXml="false"/>
-<tiles:insert name="pageBody" />
+<tiles:insert name="pageBody" flush="true"/>
<tiles:insert name="footer" />
</body>
</html>
Modified: lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/tiles-defs.xml
URL: http://svn.apache.org/viewcvs/lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/tiles-defs.xml?rev=405088&r1=405087&r2=405088&view=diff
==============================================================================
--- lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/tiles-defs.xml (original)
+++ lucene/nutch/trunk/contrib/web2/src/main/webapp/WEB-INF/tiles-defs.xml Mon May 8 09:25:53 2006
@@ -1,73 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN" "dtd/tiles-config_1_1.dtd">
<tiles-definitions>
- <definition name=".configurable">
+ <definition name="stylable">
<put name="style" value="/include/style.html" />
</definition>
- <definition name=".layout" extends=".configurable"
+
+ <definition name="masterlayout" extends="stylable"
path="/WEB-INF/jsp/template.jsp">
+ </definition>
+
+ <definition name="template" extends="masterlayout">
<put name="title" value="title" />
<put name="header" value=".header" />
- <put name="footer" value="/WEB-INF/jsp/footer.jsp" />
+ <put name="footer" value="footer" />
</definition>
- <!-- Search page -->
- <definition name="searchPage" extends=".layout"
+
+ <!-- Footer -->
+ <definition name="footer" path="/WEB-INF/jsp/footer.jsp"/>
+
+ <!-- Search -->
+ <definition name="searchPage" extends="template"
controllerClass="org.apache.nutch.webapp.controller.SearchController">
<put name="title" value="search.title" />
- <put name="pageBody" value="/WEB-INF/jsp/search.jsp" />
+ <put name="pageBody" value="search" />
</definition>
+ <definition name="search" path="/WEB-INF/jsp/search.jsp"/>
+
<!-- Cached -->
<definition name="cachedPage" path="/WEB-INF/jsp/cached.jsp"
controllerClass="org.apache.nutch.webapp.controller.CachedController">
<put name="title" value="cached.title" />
</definition>
+
<!-- Explain -->
- <definition name="explainPage" extends=".layout"
+ <definition name="explainPage" extends="template"
controllerClass="org.apache.nutch.webapp.controller.ExplainController">
- <put name="pageBody" value="/WEB-INF/jsp/explain.jsp" />
+ <put name="pageBody" value="explain" />
<put name="title" value="explain.title" />
</definition>
+ <definition name="explain" path="/WEB-INF/jsp/explain.jsp"/>
+
<!-- Anchors -->
- <definition name="anchorsPage" extends=".layout"
+ <definition name="anchorsPage" extends="template"
controllerClass="org.apache.nutch.webapp.controller.AnchorsController">
- <put name="pageBody" value="/WEB-INF/jsp/anchors.jsp" />
+ <put name="pageBody" value="anchors" />
<put name="title" value="anchors.title" />
</definition>
- <!-- Tile that displays the search results -->
+ <definition name="anchors" path="/WEB-INF/jsp/anchors.jsp"/>
+
+ <!-- Search results -->
<definition name="results" path="/WEB-INF/jsp/results.jsp">
</definition>
- <definition name="more" path="/WEB-INF/jsp/more.jsp" />
- <!-- Tile that displays the search result navigation -->
+
+ <!-- Index more ui extension, should really be in own plugin -->
+ <definition name="more" path="/WEB-INF/jsp/more.jsp" controllerClass="org.apache.nutch.webapp.controller.MoreController">
+ <putList name="moreNames" id="moreNames">
+ <add value="primaryType" type="string"/>
+ <add value="subType" type="string"/>
+ <add value="contentLength" type="string"/>
+ <add value="lastModified" type="string"/>
+ </putList>
+ </definition>
+ <!-- Search result navigation -->
<definition name="navigate" path="/WEB-INF/jsp/navigate.jsp" />
- <definition name=".header" extends=".configurable"
+
+ <definition name=".header" extends="stylable"
path="/WEB-INF/jsp/header.jsp"
- controllerClass="org.apache.nutch.webapp.controller.I18NPageController" />
- <definition name="localizedPage" extends=".layout"
+ controllerClass="org.apache.nutch.webapp.controller.I18NPageController" >
+ <put name="basePage" content="/include/header.html" />
+ <put name="attrName" content="headerContent" />
+ </definition>
+
+ <!-- Localized pages (help, about,...) -->
+ <definition name="localizedPage" extends="template"
controllerClass="org.apache.nutch.webapp.controller.I18NPageController">
- <put name="pageBody" value="/WEB-INF/jsp/i18ncontent.jsp" />
+ <put name="pageBody" value="localized" />
</definition>
+ <definition name="localized" path="/WEB-INF/jsp/i18ncontent.jsp"/>
+
<!-- Help -->
<definition name="helpPage" extends="localizedPage">
<put name="basePage" value="/help.html" />
<put name="title" value="help.title" />
</definition>
+
<!-- About -->
<definition name="aboutPage" extends="localizedPage">
<put name="basePage" value="/about.html" />
</definition>
+
<!-- No Results -->
<definition name="noResults" path="/WEB-INF/jsp/noResults.jsp" />
- <!-- i18n component -->
+
+ <!-- Loclaized component -->
<definition name="i18nComponent" path="/WEB-INF/jsp/i18ncontent.jsp"
controllerClass="org.apache.nutch.webapp.controller.I18NPageController">
</definition>
<!-- Preferences -->
- <definition name="preferencesPage" extends=".layout"
+ <definition name="preferencesPage" extends="template"
controllerClass="org.apache.nutch.webapp.controller.PreferencesController">
<put name="title" value="preferences.title" />
<put name="action" value="edit" />
- <put name="pageBody" value="/WEB-INF/jsp/preferences.jsp" />
+ <put name="pageBody" value="preferences" />
+ </definition>
+
+ <definition name="preferences" page="/WEB-INF/jsp/preferences.jsp">
<putList name="languages">
<add value="ca"/>
<add value="de"/>
@@ -91,7 +129,7 @@
<add value="20"/>
<add value="50"/>
</putList>
- </definition>
+ </definition>
<definition name="preferencesSavePage" extends="preferencesPage">
<put name="action" value="save" />