forked from I2P_Developers/i2p.i2p
* i2psnark:
- Show comment metadata on details page - Fix rar icon - Escape [] in URLs, chrome doesn't do it for us - Tweak column spacing
This commit is contained in:
@ -62,6 +62,9 @@ public class MetaInfo
|
||||
private final long length;
|
||||
private final boolean privateTorrent;
|
||||
private final List<List<String>> announce_list;
|
||||
private final String comment;
|
||||
private final String created_by;
|
||||
private final long creation_date;
|
||||
private Map<String, BEValue> infoMap;
|
||||
|
||||
/**
|
||||
@ -87,6 +90,9 @@ public class MetaInfo
|
||||
this.length = length;
|
||||
this.privateTorrent = privateTorrent;
|
||||
this.announce_list = announce_list;
|
||||
this.comment = null;
|
||||
this.created_by = null;
|
||||
this.creation_date = 0;
|
||||
|
||||
// TODO if we add a parameter for other keys
|
||||
//if (other != null) {
|
||||
@ -162,6 +168,32 @@ public class MetaInfo
|
||||
}
|
||||
}
|
||||
|
||||
// misc. optional top-level stuff
|
||||
val = m.get("comment");
|
||||
String st = null;
|
||||
if (val != null) {
|
||||
try {
|
||||
st = val.getString();
|
||||
} catch (InvalidBEncodingException ibee) {}
|
||||
}
|
||||
this.comment = st;
|
||||
val = m.get("created by");
|
||||
st = null;
|
||||
if (val != null) {
|
||||
try {
|
||||
st = val.getString();
|
||||
} catch (InvalidBEncodingException ibee) {}
|
||||
}
|
||||
this.created_by = st;
|
||||
val = m.get("creation date");
|
||||
long time = 0;
|
||||
if (val != null) {
|
||||
try {
|
||||
time = val.getLong() * 1000;
|
||||
} catch (InvalidBEncodingException ibee) {}
|
||||
}
|
||||
this.creation_date = time;
|
||||
|
||||
val = m.get("info");
|
||||
if (val == null)
|
||||
throw new InvalidBEncodingException("Missing info map");
|
||||
@ -381,6 +413,33 @@ public class MetaInfo
|
||||
return lengths;
|
||||
}
|
||||
|
||||
/**
|
||||
* The comment string or null.
|
||||
* Not available for locally-created torrents.
|
||||
* @since 0.9.7
|
||||
*/
|
||||
public String getComment() {
|
||||
return this.comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* The created-by string or null.
|
||||
* Not available for locally-created torrents.
|
||||
* @since 0.9.7
|
||||
*/
|
||||
public String getCreatedBy() {
|
||||
return this.created_by;
|
||||
}
|
||||
|
||||
/**
|
||||
* The creation date (ms) or zero.
|
||||
* Not available for locally-created torrents.
|
||||
* @since 0.9.7
|
||||
*/
|
||||
public long getCreationDate() {
|
||||
return this.creation_date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of pieces.
|
||||
*/
|
||||
|
@ -9,10 +9,12 @@ import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.text.Collator;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@ -2181,7 +2183,8 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
|
||||
/** @since 0.8.13 */
|
||||
private static String urlEncode(String s) {
|
||||
return s.replace(";", "%3B").replace("&", "&").replace(" ", "%20");
|
||||
return s.replace(";", "%3B").replace("&", "&").replace(" ", "%20")
|
||||
.replace("[", "%5B").replace("]", "%5D");
|
||||
}
|
||||
|
||||
private static final String DOCTYPE = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
|
||||
@ -2343,6 +2346,38 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
}
|
||||
}
|
||||
|
||||
if (meta != null) {
|
||||
String com = meta.getComment();
|
||||
if (com != null) {
|
||||
if (com.length() > 1024)
|
||||
com = com.substring(0, 1024);
|
||||
buf.append("<tr><td><img alt=\"\" border=\"0\" src=\"")
|
||||
.append(_imgPath).append("details.png\"> <b>")
|
||||
.append(_("Comment")).append(":</b> ")
|
||||
.append(DataHelper.stripHTML(com))
|
||||
.append("</td></tr>\n");
|
||||
}
|
||||
long dat = meta.getCreationDate();
|
||||
if (dat > 0) {
|
||||
String date = (new SimpleDateFormat("yyyy-MM-dd HH:mm")).format(new Date(dat));
|
||||
buf.append("<tr><td><img alt=\"\" border=\"0\" src=\"")
|
||||
.append(_imgPath).append("details.png\"> <b>")
|
||||
.append(_("Created")).append(":</b> ")
|
||||
.append(date).append(" UTC")
|
||||
.append("</td></tr>\n");
|
||||
}
|
||||
String cby = meta.getCreatedBy();
|
||||
if (cby != null) {
|
||||
if (cby.length() > 128)
|
||||
cby = com.substring(0, 128);
|
||||
buf.append("<tr><td><img alt=\"\" border=\"0\" src=\"")
|
||||
.append(_imgPath).append("details.png\"> <b>")
|
||||
.append(_("Created By")).append(":</b> ")
|
||||
.append(DataHelper.stripHTML(cby))
|
||||
.append("</td></tr>\n");
|
||||
}
|
||||
}
|
||||
|
||||
String hex = I2PSnarkUtil.toHex(snark.getInfoHash());
|
||||
if (meta == null || !meta.isPrivate()) {
|
||||
buf.append("<tr><td><a href=\"")
|
||||
@ -2357,6 +2392,7 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
.append(_("Private torrent"))
|
||||
.append("</td></tr>\n");
|
||||
}
|
||||
|
||||
// We don't have the hash of the torrent file
|
||||
//buf.append("<tr><td>").append(_("Maggot link")).append(": <a href=\"").append(MAGGOT).append(hex).append(':').append(hex).append("\">")
|
||||
// .append(MAGGOT).append(hex).append(':').append(hex).append("</a></td></tr>");
|
||||
@ -2625,7 +2661,7 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
icon = "film";
|
||||
else if (mime.equals("application/zip") || mime.equals("application/x-gtar") ||
|
||||
mime.equals("application/compress") || mime.equals("application/gzip") ||
|
||||
mime.equals("application/x-7z-compressed") || mime.equals("application/x-rar-compresed") ||
|
||||
mime.equals("application/x-7z-compressed") || mime.equals("application/x-rar-compressed") ||
|
||||
mime.equals("application/x-tar") || mime.equals("application/x-bzip2"))
|
||||
icon = "compress";
|
||||
else if (plc.endsWith(".exe"))
|
||||
|
@ -246,7 +246,7 @@ tfoot tr:nth-child(n+1) {
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 1px;
|
||||
padding: 2px 4px;
|
||||
color: #001 !important;
|
||||
opacity: 1;
|
||||
font-size: 8pt;
|
||||
|
@ -241,7 +241,7 @@ tfoot tr:nth-child(n+1) {
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 1px;
|
||||
padding: 2px 4px;
|
||||
color: #ddd !important;
|
||||
opacity: 1;
|
||||
font-size: 8pt;
|
||||
|
@ -254,7 +254,7 @@ tfoot tr:nth-child(n+1) {
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 2px 1px;
|
||||
padding: 2px 4px;
|
||||
color: #501 !important;
|
||||
opacity: 1;
|
||||
font-size: 8pt;
|
||||
|
Reference in New Issue
Block a user