mast.jsp revision 954
7e5b2100ea65658a7ec3795919b4ecd29a6f118aMark AndrewsCDDL HEADER START
eae67738cba5ca069e9d1d4e7b836a2f7b00a374Mark AndrewsThe contents of this file are subject to the terms of the
eae67738cba5ca069e9d1d4e7b836a2f7b00a374Mark AndrewsCommon Development and Distribution License (the "License").
2a40fdc2d34adb8a5c72a748449699666032d461Mark AndrewsYou may not use this file except in compliance with the License.
a3b428812703d22a605a9f882e71ed65f0ffdc65Mark AndrewsSee LICENSE.txt included in this distribution for the specific
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrewslanguage governing permissions and limitations under the License.
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian WellingtonWhen distributing Covered Code, include this CDDL HEADER in each
068a66979695c77359e7a9181bb3f831c965b21cMark Andrewsfile and include the License file at LICENSE.txt.
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian WellingtonIf applicable, add the following below this CDDL HEADER, with the
01bf5871f8861eb805dd8ca79bdb9b0b9e4e6a5eMark Andrewsfields enclosed by brackets "[]" replaced with your own identifying
c718d15a9a95054ee3c71540c02335426071fc6dMark Andrewsinformation: Portions Copyright [yyyy] [name of copyright owner]
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark AndrewsCDDL HEADER END
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark AndrewsCopyright 2009 Sun Microsystems, Inc. All rights reserved.
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark AndrewsUse is subject to license terms.
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews--%><%@ page import = "javax.servlet.*,
a3b428812703d22a605a9f882e71ed65f0ffdc65Mark Andrews %><%@ page session="false" %><%@ page errorPage="error.jsp"%><%
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark AndrewsString context = request.getContextPath();
c718d15a9a95054ee3c71540c02335426071fc6dMark AndrewsString servlet = request.getServletPath();
c6d4f781529d2f28693546b25b2967d44ec89e60Mark AndrewsString reqURI = request.getRequestURI();
c718d15a9a95054ee3c71540c02335426071fc6dMark Andrewsif (path == null) path = "";
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark AndrewsRuntimeEnvironment environment = RuntimeEnvironment.getInstance();
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark AndrewsString rawSource = environment.getSourceRootPath();
605bd686e437162b5ab65ac4e7c1be0bba1886ddMark AndrewsString resourcePath = rawSource + path;
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark AndrewsFile resourceFile = new File(resourcePath);
1eb1e1e838d2ea00b166c918bf50764a95826be8Mark Andrewsboolean valid = true;
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrewsboolean noHistory = true;
821d2613356f81e5bb5c107288d6d5cf35c2a1e8Mark Andrewsboolean noAnnotation = true;
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafssonboolean annotate = false;
821d2613356f81e5bb5c107288d6d5cf35c2a1e8Mark AndrewsString basename = resourceFile.getName();
821d2613356f81e5bb5c107288d6d5cf35c2a1e8Mark Andrewsboolean isDir = false;
91216cff91b34c9ff6e846dc23f248219cafe660Andreas GustafssonEftarFileReader ef = null;
821d2613356f81e5bb5c107288d6d5cf35c2a1e8Mark AndrewsString parent = null;
821d2613356f81e5bb5c107288d6d5cf35c2a1e8Mark AndrewsString parentBasename = resourceFile.getParentFile().getName();
91216cff91b34c9ff6e846dc23f248219cafe660Andreas GustafssonIgnoredNames ignoredNames = environment.getIgnoredNames();
821d2613356f81e5bb5c107288d6d5cf35c2a1e8Mark AndrewsString uriEncodedName = Util.URIEncodePath(path);
7e5b2100ea65658a7ec3795919b4ecd29a6f118aMark Andrews|| ignoredNames.ignore(parentBasename)
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews valid = false;
e086341ea57e618a60c9f166b95daee1fab71b3bMark Andrews} else if (!resourceFile.canRead() && resourcePath.startsWith(rawSource)) {
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews String newPath = rawSource + "/on/" + path; //TODO do we still use "on" ???
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews File newFile = new File(newPath);
821d2613356f81e5bb5c107288d6d5cf35c2a1e8Mark Andrews if(newFile.isDirectory() && servlet.startsWith("/xref") && !path.endsWith("/")) {
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson response.sendRedirect(context + servlet + "/on" + path + "/");
821d2613356f81e5bb5c107288d6d5cf35c2a1e8Mark Andrews response.sendRedirect(context + servlet + "/on" + path);
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson valid = false;
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews valid = true;
46e873c835bf7d9ec3e1097e0aceb8db5b1ae93aMark Andrews path = resourcePath.substring(rawSource.length());
46e873c835bf7d9ec3e1097e0aceb8db5b1ae93aMark Andrews if ("".equals(path)) {
413988c8166976498250c0ebb2e3a645d0366bd3Mark Andrews path = path.replace('\\','/');
6b5c57e52ac8c3e0af1547be3140ebbfb41a85b3Mark Andrews if (isDir && !servlet.startsWith("/xref") && !servlet.startsWith("/hist")) { //if it is an existing directory perhaps people wanted directory xref
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews response.sendRedirect(context + "/xref" + path + "/");
6b5c57e52ac8c3e0af1547be3140ebbfb41a85b3Mark Andrews response.sendRedirect(context + "/xref" + path);
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews } if (isDir && !reqURI.endsWith("/")) {
6b5c57e52ac8c3e0af1547be3140ebbfb41a85b3Mark Andrews response.sendRedirect(context + servlet + path +"/");
642e0716c8b4ab82ebc8e60f94c9e897ee89f19aMark Andrews String dtag = "";
6b5c57e52ac8c3e0af1547be3140ebbfb41a85b3Mark Andrews if (request.getDateHeader("If-Modified-Since") >= flast ) {
6b5c57e52ac8c3e0af1547be3140ebbfb41a85b3Mark Andrews response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
6b5c57e52ac8c3e0af1547be3140ebbfb41a85b3Mark Andrews valid = false;
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews response.setDateHeader("Last-Modified", flast);
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews int lastSlash = path.lastIndexOf('/');
6b5c57e52ac8c3e0af1547be3140ebbfb41a85b3Mark Andrews parent = (lastSlash != -1) ? path.substring(0, lastSlash) : "";
413988c8166976498250c0ebb2e3a645d0366bd3Mark Andrews int pLastSlash = parent.lastIndexOf('/');
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews parentBasename = pLastSlash != -1 ? parent.substring(pLastSlash+1) : parent;
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews noHistory = !HistoryGuru.getInstance().hasHistory(resourceFile);
6b5c57e52ac8c3e0af1547be3140ebbfb41a85b3Mark Andrews noAnnotation = isDir ||
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews !HistoryGuru.getInstance().hasAnnotation(resourceFile);
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews annotate = !noAnnotation &&
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews Boolean.parseBoolean(request.getParameter("a"));
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews ef = new EftarFileReader(environment.getDataRootPath() + "/index/dtags.eftar");
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews dtag = ef.get(path);
6b5c57e52ac8c3e0af1547be3140ebbfb41a85b3Mark Andrews if(ef != null) {
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews } catch (IOException e) {
dd9ad704c3800e3ab07ede8595871eac79984871Mark Andrews } catch (Exception e) {
46e873c835bf7d9ec3e1097e0aceb8db5b1ae93aMark Andrews String pageTitle="Cross Reference: " + path;
6b5c57e52ac8c3e0af1547be3140ebbfb41a85b3Mark Andrews%><%@ include file="httpheader.jspf" %>
605bd686e437162b5ab65ac4e7c1be0bba1886ddMark Andrews<% if (annotate) { %>
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington<script type="text/javascript" src="<%=context%>/jquery-1.4.min.js"></script>
068a66979695c77359e7a9181bb3f831c965b21cMark Andrews<script type="text/javascript" src="<%=context%>/jquery.tooltip-1.3.pack.js"></script>
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews<script type="text/javascript">/* <![CDATA[ */
62ee2c9f460d2e2e45dcf1abc8b4b4a4a43f5618Mark Andrewsfunction toggle_annotations() {
1eb1e1e838d2ea00b166c918bf50764a95826be8Mark Andrews var spans = document.getElementsByTagName("span");
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews for (var i = 0; i < spans.length; i++) {
ea206aebcafe1ed5d470dd99daab9a1cedc81c7cMark Andrews var span = spans[i];
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson if (span.className == 'blame') {
ea206aebcafe1ed5d470dd99daab9a1cedc81c7cMark Andrews span.className = 'blame-hidden';
068a66979695c77359e7a9181bb3f831c965b21cMark Andrews } else if (span.className == 'blame-hidden') {
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews$().ready(function() {
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews $('a[id=r]').tooltip({
605bd686e437162b5ab65ac4e7c1be0bba1886ddMark Andrews showURL: false
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson/* ]]> */</script>
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington<div id="page">
75216e007570b8ea36b3ac9cca096bf70c0ca6f6Mark Andrews<div id="whole_header" >
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews<form action="<%=context%>/search">
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews <div id="header"><%@ include file="pageheader.jspf" %>
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews <div id="pagetitle"><b id="filename">Cross Reference: <%=basename%></b><% if (dtag!=null & dtag!="") { %><br/><%=dtag%><% } %></div>
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews <div id="Masthead"><tt><a href="<%=context%>/xref/">xref</a>: <%=org.opensolaris.opengrok.web.Util.breadcrumbPath(context + "/xref", path)%></tt></div>
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews <div id="bar"><a href="<%=context%>" id="home">Home</a> |
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews if (noHistory || servlet.startsWith("/hi")) {
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews %> <span class="c" id="history">History</span><%
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews %><a id="history" href="<%=context%>/history<%=path%>">History</a><%
e076d0c88be69de7c190ab924d095e69d2e11f7aAndreas Gustafsson if (noAnnotation) {
068a66979695c77359e7a9181bb3f831c965b21cMark Andrews %> | <span class="c" id="annotate">Annotate</span><%
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews String rev = request.getParameter("r");
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews if (rev == null) {
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson } else if (rev.length() > 0) {
821d2613356f81e5bb5c107288d6d5cf35c2a1e8Mark Andrews rev = "&r=" + rev;
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson if (Boolean.parseBoolean(request.getParameter("a"))) {
821d2613356f81e5bb5c107288d6d5cf35c2a1e8Mark Andrews %> | <span id="toggle-annotate-by-javascript" style="display: none">
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington <a href="#" onclick="javascript:toggle_annotations(); return false;" title="Show or hide line annotation(commit revisions,authors)." >Annotate</a>
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington <span id="toggle-annotate">
eaccf5e805405de257b5a4840256c580fefe00e3Mark Andrews <a href="<%=context%>/xref<%=path%><%
068a66979695c77359e7a9181bb3f831c965b21cMark Andrews %>?<%=rev%><%
068a66979695c77359e7a9181bb3f831c965b21cMark Andrews } %>">Annotate</a></span>
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews <script type="text/javascript">
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews var toggle_js = document.getElementById('toggle-annotate-by-javascript');
abf32d940f8f674b3971ef41b306a01b3da8d2cfMark Andrews var toggle_ss = document.getElementById('toggle-annotate');
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington %> | <a href="<%=context%>/xref<%=path%>?a=true<%=rev%>">Annotate</a><%
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington if (!isDir) {
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington %> | <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><%
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington String rev = request.getParameter("r");
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington if (rev == null || rev.equals("")) {
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington %> | <a id="download" href="<%=context%>/raw<%=path%>">Download</a><%
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington %> | <a id="download" href="<%=context%>/raw<%=path%>?r=<%=rev%>">Download</a><%
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington Project proj = Project.getProject(resourceFile);
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington if (proj != null || !environment.hasProjects()) {
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington %> | <input id="search" name="q" class="q"/>
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington <input type="submit" value="Search" class="submit"/>
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington if (proj != null) {
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington %><input type="hidden" name="project" value="<%=proj.getDescription()%>"/><%
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington %><input type="checkbox" name="path" value="<%=path%>"/> only in <b><%=path%></b><%
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington %><input type="checkbox" name="path" value="<%=parent%>"/> only in <b><%=parentBasename%></b><%
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington</div></form></div>
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington <div id="filler_for_whole_header"> </div>
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington} // date check
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington } // not a directory redirect