forked from I2P_Developers/i2p.i2p
Store router console theme setting in themes.config
This commit is contained in:
@ -12,7 +12,8 @@ public class CSSHelper extends HelperBase {
|
||||
private static final Map<String, Boolean> _UACache = new ConcurrentHashMap();
|
||||
|
||||
public CSSHelper() {}
|
||||
|
||||
|
||||
public static final String THEME_CONFIG_FILE = "themes.config";
|
||||
public static final String PROP_THEME_NAME = "routerconsole.theme";
|
||||
public static final String DEFAULT_THEME = "light";
|
||||
public static final String BASE_THEME_PATH = "/themes/console/";
|
||||
@ -31,7 +32,7 @@ public class CSSHelper extends HelperBase {
|
||||
// This is the first thing to use _context on most pages
|
||||
if (_context == null)
|
||||
throw new IllegalStateException("No contexts. This is usually because the router is either starting up or shutting down.");
|
||||
String theme = _context.getProperty(PROP_THEME_NAME, DEFAULT_THEME);
|
||||
String theme = _context.readConfigFile(THEME_CONFIG_FILE).getProperty(PROP_THEME_NAME, DEFAULT_THEME);
|
||||
url += theme + "/";
|
||||
}
|
||||
return url;
|
||||
|
@ -1,5 +1,7 @@
|
||||
package net.i2p.router.web;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/** set the theme */
|
||||
public class ConfigUIHandler extends FormHandler {
|
||||
private boolean _shouldSave;
|
||||
@ -21,12 +23,14 @@ public class ConfigUIHandler extends FormHandler {
|
||||
private void saveChanges() {
|
||||
if (_config == null)
|
||||
return;
|
||||
String oldTheme = _context.getProperty(CSSHelper.PROP_THEME_NAME, CSSHelper.DEFAULT_THEME);
|
||||
Properties props = _context.readConfigFile(CSSHelper.THEME_CONFIG_FILE);
|
||||
String oldTheme = props.getProperty(CSSHelper.PROP_THEME_NAME, CSSHelper.DEFAULT_THEME);
|
||||
boolean ok;
|
||||
if (_config.equals("default")) // obsolete
|
||||
ok = _context.router().saveConfig(CSSHelper.PROP_THEME_NAME, null);
|
||||
props.put(CSSHelper.PROP_THEME_NAME, null);
|
||||
else
|
||||
ok = _context.router().saveConfig(CSSHelper.PROP_THEME_NAME, _config);
|
||||
props.put(CSSHelper.PROP_THEME_NAME, _config);
|
||||
ok = _context.writeConfigFile("themes.config", props);
|
||||
if (ok) {
|
||||
if (!oldTheme.equals(_config))
|
||||
addFormNotice(_("Theme change saved.") +
|
||||
|
@ -9,7 +9,7 @@ public class ConfigUIHelper extends HelperBase {
|
||||
|
||||
public String getSettings() {
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
String current = _context.getProperty(CSSHelper.PROP_THEME_NAME, CSSHelper.DEFAULT_THEME);
|
||||
String current = _context.readConfigFile(CSSHelper.THEME_CONFIG_FILE).getProperty(CSSHelper.PROP_THEME_NAME, CSSHelper.DEFAULT_THEME);
|
||||
Set<String> themes = themeSet();
|
||||
for (String theme : themes) {
|
||||
buf.append("<input type=\"radio\" class=\"optbox\" name=\"theme\" ");
|
||||
|
Reference in New Issue
Block a user