history.jsp revision 0dafcea0c31887f3a3b35be121d3f35ff19ec4b4
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster<%--
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterCDDL HEADER START
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterThe contents of this file are subject to the terms of the
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterCommon Development and Distribution License (the "License").
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterYou may not use this file except in compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterSee LICENSE.txt included in this distribution for the specific
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterlanguage governing permissions and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterWhen distributing Covered Code, include this CDDL HEADER in each
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterfile and include the License file at LICENSE.txt.
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterIf applicable, add the following below this CDDL HEADER, with the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterfields enclosed by brackets "[]" replaced with your own identifying
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterinformation: Portions Copyright [yyyy] [name of copyright owner]
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterCDDL HEADER END
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterCopyright 2005 Sun Microsystems, Inc. All rights reserved.
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterUse is subject to license terms.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterident "@(#)history.jsp 1.1 05/11/11 SMI"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster--%><%@ page import = "javax.servlet.*,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterjava.lang.*,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterjavax.servlet.http.*,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterjava.util.*,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterjava.io.*,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterjava.text.*,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterorg.opensolaris.opengrok.analysis.*,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterorg.opensolaris.opengrok.web.*,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterorg.opensolaris.opengrok.history.*,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterjava.util.regex.*
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster%><%@include file="mast.jsp"%><% String hcontext = request.getContextPath(); %>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster<script type="text/javascript" src="<%=hcontext%>/jquery-1.4.2.min.js"></script>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster<script type="text/javascript">
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster// <![CDATA[
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterfunction toggle_filelist() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster $("span").each(function() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (this.className == "filelist") {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster this.setAttribute("style", "display: none;");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster this.className = "filelist-hidden";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else if (this.className == "filelist-hidden") {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster this.setAttribute("style", "display: inline;");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster this.className = "filelist";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster );
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster}
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterfunction togglediffs() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster var cr2 = false;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster var cr1 = false;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster $("#revisions input[type=radio]").each(function() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (this.name=="r1") { if (this.checked) {cr1=true;return true;};
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (cr2) { this.disabled = ''}
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster else {this.disabled = 'true'} }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster else if (this.name=="r2") { if (this.checked) {cr2=true;return true;}
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (!cr1) { this.disabled = ''}
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster else {this.disabled = 'true'} }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster );
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster}
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster$(document).ready(function(){
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // start state should ALWAYS be: first row: r1 hidden, r2 checked ; second row: r1 clicked, (r2 hidden)(optionally)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // I cannot say what will happen if they are not like that, togglediffs will go mad !
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster $("#revisions input[type=radio]").bind("click",togglediffs);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster togglediffs();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster});
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster// ]]>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster</script><%
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterif (path.length() > 0 && valid) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster boolean striked = false;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String userPage = environment.getUserPage();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String bugPage = environment.getBugPage();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String bugRegex = environment.getBugPattern();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if(bugRegex == null || bugRegex.equals("")) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster bugRegex = "\\b([12456789][0-9]{6})\\b";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Pattern bugPattern = Pattern.compile(bugRegex);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String reviewPage = environment.getReviewPage();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String reviewRegex = environment.getReviewPattern();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if(reviewRegex == null || reviewRegex.equals("")) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster reviewRegex = "\\b(\\d{4}/\\d{3})\\b";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Pattern reviewPattern = Pattern.compile(reviewRegex);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Format df = new SimpleDateFormat("dd-MMM-yyyy");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Date tstart = new Date();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster File f = new File(rawSource + path);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (!HistoryGuru.getInstance().hasHistory(f)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster response.sendError(404, "No history");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster History hist=null;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster try {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster hist = HistoryGuru.getInstance().getHistory(f);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } catch (Exception e) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster %>Problem: <%=e.getMessage()%><%
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (hist == null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // response.sendError(404, "No history");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster %><%@include file="foot.jspf"%><%
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster%><form action="<%=context%>/diff<%=path%>">
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster<table cellspacing="0" cellpadding="2" border="0" width="100%" class="src" id="revisions">
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster<tr>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster <td colspan="5"><span class="pagetitle">History log of <a href="<%= context +"/xref" + path %>"><%=path%></a></span></td>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster</tr>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster<tr class="thead">
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster <td>Revision</td><%
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (!isDir) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster %><th><input type="submit" value=" Compare "/></th><%
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
%><td>Date</td><td>Author</td><td>Comments<%
if (hist.hasFileList()) {
%> <a href="#" onclick="javascript: toggle_filelist(); return false;">
<span class="filelist-hidden" style="display: none;">
(&lt;&lt;&lt; Hide modified files)
</span>
<span class="filelist" style="display: inline;">
(Show modified files &gt;&gt;&gt;)
</span>
</a><%
}
%></td>
</tr><%
boolean alt = true;int count=0;
for (HistoryEntry entry : hist.getHistoryEntries()) {
String rev = entry.getRevision();
if (rev == null || rev.length() == 0) {
rev = "";
}
alt = !alt;
%><tr valign="top" <%= alt ? "class=\"alt\"" : "" %>><%
if (isDir) {
%><td>&nbsp;<%=rev%>&nbsp;</td><%
} else {
if (entry.isActive()) {
String rp = Util.URIEncodePath(path);
%><td>&nbsp;<a name="<%=rev%>" href="<%= context +"/xref" + rp + "?r=" + Util.URIEncode(rev) %>"><%=rev%></a>&nbsp;</td><td align="center">
<input type="radio" <% if (count==0) {%>disabled<% } else if (count==1) {%>checked<%} %> name="r1" value="<%=rp%>@<%=rev%>"/>
<input type="radio" name="r2" <% if (count==0) {%>checked<% } %> value="<%=rp%>@<%=rev%>"/></td><%
} else {
striked = true;
%><td><strike>&nbsp;<%=rev%>&nbsp; </strike></td><td>&nbsp;</td><%
}
}
%><td><%
Date date = entry.getDate();
if (date != null) {
%><%=df.format(date)%><%
} else {
%>&nbsp;<%
}
%>&nbsp;</td>
<td>
<%
String author = entry.getAuthor();
if (author == null) {
%>(no author)<%
} else if (userPage != null && ! userPage.equals("")) {
%><a href="<%= userPage + author %>"><%= author %></a><%
} else {
%><%= author %><%
}
%>&nbsp;</td><td><%
String cout=Util.htmlize(entry.getMessage());
if (bugPage != null && ! bugPage.equals("")){
cout=bugPattern.matcher(cout).replaceAll("<a href=\"" + bugPage + "$1\">$1</a>"); }
if (reviewPage != null && ! reviewPage.equals("")) {
cout=reviewPattern.matcher(cout).replaceAll("<a href=\"" + reviewPage + "$1\">$1</a>"); }
%><%= cout %>
<%
Set<String> files = entry.getFiles();
if(files != null) {%><span class="filelist-hidden" style="display: none;"><br/><%
for (String ifile : files) {
String jfile = ifile;
if ("/".equals(path)) {
jfile = ifile.substring(1);
} else if (ifile.startsWith(path) && ifile.length() > (path.length()+1)) {
jfile = ifile.substring(path.length()+1);
}
if (rev == "") {
%><a class="h" href="<%=context%>/xref<%=ifile%>"><%=jfile%></a><br/><%
} else {
%><a class="h" href="<%=context%>/xref<%=ifile%>?r=<%=rev%>"><%=jfile%></a><br/><%
}
}%></span><%
}
%></td></tr><%
count++;
}
%></table></form><%
if(striked) {
%><p><b>Note:</b> No associated file changes are available for revisions with strike-through numbers (eg. <strike>1.45</strike>)</p><%
}
%><p class="rssbadge"><a href="<%=context%>/rss<%=Util.URIEncodePath(path)%>"><img src="<%=context%>/<%=environment.getWebappLAF()%>/img/rss.png" width="80" height="15" alt="RSS XML Feed" title="RSS XML Feed of latest changes"/></a></p><%
}
%><%@include file="foot.jspf"%>