();
int offset = -1;
EftarFileReader.FNode parentFNode = null;
EftarFileReader desc = cfg.getEftarReader();
if (desc != null) {
parentFNode = desc.getNode(path);
if (parentFNode != null) {
offset = parentFNode.childOffset;
}
}
%>
|
Name |
Date |
<%= virtual ? "Revision" : "Size" %> | <%
if (offset > 0) {
%> Description | <%
}
%>
<%
IgnoredNames ignoredNames = cfg.getIgnoredNames();
Format dateFormatter =
new SimpleDateFormat(cfg.getConfig().getDirlistDatePattern());
boolean useToday = cfg.getConfig().isDirlistUseToday();
// upper directory
if (path.length() != 0) {
long lastm = 0;
if (!modTimes.isEmpty()) {
for (Date d : modTimes.values()) {
long l = d.getTime();
if (l > lastm) {
lastm = l;
}
}
} else if (!virtual) {
lastm = resourceFile.getParentFile().lastModified();
} else {
lastm = now;
}
String css = now - lastm < 86400000 ? " class='x'" : "";
%>
|
.. |
><%= useToday && now - lastm < 86400000
? "Today" : dateFormatter.format(lastm) %> |
<%= virtual
? path2rev.size() + " entries"
: resourceFile.getParentFile().length() + ""
%> | <%
if (offset > 0) { %>
| <%
} %>
<%
}
// 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'" : "";
%>
|
<%= isDir ? ""
+ Util.htmlize(file) + "" : Util.htmlize(file) %> |
><%= useToday && now-lastm < 86400000
? "Today" : dateFormatter.format(lastm) %> |
<%= size %> | <%
if (offset > 0) {
String briefDesc = desc.getChildTag(parentFNode, file); %>
<%= briefDesc == null ? "" : Util.htmlize(briefDesc) %> | <%
} %>
<%
}
%>
<%
if (readMes.size() != 0) {
ArrayList
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(3);
}
readMesImg.add(readme.getName());
continue;
} else if (g != Genre.HTML && g != Genre.PLAIN) {
continue;
}
pre = true;
// else dump
}
%>
<%= readMes.get(i) %>
<%
if (pre) {
out.write("");
}
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("");
}
}
if (readMesImg != null) {
for (String image : readMesImg) {
%>
<%= image %>
<%
}
}
}
%>
<%
// 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) {
%>
<%= basename %> for revision <%= rev.substring(2) %> is empty. It was
probably moved to a different location or deleted. A click on the History
button may reveal more details.
<%
} else {
if (g == null) {
a = AnalyzerGuru.find(in);
g = AnalyzerGuru.getGenre(a);
}
if (g == Genre.DATA || g == Genre.XREFABLE || g == null) {
%>
Binary file [Click here to download]
<%
} else {
%>
<%= Util.htmlize(basename) %> revision <%=
rev.substring(2) %><%
if (g == Genre.PLAIN) {
%>
<%
// 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) {
%>
 %>?<%= rev %>)
<%
} else if (g == Genre.HTML) {
r = new InputStreamReader(in);
Util.dump(out, r);
} else {
%> Click
download <%= Util.htmlize(basename) %><%
}
%>
<%
}
}
} 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 {
%>
Error reading file
<%
if (error != null) {
%>
<%= error %>
<%
}
}
} else if (g == Genre.IMAGE) {
%>
<%
} else {
%>
Binary file [Click here to download]
<%
}
// 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
%>
<%
XrefInputStream.dump(xrefFile, out, true);
%>
<%
// 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) {
%>
<%
} else if (g == Genre.HTML) {
r = new InputStreamReader(bin);
Util.dump(out, r);
} else if (g == Genre.PLAIN) {
%>
<%
// 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));
%>
<%
} else {
%>
Click download <%=
Util.htmlize(basename) %><%
}
} 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"
%>