forked from I2P_Developers/i2p.i2p
details page for single-file torrents
This commit is contained in:
@@ -161,7 +161,7 @@ public class I2PSnarkServlet extends Default {
|
|||||||
resp.setCharacterEncoding("UTF-8");
|
resp.setCharacterEncoding("UTF-8");
|
||||||
resp.setContentType("text/html; charset=UTF-8");
|
resp.setContentType("text/html; charset=UTF-8");
|
||||||
Resource resource = getResource(pathInContext);
|
Resource resource = getResource(pathInContext);
|
||||||
if (resource == null || (!resource.exists()) || !resource.isDirectory()) {
|
if (resource == null || (!resource.exists())) {
|
||||||
resp.sendError(HttpResponse.__404_Not_Found);
|
resp.sendError(HttpResponse.__404_Not_Found);
|
||||||
} else {
|
} else {
|
||||||
String base = URI.addPaths(req.getRequestURI(), "/");
|
String base = URI.addPaths(req.getRequestURI(), "/");
|
||||||
@@ -853,14 +853,13 @@ public class I2PSnarkServlet extends Default {
|
|||||||
out.write(statusString + "</td>\n\t");
|
out.write(statusString + "</td>\n\t");
|
||||||
|
|
||||||
out.write("<td class=\"" + rowClass + "\">");
|
out.write("<td class=\"" + rowClass + "\">");
|
||||||
String announce = null;
|
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
announce = meta.getAnnounce();
|
StringBuilder buf = new StringBuilder(128);
|
||||||
if (announce != null) {
|
buf.append("<a href=\"").append(snark.getBaseName())
|
||||||
String trackerLink = getTrackerLink(announce, snark.getInfoHash());
|
.append("/\" title=\"").append(_("Torrent details"))
|
||||||
if (trackerLink != null)
|
.append("\"><img alt=\"").append(_("Info")).append("\" border=\"0\" src=\"")
|
||||||
out.write(trackerLink);
|
.append(_imgPath).append("details.png\"></a>");
|
||||||
}
|
out.write(buf.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
out.write("</td>\n<td class=\"" + rowClass + "\">");
|
out.write("</td>\n<td class=\"" + rowClass + "\">");
|
||||||
@@ -1555,13 +1554,11 @@ public class I2PSnarkServlet extends Default {
|
|||||||
private String getListHTML(Resource r, String base, boolean parent, Map postParams)
|
private String getListHTML(Resource r, String base, boolean parent, Map postParams)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
if (!r.isDirectory())
|
String[] ls = null;
|
||||||
return null;
|
if (r.isDirectory()) {
|
||||||
|
ls = r.list();
|
||||||
String[] ls = r.list();
|
Arrays.sort(ls, Collator.getInstance());
|
||||||
if (ls==null)
|
} // if r is not a directory, we are only showing torrent info section
|
||||||
return null;
|
|
||||||
Arrays.sort(ls, Collator.getInstance());
|
|
||||||
|
|
||||||
StringBuilder buf=new StringBuilder(4096);
|
StringBuilder buf=new StringBuilder(4096);
|
||||||
buf.append(DOCTYPE + "<HTML><HEAD><TITLE>");
|
buf.append(DOCTYPE + "<HTML><HEAD><TITLE>");
|
||||||
@@ -1592,7 +1589,7 @@ public class I2PSnarkServlet extends Default {
|
|||||||
|
|
||||||
if (parent) // always true
|
if (parent) // always true
|
||||||
buf.append("<div class=\"page\"><div class=\"mainsection\">");
|
buf.append("<div class=\"page\"><div class=\"mainsection\">");
|
||||||
boolean showPriority = snark != null && snark.getStorage() != null && !snark.getStorage().complete();
|
boolean showPriority = ls != null && snark != null && snark.getStorage() != null && !snark.getStorage().complete();
|
||||||
if (showPriority)
|
if (showPriority)
|
||||||
buf.append("<form action=\"").append(base).append("\" method=\"POST\">\n");
|
buf.append("<form action=\"").append(base).append("\" method=\"POST\">\n");
|
||||||
buf.append("<TABLE BORDER=0 class=\"snarkTorrents\" ><thead>");
|
buf.append("<TABLE BORDER=0 class=\"snarkTorrents\" ><thead>");
|
||||||
@@ -1621,15 +1618,17 @@ public class I2PSnarkServlet extends Default {
|
|||||||
if (meta != null) {
|
if (meta != null) {
|
||||||
String announce = meta.getAnnounce();
|
String announce = meta.getAnnounce();
|
||||||
if (announce != null) {
|
if (announce != null) {
|
||||||
|
buf.append("<br>");
|
||||||
String trackerLink = getTrackerLink(announce, snark.getInfoHash());
|
String trackerLink = getTrackerLink(announce, snark.getInfoHash());
|
||||||
if (trackerLink != null) {
|
if (trackerLink != null)
|
||||||
if (announce.startsWith("http://"))
|
buf.append(trackerLink).append(' ');
|
||||||
announce = announce.substring(7);
|
buf.append(_("Tracker")).append(": ");
|
||||||
int slsh = announce.indexOf('/');
|
if (announce.startsWith("http://"))
|
||||||
if (slsh > 0)
|
announce = announce.substring(7);
|
||||||
announce = announce.substring(0, slsh);
|
int slsh = announce.indexOf('/');
|
||||||
buf.append("<br>").append(trackerLink).append(' ').append(announce);
|
if (slsh > 0)
|
||||||
}
|
announce = announce.substring(0, slsh);
|
||||||
|
buf.append(announce);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1642,6 +1641,12 @@ public class I2PSnarkServlet extends Default {
|
|||||||
// .append(MAGGOT).append(hex).append(':').append(hex).append("</a>");
|
// .append(MAGGOT).append(hex).append(':').append(hex).append("</a>");
|
||||||
buf.append("</div></th></tr>");
|
buf.append("</div></th></tr>");
|
||||||
}
|
}
|
||||||
|
if (ls == null) {
|
||||||
|
// We are only showing the torrent info section
|
||||||
|
buf.append("</thead></table></div></div></BODY></HTML>");
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
|
||||||
// second row - dir info
|
// second row - dir info
|
||||||
buf.append("<tr><th>")
|
buf.append("<tr><th>")
|
||||||
.append("<img alt=\"\" border=\"0\" src=\"" + _imgPath + "file.png\" > ")
|
.append("<img alt=\"\" border=\"0\" src=\"" + _imgPath + "file.png\" > ")
|
||||||
|
Reference in New Issue
Block a user