list.jsp revision 1474
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano<%--
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano$Id$
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoCDDL HEADER START
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoThe contents of this file are subject to the terms of the
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoCommon Development and Distribution License (the "License").
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoYou may not use this file except in compliance with the License.
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoSee LICENSE.txt included in this distribution for the specific
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanolanguage governing permissions and limitations under the License.
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoWhen distributing Covered Code, include this CDDL HEADER in each
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanofile and include the License file at LICENSE.txt.
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoIf applicable, add the following below this CDDL HEADER, with the
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanofields enclosed by brackets "[]" replaced with your own identifying
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoinformation: Portions Copyright [yyyy] [name of copyright owner]
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoCDDL HEADER END
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoCopyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoPortions Copyright 2011, 2012 Jens Elkner.
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano--%><%@page import="java.util.Collections"%>
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano<%@page import="java.util.Arrays"%>
99e4008cad9e959b683c6f48411fcf15a92be3b5Michel Normand<%@page import="java.util.LinkedHashMap"%>
99e4008cad9e959b683c6f48411fcf15a92be3b5Michel Normand<%@page import="java.util.HashMap"%>
10fba81b9d0221b8e47aa1e0b43236413b7d28dfMichel Normand<%@page session="false" errorPage="error.jsp" import="
99e4008cad9e959b683c6f48411fcf15a92be3b5Michel Normandjava.io.BufferedInputStream,
99e4008cad9e959b683c6f48411fcf15a92be3b5Michel Normandjava.io.File,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanojava.io.IOException,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanojava.io.FileInputStream,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanojava.io.InputStream,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanojava.io.InputStreamReader,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanojava.io.Reader,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanojava.text.Format,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanojava.text.SimpleDateFormat,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanojava.util.ArrayList,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanojava.util.Date,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanojava.util.List,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanojava.util.Map,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanojava.util.Set,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoorg.opensolaris.opengrok.analysis.AnalyzerGuru,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoorg.opensolaris.opengrok.analysis.Definitions,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoorg.opensolaris.opengrok.analysis.FileAnalyzer.Genre,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoorg.opensolaris.opengrok.analysis.FileAnalyzerFactory,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoorg.opensolaris.opengrok.analysis.XrefInputStream,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoorg.opensolaris.opengrok.analysis.XrefWriter,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoorg.opensolaris.opengrok.history.Annotation,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoorg.opensolaris.opengrok.history.HistoryGuru,
201172806c477ecb36bc00fad92b85e067712c38Cedric Le Goaterorg.opensolaris.opengrok.index.IgnoredNames,
201172806c477ecb36bc00fad92b85e067712c38Cedric Le Goaterorg.opensolaris.opengrok.index.IndexDatabase,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoorg.opensolaris.opengrok.util.IOUtils,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoorg.opensolaris.opengrok.web.EftarFileReader"
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano%><%
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano{
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano // need to set it here since requesting parameters
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano if (request.getCharacterEncoding() == null) {
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano request.setCharacterEncoding("UTF-8");
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano }
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano cfg = PageConfig.get(request);
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand Annotation annotation = cfg.getAnnotation();
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand if (annotation != null) {
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand float r = annotation.getWidestRevision() * 1.15f;
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand float a = annotation.getWidestAuthor() * 1.15f;
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand cfg.addHeaderData("<style type=\"text/css\">"
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand + ".r { width: " + (r == 0 ? 6 : r) + "ex; } "
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand + ".a { width: " + (a == 0 ? 6 : a) + "ex; } "
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand + "</style>");
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand }
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand}
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano%><%@include
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanofile="mast.jsp"
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano%><%
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand/* ---------------------- list.jsp start --------------------- */
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand{
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand cfg = PageConfig.get(request);
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand String rev = cfg.getRequestedRevision();
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand File resourceFile = cfg.getResourceFile();
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand String path = cfg.getPath();
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand String basename = resourceFile.getName();
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand String rawPath = request.getContextPath() + Prefix.RAW_P + path;
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand Reader r = null;
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand if (cfg.isDir()) {
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano // directory listing
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano boolean virtual =
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano basename.isEmpty() || request.getParameter("all") != null;
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano Project activeProject = Project.getProject(path);
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano String cookieValue = cfg.getRequestedProjectsAsString();
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano if (activeProject != null) {
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano Set<String> projects = cfg.getRequestedProjects();
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand if (!projects.contains(activeProject.getDescription())) {
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano projects.add(activeProject.getDescription());
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano // update cookie
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano cookieValue = cookieValue.length() == 0
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano ? activeProject.getDescription()
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano : activeProject.getDescription() + '/' + cookieValue;
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano Cookie cookie = new Cookie("OpenGrokProject", cookieValue);
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand // TODO hmmm, projects.jspf doesn't set a path
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand cookie.setPath(request.getContextPath() + '/');
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand response.addCookie(cookie);
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand }
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand }
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano LinkedHashMap<String,String> path2rev =
201172806c477ecb36bc00fad92b85e067712c38Cedric Le Goater virtual ? new LinkedHashMap<String,String>() : null;
201172806c477ecb36bc00fad92b85e067712c38Cedric Le Goater Map<String, Date> modTimes = HistoryGuru.getInstance()
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand .getLastModifiedTimes(new File(cfg.getSourceRootPath() + path), path2rev);
201172806c477ecb36bc00fad92b85e067712c38Cedric Le Goater List<String> files = virtual
201172806c477ecb36bc00fad92b85e067712c38Cedric Le Goater ? new ArrayList<String>(modTimes.keySet())
201172806c477ecb36bc00fad92b85e067712c38Cedric Le Goater : cfg.getResourceFileList();
201172806c477ecb36bc00fad92b85e067712c38Cedric Le Goater if (virtual) {
201172806c477ecb36bc00fad92b85e067712c38Cedric Le Goater // to be consistent with resource file listing
201172806c477ecb36bc00fad92b85e067712c38Cedric Le Goater Collections.sort(files, String.CASE_INSENSITIVE_ORDER);
201172806c477ecb36bc00fad92b85e067712c38Cedric Le Goater }
201172806c477ecb36bc00fad92b85e067712c38Cedric Le Goater
201172806c477ecb36bc00fad92b85e067712c38Cedric Le Goater long now = System.currentTimeMillis();
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano ArrayList<String> readMes = new ArrayList<String>();
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano int offset = -1;
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano EftarFileReader.FNode parentFNode = null;
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano EftarFileReader desc = cfg.getEftarReader();
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano if (desc != null) {
10fba81b9d0221b8e47aa1e0b43236413b7d28dfMichel Normand parentFNode = desc.getNode(path);
10fba81b9d0221b8e47aa1e0b43236413b7d28dfMichel Normand if (parentFNode != null) {
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano offset = parentFNode.childOffset;
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano }
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano }
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano%><table id="dirlist">
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano<thead>
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano<tr>
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano <th/>
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano <th>Name</th>
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano <th>Date</th>
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano <th><%= virtual ? "Revision" : "Size" %></th><%
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano if (offset > 0) {
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano%> <th>Description</th><%
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano }
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano%>
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano</tr>
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano</thead>
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano<tbody><%
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano IgnoredNames ignoredNames = cfg.getIgnoredNames();
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano Format dateFormatter =
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano new SimpleDateFormat(cfg.getConfig().getDirlistDatePattern());
99e4008cad9e959b683c6f48411fcf15a92be3b5Michel Normand boolean useToday = cfg.getConfig().isDirlistUseToday();
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano // upper directory
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano if (path.length() != 0) {
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano long lastm = 0;
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano if (!modTimes.isEmpty()) {
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano for (Date d : modTimes.values()) {
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano long l = d.getTime();
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano if (l > lastm) {
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano lastm = l;
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano }
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano }
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano } else if (!virtual) {
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano lastm = resourceFile.getParentFile().lastModified();
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano } else {
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano lastm = now;
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano }
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano String css = now - lastm < 86400000 ? " class='x'" : "";
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano%>
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano<tr>
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano <td><p class="u"/></td>
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano <td><b><a href="..">..</a></b></td>
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano <td<%= css%>><%= useToday && now - lastm < 86400000
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano ? "Today" : dateFormatter.format(lastm) %></td>
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano <td><%= virtual
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano ? path2rev.size() + " entries"
: resourceFile.getParentFile().length() + ""
%></td><%
if (offset > 0) { %>
<td/><%
} %>
</tr><%
}
// entries
boolean isDir;
long lastm;
String size;
String link;
for (String file : files) {
if (ignoredNames.match(file)) {
continue;
}
if (virtual) {
isDir = file.endsWith("/");
lastm = modTimes.get(file).getTime();
size = path2rev.get(file);
// we do not display any readmes for virtual dirs
link = Util.uriEncodePath(file);
if (!isDir) {
link += "?r=" + size;
}
} else {
File child = new File(resourceFile, file);
if ((file.startsWith("README") || file.endsWith("README")
|| file.startsWith("readme")) && child.isFile())
{
readMes.add(file);
}
isDir = child.isDirectory();
Date lmd = modTimes.get(isDir ? file : file + '/');
lastm = lmd == null ? child.lastModified() : lmd.getTime();
size = Util.readableSize(child.length());
link = Util.uriEncodePath(file);
}
String css = now - lastm < 86400000 ? " class='x'" : "";
%>
<tr>
<td><p class="<%= isDir ? 'v' : 'w' %>"/></td>
<td><a href="<%= link %>"><%= isDir ? "<b>"
+ Util.htmlize(file) + "</b>" : Util.htmlize(file) %></a></td>
<td<%= css%>><%= useToday && now-lastm < 86400000
? "Today" : dateFormatter.format(lastm) %></td>
<td><%= size %></td><%
if (offset > 0) {
String briefDesc = desc.getChildTag(parentFNode, file); %>
<td><%= briefDesc == null ? "" : Util.htmlize(briefDesc) %></td><%
} %>
</tr><%
}
%>
</tbody>
</table>
<div id="src"><%
if (readMes.size() != 0) {
ArrayList<String> readMesImg = null;
File[] xrefs = cfg.findDataFiles(readMes);
for (int i=0; i < xrefs.length; i++) {
File readme = xrefs[i];
boolean pre = false;
if (readme == null) { // no xref avail or outdated or img
readme = new File(resourceFile, readMes.get(i));
Genre g = AnalyzerGuru.getGenre(readme.getName());
if (g == null) {
BufferedInputStream in = null;
try {
in = new BufferedInputStream(new FileInputStream(readme));
g = AnalyzerGuru.getGenre(in);
} catch (Exception e) {
// ignore
} finally {
IOUtils.close(in);
}
}
if (g == Genre.IMAGE) {
if (readMesImg == null) {
readMesImg = new ArrayList<String>(3);
}
readMesImg.add(readme.getName());
continue;
} else if (g != Genre.HTML && g != Genre.PLAIN) {
continue;
}
pre = true;
// else dump
}
%>
<h3><%= readMes.get(i) %></h3><%
if (pre) {
out.write("<pre>");
}
if (xrefs[i] != null) {
XrefInputStream.dump(xrefs[i], out, false);
} else {
// not clean, but usually works
Util.dump(out,readme, readme.getName().endsWith(".gz"));
}
if (pre) {
out.write("</pre>");
}
}
if (readMesImg != null) {
for (String image : readMesImg) {
%>
<h3><%= image %></h3>
<img src="<%= Util.uriEncodePath(rawPath + '/' + image) %>"/><%
}
}
}
%>
</div><%
// end of directory listing
} else if (rev.length() != 0) {
// list a previous revision of a file
String parent = resourceFile.getParent();
if (basename.isEmpty()) {
// virtual file
int idx = path.lastIndexOf('/');
if (idx != -1) {
basename = path.substring(idx+1);
parent = cfg.getSourceRootPath() + '/' + path.substring(0, idx);
}
}
FileAnalyzerFactory a = AnalyzerGuru.find(basename);
Genre g = AnalyzerGuru.getGenre(a);
String error = null;
if (g == Genre.PLAIN|| g == Genre.HTML || g == null) {
InputStream in = null;
try {
in = HistoryGuru.getInstance()
.getRevision(parent, basename, rev.substring(2));
} catch (Exception e) {
// fall through to error message
error = e.getMessage();
}
if (in != null) {
XrefWriter xout = null;
try {
// we don't get enough info from history guru, that's why
// this little hack to emp. detect deleted/moved files
in.mark(2);
int b = in.read();
in.reset();
if (b == -1) {
%>
<div id="src"></div>
<p><%= basename %> for revision <%= rev.substring(2) %> is empty. It was
probably moved to a different location or deleted. A click on the <b>History</b>
button may reveal more details.</p>
<%
} else {
if (g == null) {
a = AnalyzerGuru.find(in);
g = AnalyzerGuru.getGenre(a);
}
if (g == Genre.DATA || g == Genre.XREFABLE || g == null) {
%>
<div id="src"></div>
<p>Binary file [Click <a href="<%= Util.uriEncodePath(rawPath) %>?<%= rev
%>">here</a> to download]</p><%
} else {
%>
<div id="src">
<span class="pagetitle"><%= Util.htmlize(basename) %> revision <%=
rev.substring(2) %></span><%
if (g == Genre.PLAIN) {
%>
<div id='linenums'></div><div id='annos'></div><%
// We don't have any way to get definitions
// for old revisions currently.
Definitions defs = null;
Annotation annotation = cfg.getAnnotation();
r = new InputStreamReader(in);
xout = new XrefWriter(out);
AnalyzerGuru.writeXref(a, r, xout , defs,
annotation, Project.getProject(resourceFile));
} else if (g == Genre.IMAGE) {
%>
<img src="<%= Util.uriEncodePath(rawPath) %>?<%= rev %>"/><%
} else if (g == Genre.HTML) {
r = new InputStreamReader(in);
Util.dump(out, r);
} else {
%> Click <a href="<%= Util.uriEncodePath(rawPath) %>?<%=
rev %>">download <%= Util.htmlize(basename) %></a><%
}
%>
</div><%
}
}
} catch (IOException e) {
error = e.getMessage();
} finally {
if (r != null) {
try { r.close(); in = null;}
catch (Exception e) { /* ignore */ }
}
IOUtils.close(in);
IOUtils.close(xout);
}
} else {
%>
<h3 class="error">Error reading file</h3><%
if (error != null) {
%>
<p class="error"><%= error %></p><%
}
}
} else if (g == Genre.IMAGE) {
%>
<div id="src">
<img src="<%= Util.uriEncodePath(rawPath) %>?<%= rev %>"/>
</div><%
} else {
%>
<div id="src"></div>
<p>Binary file [Click <a href="<%= Util.uriEncodePath(rawPath) %>?<%= rev
%>">here</a> to download]</p><%
}
// end list a previous revision of a file
} else {
// list current version of a file
File xrefFile = null;
if (!cfg.annotate()) {
xrefFile = cfg.findDataFile();
}
if (xrefFile != null) {
// dump cross file
%>
<div id="src"><div id='linenums'></div><div id='annos'></div><%
XrefInputStream.dump(xrefFile, out, true);
%>
</div><%
// end dump cross file
} else {
// dump [annotated] source file
BufferedInputStream bin =
new BufferedInputStream(new FileInputStream(resourceFile));
XrefWriter xout = null;
try {
FileAnalyzerFactory a = AnalyzerGuru.find(basename);
Genre g = AnalyzerGuru.getGenre(a);
if (g == null) {
a = AnalyzerGuru.find(bin);
g = AnalyzerGuru.getGenre(a);
}
if (g == Genre.IMAGE) {
%>
<div id="src">
<img src="<%= Util.uriEncodePath(rawPath) %>"/>
</div><%
} else if (g == Genre.HTML) {
r = new InputStreamReader(bin);
Util.dump(out, r);
} else if (g == Genre.PLAIN) {
%>
<div id="src"><div id='linenums'></div><div id='annos'></div><%
// We're generating xref for the latest revision, so we can
// find the definitions in the index.
Definitions defs = IndexDatabase.getDefinitions(resourceFile);
Annotation annotation = cfg.getAnnotation();
r = new InputStreamReader(bin);
xout = new XrefWriter(out);
AnalyzerGuru.writeXref(a, r, xout, defs, annotation,
Project.getProject(resourceFile));
%>
</div><%
} else {
%>
Click <a href="<%= Util.uriEncodePath(rawPath) %>">download <%=
Util.htmlize(basename) %></a><%
}
} finally {
if (r != null) {
try { r.close(); bin = null; }
catch (Exception e) { /* ignore */ }
}
IOUtils.close(bin);
IOUtils.close(xout);
}
// end dump [annotated] source file
}
// end list current version of a file
}
}
/* ---------------------- list.jsp end --------------------- */
%><%@
include file="foot.jspf"
%>