From 6482437795f7fe8fc35aaab6fcc00d6a1fdd4630 Mon Sep 17 00:00:00 2001 From: hankhill19580 Date: Wed, 15 Jul 2020 16:06:06 +0000 Subject: [PATCH] Move plugins to their own section on /home, and make it so that if all the elements of a section are shown, that section becomes hidden(so that plugins are not enabled by default) --- .../i2p/router/web/helpers/HomeHelper.java | 108 +++++++++++++++++- apps/routerconsole/jsp/home.jsp | 39 ++----- 2 files changed, 112 insertions(+), 35 deletions(-) diff --git a/apps/routerconsole/java/src/net/i2p/router/web/helpers/HomeHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/helpers/HomeHelper.java index 21ac4dcdb..c55d5233a 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/helpers/HomeHelper.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/helpers/HomeHelper.java @@ -111,28 +111,113 @@ public class HomeHelper extends HelperBase { } public String getServices() { - List plugins = NavHelper.getClientApps(_context); - return homeTable(PROP_SERVICES, DEFAULT_SERVICES, plugins); + String table = homeTable(PROP_SERVICES, DEFAULT_SERVICES, null); + if (table.length() == 0) { + return ""; + } + StringBuilder buf = new StringBuilder(1380); + buf.append("
"); + buf.append("

"); + buf.append(_t("Applications")); + buf.append("

"); + buf.append("
"); + buf.append(table); + buf.append("
"); + buf.append("
 
"); + buf.append("
"); + buf.append("
"); + return buf.toString(); } - + + /** @since 0.9.47 */ + public String getPlugins(){ + List plugins = NavHelper.getClientApps(_context); + String table = pluginTable(plugins); + if (table.length() == 0) { + return ""; + } + StringBuilder buf = new StringBuilder(1380); + buf.append("
"); + buf.append("

"); + buf.append(_t("Plugins")); + buf.append("

"); + buf.append("
"); + buf.append(table); + buf.append("
"); + buf.append("
 
"); + buf.append("
"); + buf.append("
"); + return buf.toString(); + } + /** @since 0.9.44 */ public String getConfig(){ - return homeTable(PROP_CONFIG, DEFAULT_CONFIG, null); + String table = homeTable(PROP_CONFIG, DEFAULT_CONFIG, null); + if (table.length() == 0) { + return ""; + } + StringBuilder buf = new StringBuilder(1380); + buf.append("
"); + buf.append("

"); + buf.append(_t("Configuration")); + buf.append("

"); + buf.append("
"); + buf.append(table); + buf.append("
"); + buf.append("
 
"); + buf.append("
"); + buf.append("
"); + return buf.toString(); } /** @since 0.9.44 */ public String getMonitoring(){ - return homeTable(PROP_MONITORING, DEFAULT_MONITORING, null); + String table = homeTable(PROP_MONITORING, DEFAULT_MONITORING, null); + if (table.length() == 0) { + return ""; + } + StringBuilder buf = new StringBuilder(1380); + buf.append("
"); + buf.append("

"); + buf.append(_t("Developer Information")); + buf.append("

"); + buf.append("
"); + buf.append(table); + buf.append("
"); + buf.append("
 
"); + buf.append("
"); + buf.append("
"); + return buf.toString(); } public String getFavorites() { - return homeTable(PROP_FAVORITES, DEFAULT_FAVORITES, null); + String table = homeTable(PROP_FAVORITES, DEFAULT_FAVORITES, null); + if (table.length() == 0) { + return ""; + } + StringBuilder buf = new StringBuilder(1380); + buf.append("
"); + buf.append("

"); + buf.append(_t("I2P Sites")); + buf.append("

"); + buf.append("
"); + buf.append(table); + buf.append("
"); + buf.append("
 
"); + buf.append("
"); + buf.append("
"); + return buf.toString(); } public String getConfigServices() { return configTable(PROP_SERVICES, DEFAULT_SERVICES); } + /** @since 0.9.47 */ + public String getConfigPlugins() { + return getPlugins(); + } + /** @since 0.9.44 */ public String getConfigConfig() { return configTable(PROP_CONFIG, DEFAULT_CONFIG); @@ -165,6 +250,14 @@ public class HomeHelper extends HelperBase { "\">"; } + + private String pluginTable(Collection toAdd) { + Collection apps = buildApps(_context, ""); + if (toAdd != null) + apps.addAll(toAdd); + return renderApps(apps); + } + private String homeTable(String prop, String dflt, Collection toAdd) { String config = _context.getProperty(prop, dflt); Collection apps = buildApps(_context, config); @@ -223,6 +316,9 @@ public class HomeHelper extends HelperBase { } private String renderApps(Collection apps) { + if (apps.size() == 0) { + return ""; + } String website = _t("Web Server"); StringBuilder buf = new StringBuilder(1024); buf.append("
"); diff --git a/apps/routerconsole/jsp/home.jsp b/apps/routerconsole/jsp/home.jsp index 9ceae72da..9cd7a8b02 100644 --- a/apps/routerconsole/jsp/home.jsp +++ b/apps/routerconsole/jsp/home.jsp @@ -84,34 +84,15 @@ <% } // shouldShowSearch() %> -
-

<%=intl._t("Applications")%>

-
-
-
 
-
-
-
-

<%=intl._t("Websites Inside I2P")%>

-
-
-
 
-
-
-
-

<%=intl._t("Configuration")%>

-
-
-
 
-
-
-
-

<%=intl._t("Developer Information")%>

-
-
-
 
-
-
-
+ + + + +
+ +
+ +
+