From 9012baf51eabd72760fb88239eea97f05754d68d Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Sun, 7 Feb 2010 19:01:06 +0000 Subject: [PATCH] plugin links --- .../src/net/i2p/router/web/NavHelper.java | 25 +++++++++++-------- .../src/net/i2p/router/web/PluginStarter.java | 9 +++++++ .../i2p/router/web/SummaryBarRenderer.java | 6 ++++- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/apps/routerconsole/java/src/net/i2p/router/web/NavHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/NavHelper.java index cabb68f156..37ca94cd66 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/NavHelper.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/NavHelper.java @@ -1,14 +1,13 @@ package net.i2p.router.web; -import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import net.i2p.I2PAppContext; -public class NavHelper extends HelperBase { - private static Map _apps = new HashMap(); - - public NavHelper() {} +public class NavHelper { + private static Map<String, String> _apps = new ConcurrentHashMap(); /** * To register a new client application so that it shows up on the router @@ -25,13 +24,17 @@ public class NavHelper extends HelperBase { _apps.remove(name); } - public String getClientAppLinks() { + /** + * Fixme, this translates with the router console bundle, not + * the plugin bundle + */ + public static String getClientAppLinks(I2PAppContext ctx) { StringBuilder buf = new StringBuilder(1024); - for (Iterator iter = _apps.keySet().iterator(); iter.hasNext(); ) { - String name = (String)iter.next(); - String path = (String)_apps.get(name); - buf.append("<a href=\"").append(path).append("\">"); - buf.append(name).append("</a> |"); + for (Iterator<String> iter = _apps.keySet().iterator(); iter.hasNext(); ) { + String name = iter.next(); + String path = _apps.get(name); + buf.append(" <a target=\"_top\" href=\"").append(path).append("\">"); + buf.append(Messages.getString(name, ctx)).append("</a>"); } return buf.toString(); } diff --git a/apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java b/apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java index 3d11191a97..99562789ab 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java @@ -131,6 +131,15 @@ public class PluginStarter implements Runnable { // add themes in console/themes // add summary bar link + File pluginConfig = new File(pluginDir, "plugin.config"); + if (pluginConfig.exists()) { + Properties props = new Properties(); + DataHelper.loadProps(props, pluginConfig); + String name = props.getProperty("consoleLinkName"); + String url = props.getProperty("consoleLinkURL"); + if (name != null && url != null && name.length() > 0 && url.length() > 0) + NavHelper.registerApp(name, url); + } return true; } diff --git a/apps/routerconsole/java/src/net/i2p/router/web/SummaryBarRenderer.java b/apps/routerconsole/java/src/net/i2p/router/web/SummaryBarRenderer.java index 7dd28c0efa..153ef06301 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/SummaryBarRenderer.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/SummaryBarRenderer.java @@ -70,7 +70,11 @@ public class SummaryBarRenderer { .append(_("Anonymous resident webserver")) .append("\">") .append(_("Webserver")) - .append("</a></td></tr></table>\n" + + .append("</a>") + + .append(NavHelper.getClientAppLinks(_context)) + + .append("</td></tr></table>\n" + "<hr><h3><a href=\"/config.jsp\" target=\"_top\" title=\"") .append(_("Configure I2P Router")) -- GitLab