<%-- $Id$ CDDL HEADER START The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. See LICENSE.txt included in this distribution for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at LICENSE.txt. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] CDDL HEADER END Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. Portions Copyright 2011 Jens Elkner. --%> <%@page session="false" errorPage="error.jsp" import=" org.opensolaris.opengrok.search.Results, org.opensolaris.opengrok.web.SearchHelper, org.opensolaris.opengrok.web.SortOrder, org.opensolaris.opengrok.web.Suggestion" %><%@ include file="projects.jspf" %><%! private StringBuilder createUrl(SearchHelper sh, boolean menu) { StringBuilder url = new StringBuilder(64); QueryBuilder qb = sh.builder; if (menu) { url.append("search?"); } else { Util.appendQuery(url, "sort", sh.order.toString()); } if (qb != null) { Util.appendQuery(url, "q", qb.getFreetext()); Util.appendQuery(url, "defs", qb.getDefs()); Util.appendQuery(url, "refs", qb.getRefs()); Util.appendQuery(url, "path", qb.getPath()); Util.appendQuery(url, "hist", qb.getHist()); Util.appendQuery(url, "type", qb.getType()); } if (sh.projects != null && sh.projects.size() != 0) { Util.appendQuery(url, "project", cfg.getRequestedProjectsAsString()); } return url; } %><% /* ---------------------- search.jsp start --------------------- */ { cfg = PageConfig.get(request); String lastEditedDisplayMode = config.getInitParameter("lastEditedDisplayMode"); if (lastEditedDisplayMode != null) { if(!(lastEditedDisplayMode.compareTo("true") == 0 || lastEditedDisplayMode.compareTo("1") == 0 || lastEditedDisplayMode.isEmpty())){ cfg.setLastEditedDisplayMode(false); } } long starttime = System.currentTimeMillis(); SearchHelper searchHelper = cfg.prepareSearch(); request.setAttribute("SearchHelper", searchHelper); searchHelper.prepareExec(cfg.getRequestedProjects()).executeQuery().prepareSummary(); if (searchHelper.redirect != null) { response.sendRedirect(searchHelper.redirect); } if (searchHelper.errorMsg != null) { cfg.setTitle("Search Error"); } else { cfg.setTitle("Search"); } response.addCookie(new Cookie("OpenGrokSorting", URLEncoder.encode(searchHelper.order.toString(), "utf-8"))); %><%@ include file="httpheader.jspf" %>
<%-- TODO: jel: IMHO it should be move to menu.jspf as combobox --%>
    <% StringBuilder url = createUrl(searchHelper, true).append("&sort="); for (SortOrder o : SortOrder.values()) { if (searchHelper.order == o) { %>
  • <%= o.getDesc() %>
  • <% } else { %>
  • <%= o.getDesc() %>
  • <% } } %>
<% // TODO spellchecking cycle below is not that great and we only create // suggest links for every token in query, not for a query as whole if (searchHelper.errorMsg != null) { %>

Error

<% if (searchHelper.errorMsg.startsWith((SearchHelper.PARSE_ERROR_MSG))) { %><%= Util.htmlize(SearchHelper.PARSE_ERROR_MSG) %>
You might try to enclose your search term in quotes, escape special characters with \, or read the Help on the query language. Error message from parser:
<%= Util.htmlize(searchHelper.errorMsg.substring( SearchHelper.PARSE_ERROR_MSG.length())) %><% } else { %><%= Util.htmlize(searchHelper.errorMsg) %><% }%>

<% } else if (searchHelper.hits == null) { %>

No hits

<% } else if (searchHelper.hits.length == 0) { List hints = searchHelper.getSuggestions(); for (Suggestion hint : hints) { %>

Did you mean (for <%= hint.name %>):<% if (hint.freetext!=null) { for (String word : hint.freetext) { %> <%= Util.htmlize(word) %>   <% } } if (hint.refs!=null) { for (String word : hint.refs) { %> <%= Util.htmlize(word) %>   <% } } if (hint.defs!=null) { for (String word : hint.defs) { %> <%= Util.htmlize(word) %>   <% } } %>

<% } %>

Your search <% Util.htmlize(searchHelper.query.toString(), out); %> did not match any files.
Suggestions:

  • Make sure all terms are spelled correctly.
  • Try different keywords.
  • Try more general keywords.
  • Use 'wil*' cards if you are looking for partial match.

Completed in <%= System.currentTimeMillis() - starttime %> milliseconds

<% } else { // We have a lots of results to show: create a slider for String slider = ""; int thispage; // number of items to display on the current page int start = searchHelper.start; int max = searchHelper.maxItems; int totalHits = searchHelper.totalHits; if (searchHelper.maxItems < searchHelper.totalHits) { StringBuilder buf = new StringBuilder(4096); thispage = (start + max) < totalHits ? max : totalHits - start; StringBuilder urlp = createUrl(searchHelper, false); int labelStart = 1; int sstart = start - max * (start / max % 10 + 1) ; if (sstart < 0) { sstart = 0; labelStart = 1; } else { labelStart = sstart / max + 1; } int label = labelStart; int labelEnd = label + 11; for (int i = sstart; i < totalHits && label <= labelEnd; i+= max) { if (i <= start && start < i + max) { buf.append("").append(label).append(""); } else { buf.append(""); if (label == labelStart && label != 1) { buf.append("<<"); } else if (label == labelEnd && i < totalHits) { buf.append(">>"); } else { buf.append(label); } buf.append(""); } label++; } slider = buf.toString(); } else { // set the max index to max or last thispage = totalHits - start; } %>

Searched <% Util.htmlize(searchHelper.query.toString(), out); %> (Results <%= start + 1 %> - <%= thispage + start %> of <%= totalHits %>) sorted by <%= searchHelper.order.getDesc() %>

<% if (slider.length() > 0) { %>

<%= slider %>

<% } %> <% Results.prettyPrint(out, searchHelper, start, start + thispage); %>

Completed in <%= System.currentTimeMillis() - starttime %> milliseconds

<% if (slider.length() > 0) { %>

<%= slider %>

<% } %>
<% } // Note that searchHelper.destroy() is called via WebappListener.requestDestroyed(). } /* ---------------------- search.jsp end --------------------- */ %><%@ include file="foot.jspf" %>