I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 0c03b6ba authored by zzz's avatar zzz
Browse files

i2psnark: More details page fixups;

          List directories first
parent cd6376e3
No related branches found
No related tags found
No related merge requests found
...@@ -2177,6 +2177,23 @@ public class I2PSnarkServlet extends BasicServlet { ...@@ -2177,6 +2177,23 @@ public class I2PSnarkServlet extends BasicServlet {
private static final String FOOTER = "</div></center></body></html>"; private static final String FOOTER = "</div></center></body></html>";
/**
* Sort alphabetically in current locale, ignore case,
* directories first
* @since 0.9.6
*/
private static class ListingComparator implements Comparator<File> {
private final Comparator collator = Collator.getInstance();
public int compare(File l, File r) {
if (l.isDirectory() && !r.isDirectory())
return -1;
if (r.isDirectory() && !l.isDirectory())
return 1;
return collator.compare(l.getName(), r.getName());
}
}
/** /**
* Modded heavily from the Jetty version in Resource.java, * Modded heavily from the Jetty version in Resource.java,
* pass Resource as 1st param * pass Resource as 1st param
...@@ -2210,10 +2227,10 @@ public class I2PSnarkServlet extends BasicServlet { ...@@ -2210,10 +2227,10 @@ public class I2PSnarkServlet extends BasicServlet {
private String getListHTML(File r, String base, boolean parent, Map postParams) private String getListHTML(File r, String base, boolean parent, Map postParams)
throws IOException throws IOException
{ {
String[] ls = null; File[] ls = null;
if (r.isDirectory()) { if (r.isDirectory()) {
ls = r.list(); ls = r.listFiles();
Arrays.sort(ls, Collator.getInstance()); Arrays.sort(ls, new ListingComparator());
} // if r is not a directory, we are only showing torrent info section } // if r is not a directory, we are only showing torrent info section
String title = decodePath(base); String title = decodePath(base);
...@@ -2289,7 +2306,9 @@ public class I2PSnarkServlet extends BasicServlet { ...@@ -2289,7 +2306,9 @@ public class I2PSnarkServlet extends BasicServlet {
} }
List<List<String>> alist = meta.getAnnounceList(); List<List<String>> alist = meta.getAnnounceList();
if (alist != null) { if (alist != null) {
buf.append("<tr><td><b>"); buf.append("<tr><td>" +
"<img alt=\"\" border=\"0\" src=\"")
.append(_imgPath).append("details.png\"> <b>");
buf.append(_("Tracker List")).append(":</b> "); buf.append(_("Tracker List")).append(":</b> ");
for (List<String> alist2 : alist) { for (List<String> alist2 : alist) {
buf.append('['); buf.append('[');
...@@ -2421,12 +2440,12 @@ public class I2PSnarkServlet extends BasicServlet { ...@@ -2421,12 +2440,12 @@ public class I2PSnarkServlet extends BasicServlet {
boolean showSaveButton = false; boolean showSaveButton = false;
for (int i=0 ; i< ls.length ; i++) for (int i=0 ; i< ls.length ; i++)
{ {
String encoded = encodePath(ls[i]); String encoded = encodePath(ls[i].getName());
// bugfix for I2P - Backport from Jetty 6 (zero file lengths and last-modified times) // bugfix for I2P - Backport from Jetty 6 (zero file lengths and last-modified times)
// http://jira.codehaus.org/browse/JETTY-361?page=com.atlassian.jira.plugin.system.issuetabpanels%3Achangehistory-tabpanel#issue-tabs // http://jira.codehaus.org/browse/JETTY-361?page=com.atlassian.jira.plugin.system.issuetabpanels%3Achangehistory-tabpanel#issue-tabs
// See resource.diff attachment // See resource.diff attachment
//Resource item = addPath(encoded); //Resource item = addPath(encoded);
File item = new File(r, ls[i]); File item = ls[i];
String rowClass = (i % 2 == 0 ? "snarkTorrentEven" : "snarkTorrentOdd"); String rowClass = (i % 2 == 0 ? "snarkTorrentEven" : "snarkTorrentOdd");
buf.append("<TR class=\"").append(rowClass).append("\">"); buf.append("<TR class=\"").append(rowClass).append("\">");
...@@ -2437,7 +2456,7 @@ public class I2PSnarkServlet extends BasicServlet { ...@@ -2437,7 +2456,7 @@ public class I2PSnarkServlet extends BasicServlet {
long length = item.length(); long length = item.length();
if (item.isDirectory()) { if (item.isDirectory()) {
complete = true; complete = true;
status = toImg("tick") + ' ' + _("Directory"); //status = toImg("tick") + ' ' + _("Directory");
} else { } else {
if (snark == null || snark.getStorage() == null) { if (snark == null || snark.getStorage() == null) {
// Assume complete, perhaps he removed a completed torrent but kept a bookmark // Assume complete, perhaps he removed a completed torrent but kept a bookmark
...@@ -2501,7 +2520,7 @@ public class I2PSnarkServlet extends BasicServlet { ...@@ -2501,7 +2520,7 @@ public class I2PSnarkServlet extends BasicServlet {
.append(rowClass).append("\">"); .append(rowClass).append("\">");
if (complete) if (complete)
buf.append("<a href=\"").append(path).append("\">"); buf.append("<a href=\"").append(path).append("\">");
buf.append(ls[i]); buf.append(item.getName());
if (complete) if (complete)
buf.append("</a>"); buf.append("</a>");
buf.append("</TD><TD ALIGN=right class=\"").append(rowClass).append(" snarkFileSize\">"); buf.append("</TD><TD ALIGN=right class=\"").append(rowClass).append(" snarkFileSize\">");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment