mast.jsp revision 976
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric LuceCDDL HEADER START
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric LuceThe contents of this file are subject to the terms of the
727f5b8846457a33d06f515a10a7e1aa849ddf18Andreas GustafssonCommon Development and Distribution License (the "License").
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric LuceYou may not use this file except in compliance with the License.
2cd182921e1b04ccda0a56995c4cc491c882af04Mark AndrewsSee LICENSE.txt included in this distribution for the specific
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Lucelanguage governing permissions and limitations under the License.
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric LuceWhen distributing Covered Code, include this CDDL HEADER in each
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Lucefile and include the License file at LICENSE.txt.
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric LuceIf applicable, add the following below this CDDL HEADER, with the
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Lucefields enclosed by brackets "[]" replaced with your own identifying
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luceinformation: Portions Copyright [yyyy] [name of copyright owner]
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric LuceCDDL HEADER END
fcc9f7f86c2fa2ceb8a5c16dc934fea7fa6887f2Andreas GustafssonCopyright 2009 Sun Microsystems, Inc. All rights reserved.
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric LuceUse is subject to license terms.
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce--%><%@ page import = "javax.servlet.*,
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce %><%@ page session="false" %><%@ page errorPage="error.jsp"%><%
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric LuceString context = request.getContextPath();
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric LuceString servlet = request.getServletPath();
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric LuceString reqURI = request.getRequestURI();
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric LuceString path = request.getPathInfo();
fcc9f7f86c2fa2ceb8a5c16dc934fea7fa6887f2Andreas Gustafssonif (path == null) path = "";
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric LuceRuntimeEnvironment environment = RuntimeEnvironment.getInstance();
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric LuceString rawSource = environment.getSourceRootPath();
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric LuceString resourcePath = rawSource + path;
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric LuceFile resourceFile = new File(resourcePath);
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luceboolean valid = true;
3970098dcd2a7122541667b4b56cea8abce8ccf2Mark Andrewsboolean noHistory = true;
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luceboolean noAnnotation = true;
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luceboolean annotate = false;
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric LuceString basename = resourceFile.getName();
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luceboolean isDir = false;
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric LuceEftarFileReader ef = null;
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric LuceString parent = null;
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric LuceString parentBasename = resourceFile.getParentFile().getName();
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric LuceIgnoredNames ignoredNames = environment.getIgnoredNames();
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric LuceString uriEncodedName = Util.URIEncodePath(path);
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce|| ignoredNames.ignore(parentBasename)
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce valid = false;
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce} else if (!resourceFile.canRead() && resourcePath.startsWith(rawSource)) {
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce String newPath = rawSource + "/on/" + path; //TODO do we still use "on" ???
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce File newFile = new File(newPath);
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce if(newFile.isDirectory() && servlet.startsWith("/xref") && !path.endsWith("/")) {
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce response.sendRedirect(context + servlet + "/on" + path + "/");
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce response.sendRedirect(context + servlet + "/on" + path);
2cd182921e1b04ccda0a56995c4cc491c882af04Mark Andrews valid = false;
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce valid = true;
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce path = resourcePath.substring(rawSource.length());
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce if ("".equals(path)) {
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce path = path.replace('\\','/');
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce if (isDir && !servlet.startsWith("/xref") && !servlet.startsWith("/hist")) { //if it is an existing directory perhaps people wanted directory xref
0707a8c04f0d350cb964ce9db07c3ed66f7442eaMark Andrews response.sendRedirect(context + "/xref" + path + "/");
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce response.sendRedirect(context + "/xref" + path);
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce } if (isDir && !reqURI.endsWith("/")) {
0707a8c04f0d350cb964ce9db07c3ed66f7442eaMark Andrews response.sendRedirect(context + servlet + path +"/");
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce String dtag = "";
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce if (request.getDateHeader("If-Modified-Since") >= flast ) {
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce valid = false;
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce response.setDateHeader("Last-Modified", flast);
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce int lastSlash = path.lastIndexOf('/');
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce parent = (lastSlash != -1) ? path.substring(0, lastSlash) : "";
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce int pLastSlash = parent.lastIndexOf('/');
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce parentBasename = pLastSlash != -1 ? parent.substring(pLastSlash+1) : parent;
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce noHistory = !HistoryGuru.getInstance().hasHistory(resourceFile);
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce noAnnotation = isDir ||
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce !HistoryGuru.getInstance().hasAnnotation(resourceFile);
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce annotate = !noAnnotation &&
0707a8c04f0d350cb964ce9db07c3ed66f7442eaMark Andrews ef = new EftarFileReader(environment.getDataRootPath() + "/index/dtags.eftar");
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce if(ef != null) {
727f5b8846457a33d06f515a10a7e1aa849ddf18Andreas Gustafsson } catch (IOException e) {
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce } catch (Exception e) {
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce String pageTitle="Cross Reference: " + path;
727f5b8846457a33d06f515a10a7e1aa849ddf18Andreas Gustafsson%><%@ include file="httpheader.jspf" %><%//below style is for the fancy always on top search bar%>
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce<script type="text/javascript" src="<%=context%>/jquery-1.4.2.min.js"></script>
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce<body style="overflow: hidden;" onload="$('#search').focus();">
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce<% if (annotate) { %>
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce<script type="text/javascript" src="<%=context%>/jquery.tooltip-1.3.pack.js"></script>
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce<script type="text/javascript">/* <![CDATA[ */
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Lucefunction toggle_annotations() {
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce $("span").each(function() {
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce if (this.className == 'blame') {
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce this.className = 'blame-hidden';
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce } else if (this.className == 'blame-hidden') {
727f5b8846457a33d06f515a10a7e1aa849ddf18Andreas Gustafsson$().ready(function() {
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce $('a[id=r]').tooltip({
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce showURL: false
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce/* ]]> */</script>
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce<div id="page">
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce<div id="whole_header" >
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce<form action="<%=context%>/search">
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce <div id="header"><%@ include file="pageheader.jspf" %>
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce <div id="pagetitle"><b id="filename">Cross Reference: <%=basename%></b><% if (dtag!=null & dtag!="") { %><br/><%=dtag%><% } %></div>
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce <div id="Masthead"><tt><a href="<%=context%>/xref/">xref</a>: <%=org.opensolaris.opengrok.web.Util.breadcrumbPath(context + "/xref", path)%></tt></div>
8e245ec21beee31a780de9b89ba1e8bb2b9f4c9aAndreas Gustafsson <div id="bar"><a href="<%=context%>" id="home">Home</a> |
8e245ec21beee31a780de9b89ba1e8bb2b9f4c9aAndreas Gustafsson if (noHistory || servlet.startsWith("/hi")) {
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce %> <span class="c" id="history">History</span><%
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce %><a id="history" href="<%=context%>/history<%=path%>">History</a><%
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce if (noAnnotation) {
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce %> | <span class="c" id="annotate">Annotate</span><%
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce String rev = request.getParameter("r");
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce if (rev == null) {
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce } else if (rev.length() > 0) {
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce rev = "&r=" + rev;
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce if (Boolean.parseBoolean(request.getParameter("a"))) {
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce %> | <span id="toggle-annotate-by-javascript" style="display: none">
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce <a href="#" onclick="javascript:toggle_annotations(); return false;" title="Show or hide line annotation(commit revisions,authors)." >Annotate</a>
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce <span id="toggle-annotate">
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce <a href="<%=context%>/xref<%=path%><%
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce %>?<%=rev%><%
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce } %>">Annotate</a></span>
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce <script type="text/javascript">
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce var toggle_js = document.getElementById('toggle-annotate-by-javascript');
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce var toggle_ss = document.getElementById('toggle-annotate');
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce </script> <%
0707a8c04f0d350cb964ce9db07c3ed66f7442eaMark Andrews %> | <a href="<%=context%>/xref<%=path%>?a=true<%=rev%>">Annotate</a><%
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce if (!isDir) {
2cd182921e1b04ccda0a56995c4cc491c882af04Mark Andrews %> | <a href="#" onclick="javascript:lntoggle();return false;" title="Show or hide line numbers (might be slower if file has more than 10 000 lines).">Line #</a><%
2cd182921e1b04ccda0a56995c4cc491c882af04Mark Andrews String rev = request.getParameter("r");
727f5b8846457a33d06f515a10a7e1aa849ddf18Andreas Gustafsson if (rev == null || rev.equals("")) {
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce %> | <a id="download" href="<%=context%>/raw<%=path%>">Download</a><%
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce %> | <a id="download" href="<%=context%>/raw<%=path%>?r=<%=rev%>">Download</a><%
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce Project proj = Project.getProject(resourceFile);
2cd182921e1b04ccda0a56995c4cc491c882af04Mark Andrews if (proj != null || !environment.hasProjects()) {
2cd182921e1b04ccda0a56995c4cc491c882af04Mark Andrews %> | <input id="search" name="q" class="q"/>
fcc9f7f86c2fa2ceb8a5c16dc934fea7fa6887f2Andreas Gustafsson <input type="submit" value="Search" class="submit"/>
fcc9f7f86c2fa2ceb8a5c16dc934fea7fa6887f2Andreas Gustafsson if (proj != null) {
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce %><input type="hidden" name="project" value="<%=proj.getDescription()%>"/><%
fcc9f7f86c2fa2ceb8a5c16dc934fea7fa6887f2Andreas Gustafsson %><input type="checkbox" name="path" value="<%=path%>"/> only in <b><%=path%></b><%
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce %><input type="checkbox" name="path" value="<%=parent%>"/> only in <b><%=parentBasename%></b><%
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce</div></form></div>
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce <div id="content"><%
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce} // date check
f293a69bcd1c1dd7bdac8f4102fc2398b9e475c8Eric Luce } // not a directory redirect