<%-- $Id$ CDDL HEADER START The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. See LICENSE.txt included in this distribution for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at LICENSE.txt. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] CDDL HEADER END Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. Portions Copyright 2011 Jens Elkner. Portions Copyright (c) 2018-2020, Chris Fraire . --%> <%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page errorPage="error.jsp" import=" java.io.IOException, java.io.File, java.text.Format, java.text.SimpleDateFormat, java.util.Date, java.util.logging.Level, java.util.logging.Logger, java.util.Objects, java.util.Set, java.util.regex.Pattern, org.opengrok.indexer.configuration.RuntimeEnvironment, org.opengrok.indexer.history.History, org.opengrok.indexer.history.HistoryEntry, org.opengrok.indexer.history.HistoryGuru, org.opengrok.indexer.logger.LoggerFactory, org.opengrok.indexer.util.ForbiddenSymlinkException, org.opengrok.indexer.web.QueryParameters, org.opengrok.indexer.web.SearchHelper, org.opengrok.indexer.web.Util" %> <%/* ---------------------- history.jsp start --------------------- */ { final Logger LOGGER = LoggerFactory.getLogger(getClass()); PageConfig cfg = PageConfig.get(request); cfg.checkSourceRootExistence(); // Need to set the title before including httpheader.jspf cfg.setTitle(cfg.getHistoryTitle()); String path = cfg.getPath(); if (path.length() > 0) { String primePath = path; Project project = cfg.getProject(); if (project != null) { SearchHelper searchHelper = cfg.prepareInternalSearch(); /* * N.b. searchHelper.destroy() is called via * WebappListener.requestDestroyed() on presence of the following * REQUEST_ATTR. */ request.setAttribute(SearchHelper.REQUEST_ATTR, searchHelper); searchHelper.prepareExec(project); try { primePath = searchHelper.getPrimeRelativePath(project.getName(), path); } catch (IOException | ForbiddenSymlinkException ex) { LOGGER.log(Level.WARNING, String.format( "Error getting prime relative for %s", path), ex); } } File file = cfg.getResourceFile(primePath); History hist; try { hist = HistoryGuru.getInstance().getHistoryUI(file); } catch (Exception e) { // should not happen response.sendError(HttpServletResponse.SC_NOT_FOUND, e.getMessage()); return; } if (hist == null) { /* * The history is not available even for a renamed file. * Send 404 Not Found. */ response.sendError(HttpServletResponse.SC_NOT_FOUND); return; } request.setAttribute("history.jsp-hist", hist); } } %> <%@ include file="httpheader.jspf" %> <% { if ((request.getAttribute("history.jsp-hist")) != null) { %>
<% } } { if (request.getAttribute("history.jsp-hist") != null) { %> <%@include file="pageheader.jspf" %> <% } } { PageConfig cfg = PageConfig.get(request); String context = request.getContextPath(); String path = cfg.getPath(); History hist; if ((hist = (History) request.getAttribute("history.jsp-hist")) != null) { int start = cfg.getSearchStart(); int max = cfg.getSearchMaxItems(); long totalHits = hist.getHistoryEntries().size(); long thispage = Math.min(totalHits - start, max); // We have a lots of results to show: create a slider for them request.setAttribute("history.jsp-slider", Util.createSlider(start, max, totalHits, request)); %>
History log of <%= Util.breadcrumbPath(context + Prefix.XREF_P, path,'/',"",true,cfg.isDir()) %> (Results <%= totalHits != 0 ? start + 1 : 0 %> – <%= thispage + start %> of <%= totalHits %>)
<% } } { if (request.getAttribute("history.jsp-hist") != null) { %> <%@ include file="minisearch.jspf" %> <% } } { PageConfig cfg = PageConfig.get(request); String context = request.getContextPath(); String path = cfg.getPath(); History hist; if ((hist = (History) request.getAttribute("history.jsp-hist")) != null) { RuntimeEnvironment env = cfg.getEnv(); String uriEncodedName = cfg.getUriEncodedPath(); boolean striked = false; String userPage = env.getUserPage(); String userPageSuffix = env.getUserPageSuffix(); String bugPage = env.getBugPage(); String bugRegex = env.getBugPattern(); Pattern bugPattern = Pattern.compile(bugRegex); String reviewPage = env.getReviewPage(); String reviewRegex = env.getReviewPattern(); Pattern reviewPattern = Pattern.compile(reviewRegex); Format df = new SimpleDateFormat("dd-MMM-yyyy"); int revision2 = Math.max(cfg.getIntParam(QueryParameters.REVISION_2_PARAM, -1), 0); int revision1 = cfg.getIntParam(QueryParameters.REVISION_1_PARAM, -1) < revision2 ? revision2 + 1 : cfg.getIntParam(QueryParameters.REVISION_1_PARAM, -1); revision2 = revision2 >= hist.getHistoryEntries().size() ? hist.getHistoryEntries().size() - 1 : revision2; int start = cfg.getSearchStart(); int max = cfg.getSearchMaxItems(); %>
<% if (!cfg.isDir()) { %> <% } %> <% int count=0; for (HistoryEntry entry : hist.getHistoryEntries(max, start)) { String rev = entry.getRevision(); if (rev == null || rev.length() == 0) { rev = ""; } String tags = hist.getTags().get(rev); if (tags != null) { int colspan; if (cfg.isDir()) colspan = 4; else colspan = 5; %> <% } %> <% if (cfg.isDir()) { %> <% } else { if (entry.isActive()) { StringBuffer urlBuffer = request.getRequestURL(); if (request.getQueryString() != null) { urlBuffer.append('?').append(request.getQueryString()); } urlBuffer.append('#').append(rev); %> <% } else { striked = true; %> <% } } %> <% count++; } %>
Revision <% if (hist.hasTags()) { %> (<<< Hide revision tags) (Show revision tags >>>)<% } %> <% if (hist.getHistoryEntries().size() > revision1 && revision1 >= 0) { %> <% } %> <% if (hist.getHistoryEntries().size() > revision2 && revision2 >= 0) { %> <% } %> Date Author Comments <% if (hist.hasFileList()) { %>
(<<< Hide modified files)
(Show modified files >>>)
<% } %>
Revision tags: <%= tags %>
<%= rev %># "><%= rev %> <% %> revision1 || (count + start > revision2 && count + start <= revision1 - 1)) { // revision1 enabled } else if (count + start == revision1 ) { // revision1 selected %> checked="checked"<% } else if( count + start <= revision2 ) { // revision1 disabled %> disabled="disabled" <% } %>/><% %> revision2 && count + start <= revision1 - 1) ) { // revision2 enabled } else if( count + start == revision2 ) { // revision2 selected %> checked="checked" <% } else if (count + start >= revision1 ) { // revision2 disabled %> disabled="disabled" <% } %>/><% %><%= rev %> <% Date date = entry.getDate(); if (date != null) { %><%= df.format(date) %><% } %> <% String author = entry.getAuthor(); if (author == null) { %>(no author)<% } else if (userPage != null && userPage.length() > 0) { String alink = Util.getEmail(author); %><%= Util.htmlize(author)%><% } else { %><%= Util.htmlize(author) %><% } %> <% // revision message collapse threshold minimum of 10 int summaryLength = Math.max(10, cfg.getRevisionMessageCollapseThreshold()); String cout = Util.htmlize(entry.getMessage()); if (bugPage != null && bugPage.length() > 0) { cout = Util.linkifyPattern(cout, bugPattern, "$1", Util.completeUrl(bugPage + "$1", request)); } if (reviewPage != null && reviewPage.length() > 0) { cout = Util.linkifyPattern(cout, reviewPattern, "$1", Util.completeUrl(reviewPage + "$1", request)); } boolean showSummary = false; String coutSummary = entry.getMessage(); if (coutSummary.length() > summaryLength) { showSummary = true; coutSummary = coutSummary.substring(0, summaryLength - 1); coutSummary = Util.htmlize(coutSummary); if (bugPage != null && bugPage.length() > 0) { coutSummary = Util.linkifyPattern(coutSummary, bugPattern, "$1", Util.completeUrl(bugPage + "$1", request)); } if (reviewPage != null && reviewPage.length() > 0) { coutSummary = Util.linkifyPattern(coutSummary, reviewPattern, "$1", Util.completeUrl(reviewPage + "$1", request)); } } if (showSummary) { %>

<%= coutSummary %>

<%= cout %>

show more ...

<% } else { %>

<%= cout %>

<% } Set files = entry.getFiles(); if (files != null) { %>

<% for (String ifile : files) { String jfile = Util.stripPathPrefix(path, ifile); if (Objects.equals(rev, "")) { %> <%= jfile %>
<% } else { %> <%= jfile %>
<% } } %>
<% } %>
<% String slider; if ((slider = (String) request.getAttribute("history.jsp-slider")) != null) { // NOTE: shouldn't happen that it doesn't have this attribute %>

<%= slider %>

<% } %>
<% if (striked) { %>

Note: No associated file changes are available for revisions with strike-through numbers (eg. 1.45)

<% } %>

<% } } /* ---------------------- history.jsp end --------------------- */ %><%@ include file="foot.jspf" %>