From 00667151da7ae9ff722aea8c594c31bfd76df009 Mon Sep 17 00:00:00 2001 From: zzz Date: Tue, 3 Dec 2019 19:18:20 +0000 Subject: [PATCH] Console: Rework summary bar services section Move icon selection from CSS to code Use plugin-configured icon if available --- .../src/net/i2p/router/web/NavHelper.java | 37 ++++++-- .../web/helpers/SummaryBarRenderer.java | 20 +++-- .../resources/themes/console/dark/console.css | 88 ++----------------- .../themes/console/light/console.css | 66 ++------------ 4 files changed, 54 insertions(+), 157 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 6d71d888f..9155d6808 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/NavHelper.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/NavHelper.java @@ -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 l = new ArrayList(_apps.keySet()); Collections.sort(l); for (String name : l) { String path = _apps.get(name); if (path == null) continue; - buf.append(" "); + getClientAppImg(buf, name); + buf.append("').append(name.replace(" ", " ")).append(""); + buf.append('>').append(name.replace(" ", " ")).append("\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("\"\""); + } else { + String iconpath = _icons.get(name); + if (iconpath != null) { + buf.append("\"\""); + } else if (name.equals("Orchid")) { + buf.append("\"\""); + } else if (name.equals("i2pbote")) { + buf.append("\"\""); + } else { + buf.append("\"\""); + } + } + } + /** * For HomeHelper * @param ctx unused diff --git a/apps/routerconsole/java/src/net/i2p/router/web/helpers/SummaryBarRenderer.java b/apps/routerconsole/java/src/net/i2p/router/web/helpers/SummaryBarRenderer.java index 4e49c6813..efd99e225 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/helpers/SummaryBarRenderer.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/helpers/SummaryBarRenderer.java @@ -199,48 +199,50 @@ class SummaryBarRenderer { .append("\">") .append(_t("I2P Services")) .append("\n" + - - "
"); + "
"); PortMapper pm = _context.portMapper(); if (pm.isRegistered(PortMapper.SVC_SUSIMAIL)) { + buf.append("\n"); } if (pm.isRegistered(PortMapper.SVC_JSONRPC)) { + buf.append("\n"); } if (pm.isRegistered(PortMapper.SVC_I2PSNARK)) { + buf.append("\n"); } String url = getEepsiteURL(pm); if (url != null) { + buf.append("\n"); } - buf.append(NavHelper.getClientAppLinks(_context)) - - .append("
\"\""); buf.append("") .append(nbsp(_t("Email"))) - .append("\n"); + .append("
\"\""); buf.append("") .append(nbsp(_t("I2PControl"))) - .append("\n"); + .append("
\"\""); buf.append("") .append(nbsp(_t("Torrents"))) - .append("\n"); + .append("
\"\""); buf.append("") .append(nbsp(_t("Web Server"))) - .append("\n"); + .append("
\n"); + NavHelper.getClientAppLinks(buf); + buf.append("
\n"); return buf.toString(); } diff --git a/installer/resources/themes/console/dark/console.css b/installer/resources/themes/console/dark/console.css index c6e533056..cd4988788 100644 --- a/installer/resources/themes/console/dark/console.css +++ b/installer/resources/themes/console/dark/console.css @@ -483,7 +483,7 @@ div.warning { margin-top: -4px !important; } -#sb_internals a, #sb_services a, #sb_advanced a, #sb_help a { +#sb_internals a, #sb_advanced a, #sb_help a { padding: 1px 3px; display: inline-block; vertical-align: middle; @@ -507,6 +507,11 @@ div.warning { line-height: 140%; } +#sb_services td:first-child { + width: 16px; + padding: 1px 2px; +} + #sb_peersadvanced a { color: #ee9; } @@ -583,87 +588,6 @@ div.refresh { color: #f60; } -/* "experimental" custom sidebar links for apps */ -/* -#sb_services { - width: 192px !important; - margin: 0 !important; - margin: -7px -10px -9px !important; - border-collapse: collapse; - background: url(images/camotile.png) repeat fixed left top; -} - -#sb_services tr { - padding: 0; -} - -#sb_services td { - padding: 0; -} - -#sb_services a, #sb_services a:hover, #sb_services a:active { - border-bottom: 1px solid #151 !important; - outline: none !important; - display: inline-block; - width: calc(100% - 32px) !important; -} - -#sb_services a:hover { - background: #020; -} - -#sb_services a:last-child { - border-bottom: 1px solid transparent !important; -} - -#sb_services a[href*="mail"], #sb_services a[href*="snark"], #sb_services a[href*="7658"], #sb_services a[href*="bote"] { - padding: 5px 5px 5px 26px !important; - border: 1px outset transparent; - margin: 0 !important; - float: left; - text-align: left; - text-decoration: none; - text-transform: uppercase; - letter-spacing: 0.1em; - white-space: nowrap; - text-overflow: ellipsis; - overflow: hidden; - clear: both; -} - -#sb_services a[href*="mail"] { - background: #000 url(images/mail.png) 5px center no-repeat; -} -#sb_services a[href*="mail"]:hover { - background: #020 url(images/mail.png) 5px center no-repeat; -} - -#sb_services a[href*="bote"] { - background: #000 url(images/webmail.png) 5px center no-repeat; -} - -#sb_services a[href*="bote"]:hover { - background: #020 url(images/webmail.png) 5px center no-repeat; -} - -#sb_services a[href*="snark"] { - background: #000 url(images/magnet.png) 5px center no-repeat; -} - -#sb_services a[href*="snark"]:hover { - background: #020 url(images/magnet.png) 5px center no-repeat; -} - -#sb_services a[href*="7658"] { - background: #000 url(images/webserver.png) 5px center no-repeat; -} - -#sb_services a[href*="7658"]:hover { - background: #020 url(images/webserver.png) 5px center no-repeat; -} -*/ -/* end custom sidebar links */ - .routersummary td { padding: 0 2px 0 2px; background-image: none !important; diff --git a/installer/resources/themes/console/light/console.css b/installer/resources/themes/console/light/console.css index d859cb9f9..3454104a0 100644 --- a/installer/resources/themes/console/light/console.css +++ b/installer/resources/themes/console/light/console.css @@ -682,80 +682,28 @@ p:empty + .sb_notice { } #sb_services td { - padding-top: 4px; - padding-bottom: 4px; + text-align: left !important; +} + +#sb_services td:first-child { + width: 16px; + padding: 1px 2px; } #sb_services a:link, #sb_services a:visited { - display: inline-block; - width: 100%; - padding: 4px 2px 4px 24px; + padding: 4px 2px 4px 3px; text-align: left; - border-bottom: 1px; - background: #f8f8ff url(/themes/console/images/plugin.png) 3px center no-repeat; - background: rgba(248, 248, 255, 0.8) url(/themes/console/images/plugin.png) 3px center no-repeat; - background-size: 16px 16px !important; } #sb_services a:link:last-child { border-bottom: none; } -#sb_services a { - background-blend-mode: luminosity; - vertical-align: sub !important; -} - #sb_services a:hover { background-blend-mode: normal; background-color: #e9ecef; } -#sb_services a[href="/susimail/susimail"], #sb_services a[href="/webmail"] { - background: #f8f8ff url(images/inbox.png) 3px center no-repeat; - background: rgba(248, 248, 255, 0.8) url(images/inbox.png) 3px center no-repeat; -} - -#sb_services a[href="/susimail/susimail"]:hover, #sb_services a[href="/webmail"]:hover { - background: #e9ecef url(images/inbox.png) 3px center no-repeat; -} - -#sb_services a[href="/i2psnark/"], #sb_services a[href="/torrents"] { - background: #f8f8ff url(/themes/console/images/i2psnark.png) 3px center no-repeat; - background: rgba(248, 248, 255, 0.8) url(/themes/console/images/i2psnark.png) 3px center no-repeat; -} - -#sb_services a[href="/i2psnark/"]:hover, #sb_services a[href="/torrents"]:hover { - background: #e9ecef url(/themes/console/images/i2psnark.png) 3px center no-repeat; -} - -#sb_services a[href="http://127.0.0.1:7658/"] { - background: #f8f8ff url(images/server.png) 3px center no-repeat; - background: rgba(248, 248, 255, 0.8) url(images/server.png) 3px center no-repeat; -} - -#sb_services a[href="http://127.0.0.1:7658/"]:hover { - background: #e9ecef url(images/server.png) 3px center no-repeat; -} - -#sb_services a[href="/orchid/"] { - background: #f8f8ff url(images/flower.png) 3px center no-repeat; - background: rgba(248, 248, 255, 0.8) url(images/flower.png) 3px center no-repeat; -} - -#sb_services a[href="/orchid/"]:hover { - background: #e9ecef url(images/flower.png) 3px center no-repeat; -} - -#sb_services a[href*="bote"] { - background: #f8f8ff url(images/mail_black.png) 3px center no-repeat; - background: rgba(248, 248, 255, 0.8) url(images/mail_black.png) 3px center no-repeat; -} - -#sb_services a[href*="bote"]:hover { - background: #e9ecef url(images/mail_black.png) 3px center no-repeat; -} - /* end webapp navigation */ .routersummary tr {