Author: magnuse
Date: 2006-05-09 16:27:42 +0200 (Tue, 09 May 2006)
New Revision: 2886
Modified:
trunk/src/java/no/schibstedsok/front/searchportal/servlet/SearchServlet.java
trunk/src/java/no/schibstedsok/front/searchportal/util/PagingDisplayHelper.java
trunk/src/java/no/schibstedsok/front/searchportal/view/config/SearchTab.java
trunk/src/java/no/schibstedsok/front/searchportal/view/config/SearchTabFactory.java
trunk/src/webapp/WEB-INF/jsp/decorators/mobileDecorator.jsp
Log:
Support for getting the tab via navigation hint added.
Magic search for mobile added.
Modified:
trunk/src/java/no/schibstedsok/front/searchportal/servlet/SearchServlet.java
===================================================================
---
trunk/src/java/no/schibstedsok/front/searchportal/servlet/SearchServlet.java
2006-05-09 14:03:51 UTC (rev 2885)
+++
trunk/src/java/no/schibstedsok/front/searchportal/servlet/SearchServlet.java
2006-05-09 14:27:42 UTC (rev 2886)
@@ -105,9 +105,7 @@
searchTabKey = "d";
}
- final SearchTab searchTab = SearchTabFactory.valueOf(
- ContextWrapper.wrap(SearchTabFactory.Context.class,
genericCxt))
- .getTabByKey(searchTabKey);
+ final SearchTab searchTab =
SearchTabFactory.valueOf(ContextWrapper.wrap(SearchTabFactory.Context.class,
genericCxt)).getTabByKey(searchTabKey);
if( searchTab == null ){
LOG.error(ERR_MISSING_TAB + searchTabKey);
@@ -202,6 +200,12 @@
// TODO. Any better way to do this. Sitemesh?
if (site.getName().startsWith("mobil")) {
response.setContentType("text/xml; charset=utf-8");
+ try {
+ // Just can't get sitemesh to work in the way I imagine it
works.
+ response.getWriter().write("<html><head><META
name=\"decorator\" content=\"mobiledecorator\"/></head></html>");
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
} else {
response.setContentType("text/html; charset=utf-8");
}
Modified:
trunk/src/java/no/schibstedsok/front/searchportal/util/PagingDisplayHelper.java
===================================================================
---
trunk/src/java/no/schibstedsok/front/searchportal/util/PagingDisplayHelper.java
2006-05-09 14:03:51 UTC (rev 2885)
+++
trunk/src/java/no/schibstedsok/front/searchportal/util/PagingDisplayHelper.java
2006-05-09 14:27:42 UTC (rev 2886)
@@ -104,4 +104,8 @@
public int getNumberOfResults() {
return numberOfResults;
}
+
+ public int getCurrentOffset() {
+ return currentOffset;
+ }
}
Modified:
trunk/src/java/no/schibstedsok/front/searchportal/view/config/SearchTab.java
===================================================================
---
trunk/src/java/no/schibstedsok/front/searchportal/view/config/SearchTab.java
2006-05-09 14:03:51 UTC (rev 2885)
+++
trunk/src/java/no/schibstedsok/front/searchportal/view/config/SearchTab.java
2006-05-09 14:27:42 UTC (rev 2886)
@@ -36,7 +36,7 @@
/** Creates a new instance of SearchTab */
SearchTab(
- final SearchTab inherit,
+ final SearchTab inherit,
final String id,
final String mode,
final String key,
@@ -61,7 +61,7 @@
? parentKey
: inherit != null ? inherit.parentKey : null;
this.pageSize = pageSize >=0 || inherit == null ? pageSize :
inherit.pageSize;
- this.navigators.addAll(navigators);
+ this.navigators.addAll(navigations);
this.enrichmentLimit = enrichmentLimit >=0 || inherit == null ?
enrichmentLimit : inherit.enrichmentLimit;
this.enrichmentOnTop = enrichmentOnTop >=0 || inherit == null ?
enrichmentOnTop : inherit.enrichmentOnTop;
this.enrichmentOnTopScore = enrichmentOnTopScore >=0 || inherit ==
null
@@ -331,13 +331,15 @@
public NavigatorHint(
final String name,
final MatchType match,
- final String tab,
- final String urlSuffix){
+ final String tabName,
+ final String urlSuffix,
+ final SearchTabFactory tabFactory){
this.name = name;
this.match = match;
- this.tab = tab;
+ this.tabName = tabName;
this.urlSuffix = urlSuffix;
+ this.tabFactory = tabFactory;
}
public enum MatchType {
@@ -345,22 +347,32 @@
EQUAL,
SUFFIX;
}
-
+
+ private final SearchTabFactory tabFactory;
+
/**
- * Holds value of property tab.
+ * Holds value of property tabName.
*/
- private final String tab;
-
+ private final String tabName;
+
+
/**
* Getter for property tab.
* @return Value of property tab.
*/
- public String getTab() {
+ public String getTabName() {
- return this.tab;
+ return this.tabName;
}
/**
+ * Returns the tab associated with this hint.
+ */
+ public SearchTab getTab() {
+ return tabFactory.getTabByName(tabName);
+ }
+
+ /**
* Holds value of property name.
*/
private final String name;
@@ -414,8 +426,29 @@
public Collection<NavigatorHint> getNavigators() {
return Collections.unmodifiableCollection(navigators);
}
-
+ /**
+ * Returns the navigator hint matching name. Returns null if no navigator
+ * hint matches.
+ */
+ public NavigatorHint getNavigatorHint(String name) {
+ for (NavigatorHint hint : navigators) {
+ switch(hint.match) {
+ case EQUAL:
+ if (hint.name.equals(name))
+ return hint;
+ break;
+ case PREFIX:
+ if (name.startsWith(hint.name))
+ return hint;
+ case SUFFIX:
+ if (name.endsWith(hint.name))
+ return hint;
+ }
+ }
+ return null;
+ }
+
public String toString(){
return id + (inherit != null ? " --> " + inherit.toString() : "");
}
Modified:
trunk/src/java/no/schibstedsok/front/searchportal/view/config/SearchTabFactory.java
===================================================================
---
trunk/src/java/no/schibstedsok/front/searchportal/view/config/SearchTabFactory.java
2006-05-09 14:03:51 UTC (rev 2885)
+++
trunk/src/java/no/schibstedsok/front/searchportal/view/config/SearchTabFactory.java
2006-05-09 14:27:42 UTC (rev 2886)
@@ -217,7 +217,7 @@
final String tab = n.getAttribute("tab");
final String urlSuffix = n.getAttribute("url-suffix");
final SearchTab.NavigatorHint navHint
- = new SearchTab.NavigatorHint(name, match, tab,
urlSuffix);
+ = new SearchTab.NavigatorHint(name, match, tab,
urlSuffix, this);
navigations.add(navHint);
}
Modified: trunk/src/webapp/WEB-INF/jsp/decorators/mobileDecorator.jsp
===================================================================
--- trunk/src/webapp/WEB-INF/jsp/decorators/mobileDecorator.jsp 2006-05-09
14:03:51 UTC (rev 2885)
+++ trunk/src/webapp/WEB-INF/jsp/decorators/mobileDecorator.jsp 2006-05-09
14:27:42 UTC (rev 2886)
@@ -1,4 +1,4 @@
-<%@ page import="java.io.StringWriter"%><%@ page
import="java.net.URLEncoder"%><%@ page import="java.util.List"%><%@ page
import="java.util.Iterator"%><%@ page
import="com.opensymphony.module.sitemesh.Page"%><%@ page
import="com.opensymphony.module.sitemesh.RequestConstants"%><%@ page
import="com.opensymphony.module.sitemesh.util.OutputConverter"%><%@ page
import="no.schibstedsok.front.searchportal.view.i18n.TextMessages"%><%@ page
import="no.schibstedsok.front.searchportal.view.output.VelocityResultHandler"%><%@
page import="no.schibstedsok.front.searchportal.query.run.RunningQuery" %><%@
page import="no.schibstedsok.front.searchportal.result.Enrichment"%><%@ page
import="no.schibstedsok.front.searchportal.result.Modifier"%><%@ page
import="no.schibstedsok.front.searchportal.site.Site"%><%@ page
import="org.apache.commons.lang.StringEscapeUtils" %><%@ page
import="org.apache.velocity.Template"%><%@ page
import="org.apache.velocity.VelocityContext"%><%@ page import="org.apac
he.velocity.app.VelocityEngine"%><%
+<%@ page language="java" pageEncoding="UTF-8"
contentType="text/html;charset=utf-8" %><%@ page
import="java.io.StringWriter"%><%@ page import="java.net.URLEncoder"%><%@ page
import="java.util.List"%><%@ page import="java.util.Iterator"%><%@ page
import="com.opensymphony.module.sitemesh.Page"%><%@ page
import="com.opensymphony.module.sitemesh.RequestConstants"%><%@ page
import="com.opensymphony.module.sitemesh.util.OutputConverter"%><%@ page
import="no.schibstedsok.front.searchportal.view.i18n.TextMessages"%><%@ page
import="no.schibstedsok.front.searchportal.view.output.VelocityResultHandler"%><%@
page import="no.schibstedsok.front.searchportal.query.run.RunningQuery" %><%@
page import="no.schibstedsok.front.searchportal.result.Enrichment"%><%@ page
import="no.schibstedsok.front.searchportal.result.Modifier"%><%@ page
import="no.schibstedsok.front.searchportal.site.Site"%><%@ page
import="org.apache.commons.lang.StringEscapeUtils" %><%@ page
import="org.apache.velocity.Templ
ate"%><%@ page import="org.apache.velocity.VelocityContext"%><%@ page
import="org.apache.velocity.app.VelocityEngine"%><%
final Site site = (Site)request.getAttribute(Site.NAME_KEY);
final Page siteMeshPage = (Page)
request.getAttribute(RequestConstants.PAGE);
final TextMessages text = (TextMessages) request.getAttribute("text");
@@ -22,6 +22,10 @@
context.put("base", request.getContextPath());
context.put("title", OutputConverter.convert(siteMeshPage.getTitle()));
context.put("text", text);
+ context.put("currentTab", query.getSearchTab());
+ context.put("runningQuery", query);
+ context.put("query", query.getQueryString());
+
{
final StringWriter buffer = new StringWriter();
siteMeshPage.writeBody(OutputConverter.getWriter(buffer));
_______________________________________________
Kernel-commits mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-commits