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