opensearch.jsp revision 1478
123N/A<%--
123N/A$Id$
123N/A
123N/ACDDL HEADER START
123N/A
123N/AThe contents of this file are subject to the terms of the
123N/ACommon Development and Distribution License (the "License").
123N/AYou may not use this file except in compliance with the License.
123N/A
123N/ASee LICENSE.txt included in this distribution for the specific
123N/Alanguage governing permissions and limitations under the License.
123N/A
123N/AWhen distributing Covered Code, include this CDDL HEADER in each
123N/Afile and include the License file at LICENSE.txt.
123N/AIf applicable, add the following below this CDDL HEADER, with the
123N/Afields enclosed by brackets "[]" replaced with your own identifying
123N/Ainformation: Portions Copyright [yyyy] [name of copyright owner]
123N/A
123N/ACDDL HEADER END
123N/A
123N/ACopyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
123N/A
123N/APortions Copyright 2011 Jens Elkner.
123N/A
123N/A--%><%@page session="false" errorPage="error.jsp" import="
123N/Ajava.util.Set,
123N/A
123N/Aorg.opensolaris.opengrok.web.PageConfig,
123N/Aorg.opensolaris.opengrok.web.Prefix,
123N/Aorg.opensolaris.opengrok.web.Util"
123N/A%><%@
123N/A
123N/Ainclude file="pageconfig.jspf"
123N/A
123N/A%><%@
123N/A
123N/Ainclude file="projects.jspf"
123N/A
123N/A%><%
123N/A /* ---------------------- opensearch.jsp start --------------------- */
123N/A{
123N/A cfg = PageConfig.get(request);
123N/A
123N/A // Optimize for URLs up to 128 characters.
123N/A StringBuilder url = new StringBuilder(128);
123N/A String ForwardedHost = request.getHeader("X-Forwarded-Host");
123N/A String scheme = request.getScheme();
123N/A int port = request.getServerPort();
123N/A
123N/A url.append(scheme).append("://");
123N/A
123N/A // Play nice in proxy environment by using hostname from the original
123N/A // request to construct the URLs.
123N/A // Will not work well if the scheme or port is different for proxied server
123N/A // and original server. Unfortunately the X-Forwarded-Host does not seem to
123N/A // contain the port number so there is no way around it.
123N/A if (ForwardedHost != null) {
123N/A url.append(ForwardedHost);
123N/A } else {
123N/A url.append(request.getServerName());
123N/A
123N/A // Append port if needed.
123N/A if ((port != 80 && scheme.equals("http")) ||
123N/A (port != 443 && scheme.equals("https"))) {
123N/A url.append(':').append(port);
123N/A }
123N/A }
123N/A
123N/A String imgurl = url + cfg.getCssDir() + "/img/icon.png";
123N/A
/* TODO Bug 11749 ??? */
StringBuilder text = new StringBuilder();
url.append(request.getContextPath()).append(Prefix.SEARCH_P).append('?');
Set<String> projects = cfg.getRequestedProjects();
for (String name : projects) {
text.append(name).append(',');
Util.appendQuery(url, "project", name);
}
if (text.length() != 0) {
text.setLength(text.length()-1);
}
%><?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>OpenGrok <%= text.toString() %></ShortName>
<Description>Search in OpenGrok <%= text.toString() %></Description>
<InputEncoding>UTF-8</InputEncoding>
<Image height="16" width="16" type="image/png"><%= imgurl %></Image>
<%-- <Url type="application/x-suggestions+json" template="suggestionURL"/>--%>
<Url template="<%= url.toString() %>&amp;q={searchTerms}" type="text/html"/>
</OpenSearchDescription>
<%
}
/* ---------------------- opensearch.jsp end --------------------- */
%>