forked from I2P_Developers/i2p.i2p
Console: Rework summary bar services section
Move icon selection from CSS to code Use plugin-configured icon if available
This commit is contained in:
@ -20,6 +20,7 @@ public class NavHelper {
|
||||
* console's nav bar, it should be registered with this singleton.
|
||||
*
|
||||
* @param name pretty name the app will be called in the link
|
||||
* warning, this is the display name aka ConsoleLinkName, not the plugin name
|
||||
* @param path full path pointing to the application's root
|
||||
* (e.g. /i2ptunnel/index.jsp), non-null
|
||||
* @param tooltip HTML escaped text or null
|
||||
@ -66,27 +67,49 @@ public class NavHelper {
|
||||
|
||||
/**
|
||||
* Translated string is loaded by PluginStarter
|
||||
* @param ctx unused
|
||||
* @param buf appended to
|
||||
*/
|
||||
public static String getClientAppLinks(I2PAppContext ctx) {
|
||||
public static void getClientAppLinks(StringBuilder buf) {
|
||||
if (_apps.isEmpty())
|
||||
return "";
|
||||
StringBuilder buf = new StringBuilder(256);
|
||||
return;
|
||||
List<String> l = new ArrayList<String>(_apps.keySet());
|
||||
Collections.sort(l);
|
||||
for (String name : l) {
|
||||
String path = _apps.get(name);
|
||||
if (path == null)
|
||||
continue;
|
||||
buf.append(" <a target=\"_blank\" href=\"").append(path).append("\" ");
|
||||
buf.append("<tr><td>");
|
||||
getClientAppImg(buf, name);
|
||||
buf.append("</td><td align=\"left\"><a target=\"_blank\" href=\"").append(path).append("\" ");
|
||||
String tip = _tooltips.get(name);
|
||||
if (tip != null)
|
||||
buf.append("title=\"").append(tip).append("\" ");
|
||||
buf.append('>').append(name.replace(" ", " ")).append("</a>");
|
||||
buf.append('>').append(name.replace(" ", " ")).append("</a></td></tr>\n");
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get icon img and append to buf
|
||||
* @param name warning this is the display name aka ConsoleLinkName, not the plugin name
|
||||
* @since 0.9.45
|
||||
*/
|
||||
static void getClientAppImg(StringBuilder buf, String name) {
|
||||
if (_binary.containsKey(name)) {
|
||||
buf.append("<img src=\"/Plugins/pluginicon?plugin=").append(name).append("\" height=\"16\" width=\"16\" alt=\"\">");
|
||||
} else {
|
||||
String iconpath = _icons.get(name);
|
||||
if (iconpath != null) {
|
||||
buf.append("<img src=\"").append(iconpath).append("\" height=\"16\" width=\"16\" alt=\"\">");
|
||||
} else if (name.equals("Orchid")) {
|
||||
buf.append("<img src=\"/themes/console/light/images/flower.png\" alt=\"\">");
|
||||
} else if (name.equals("i2pbote")) {
|
||||
buf.append("<img src=\"/themes/console/light/images/mail_black.png\" alt=\"\">");
|
||||
} else {
|
||||
buf.append("<img src=\"/themes/console/images/plugin.png\" height=\"16\" width=\"16\" alt=\"\">");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For HomeHelper
|
||||
* @param ctx unused
|
||||
|
@ -199,48 +199,50 @@ class SummaryBarRenderer {
|
||||
.append("\">")
|
||||
.append(_t("I2P Services"))
|
||||
.append("</a></h3>\n" +
|
||||
|
||||
"<hr class=\"b\"><table id=\"sb_services\"><tr><td>");
|
||||
"<hr class=\"b\"><table id=\"sb_services\">");
|
||||
|
||||
PortMapper pm = _context.portMapper();
|
||||
if (pm.isRegistered(PortMapper.SVC_SUSIMAIL)) {
|
||||
buf.append("<tr><td><img src=\"/themes/console/light/images/inbox.png\" height=\"16\" width=\"16\" alt=\"\"></td><td align=\"left\">");
|
||||
buf.append("<a href=\"/webmail\" target=\"_top\" title=\"")
|
||||
.append(_t("Anonymous webmail client"))
|
||||
.append("\">")
|
||||
.append(nbsp(_t("Email")))
|
||||
.append("</a>\n");
|
||||
.append("</a></td></tr>\n");
|
||||
}
|
||||
|
||||
if (pm.isRegistered(PortMapper.SVC_JSONRPC)) {
|
||||
buf.append("<tr><td><img src=\"/themes/console/images/plugin.png\" height=\"16\" width=\"16\" alt=\"\"></td><td align=\"left\">");
|
||||
buf.append("<a href=\"/jsonrpc/\" target=\"_top\" title=\"")
|
||||
.append(_t("RPC Service"))
|
||||
.append("\">")
|
||||
.append(nbsp(_t("I2PControl")))
|
||||
.append("</a>\n");
|
||||
.append("</a></td></tr>\n");
|
||||
}
|
||||
|
||||
if (pm.isRegistered(PortMapper.SVC_I2PSNARK)) {
|
||||
buf.append("<tr><td><img src=\"/themes/console/images/i2psnark.png\" height=\"16\" width=\"16\" alt=\"\"></td><td align=\"left\">");
|
||||
buf.append("<a href=\"/torrents\" target=\"_top\" title=\"")
|
||||
.append(_t("Built-in anonymous BitTorrent Client"))
|
||||
.append("\">")
|
||||
.append(nbsp(_t("Torrents")))
|
||||
.append("</a>\n");
|
||||
.append("</a></td></tr>\n");
|
||||
}
|
||||
|
||||
String url = getEepsiteURL(pm);
|
||||
if (url != null) {
|
||||
buf.append("<tr><td><img src=\"/themes/console/images/server.png\" height=\"16\" width=\"16\" alt=\"\"></td><td align=\"left\">");
|
||||
buf.append("<a href=\"")
|
||||
.append(url)
|
||||
.append("\" target=\"_blank\" title=\"")
|
||||
.append(_t("Local web server"))
|
||||
.append("\">")
|
||||
.append(nbsp(_t("Web Server")))
|
||||
.append("</a>\n");
|
||||
.append("</a></td></tr>\n");
|
||||
}
|
||||
|
||||
buf.append(NavHelper.getClientAppLinks(_context))
|
||||
|
||||
.append("</td></tr></table>\n");
|
||||
NavHelper.getClientAppLinks(buf);
|
||||
buf.append("</table>\n");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user