From 679549cbf2df4a9fc8e103ced6c15be28af931a4 Mon Sep 17 00:00:00 2001 From: str4d <str4d@mail.i2p> Date: Wed, 1 Aug 2012 02:04:00 +0000 Subject: [PATCH] Reverted susidns to storing theme itself, but checking routerconsole for universal theming --- .../src/java/src/i2p/susi/dns/BaseBean.java | 38 +++++++++---------- apps/susidns/src/jsp/config.jsp | 3 ++ 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/apps/susidns/src/java/src/i2p/susi/dns/BaseBean.java b/apps/susidns/src/java/src/i2p/susi/dns/BaseBean.java index a58d49602d..dcce833181 100644 --- a/apps/susidns/src/java/src/i2p/susi/dns/BaseBean.java +++ b/apps/susidns/src/java/src/i2p/susi/dns/BaseBean.java @@ -14,14 +14,14 @@ public class BaseBean { private final I2PAppContext _context; protected final Properties properties; - private String _theme; private long configLastLoaded = 0; private static final String PRIVATE_BOOK = "private_addressbook"; private static final String DEFAULT_PRIVATE_BOOK = "../privatehosts.txt"; - public static final String THEME_CONFIG_FILE = "themes.config"; - public static final String PROP_THEME_NAME = "susidns.theme"; + public static final String RC_PROP_THEME_NAME = "routerconsole.theme"; + public static final String RC_PROP_UNIVERSAL_THEMING = "routerconsole.theme.universal"; + public static final String PROP_THEME_NAME = "theme"; public static final String DEFAULT_THEME = "light"; public static final String BASE_THEME_PATH = "/themes/susidns/"; @@ -46,21 +46,6 @@ public class BaseBean // added in 0.5, for compatibility with 0.4 config.txt if( properties.getProperty(PRIVATE_BOOK) == null) properties.setProperty(PRIVATE_BOOK, DEFAULT_PRIVATE_BOOK); - // Fetch theme - Properties themeProps = _context.readConfigFile(THEME_CONFIG_FILE); - _theme = themeProps.getProperty(PROP_THEME_NAME); - // Ensure that theme config line exists in config file, and theme exists - String[] themes = getThemes(); - boolean themeExists = false; - for (int i = 0; i < themes.length; i++) { - if (themes[i].equals(_theme)) - themeExists = true; - } - if (_theme == null || !themeExists) { - _theme = DEFAULT_THEME; - themeProps.put(PROP_THEME_NAME, _theme); - _context.writeConfigFile(THEME_CONFIG_FILE, themeProps); - } configLastLoaded = currentTime; } catch (Exception e) { @@ -78,7 +63,22 @@ public class BaseBean public String getTheme() { loadConfig(); String url = BASE_THEME_PATH; - url += _theme + "/"; + String theme = properties.getProperty(PROP_THEME_NAME, DEFAULT_THEME); + boolean universalTheming = _context.getBooleanProperty(RC_PROP_UNIVERSAL_THEMING); + if (universalTheming) { + // Fetch routerconsole theme (or use our default if it doesn't exist) + theme = _context.getProperty(RC_PROP_THEME_NAME, DEFAULT_THEME); + // Ensure that theme exists + String[] themes = getThemes(); + boolean themeExists = false; + for (int i = 0; i < themes.length; i++) { + if (themes[i].equals(theme)) + themeExists = true; + } + if (!themeExists) + theme = DEFAULT_THEME; + } + url += theme + "/"; return url; } diff --git a/apps/susidns/src/jsp/config.jsp b/apps/susidns/src/jsp/config.jsp index 10cc595808..95e904c3a3 100644 --- a/apps/susidns/src/jsp/config.jsp +++ b/apps/susidns/src/jsp/config.jsp @@ -130,6 +130,9 @@ <li><b>log</b> - <%=intl._("File to log activity to (change to /dev/null if you like)")%> </li> +<li><b>theme</b> - +<%=intl._("Name of the theme to use (defaults to 'light')")%> +</li> </ul> </div><hr> <div id="footer"> -- GitLab