diff --git a/apps/i2psnark/java/src/org/klomp/snark/Snark.java b/apps/i2psnark/java/src/org/klomp/snark/Snark.java index c7272eca6d2403dfefb08c7d71f05d98a2468cf2..83c839fd293cbc4ec8445b47245f0f14b444bb1b 100644 --- a/apps/i2psnark/java/src/org/klomp/snark/Snark.java +++ b/apps/i2psnark/java/src/org/klomp/snark/Snark.java @@ -1029,6 +1029,8 @@ public class Snark //if (debug >= INFO && t != null) // t.printStackTrace(); stopTorrent(); + if (t != null) + s += ": " + t; throw new RuntimeException(s, t); } diff --git a/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java b/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java index 4c46ec6f040291f2fc584dc10124e9fddcfbfbab..f08e07c7101b61c54ed3462583912fbf33924eac 100644 --- a/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java +++ b/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java @@ -51,7 +51,7 @@ public class SnarkManager implements Snark.CompleteListener { private Properties _config; private final I2PAppContext _context; private final Log _log; - private final List _messages; + private final List<String> _messages; private final I2PSnarkUtil _util; private PeerCoordinatorSet _peerCoordinatorSet; private ConnectionAcceptor _connectionAcceptor; @@ -156,6 +156,7 @@ public class SnarkManager implements Snark.CompleteListener { public I2PSnarkUtil util() { return _util; } private static final int MAX_MESSAGES = 5; + public void addMessage(String message) { synchronized (_messages) { _messages.add(message); @@ -167,12 +168,19 @@ public class SnarkManager implements Snark.CompleteListener { } /** newest last */ - public List getMessages() { + public List<String> getMessages() { synchronized (_messages) { return new ArrayList(_messages); } } + /** @since 0.9 */ + public void clearMessages() { + synchronized (_messages) { + _messages.clear(); + } + } + /** * @return default false * @since 0.8.9 diff --git a/apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java b/apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java index c0c37033797b663c8e98d9a6162ed66c85054490..db4827dfcbd683c0293e45de69d70d4ebba91626 100644 --- a/apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java +++ b/apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java @@ -160,7 +160,7 @@ public class I2PSnarkServlet extends DefaultServlet { PrintWriter out = resp.getWriter(); //if (_log.shouldLog(Log.DEBUG)) // _manager.addMessage((_context.clock().now() / 1000) + " xhr1 p=" + req.getParameter("p")); - writeMessages(out); + writeMessages(out, false); writeTorrents(out, req); return; } @@ -277,7 +277,7 @@ public class I2PSnarkServlet extends DefaultServlet { _manager.addMessage(_("Click \"Add torrent\" button to fetch torrent")); out.write("<div class=\"page\"><div id=\"mainsection\" class=\"mainsection\">"); - writeMessages(out); + writeMessages(out, isConfigure); if (isConfigure) { // end of mainsection div @@ -297,14 +297,20 @@ public class I2PSnarkServlet extends DefaultServlet { out.write(FOOTER); } - private void writeMessages(PrintWriter out) throws IOException { - out.write("<div class=\"snarkMessages\"><table><tr><td align=\"left\"><pre>"); - List msgs = _manager.getMessages(); - for (int i = msgs.size()-1; i >= 0; i--) { - String msg = (String)msgs.get(i); - out.write(msg + "\n"); + private void writeMessages(PrintWriter out, boolean isConfigure) throws IOException { + List<String> msgs = _manager.getMessages(); + if (!msgs.isEmpty()) { + out.write("<div class=\"snarkMessages\"><ul>"); + for (int i = msgs.size()-1; i >= 0; i--) { + String msg = (String)msgs.get(i); + out.write("<li>" + msg + "</li>\n"); + } + // lazy GET, lose p parameter + out.write("</ul><p><a href=\"/i2psnark/"); + if (isConfigure) + out.write("configure"); + out.write("?action=Clear&nonce=" + _nonce + "\">" + _("clear messages") + "</a></p></div>"); } - out.write("</pre></td></tr></table></div>"); } private void writeTorrents(PrintWriter out, HttpServletRequest req) throws IOException { @@ -751,6 +757,8 @@ public class I2PSnarkServlet extends DefaultServlet { if (snark.isStopped()) snark.startTorrent(); } + } else if ("Clear".equals(action)) { + _manager.clearMessages(); } else { _manager.addMessage("Unknown POST action: \"" + action + '\"'); } diff --git a/installer/resources/themes/snark/ubergine/snark.css b/installer/resources/themes/snark/ubergine/snark.css index 560a212209f1fe3ae0e015bf3618d6ef142c82f3..2a870c83ffecb68fd62871f5d3e595377fc8fc11 100644 --- a/installer/resources/themes/snark/ubergine/snark.css +++ b/installer/resources/themes/snark/ubergine/snark.css @@ -82,7 +82,7 @@ body { } .snarkMessages { - font: bold 9pt "Lucida Console","DejaVu Sans Mono",Courier,mono !important; + font: bold 8pt "Lucida Console","DejaVu Sans Mono",Courier,mono !important; text-align: left; margin: 0 0 10px 0; padding: 3px 5px; @@ -93,7 +93,8 @@ body { border: 1px solid #000; overflow: auto; color: #26f; - height: 70px; + max-height: 76px; + min-height: 45px; width: auto; background: #2a192a url('/themes/snark/ubergine/images/hat.png') no-repeat scroll right center; } @@ -106,6 +107,17 @@ body { color: #f90 !important; } +.snarkMessages ul { + margin: 0; + padding: 0 0 0 16px; +} + +.snarkMessages p { + font-style: italic; + margin: 0; + text-align: right; +} + .logshim { margin-top: -10px !important; } diff --git a/installer/resources/themes/snark/vanilla/snark.css b/installer/resources/themes/snark/vanilla/snark.css index efd061582de04be6360e211920bd57cfadbee5e6..29190dca7e3c33354c2be98cb83021d94e3153d7 100644 --- a/installer/resources/themes/snark/vanilla/snark.css +++ b/installer/resources/themes/snark/vanilla/snark.css @@ -81,7 +81,7 @@ body { } .snarkMessages { - font: bold 9pt "Lucida Console","DejaVu Sans Mono",Courier,mono !important; + font: bold 8pt "Lucida Console","DejaVu Sans Mono",Courier,mono !important; text-align: left; margin: 0 0 10px 0; padding: 3px 5px; @@ -92,7 +92,8 @@ body { border: 1px solid #000; overflow: auto; color: #26f; - height: 70px; + max-height: 76px; + min-height: 45px; width: auto; background: #eda url('/themes/snark/ubergine/images/hat.png') no-repeat scroll right center; } @@ -108,6 +109,18 @@ body { .snarkMessages a:visited { color: #d30 !important; } + +.snarkMessages ul { + margin: 0; + padding: 0 0 0 16px; +} + +.snarkMessages p { + font-style: italic; + margin: 0; + text-align: right; +} + .logshim { margin-top: -10px !important; }