forked from I2P_Developers/i2p.i2p
propagate from branch 'i2p.i2p' (head ab5f37b28e499d49e108e8e6869164d107c7049e)
to branch 'i2p.i2p.str4d.fux' (head fb4425cd3e38762f211f73d91c7a173972e7145c)
This commit is contained in:
@ -16,7 +16,7 @@ public class NewsHelper extends ContentHelper {
|
||||
if (!news.exists())
|
||||
_page = (new File(_context.getBaseDir(), "docs/initialNews/initialNews.xml")).getAbsolutePath();
|
||||
return super.getContent();
|
||||
}
|
||||
}
|
||||
|
||||
/** @since 0.8.12 */
|
||||
public boolean shouldShowNews() {
|
||||
|
@ -3,6 +3,9 @@ package net.i2p.router.web;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.router.RouterContext;
|
||||
@ -12,6 +15,32 @@ import net.i2p.router.RouterContext;
|
||||
*
|
||||
*/
|
||||
public class SummaryBarRenderer {
|
||||
// Commented out because broken. Replaced by if-elseif blob below.
|
||||
/*static final Map<String, java.lang.reflect.Method> ALL_SECTIONS;
|
||||
static {
|
||||
Map<String, java.lang.reflect.Method> aMap = new HashMap<String, java.lang.reflect.Method>();;
|
||||
try {
|
||||
aMap.put("HelpAndFAQ", SummaryBarRenderer.class.getMethod("renderHelpAndFAQHTML"));
|
||||
aMap.put("I2PServices", SummaryBarRenderer.class.getMethod("renderI2PServicesHTML"));
|
||||
aMap.put("I2PInternals", SummaryBarRenderer.class.getMethod("renderI2PInternalsHTML"));
|
||||
aMap.put("General", SummaryBarRenderer.class.getMethod("renderGeneralHTML"));
|
||||
aMap.put("ShortGeneral", SummaryBarRenderer.class.getMethod("renderShortGeneralHTML"));
|
||||
aMap.put("NetworkReachability", SummaryBarRenderer.class.getMethod("renderNetworkReachabilityHTML"));
|
||||
aMap.put("UpdateStatus", SummaryBarRenderer.class.getMethod("renderUpdateStatusHTML"));
|
||||
aMap.put("RestartStatus", SummaryBarRenderer.class.getMethod("renderRestartStatusHTMLHTML"));
|
||||
aMap.put("Peers", SummaryBarRenderer.class.getMethod("renderPeersHTML"));
|
||||
aMap.put("FirewallAndReseedStatus", SummaryBarRenderer.class.getMethod("renderFirewallAndReseedStatusHTML"));
|
||||
aMap.put("Bandwidth", SummaryBarRenderer.class.getMethod("renderBandwidthHTML"));
|
||||
aMap.put("Tunnels", SummaryBarRenderer.class.getMethod("renderTunnelsHTML"));
|
||||
aMap.put("Congestion", SummaryBarRenderer.class.getMethod("renderCongestionHTML"));
|
||||
aMap.put("TunnelStatus", SummaryBarRenderer.class.getMethod("renderTunnelStatusHTML"));
|
||||
aMap.put("Destinations", SummaryBarRenderer.class.getMethod("renderDestinationsHTML"));
|
||||
aMap.put("NewsHeadings", SummaryBarRenderer.class.getMethod("renderNewsHeadingsHTML"));
|
||||
} catch (java.lang.NoSuchMethodException e) {
|
||||
}
|
||||
ALL_SECTIONS = Collections.unmodifiableMap(aMap);
|
||||
}*/
|
||||
|
||||
private final RouterContext _context;
|
||||
private final SummaryHelper _helper;
|
||||
|
||||
@ -26,147 +55,188 @@ public class SummaryBarRenderer {
|
||||
*/
|
||||
public void renderSummaryHTML(Writer out) throws IOException {
|
||||
StringBuilder buf = new StringBuilder(8*1024);
|
||||
String theme = _context.getProperty(CSSHelper.PROP_THEME_NAME, CSSHelper.DEFAULT_THEME);
|
||||
|
||||
// TODO - the bar would render more cleanly if we specified the img height and width here,
|
||||
// but unfortunately the images in the different themes are different sizes.
|
||||
// They range in height from 37 to 43 px. But there's a -2 bottom margin...
|
||||
// So put it in a div.
|
||||
buf.append("<div style=\"height: 36px;\"><a href=\"/\" target=\"_top\"><img src=\"")
|
||||
.append(CSSHelper.BASE_THEME_PATH)
|
||||
.append(theme)
|
||||
.append("/images/i2plogo.png\" alt=\"")
|
||||
.append(_("I2P Router Console"))
|
||||
.append("\" title=\"")
|
||||
.append(_("I2P Router Console"))
|
||||
.append("\"></a></div><hr>")
|
||||
|
||||
.append("<h3><a href=\"/help\" target=\"_top\" title=\"")
|
||||
String[] sections = _helper.getSummaryBarSections();
|
||||
for (int i = 0; i < sections.length; i++) {
|
||||
// Commented out because broken. Replaced by if-elseif blob below.
|
||||
/*try {
|
||||
String section = (String)ALL_SECTIONS.get(sections[i]).invoke(this);
|
||||
if (section != null && section != "") {
|
||||
out.write("<hr>" + i + "<hr>\n" + section);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
out.write("<hr>" +i + " - Exception<hr>\n" + e);
|
||||
}*/
|
||||
buf.setLength(0);
|
||||
|
||||
String section = sections[i];
|
||||
|
||||
buf.append("<hr>\n");
|
||||
if ("HelpAndFAQ".equals(section))
|
||||
buf.append(renderHelpAndFAQHTML());
|
||||
else if ("I2PServices".equals(section))
|
||||
buf.append(renderI2PServicesHTML());
|
||||
else if ("I2PInternals".equals(section))
|
||||
buf.append(renderI2PInternalsHTML());
|
||||
else if ("General".equals(section))
|
||||
buf.append(renderGeneralHTML());
|
||||
else if ("ShortGeneral".equals(section))
|
||||
buf.append(renderShortGeneralHTML());
|
||||
else if ("NetworkReachability".equals(section))
|
||||
buf.append(renderNetworkReachabilityHTML());
|
||||
else if ("UpdateStatus".equals(section))
|
||||
buf.append(renderUpdateStatusHTML());
|
||||
else if ("RestartStatus".equals(section))
|
||||
buf.append(renderRestartStatusHTML());
|
||||
else if ("Peers".equals(section))
|
||||
buf.append(renderPeersHTML());
|
||||
else if ("FirewallAndReseedStatus".equals(section))
|
||||
buf.append(renderFirewallAndReseedStatusHTML());
|
||||
else if ("Bandwidth".equals(section))
|
||||
buf.append(renderBandwidthHTML());
|
||||
else if ("Tunnels".equals(section))
|
||||
buf.append(renderTunnelsHTML());
|
||||
else if ("Congestion".equals(section))
|
||||
buf.append(renderCongestionHTML());
|
||||
else if ("TunnelStatus".equals(section))
|
||||
buf.append(renderTunnelStatusHTML());
|
||||
else if ("Destinations".equals(section))
|
||||
buf.append(renderDestinationsHTML());
|
||||
else if ("NewsHeadings".equals(section))
|
||||
buf.append(renderNewsHeadingsHTML());
|
||||
|
||||
// Only output section if there's more than the <hr> to print
|
||||
if (buf.length() > 5)
|
||||
out.write(buf.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public String renderHelpAndFAQHTML() {
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append("<h3><a href=\"/help\" target=\"_top\" title=\"")
|
||||
.append(_("I2P Router Help & FAQ"))
|
||||
.append("\">")
|
||||
.append(_("Help & FAQ"))
|
||||
.append("</a></h3><hr>");
|
||||
.append("</a></h3>");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
File lpath = new File(_context.getBaseDir(), "docs/toolbar.html");
|
||||
// you better have target="_top" for the links in there...
|
||||
if (lpath.exists()) {
|
||||
ContentHelper linkhelper = new ContentHelper();
|
||||
linkhelper.setPage(lpath.getAbsolutePath());
|
||||
linkhelper.setMaxLines("100");
|
||||
buf.append(linkhelper.getContent());
|
||||
} else {
|
||||
buf.append("<h3><a href=\"/configclients\" target=\"_top\" title=\"")
|
||||
.append(_("Configure startup of clients and webapps (services); manually start dormant services"))
|
||||
.append("\">")
|
||||
.append(_("I2P Services"))
|
||||
.append("</a></h3>\n" +
|
||||
public String renderI2PServicesHTML() {
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append("<h3><a href=\"/configclients\" target=\"_top\" title=\"")
|
||||
.append(_("Configure startup of clients and webapps (services); manually start dormant services"))
|
||||
.append("\">")
|
||||
.append(_("I2P Services"))
|
||||
.append("</a></h3>\n" +
|
||||
|
||||
"<hr class=\"b\"><table><tr><td>" +
|
||||
"<hr class=\"b\"><table><tr><td>" +
|
||||
|
||||
"<a href=\"/susimail/susimail\" target=\"blank\" title=\"")
|
||||
.append(_("Anonymous webmail client"))
|
||||
.append("\">")
|
||||
.append(_("Email"))
|
||||
.append("</a>\n" +
|
||||
"<a href=\"/susimail/susimail\" target=\"blank\" title=\"")
|
||||
.append(_("Anonymous webmail client"))
|
||||
.append("\">")
|
||||
.append(_("Email"))
|
||||
.append("</a>\n" +
|
||||
|
||||
"<a href=\"/i2psnark/\" target=\"_blank\" title=\"")
|
||||
.append(_("Built-in anonymous BitTorrent Client"))
|
||||
.append("\">")
|
||||
.append(_("Torrents"))
|
||||
.append("</a>\n" +
|
||||
"<a href=\"/i2psnark/\" target=\"_blank\" title=\"")
|
||||
.append(_("Built-in anonymous BitTorrent Client"))
|
||||
.append("\">")
|
||||
.append(_("Torrents"))
|
||||
.append("</a>\n" +
|
||||
|
||||
"<a href=\"http://127.0.0.1:7658/\" target=\"_blank\" title=\"")
|
||||
.append(_("Local web server"))
|
||||
.append("\">")
|
||||
.append(_("Website"))
|
||||
.append("</a>\n")
|
||||
"<a href=\"http://127.0.0.1:7658/\" target=\"_blank\" title=\"")
|
||||
.append(_("Local web server"))
|
||||
.append("\">")
|
||||
.append(_("Website"))
|
||||
.append("</a>\n")
|
||||
|
||||
.append(NavHelper.getClientAppLinks(_context))
|
||||
.append(NavHelper.getClientAppLinks(_context))
|
||||
|
||||
.append("</td></tr></table>\n" +
|
||||
.append("</td></tr></table>\n");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
"<hr><h3><a href=\"/config\" target=\"_top\" title=\"")
|
||||
.append(_("Configure I2P Router"))
|
||||
.append("\">")
|
||||
.append(_("I2P Internals"))
|
||||
.append("</a></h3><hr class=\"b\">\n" +
|
||||
public String renderI2PInternalsHTML() {
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append("<h3><a href=\"/config\" target=\"_top\" title=\"")
|
||||
.append(_("Configure I2P Router"))
|
||||
.append("\">")
|
||||
.append(_("I2P Internals"))
|
||||
.append("</a></h3><hr class=\"b\">\n" +
|
||||
|
||||
"<table><tr><td>\n" +
|
||||
"<table><tr><td>\n" +
|
||||
|
||||
"<a href=\"/tunnels\" target=\"_top\" title=\"")
|
||||
.append(_("View existing tunnels and tunnel build status"))
|
||||
.append("\">")
|
||||
.append(_("Tunnels"))
|
||||
.append("</a>\n" +
|
||||
"<a href=\"/tunnels\" target=\"_top\" title=\"")
|
||||
.append(_("View existing tunnels and tunnel build status"))
|
||||
.append("\">")
|
||||
.append(_("Tunnels"))
|
||||
.append("</a>\n" +
|
||||
|
||||
"<a href=\"/peers\" target=\"_top\" title=\"")
|
||||
.append(_("Show all current peer connections"))
|
||||
.append("\">")
|
||||
.append(_("Peers"))
|
||||
.append("</a>\n" +
|
||||
"<a href=\"/peers\" target=\"_top\" title=\"")
|
||||
.append(_("Show all current peer connections"))
|
||||
.append("\">")
|
||||
.append(_("Peers"))
|
||||
.append("</a>\n" +
|
||||
|
||||
"<a href=\"/profiles\" target=\"_top\" title=\"")
|
||||
.append(_("Show recent peer performance profiles"))
|
||||
.append("\">")
|
||||
.append(_("Profiles"))
|
||||
.append("</a>\n" +
|
||||
"<a href=\"/profiles\" target=\"_top\" title=\"")
|
||||
.append(_("Show recent peer performance profiles"))
|
||||
.append("\">")
|
||||
.append(_("Profiles"))
|
||||
.append("</a>\n" +
|
||||
|
||||
"<a href=\"/netdb\" target=\"_top\" title=\"")
|
||||
.append(_("Show list of all known I2P routers"))
|
||||
.append("\">")
|
||||
.append(_("NetDB"))
|
||||
.append("</a>\n" +
|
||||
"<a href=\"/netdb\" target=\"_top\" title=\"")
|
||||
.append(_("Show list of all known I2P routers"))
|
||||
.append("\">")
|
||||
.append(_("NetDB"))
|
||||
.append("</a>\n" +
|
||||
|
||||
"<a href=\"/logs\" target=\"_top\" title=\"")
|
||||
.append(_("Health Report"))
|
||||
.append("\">")
|
||||
.append(_("Logs"))
|
||||
.append("</a>\n");
|
||||
"<a href=\"/logs\" target=\"_top\" title=\"")
|
||||
.append(_("Health Report"))
|
||||
.append("\">")
|
||||
.append(_("Logs"))
|
||||
.append("</a>\n");
|
||||
|
||||
// "<a href=\"/jobs.jsp\" target=\"_top\" title=\"")
|
||||
// .append(_("Show the router's workload, and how it's performing"))
|
||||
// .append("\">")
|
||||
// .append(_("Jobs"))
|
||||
// .append("</a>\n" +
|
||||
// "<a href=\"/jobs.jsp\" target=\"_top\" title=\"")
|
||||
// .append(_("Show the router's workload, and how it's performing"))
|
||||
// .append("\">")
|
||||
// .append(_("Jobs"))
|
||||
// .append("</a>\n" +
|
||||
|
||||
if (!StatSummarizer.isDisabled()) {
|
||||
buf.append("<a href=\"/graphs\" target=\"_top\" title=\"")
|
||||
if (!StatSummarizer.isDisabled()) {
|
||||
buf.append("<a href=\"/graphs\" target=\"_top\" title=\"")
|
||||
.append(_("Graph router performance"))
|
||||
.append("\">")
|
||||
.append(_("Graphs"))
|
||||
.append("</a>\n");
|
||||
}
|
||||
|
||||
buf.append("<a href=\"/stats\" target=\"_top\" title=\"")
|
||||
.append(_("Textual router performance statistics"))
|
||||
.append("\">")
|
||||
.append(_("Stats"))
|
||||
.append("</a>\n" +
|
||||
|
||||
"<a href=\"/i2ptunnel/\" target=\"_blank\" title=\"")
|
||||
.append(_("Local Destinations"))
|
||||
.append("\">")
|
||||
.append(_("I2PTunnel"))
|
||||
.append("</a>\n" +
|
||||
|
||||
"<a href=\"/susidns/index\" target=\"_blank\" title=\"")
|
||||
.append(_("Manage your I2P hosts file here (I2P domain name resolution)"))
|
||||
.append("\">")
|
||||
.append(_("Addressbook"))
|
||||
.append("</a>\n");
|
||||
|
||||
File javadoc = new File(_context.getBaseDir(), "docs/javadoc/index.html");
|
||||
if (javadoc.exists())
|
||||
buf.append("<a href=\"/javadoc/index.html\" target=\"_blank\">Javadoc</a>\n");
|
||||
buf.append("</td></tr></table>\n");
|
||||
|
||||
out.write(buf.toString());
|
||||
buf.setLength(0);
|
||||
}
|
||||
|
||||
buf.append("<a href=\"/stats\" target=\"_top\" title=\"")
|
||||
.append(_("Textual router performance statistics"))
|
||||
.append("\">")
|
||||
.append(_("Stats"))
|
||||
.append("</a>\n" +
|
||||
|
||||
"<a href=\"/i2ptunnel/\" target=\"_blank\" title=\"")
|
||||
.append(_("Local Destinations"))
|
||||
.append("\">")
|
||||
.append(_("I2PTunnel"))
|
||||
.append("</a>\n" +
|
||||
|
||||
buf.append("<hr><h3><a href=\"/help\" target=\"_top\" title=\"")
|
||||
"<a href=\"/susidns/index\" target=\"_blank\" title=\"")
|
||||
.append(_("Manage your I2P hosts file here (I2P domain name resolution)"))
|
||||
.append("\">")
|
||||
.append(_("Addressbook"))
|
||||
.append("</a>\n");
|
||||
|
||||
File javadoc = new File(_context.getBaseDir(), "docs/javadoc/index.html");
|
||||
if (javadoc.exists())
|
||||
buf.append("<a href=\"/javadoc/index.html\" target=\"_blank\">Javadoc</a>\n");
|
||||
buf.append("</td></tr></table>\n");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public String renderGeneralHTML() {
|
||||
if (_helper == null) return "";
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append("<h3><a href=\"/help\" target=\"_top\" title=\"")
|
||||
.append(_("I2P Router Help"))
|
||||
.append("\">")
|
||||
.append(_("General"))
|
||||
@ -202,24 +272,64 @@ public class SummaryBarRenderer {
|
||||
.append(":</b></td>" +
|
||||
"<td align=\"right\">")
|
||||
.append(_helper.getUptime())
|
||||
.append("</td></tr></table>\n" +
|
||||
.append("</td></tr></table>\n");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
"<hr><h4><a href=\"/confignet#help\" target=\"_top\" title=\"")
|
||||
public String renderShortGeneralHTML() {
|
||||
if (_helper == null) return "";
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append("<table>" +
|
||||
"<tr><td align=\"left\"><b>")
|
||||
.append(_("Version"))
|
||||
.append(":</b></td>" +
|
||||
"<td align=\"right\">")
|
||||
.append(_helper.getVersion())
|
||||
.append("</td></tr>\n" +
|
||||
|
||||
"<tr title=\"")
|
||||
.append(_("How long we've been running for this session"))
|
||||
.append("\">" +
|
||||
"<td align=\"left\"><b>")
|
||||
.append(_("Uptime"))
|
||||
.append(":</b></td>" +
|
||||
"<td align=\"right\">")
|
||||
.append(_helper.getUptime())
|
||||
.append("</td></tr></table>\n");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public String renderNetworkReachabilityHTML() {
|
||||
if (_helper == null) return "";
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append("<h4><a href=\"/confignet#help\" target=\"_top\" title=\"")
|
||||
.append(_("Help with configuring your firewall and router for optimal I2P performance"))
|
||||
.append("\">")
|
||||
.append(_("Network"))
|
||||
.append(": ")
|
||||
.append(_helper.getReachability())
|
||||
.append("</a></h4><hr>\n")
|
||||
.append("</a></h4>\n");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public String renderUpdateStatusHTML() {
|
||||
if (_helper == null) return "";
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append(_helper.getUpdateStatus());
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
.append(_helper.getUpdateStatus())
|
||||
public String renderRestartStatusHTML() {
|
||||
if (_helper == null) return "";
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append(_helper.getRestartStatus());
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
|
||||
.append(_helper.getRestartStatus())
|
||||
|
||||
|
||||
.append("<hr><h3><a href=\"/peers\" target=\"_top\" title=\"")
|
||||
public String renderPeersHTML() {
|
||||
if (_helper == null) return "";
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append("<h3><a href=\"/peers\" target=\"_top\" title=\"")
|
||||
.append(_("Show all current peer connections"))
|
||||
.append("\">")
|
||||
.append(_("Peers"))
|
||||
@ -260,14 +370,20 @@ public class SummaryBarRenderer {
|
||||
.append(_helper.getAllPeers())
|
||||
.append("</td></tr>\n" +
|
||||
|
||||
"</table><hr>\n");
|
||||
|
||||
|
||||
out.write(buf.toString());
|
||||
buf.setLength(0);
|
||||
"</table>\n");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public String renderFirewallAndReseedStatusHTML() {
|
||||
if (_helper == null) return "";
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append(_helper.getFirewallAndReseedStatus());
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public String renderBandwidthHTML() {
|
||||
if (_helper == null) return "";
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append("<h3><a href=\"/config\" title=\"")
|
||||
.append(_("Configure router bandwidth allocation"))
|
||||
.append("\" target=\"_top\">")
|
||||
@ -303,9 +419,16 @@ public class SummaryBarRenderer {
|
||||
.append(_helper.getInboundTransferred())
|
||||
.append(SummaryHelper.THINSP)
|
||||
.append(_helper.getOutboundTransferred())
|
||||
.append("</td></tr></table>\n" +
|
||||
.append("</td></tr>\n" +
|
||||
|
||||
"<hr><h3><a href=\"/tunnels\" target=\"_top\" title=\"")
|
||||
"</table>\n");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public String renderTunnelsHTML() {
|
||||
if (_helper == null) return "";
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append("<h3><a href=\"/tunnels\" target=\"_top\" title=\"")
|
||||
.append(_("View existing tunnels and tunnel build status"))
|
||||
.append("\">")
|
||||
.append(_("Tunnels"))
|
||||
@ -336,7 +459,14 @@ public class SummaryBarRenderer {
|
||||
.append(_helper.getShareRatio())
|
||||
.append("</td></tr>\n" +
|
||||
|
||||
"</table><hr><h3><a href=\"/jobs\" target=\"_top\" title=\"")
|
||||
"</table>\n");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public String renderCongestionHTML() {
|
||||
if (_helper == null) return "";
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append("<h3><a href=\"/jobs\" target=\"_top\" title=\"")
|
||||
.append(_("What's in the router's job queue?"))
|
||||
.append("\">")
|
||||
.append(_("Congestion"))
|
||||
@ -369,16 +499,74 @@ public class SummaryBarRenderer {
|
||||
.append(_helper.getInboundBacklog())
|
||||
.append("</td></tr>\n" +
|
||||
|
||||
"</table><hr><h4>")
|
||||
"</table>\n");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public String renderTunnelStatusHTML() {
|
||||
if (_helper == null) return "";
|
||||
StringBuilder buf = new StringBuilder(50);
|
||||
buf.append("<h4>")
|
||||
.append(_(_helper.getTunnelStatus()))
|
||||
.append("</h4><hr>\n")
|
||||
.append("</h4>\n");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
.append(_helper.getDestinations())
|
||||
.append("<hr>\n");
|
||||
public String renderDestinationsHTML() {
|
||||
if (_helper == null) return "";
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append(_helper.getDestinations());
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
out.write(buf.toString());
|
||||
/** @since 0.9.1 */
|
||||
public String renderNewsHeadingsHTML() {
|
||||
if (_helper == null) return "";
|
||||
NewsHelper newshelper = _helper.getNewsHelper();
|
||||
if (newshelper == null || newshelper.shouldShowNews()) return "";
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
String consoleNonce = System.getProperty("router.consoleNonce");
|
||||
if (consoleNonce != null) {
|
||||
// Set up title and pre-headings stuff.
|
||||
buf.append("<h3><a href=\"/configupdate\">")
|
||||
.append(_("News & Updates"))
|
||||
.append("</a></h3><hr class=\"b\"><div class=\"newsheadings\">\n");
|
||||
// Get news content.
|
||||
String newsContent = newshelper.getContent();
|
||||
if (newsContent != "") {
|
||||
buf.append("<ul>\n");
|
||||
// Parse news content for headings.
|
||||
int start = newsContent.indexOf("<h3>");
|
||||
while (start >= 0) {
|
||||
// Add offset to start:
|
||||
// 4 - gets rid of <h3>
|
||||
// 16 - gets rid of the date as well (assuming form "<h3>yyyy-mm-dd: Foobarbaz...")
|
||||
newsContent = newsContent.substring(start+16, newsContent.length());
|
||||
int end = newsContent.indexOf("</h3>");
|
||||
if (end >= 0) {
|
||||
String heading = newsContent.substring(0, end);
|
||||
buf.append("<li>")
|
||||
.append(heading)
|
||||
.append("</li>\n");
|
||||
}
|
||||
start = newsContent.indexOf("<h3>");
|
||||
}
|
||||
buf.append("</ul>\n");
|
||||
// Set up string containing <a> to show news.
|
||||
buf.append("<a href=\"/?news=1&consoleNonce=")
|
||||
.append(consoleNonce)
|
||||
.append("\">")
|
||||
.append(_("Show news"))
|
||||
.append("</a>\n");
|
||||
} else {
|
||||
buf.append("<center><i>")
|
||||
.append(_("none"))
|
||||
.append("</i></center>");
|
||||
}
|
||||
// Add post-headings stuff.
|
||||
buf.append("</div>\n");
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/** translate a string */
|
||||
|
@ -35,6 +35,35 @@ public class SummaryHelper extends HelperBase {
|
||||
// Opera 10.63 doesn't have the char, TODO check UA
|
||||
//static final String THINSP = " / ";
|
||||
static final String THINSP = " / ";
|
||||
private static final char S = ',';
|
||||
static final String PROP_SUMMARYBAR = "routerconsole.summaryBar";
|
||||
|
||||
static final String PRESET_FULL =
|
||||
"HelpAndFAQ" + S +
|
||||
"I2PServices" + S +
|
||||
"I2PInternals" + S +
|
||||
"General" + S +
|
||||
"NetworkReachability" + S +
|
||||
"UpdateStatus" + S +
|
||||
"RestartStatus" + S +
|
||||
"Peers" + S +
|
||||
"FirewallAndReseedStatus" + S +
|
||||
"Bandwidth" + S +
|
||||
"Tunnels" + S +
|
||||
"Congestion" + S +
|
||||
"TunnelStatus" + S +
|
||||
"Destinations" + S +
|
||||
"";
|
||||
|
||||
static final String PRESET_SHORT =
|
||||
"ShortGeneral" + S +
|
||||
"NewsHeadings" + S +
|
||||
"UpdateStatus" + S +
|
||||
"NetworkReachability" + S +
|
||||
"FirewallAndReseedStatus" + S +
|
||||
"Destinations" + S +
|
||||
"RestartStatus" + S +
|
||||
"";
|
||||
|
||||
/**
|
||||
* Retrieve the shortened 4 character ident for the router located within
|
||||
@ -651,7 +680,7 @@ public class SummaryHelper extends HelperBase {
|
||||
.append(_("Download Unsigned<br>Update {0}", getUnsignedUpdateVersion()))
|
||||
.append("</button><br>\n");
|
||||
}
|
||||
buf.append("</form>\n");
|
||||
buf.append("</form><hr>\n");
|
||||
}
|
||||
}
|
||||
return buf.toString();
|
||||
@ -710,6 +739,22 @@ public class SummaryHelper extends HelperBase {
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
private NewsHelper _newshelper;
|
||||
public void storeNewsHelper(NewsHelper n) { _newshelper = n; }
|
||||
public NewsHelper getNewsHelper() { return _newshelper; }
|
||||
|
||||
public String[] getSummaryBarSections() {
|
||||
String config = _context.getProperty(PROP_SUMMARYBAR, PRESET_FULL);
|
||||
return config.split("" + S);
|
||||
}
|
||||
|
||||
public void saveSummaryBarSections(String[] sections) {
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
for(int i = 0; i < sections.length; i++)
|
||||
buf.append(sections[i]).append(S);
|
||||
_context.router().saveConfig(PROP_SUMMARYBAR, buf.toString());
|
||||
}
|
||||
|
||||
/** output the summary bar to _out */
|
||||
public void renderSummaryBar() throws IOException {
|
||||
SummaryBarRenderer renderer = new SummaryBarRenderer(_context, this);
|
||||
|
Reference in New Issue
Block a user