forked from I2P_Developers/i2p.i2p
plugin links
This commit is contained in:
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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"))
|
||||
|
Reference in New Issue
Block a user