forked from I2P_Developers/i2p.i2p
* i2psnark:
- Retry link on torrent download fail - Clear URL after clicking 'add torrent' - Message tweaks - CSS tweaks
This commit is contained in:
@@ -246,6 +246,9 @@ public class I2PSnarkServlet extends Default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
out.write("</div>\n");
|
out.write("</div>\n");
|
||||||
|
String newURL = req.getParameter("newURL");
|
||||||
|
if (newURL != null && newURL.trim().length() > 0 && req.getMethod().equals("GET"))
|
||||||
|
_manager.addMessage(_("Click \"Add torrent\" button to fetch torrent"));
|
||||||
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>");
|
||||||
List msgs = _manager.getMessages();
|
List msgs = _manager.getMessages();
|
||||||
for (int i = msgs.size()-1; i >= 0; i--) {
|
for (int i = msgs.size()-1; i >= 0; i--) {
|
||||||
@@ -491,6 +494,8 @@ public class I2PSnarkServlet extends Default {
|
|||||||
*****/
|
*****/
|
||||||
if (newURL != null) {
|
if (newURL != null) {
|
||||||
if (newURL.startsWith("http://")) {
|
if (newURL.startsWith("http://")) {
|
||||||
|
if (!_manager.util().connected())
|
||||||
|
_manager.addMessage(_("Opening the I2P tunnel"));
|
||||||
_manager.addMessage(_("Fetching {0}", urlify(newURL)));
|
_manager.addMessage(_("Fetching {0}", urlify(newURL)));
|
||||||
I2PAppThread fetch = new I2PAppThread(new FetchAndAdd(_manager, newURL), "Fetch and add", true);
|
I2PAppThread fetch = new I2PAppThread(new FetchAndAdd(_manager, newURL), "Fetch and add", true);
|
||||||
fetch.start();
|
fetch.start();
|
||||||
@@ -1174,8 +1179,9 @@ public class I2PSnarkServlet extends Default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void writeAddForm(PrintWriter out, HttpServletRequest req) throws IOException {
|
private void writeAddForm(PrintWriter out, HttpServletRequest req) throws IOException {
|
||||||
|
// display incoming parameter if a GET so links will work
|
||||||
String newURL = req.getParameter("newURL");
|
String newURL = req.getParameter("newURL");
|
||||||
if ( (newURL == null) || (newURL.trim().length() <= 0) )
|
if (newURL == null || newURL.trim().length() <= 0 || req.getMethod().equals("POST"))
|
||||||
newURL = "";
|
newURL = "";
|
||||||
else
|
else
|
||||||
newURL = DataHelper.stripHTML(newURL); // XSS
|
newURL = DataHelper.stripHTML(newURL); // XSS
|
||||||
@@ -1220,7 +1226,7 @@ public class I2PSnarkServlet extends Default {
|
|||||||
else
|
else
|
||||||
baseFile = DataHelper.stripHTML(baseFile); // XSS
|
baseFile = DataHelper.stripHTML(baseFile); // XSS
|
||||||
|
|
||||||
out.write("<div class=\"newtorrentsection\"><div class=\"snarkNewTorrent\">\n");
|
out.write("<a name=\"add\"></a><div class=\"newtorrentsection\"><div class=\"snarkNewTorrent\">\n");
|
||||||
// *not* enctype="multipart/form-data", so that the input type=file sends the filename, not the file
|
// *not* enctype="multipart/form-data", so that the input type=file sends the filename, not the file
|
||||||
out.write("<form action=\"_post\" method=\"POST\">\n");
|
out.write("<form action=\"_post\" method=\"POST\">\n");
|
||||||
out.write("<input type=\"hidden\" name=\"nonce\" value=\"" + _nonce + "\" >\n");
|
out.write("<input type=\"hidden\" name=\"nonce\" value=\"" + _nonce + "\" >\n");
|
||||||
@@ -2040,13 +2046,29 @@ private static class FetchAndAdd implements Runnable {
|
|||||||
try { if (in != null) in.close(); } catch (IOException ioe) {}
|
try { if (in != null) in.close(); } catch (IOException ioe) {}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_manager.addMessage(_("Torrent was not retrieved from {0}", urlify(_url)));
|
// Generate a retry link, but sadly can't have a form inside a table
|
||||||
|
// So make this an ugly GET
|
||||||
|
StringBuilder buf = new StringBuilder(1024);
|
||||||
|
// FIXME don't lose peer setting
|
||||||
|
//String peerParam = req.getParameter("p");
|
||||||
|
//if (peerParam != null)
|
||||||
|
// buf.append("<input type=\"hidden\" name=\"p\" value=\"").append(peerParam).append("\" >\n");
|
||||||
|
buf.append(_("Torrent was not retrieved from {0}", urlify(_url)));
|
||||||
|
String link = _url.replace("&", "&").replace(" ", "%20").replace(":", "%3A").replace("/", "%2F");
|
||||||
|
buf.append(" - [<a href=\"/i2psnark/?newURL=").append(link).append("#add\" >");
|
||||||
|
buf.append(_("Retry"));
|
||||||
|
buf.append("</a>]");
|
||||||
|
_manager.addMessage(buf.toString());
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (file != null) file.delete();
|
if (file != null) file.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String _(String s) {
|
||||||
|
return _manager.util().getString(s);
|
||||||
|
}
|
||||||
|
|
||||||
private String _(String s, String o) {
|
private String _(String s, String o) {
|
||||||
return _manager.util().getString(s, o);
|
return _manager.util().getString(s, o);
|
||||||
}
|
}
|
||||||
|
@@ -95,15 +95,15 @@ body {
|
|||||||
color: #26f;
|
color: #26f;
|
||||||
height: 70px;
|
height: 70px;
|
||||||
width: auto;
|
width: auto;
|
||||||
background: #101 url('/themes/snark/ubergine/images/hat.png') no-repeat scroll right center;
|
background: #2a192a url('/themes/snark/ubergine/images/hat.png') no-repeat scroll right center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.snarkMessages a:link, .snarkMessages a:visited {
|
.snarkMessages a:link, .snarkMessages a:visited {
|
||||||
color: #37f !important;
|
color: #69f !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.snarkMessages a:hover {
|
.snarkMessages a:hover {
|
||||||
color: #59f !important;
|
color: #f90 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.logshim {
|
.logshim {
|
||||||
@@ -116,7 +116,7 @@ pre {
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
text-align: left !important;
|
text-align: left !important;
|
||||||
height: 8px;
|
height: 8px;
|
||||||
color: #13f;
|
color: #35f;
|
||||||
font-weight: bold !important;
|
font-weight: bold !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -515,7 +515,7 @@ input[type=image]:hover, thead img:hover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
input[type=text]:active, input[type=text]:hover, input.r:hover {
|
input[type=text]:active, input[type=text]:hover, input.r:hover {
|
||||||
background: #f60;
|
background: #d60;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user