forked from I2P_Developers/i2p.i2p
When fetching a theme, if theme config key is not found, write out the default
This is required in order to get the theme config keys of the various apps into themes.config; this way, the routerconsole requires no knowledge of what apps support universal theming, and can just blanket apply themes to all known keys.
This commit is contained in:
@ -289,7 +289,14 @@ public class SnarkManager implements Snark.CompleteListener {
|
||||
if (!_config.containsKey(PROP_STARTUP_DELAY))
|
||||
_config.setProperty(PROP_STARTUP_DELAY, Integer.toString(DEFAULT_STARTUP_DELAY));
|
||||
// Fetch theme
|
||||
_theme = _context.readConfigFile(THEME_CONFIG_FILE).getProperty(PROP_THEME, DEFAULT_THEME);
|
||||
Properties themeProps = _context.readConfigFile(THEME_CONFIG_FILE);
|
||||
_theme = themeProps.getProperty(PROP_THEME);
|
||||
// Ensure that theme config line exists in config file
|
||||
if (_theme == null) {
|
||||
_theme = DEFAULT_THEME;
|
||||
themeProps.put(PROP_THEME, _theme);
|
||||
_context.writeConfigFile(THEME_CONFIG_FILE, themeProps);
|
||||
}
|
||||
updateConfig();
|
||||
}
|
||||
/**
|
||||
|
@ -29,16 +29,17 @@ public class ConfigUIHandler extends FormHandler {
|
||||
return;
|
||||
Properties props = _context.readConfigFile(CSSHelper.THEME_CONFIG_FILE);
|
||||
String oldTheme = props.getProperty(CSSHelper.PROP_THEME_NAME, CSSHelper.DEFAULT_THEME);
|
||||
// Save routerconsole theme first to ensure it is in config file
|
||||
if (_config.equals("default")) // obsolete
|
||||
props.put(CSSHelper.PROP_THEME_NAME, null);
|
||||
else
|
||||
props.put(CSSHelper.PROP_THEME_NAME, _config);
|
||||
if (_universalTheming) {
|
||||
// The routerconsole theme gets set again, but oh well
|
||||
for (Iterator it = props.keySet().iterator(); it.hasNext();) {
|
||||
String key = (String) it.next();
|
||||
props.put(key, _config);
|
||||
}
|
||||
} else {
|
||||
if (_config.equals("default")) // obsolete
|
||||
props.put(CSSHelper.PROP_THEME_NAME, null);
|
||||
else
|
||||
props.put(CSSHelper.PROP_THEME_NAME, _config);
|
||||
}
|
||||
boolean ok = _context.writeConfigFile(CSSHelper.THEME_CONFIG_FILE, props);
|
||||
if (ok) {
|
||||
|
@ -47,7 +47,14 @@ public class BaseBean
|
||||
if( properties.getProperty(PRIVATE_BOOK) == null)
|
||||
properties.setProperty(PRIVATE_BOOK, DEFAULT_PRIVATE_BOOK);
|
||||
// Fetch theme
|
||||
_theme = _context.readConfigFile(THEME_CONFIG_FILE).getProperty(PROP_THEME_NAME, DEFAULT_THEME);
|
||||
Properties themeProps = _context.readConfigFile(THEME_CONFIG_FILE);
|
||||
_theme = themeProps.getProperty(PROP_THEME_NAME);
|
||||
// Ensure that theme config line exists in config file
|
||||
if (_theme == null) {
|
||||
_theme = DEFAULT_THEME;
|
||||
themeProps.put(PROP_THEME_NAME, _theme);
|
||||
_context.writeConfigFile(THEME_CONFIG_FILE, themeProps);
|
||||
}
|
||||
configLastLoaded = currentTime;
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
@ -49,6 +49,7 @@ import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@ -1190,6 +1191,15 @@ public class WebMail extends HttpServlet
|
||||
private void processRequest( HttpServletRequest httpRequest, HttpServletResponse response )
|
||||
throws IOException, ServletException
|
||||
{
|
||||
Properties themeProps = I2PAppContext.getGlobalContext().readConfigFile(THEME_CONFIG_FILE);
|
||||
String theme = themeProps.getProperty(PROP_THEME);
|
||||
// Ensure that theme config line exists in config file
|
||||
if (theme == null) {
|
||||
theme = DEFAULT_THEME;
|
||||
themeProps.put(PROP_THEME, theme);
|
||||
I2PAppContext.getGlobalContext().writeConfigFile(THEME_CONFIG_FILE, themeProps);
|
||||
}
|
||||
|
||||
httpRequest.setCharacterEncoding("UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setHeader("X-Frame-Options", "SAMEORIGIN");
|
||||
@ -1209,7 +1219,7 @@ public class WebMail extends HttpServlet
|
||||
sessionObject.info = "";
|
||||
sessionObject.pageChanged = false;
|
||||
sessionObject.showAttachment = null;
|
||||
sessionObject.themePath = "/themes/susimail/" + I2PAppContext.getGlobalContext().readConfigFile(THEME_CONFIG_FILE).getProperty(PROP_THEME, DEFAULT_THEME) + '/';
|
||||
sessionObject.themePath = "/themes/susimail/" + theme + '/';
|
||||
sessionObject.imgPath = sessionObject.themePath + "images/";
|
||||
|
||||
processStateChangeButtons( sessionObject, request );
|
||||
|
Reference in New Issue
Block a user