merge of '20f5a25a77de641ddf49c4d47d4ede923b59bfa3'
and '7dfc6bc466e7b6ee3212af949a08c51d4e3dd3db'
@ -139,6 +139,7 @@ Applications:
|
|||||||
I2PSnark:
|
I2PSnark:
|
||||||
Copyright (C) 2003 Mark J. Wielaard
|
Copyright (C) 2003 Mark J. Wielaard
|
||||||
See licenses/LICENSE-GPLv2.txt
|
See licenses/LICENSE-GPLv2.txt
|
||||||
|
Silk icons: See licenses/LICENSE-SilkIcons.txt
|
||||||
|
|
||||||
I2PTunnel:
|
I2PTunnel:
|
||||||
(c) 2003 - 2004 mihi
|
(c) 2003 - 2004 mihi
|
||||||
@ -176,6 +177,7 @@ Applications:
|
|||||||
Router console:
|
Router console:
|
||||||
Public domain.
|
Public domain.
|
||||||
Flag icons: public domain, courtesy mjames@gmail.com http://www.famfamfam.com/
|
Flag icons: public domain, courtesy mjames@gmail.com http://www.famfamfam.com/
|
||||||
|
Silk icons: See licenses/LICENSE-SilkIcons.txt
|
||||||
|
|
||||||
GeoIP Data:
|
GeoIP Data:
|
||||||
Copyright (c) 2003 Direct Information Pvt. Ltd. All Rights Reserved.
|
Copyright (c) 2003 Direct Information Pvt. Ltd. All Rights Reserved.
|
||||||
|
BIN
apps/i2psnark/_icons/application.png
Normal file
After Width: | Height: | Size: 464 B |
BIN
apps/i2psnark/_icons/book.png
Normal file
After Width: | Height: | Size: 593 B |
BIN
apps/i2psnark/_icons/bug.png
Normal file
After Width: | Height: | Size: 774 B |
BIN
apps/i2psnark/_icons/cancel.png
Normal file
After Width: | Height: | Size: 587 B |
BIN
apps/i2psnark/_icons/clock.png
Normal file
After Width: | Height: | Size: 882 B |
BIN
apps/i2psnark/_icons/compress.png
Normal file
After Width: | Height: | Size: 766 B |
BIN
apps/i2psnark/_icons/film.png
Normal file
After Width: | Height: | Size: 653 B |
BIN
apps/i2psnark/_icons/folder.png
Normal file
After Width: | Height: | Size: 537 B |
BIN
apps/i2psnark/_icons/html.png
Normal file
After Width: | Height: | Size: 578 B |
BIN
apps/i2psnark/_icons/music.png
Normal file
After Width: | Height: | Size: 385 B |
BIN
apps/i2psnark/_icons/package.png
Normal file
After Width: | Height: | Size: 853 B |
BIN
apps/i2psnark/_icons/page.png
Normal file
After Width: | Height: | Size: 635 B |
BIN
apps/i2psnark/_icons/page_white_acrobat.png
Normal file
After Width: | Height: | Size: 591 B |
BIN
apps/i2psnark/_icons/photo.png
Normal file
After Width: | Height: | Size: 589 B |
BIN
apps/i2psnark/_icons/plugin.png
Normal file
After Width: | Height: | Size: 591 B |
BIN
apps/i2psnark/_icons/tick.png
Normal file
After Width: | Height: | Size: 537 B |
@ -52,7 +52,7 @@
|
|||||||
<classes dir="./build/obj" includes="**/I2PSnarkServlet*.class" />
|
<classes dir="./build/obj" includes="**/I2PSnarkServlet*.class" />
|
||||||
-->
|
-->
|
||||||
<target name="war" depends="jar, bundle">
|
<target name="war" depends="jar, bundle">
|
||||||
<war destfile="../i2psnark.war" webxml="../web.xml">
|
<war destfile="../i2psnark.war" webxml="../web.xml" basedir="../" includes="_icons/*" >
|
||||||
<!-- include only the web stuff, as of 0.7.12 the router will add i2psnark.jar to the classpath for the war -->
|
<!-- include only the web stuff, as of 0.7.12 the router will add i2psnark.jar to the classpath for the war -->
|
||||||
<classes dir="./build/obj" includes="**/web/*.class" />
|
<classes dir="./build/obj" includes="**/web/*.class" />
|
||||||
</war>
|
</war>
|
||||||
|
@ -53,6 +53,7 @@ public class I2PSnarkServlet extends Default {
|
|||||||
private Log _log;
|
private Log _log;
|
||||||
private SnarkManager _manager;
|
private SnarkManager _manager;
|
||||||
private static long _nonce;
|
private static long _nonce;
|
||||||
|
private Resource _resourceBase;
|
||||||
|
|
||||||
public static final String PROP_CONFIG_FILE = "i2psnark.configFile";
|
public static final String PROP_CONFIG_FILE = "i2psnark.configFile";
|
||||||
|
|
||||||
@ -67,40 +68,10 @@ public class I2PSnarkServlet extends Default {
|
|||||||
configFile = "i2psnark.config";
|
configFile = "i2psnark.config";
|
||||||
_manager.loadConfig(configFile);
|
_manager.loadConfig(configFile);
|
||||||
_manager.start();
|
_manager.start();
|
||||||
super.init(new DefaultServletConfig(cfg, _manager.getDataDir().getAbsolutePath()));
|
try {
|
||||||
}
|
_resourceBase = Resource.newResource(_manager.getDataDir().getAbsolutePath());
|
||||||
|
} catch (IOException ioe) {}
|
||||||
/**
|
super.init(cfg);
|
||||||
* A ServletConfig we will pass to super
|
|
||||||
*/
|
|
||||||
private static class DefaultServletConfig implements ServletConfig {
|
|
||||||
private final ServletConfig _sc;
|
|
||||||
private final String _path;
|
|
||||||
|
|
||||||
DefaultServletConfig(ServletConfig sc, String path) {
|
|
||||||
_sc = sc;
|
|
||||||
_path = path;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getInitParameter(String name) {
|
|
||||||
if ("acceptRanges".equals(name) || "dirAllowed".equals(name))
|
|
||||||
return "true";
|
|
||||||
if ("resourceBase".equals(name))
|
|
||||||
return _path;
|
|
||||||
return _sc.getInitParameter(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Enumeration getInitParameterNames() {
|
|
||||||
return _sc.getInitParameterNames();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServletContext getServletContext() {
|
|
||||||
return _sc.getServletContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getServletName() {
|
|
||||||
return _sc.getServletName();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -109,6 +80,21 @@ public class I2PSnarkServlet extends Default {
|
|||||||
super.destroy();
|
super.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We override this instead of passing a resource base to super(), because
|
||||||
|
* if a resource base is set, super.getResource() always uses that base,
|
||||||
|
* and we can't get any resources (like icons) out of the .war
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected Resource getResource(String pathInContext) throws IOException
|
||||||
|
{
|
||||||
|
if (pathInContext == null || pathInContext.equals("/") || pathInContext.equals("/index.jsp") ||
|
||||||
|
pathInContext.equals("/index.html") || pathInContext.startsWith("/_icons/"))
|
||||||
|
return super.getResource(pathInContext);
|
||||||
|
// files in the i2psnark/ directory
|
||||||
|
return _resourceBase.addPath(pathInContext);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some parts modified from:
|
* Some parts modified from:
|
||||||
* <pre>
|
* <pre>
|
||||||
@ -1261,26 +1247,30 @@ public class I2PSnarkServlet extends Default {
|
|||||||
long length = item.length();
|
long length = item.length();
|
||||||
if (item.isDirectory()) {
|
if (item.isDirectory()) {
|
||||||
complete = true;
|
complete = true;
|
||||||
status = _("Directory");
|
status = "<img height=\"16\" width=\"16\" src=\"/i2psnark/_icons/tick.png\"> " +
|
||||||
|
_("Directory");
|
||||||
} else {
|
} else {
|
||||||
if (snark == null) {
|
if (snark == null) {
|
||||||
status = "Snark not found?";
|
// Assume complete, perhaps he removed a completed torrent but kept a bookmark
|
||||||
|
complete = true;
|
||||||
|
status = "<img height=\"16\" width=\"16\" src=\"/i2psnark/_icons/cancel.png\"> " +
|
||||||
|
_("Torrent not found?");
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
File f = item.getFile();
|
File f = item.getFile();
|
||||||
if (f != null) {
|
if (f != null) {
|
||||||
long remaining = snark.storage.remaining(f.getCanonicalPath());
|
long remaining = snark.storage.remaining(f.getCanonicalPath());
|
||||||
if (remaining == 0) {
|
if (remaining < 0) {
|
||||||
complete = true;
|
complete = true;
|
||||||
status = _("Complete");
|
status = "<img height=\"16\" width=\"16\" src=\"/i2psnark/_icons/cancel.png\"> " +
|
||||||
} else if (remaining < 0) {
|
_("File not found in torrent?");
|
||||||
|
} else if (remaining == 0 || length <= 0) {
|
||||||
complete = true;
|
complete = true;
|
||||||
status = _("File not found in torrent?");
|
status = "<img height=\"16\" width=\"16\" src=\"/i2psnark/_icons/tick.png\"> " +
|
||||||
} else if (length <= 0) {
|
_("Complete");
|
||||||
complete = true;
|
|
||||||
status = _("Complete");
|
|
||||||
} else {
|
} else {
|
||||||
status = (100 - (100 * remaining / length)) + "% " + _("complete") +
|
status = "<img height=\"16\" width=\"16\" src=\"/i2psnark/_icons/clock.png\"> " +
|
||||||
|
(100 - (100 * remaining / length)) + "% " + _("complete") +
|
||||||
" (" + DataHelper.formatSize(remaining) + " bytes remaining)";
|
" (" + DataHelper.formatSize(remaining) + " bytes remaining)";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1295,24 +1285,72 @@ public class I2PSnarkServlet extends Default {
|
|||||||
String path=URI.addPaths(base,encoded);
|
String path=URI.addPaths(base,encoded);
|
||||||
if (item.isDirectory() && !path.endsWith("/"))
|
if (item.isDirectory() && !path.endsWith("/"))
|
||||||
path=URI.addPaths(path,"/");
|
path=URI.addPaths(path,"/");
|
||||||
|
String plc = path.toLowerCase();
|
||||||
|
|
||||||
|
// pick an icon; try to catch the common types in an i2p environment
|
||||||
|
String icon;
|
||||||
|
if (item.isDirectory()) {
|
||||||
|
icon = "folder";
|
||||||
|
} else {
|
||||||
|
// Should really just add to the mime.properties file in org.mortbay.jetty.jar
|
||||||
|
// instead of this mishmash. We can't get to HttpContext.setMimeMapping()
|
||||||
|
// from here? We could do it from a web.xml perhaps.
|
||||||
|
// Or could we put our own org/mortbay/http/mime.properties file in the war?
|
||||||
|
String mime = getServletContext().getMimeType(path);
|
||||||
|
if (mime == null)
|
||||||
|
mime = "";
|
||||||
|
if (mime.equals("text/html"))
|
||||||
|
icon = "html";
|
||||||
|
else if (mime.equals("text/plain") || plc.endsWith(".nfo"))
|
||||||
|
icon = "page";
|
||||||
|
else if (mime.equals("application/java-archive") || plc.endsWith(".war"))
|
||||||
|
icon = "package";
|
||||||
|
else if (plc.endsWith(".xpi2p"))
|
||||||
|
icon = "plugin";
|
||||||
|
else if (mime.equals("application/pdf"))
|
||||||
|
icon = "page_white_acrobat";
|
||||||
|
else if (mime.startsWith("image/") || plc.endsWith(".ico"))
|
||||||
|
icon = "photo";
|
||||||
|
else if (mime.startsWith("audio/") || mime.equals("application/ogg") ||
|
||||||
|
plc.endsWith(".flac") || plc.endsWith(".m4a") || plc.endsWith(".wma") ||
|
||||||
|
plc.endsWith(".ape"))
|
||||||
|
icon = "music";
|
||||||
|
else if (mime.startsWith("video/") || plc.endsWith(".mkv") || plc.endsWith(".m4v") ||
|
||||||
|
plc.endsWith(".mp4"))
|
||||||
|
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-tar") ||
|
||||||
|
plc.endsWith(".rar") || plc.endsWith(".bz2") || plc.endsWith(".7z"))
|
||||||
|
icon = "compress";
|
||||||
|
else if (plc.endsWith(".exe"))
|
||||||
|
icon = "application";
|
||||||
|
else
|
||||||
|
icon = "bug";
|
||||||
|
}
|
||||||
if (complete) {
|
if (complete) {
|
||||||
|
buf.append("<a href=\"").append(path).append("\"><img alt=\"\" border=\"0\" ");
|
||||||
// thumbnail ?
|
// thumbnail ?
|
||||||
String plc = path.toLowerCase();
|
if (plc.endsWith(".jpg") || plc.endsWith(".jpeg") || plc.endsWith(".png") ||
|
||||||
if (plc.endsWith(".jpg") || plc.endsWith(".png") || plc.endsWith(".gif")) {
|
plc.endsWith(".gif") || plc.endsWith(".ico")) {
|
||||||
buf.append("<a href=\"").append(path).append("\"><img alt=\"\" border=\"0\" class=\"thumb\" src=\"")
|
buf.append("class=\"thumb\" src=\"")
|
||||||
.append(path).append("\"></a> ");
|
.append(path).append("\"></a> ");
|
||||||
|
} else {
|
||||||
|
buf.append("height=\"16\" width=\"16\" src=\"/i2psnark/_icons/").append(icon).append(".png\"></a> ");
|
||||||
}
|
}
|
||||||
buf.append("<A HREF=\"");
|
buf.append("<A HREF=\"");
|
||||||
buf.append(path);
|
buf.append(path);
|
||||||
buf.append("\">");
|
buf.append("\">");
|
||||||
|
} else {
|
||||||
|
buf.append("<img height=\"16\" width=\"16\" src=\"/i2psnark/_icons/").append(icon).append(".png\"> ");
|
||||||
}
|
}
|
||||||
buf.append(ls[i]);
|
buf.append(ls[i]);
|
||||||
if (complete)
|
if (complete)
|
||||||
buf.append("</a>");
|
buf.append("</a>");
|
||||||
buf.append("</TD><TD ALIGN=right class=\"").append(rowClass).append("\">");
|
buf.append("</TD><TD ALIGN=right class=\"").append(rowClass).append(" snarkFileSize\">");
|
||||||
if (!item.isDirectory())
|
if (!item.isDirectory())
|
||||||
buf.append(DataHelper.formatSize(length)).append(' ').append(_("Bytes"));
|
buf.append(DataHelper.formatSize(length)).append(' ').append(_("Bytes"));
|
||||||
buf.append("</TD><TD>");
|
buf.append("</TD><TD class=\"").append(rowClass).append(" snarkFileStatus\">");
|
||||||
//buf.append(dfmt.format(new Date(item.lastModified())));
|
//buf.append(dfmt.format(new Date(item.lastModified())));
|
||||||
buf.append(status);
|
buf.append(status);
|
||||||
buf.append("</TD></TR>\n");
|
buf.append("</TD></TR>\n");
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
2010-05-24 zzz
|
||||||
|
* i2psnark: Listing icons and cleanups
|
||||||
|
|
||||||
2010-05-23 welterde
|
2010-05-23 welterde
|
||||||
* core:
|
* core:
|
||||||
- fixed major security hole in DatagramDissector
|
- fixed major security hole in DatagramDissector
|
||||||
|
@ -110,6 +110,15 @@ td {
|
|||||||
|
|
||||||
.snarkFileName {
|
.snarkFileName {
|
||||||
min-width: 25em;
|
min-width: 25em;
|
||||||
|
padding: 4px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.snarkFileSize {
|
||||||
|
padding: 4px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.snarkFileStatus {
|
||||||
|
padding: 4px 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.thumb {
|
.thumb {
|
||||||
@ -225,7 +234,8 @@ textarea {
|
|||||||
|
|
||||||
img {
|
img {
|
||||||
border: none;
|
border: none;
|
||||||
margin: 5px 5px 0px 5px;
|
margin: 4px 8px 4px 4px;
|
||||||
|
vertical-align: middle;
|
||||||
opacity: 1.0;
|
opacity: 1.0;
|
||||||
line-height: 100%;
|
line-height: 100%;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ public class RouterVersion {
|
|||||||
/** deprecated */
|
/** deprecated */
|
||||||
public final static String ID = "Monotone";
|
public final static String ID = "Monotone";
|
||||||
public final static String VERSION = CoreVersion.VERSION;
|
public final static String VERSION = CoreVersion.VERSION;
|
||||||
public final static long BUILD = 10;
|
public final static long BUILD = 11;
|
||||||
|
|
||||||
/** for example "-test" */
|
/** for example "-test" */
|
||||||
public final static String EXTRA = "";
|
public final static String EXTRA = "";
|
||||||
|