search.jsp revision 1282
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncCDDL HEADER START
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncThe contents of this file are subject to the terms of the
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncCommon Development and Distribution License (the "License").
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncYou may not use this file except in compliance with the License.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncSee LICENSE.txt included in this distribution for the specific
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsynclanguage governing permissions and limitations under the License.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncWhen distributing Covered Code, include this CDDL HEADER in each
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncfile and include the License file at LICENSE.txt.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncIf applicable, add the following below this CDDL HEADER, with the
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncfields enclosed by brackets "[]" replaced with your own identifying
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncinformation: Portions Copyright [yyyy] [name of copyright owner]
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncCDDL HEADER END
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncCopyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncPortions Copyright 2011 Jens Elkner.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync--%><%@page session="false" errorPage="error.jsp" import="
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync private StringBuilder createUrl(SearchHelper sh, boolean menu) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync StringBuilder url = new StringBuilder(64);
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync QueryBuilder qb = sh.builder;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync if (menu) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync Util.appendQuery(url, "sort", sh.order.toString());
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync if (qb != null) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync if (sh.projects != null && sh.projects.size() != 0) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync Util.appendQuery(url, "project", cfg.getRequestedProjectsAsString());
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync return url;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/* ---------------------- search.jsp start --------------------- */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync cfg = PageConfig.get(request);
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync long starttime = System.currentTimeMillis();
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync SearchHelper searchHelper = cfg.prepareSearch()
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync .prepareExec(cfg.getRequestedProjects()).executeQuery().prepareSummary();
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync cfg.setTitle("Search Error");
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync response.addCookie(new Cookie("OpenGrokSorting", searchHelper.order.toString()));
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<div id="page">
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync <div id="whole_header">
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync <div id="header"><%@
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync <div id="Masthead"></div>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync <div id="bar">
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync <li><a href="<%= request.getContextPath()
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync %>/"><span id="home"></span>Home</a></li>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync <%-- TODO: jel: IMHO it should be move to menu.jspf as combobox --%>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync <div id="sortfield">
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync <label for="sortby">Sort by</label>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync <ul id="sortby"><%
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync StringBuilder url = createUrl(searchHelper, true).append("&sort=");
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync for (SortOrder o : SortOrder.values()) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync %><li><span class="active"><%= o.getDesc() %></span></li><%
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync %><li><a href="<%= url %><%= o %>"><%= o.getDesc() %></a></li><%
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync <div id="menu"><%@
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncinclude file="menu.jspf"
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync <div id="results"><%
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync // TODO spellchecking cycle below is not that great and we only create
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync // suggest links for every token in query, not for a query as whole
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync %><h3>Error</h3><p><%
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync if (searchHelper.errorMsg.startsWith((SearchHelper.PARSE_ERROR_MSG))) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync %><%= Util.htmlize(SearchHelper.PARSE_ERROR_MSG) %>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync <br/>You might try to enclose your search term in quotes,
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync <a href="help.jsp#escaping">escape special characters</a>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync with <b>\</b>, or read the <a href="help.jsp">Help</a>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync on the query language. Error message from parser:<br/>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } else if (searchHelper.hits == null) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync %><p>No hits</p><%
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } else if (searchHelper.hits.length == 0) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync List<Suggestion> hints = searchHelper.getSuggestions();
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync for (Suggestion hint : hints) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync %><p><font color="#cc0000">Did you mean (for <%= hint.name %>)</font>:<%
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync for (String word : hint.freetext) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync %> <a href=search?q=<%= word %>><%= word %></a> <%
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync for (String word : hint.refs) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync %> <a href=search?refs=<%= word %>><%= word %></a> <%
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync for (String word : hint.defs) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync %> <a href=search?defs=<%= word %>><%= word %></a> <%
<p> Your search <b><%= searchHelper.query %></b> did not match any files.
int start = searchHelper.start;
int max = searchHelper.maxItems;
int totalHits = searchHelper.totalHits;
buf.append("<span class=\"sel\">").append(label).append("</span>");
buf.append("<a class=\"more\" href=\"s?n=").append(max)
buf.append("<<");
buf.append(">>");
buf.append(label);
buf.append("</a>");
slider = buf.toString();
<p class="pagetitle">Searched <b><%= searchHelper.query
searchHelper.order %></p><%
if (slider.length() > 0) {
Results.prettyPrint(out, searchHelper, start, start + thispage);
<p><b>Completed in <%= System.currentTimeMillis() - starttime
if (slider.length() > 0) {
/* ---------------------- search.jsp end --------------------- */
include file="foot.jspf"