forked from I2P_Developers/i2p.i2p
* i2psnark:
- Move config to separate page - Icon tweaks
This commit is contained in:
BIN
apps/i2psnark/_icons/cd.png
Normal file
BIN
apps/i2psnark/_icons/cd.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 673 B |
BIN
apps/i2psnark/_icons/page_white.png
Normal file
BIN
apps/i2psnark/_icons/page_white.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 294 B |
@@ -119,8 +119,9 @@ public class I2PSnarkServlet extends Default {
|
|||||||
public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
// this is the part after /i2psnark
|
// this is the part after /i2psnark
|
||||||
String path = req.getServletPath();
|
String path = req.getServletPath();
|
||||||
|
boolean isConfigure = "/configure".equals(path);
|
||||||
// index.jsp doesn't work, it is grabbed by the war handler before here
|
// index.jsp doesn't work, it is grabbed by the war handler before here
|
||||||
if (!(path == null || path.equals("/") || path.equals("/index.jsp") || path.equals("/index.html"))) {
|
if (!(path == null || path.equals("/") || path.equals("/index.jsp") || path.equals("/index.html") || isConfigure)) {
|
||||||
if (path.endsWith("/")) {
|
if (path.endsWith("/")) {
|
||||||
// bypass the horrid Resource.getListHTML()
|
// bypass the horrid Resource.getListHTML()
|
||||||
String pathInfo = req.getPathInfo();
|
String pathInfo = req.getPathInfo();
|
||||||
@@ -147,8 +148,6 @@ public class I2PSnarkServlet extends Default {
|
|||||||
req.setCharacterEncoding("UTF-8");
|
req.setCharacterEncoding("UTF-8");
|
||||||
resp.setCharacterEncoding("UTF-8");
|
resp.setCharacterEncoding("UTF-8");
|
||||||
resp.setContentType("text/html; charset=UTF-8");
|
resp.setContentType("text/html; charset=UTF-8");
|
||||||
/** dl, ul, down rate, up rate, peers, size */
|
|
||||||
final long stats[] = {0,0,0,0,0,0};
|
|
||||||
|
|
||||||
String nonce = req.getParameter("nonce");
|
String nonce = req.getParameter("nonce");
|
||||||
if ( (nonce != null) && (nonce.equals(String.valueOf(_nonce))) )
|
if ( (nonce != null) && (nonce.equals(String.valueOf(_nonce))) )
|
||||||
@@ -170,28 +169,37 @@ public class I2PSnarkServlet extends Default {
|
|||||||
out.write("</title>\n");
|
out.write("</title>\n");
|
||||||
|
|
||||||
// we want it to go to the base URI so we don't refresh with some funky action= value
|
// we want it to go to the base URI so we don't refresh with some funky action= value
|
||||||
out.write("<meta http-equiv=\"refresh\" content=\"60;" + req.getRequestURI() + peerString + "\">\n");
|
if (!isConfigure)
|
||||||
|
out.write("<meta http-equiv=\"refresh\" content=\"60;" + req.getRequestURI() + peerString + "\">\n");
|
||||||
out.write(HEADER);
|
out.write(HEADER);
|
||||||
out.write("</head><body>");
|
out.write("</head><body>");
|
||||||
out.write("<center>");
|
out.write("<center>");
|
||||||
out.write("<div class=\"snarknavbar\"><a href=\"" + req.getRequestURI() + peerString + "\" title=\"");
|
if (isConfigure) {
|
||||||
out.write(_("Refresh page"));
|
out.write("<div class=\"snarknavbar\"><a href=\"/i2psnark/\" title=\"");
|
||||||
out.write("\" class=\"snarkRefresh\">");
|
out.write(_("Torrents"));
|
||||||
out.write(_("I2PSnark"));
|
out.write("\" class=\"snarkRefresh\">");
|
||||||
out.write("</a> <a href=\"http://forum.i2p/viewforum.php?f=21\" class=\"snarkRefresh\" target=\"_blank\">");
|
out.write(_("I2PSnark"));
|
||||||
out.write(_("Forum"));
|
out.write("</a>");
|
||||||
out.write("</a>\n");
|
} else {
|
||||||
|
out.write("<div class=\"snarknavbar\"><a href=\"" + req.getRequestURI() + peerString + "\" title=\"");
|
||||||
|
out.write(_("Refresh page"));
|
||||||
|
out.write("\" class=\"snarkRefresh\">");
|
||||||
|
out.write(_("I2PSnark"));
|
||||||
|
out.write("</a> <a href=\"http://forum.i2p/viewforum.php?f=21\" class=\"snarkRefresh\" target=\"_blank\">");
|
||||||
|
out.write(_("Forum"));
|
||||||
|
out.write("</a>\n");
|
||||||
|
|
||||||
Map trackers = _manager.getTrackers();
|
Map trackers = _manager.getTrackers();
|
||||||
for (Iterator iter = trackers.entrySet().iterator(); iter.hasNext(); ) {
|
for (Iterator iter = trackers.entrySet().iterator(); iter.hasNext(); ) {
|
||||||
Map.Entry entry = (Map.Entry)iter.next();
|
Map.Entry entry = (Map.Entry)iter.next();
|
||||||
String name = (String)entry.getKey();
|
String name = (String)entry.getKey();
|
||||||
String baseURL = (String)entry.getValue();
|
String baseURL = (String)entry.getValue();
|
||||||
int e = baseURL.indexOf('=');
|
int e = baseURL.indexOf('=');
|
||||||
if (e < 0)
|
if (e < 0)
|
||||||
continue;
|
continue;
|
||||||
baseURL = baseURL.substring(e + 1);
|
baseURL = baseURL.substring(e + 1);
|
||||||
out.write(" <a href=\"" + baseURL + "\" class=\"snarkRefresh\" target=\"_blank\">" + name + "</a>");
|
out.write(" <a href=\"" + baseURL + "\" class=\"snarkRefresh\" target=\"_blank\">" + name + "</a>");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
out.write("</div>\n");
|
out.write("</div>\n");
|
||||||
out.write("<div class=\"page\"><div class=\"mainsection\"><div class=\"snarkMessages\"><table><tr><td align=\"left\"><pre>");
|
out.write("<div class=\"page\"><div class=\"mainsection\"><div class=\"snarkMessages\"><table><tr><td align=\"left\"><pre>");
|
||||||
@@ -202,6 +210,24 @@ public class I2PSnarkServlet extends Default {
|
|||||||
}
|
}
|
||||||
out.write("</pre></td></tr></table></div>");
|
out.write("</pre></td></tr></table></div>");
|
||||||
|
|
||||||
|
if (isConfigure) {
|
||||||
|
out.write("</div>\n");
|
||||||
|
writeConfigForm(out, req);
|
||||||
|
} else {
|
||||||
|
writeTorrents(out, req);
|
||||||
|
out.write("</div>\n");
|
||||||
|
writeAddForm(out, req);
|
||||||
|
writeSeedForm(out, req);
|
||||||
|
writeConfigLink(out);
|
||||||
|
}
|
||||||
|
out.write(FOOTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeTorrents(PrintWriter out, HttpServletRequest req) throws IOException {
|
||||||
|
/** dl, ul, down rate, up rate, peers, size */
|
||||||
|
final long stats[] = {0,0,0,0,0,0};
|
||||||
|
String peerParam = req.getParameter("p");
|
||||||
|
|
||||||
List snarks = getSortedSnarks(req);
|
List snarks = getSortedSnarks(req);
|
||||||
String uri = req.getRequestURI();
|
String uri = req.getRequestURI();
|
||||||
out.write(TABLE_HEADER);
|
out.write(TABLE_HEADER);
|
||||||
@@ -283,13 +309,7 @@ public class I2PSnarkServlet extends Default {
|
|||||||
"</tfoot>\n");
|
"</tfoot>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
out.write(TABLE_FOOTER);
|
out.write("</table>");
|
||||||
|
|
||||||
writeAddForm(out, req);
|
|
||||||
if (true) // seeding needs to register the torrent first, so we can't start it automatically (boo, hiss)
|
|
||||||
writeSeedForm(out, req);
|
|
||||||
writeConfigForm(out, req);
|
|
||||||
out.write(FOOTER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -993,7 +1013,9 @@ public class I2PSnarkServlet extends Default {
|
|||||||
|
|
||||||
out.write("<tr><td>");
|
out.write("<tr><td>");
|
||||||
out.write(_("Startup delay"));
|
out.write(_("Startup delay"));
|
||||||
out.write(": <td><input name=\"startupDelay\" size=\"3\" value=\"" + _manager.util().getStartupDelay() + "\"> minutes <br>\n");
|
out.write(": <td><input name=\"startupDelay\" size=\"3\" class=\"r\" value=\"" + _manager.util().getStartupDelay() + "\"> ");
|
||||||
|
out.write(_("minutes"));
|
||||||
|
out.write("<br>\n");
|
||||||
|
|
||||||
|
|
||||||
//Auto add: <input type="checkbox" name="autoAdd" value="true" title="If true, automatically add torrents that are found in the data directory" />
|
//Auto add: <input type="checkbox" name="autoAdd" value="true" title="If true, automatically add torrents that are found in the data directory" />
|
||||||
@@ -1094,6 +1116,13 @@ public class I2PSnarkServlet extends Default {
|
|||||||
out.write("</form></div>");
|
out.write("</form></div>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void writeConfigLink(PrintWriter out) throws IOException {
|
||||||
|
out.write("<div class=\"configsection\"><span class=\"snarkConfig\">\n");
|
||||||
|
out.write("<span class=\"snarkConfigTitle\"><a href=\"configure\">");
|
||||||
|
out.write(_("Configuration"));
|
||||||
|
out.write("</a></span></span></div>\n");
|
||||||
|
}
|
||||||
|
|
||||||
/** copied from ConfigTunnelsHelper */
|
/** copied from ConfigTunnelsHelper */
|
||||||
private static final String HOP = "hop";
|
private static final String HOP = "hop";
|
||||||
private static final String TUNNEL = "tunnel";
|
private static final String TUNNEL = "tunnel";
|
||||||
@@ -1170,8 +1199,6 @@ public class I2PSnarkServlet extends Default {
|
|||||||
"<thead>\n" +
|
"<thead>\n" +
|
||||||
"<tr><th align=\"center\">";
|
"<tr><th align=\"center\">";
|
||||||
|
|
||||||
private static final String TABLE_FOOTER = "</table></div>\n";
|
|
||||||
|
|
||||||
private static final String FOOTER = "</div></div></div></center></body></html>";
|
private static final String FOOTER = "</div></div></div></center></body></html>";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1379,7 +1406,7 @@ public class I2PSnarkServlet extends Default {
|
|||||||
plc.endsWith(".ape"))
|
plc.endsWith(".ape"))
|
||||||
icon = "music";
|
icon = "music";
|
||||||
else if (mime.startsWith("video/") || plc.endsWith(".mkv") || plc.endsWith(".m4v") ||
|
else if (mime.startsWith("video/") || plc.endsWith(".mkv") || plc.endsWith(".m4v") ||
|
||||||
plc.endsWith(".mp4") || plc.endsWith(".wmv"))
|
plc.endsWith(".mp4") || plc.endsWith(".wmv") || plc.endsWith(".flv"))
|
||||||
icon = "film";
|
icon = "film";
|
||||||
else if (mime.equals("application/zip") || mime.equals("application/x-gtar") ||
|
else if (mime.equals("application/zip") || mime.equals("application/x-gtar") ||
|
||||||
mime.equals("application/compress") || mime.equals("application/gzip") ||
|
mime.equals("application/compress") || mime.equals("application/gzip") ||
|
||||||
@@ -1388,8 +1415,10 @@ public class I2PSnarkServlet extends Default {
|
|||||||
icon = "compress";
|
icon = "compress";
|
||||||
else if (plc.endsWith(".exe"))
|
else if (plc.endsWith(".exe"))
|
||||||
icon = "application";
|
icon = "application";
|
||||||
|
else if (plc.endsWith(".iso"))
|
||||||
|
icon = "cd";
|
||||||
else
|
else
|
||||||
icon = "bug";
|
icon = "page_white";
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user