forked from I2P_Developers/i2p.i2p
Console: Prep for removing themes (ticket #2272)
This commit is contained in:
@ -31,6 +31,9 @@ public class CSSHelper extends HelperBase {
|
||||
public static final String PROP_FORCE_MOBILE_CONSOLE = "routerconsole.forceMobileConsole";
|
||||
/** @since 0.9.32 */
|
||||
public static final String PROP_EMBED_APPS = "routerconsole.embedApps";
|
||||
/** @since 0.9.36 */
|
||||
public static final String PROP_DISABLE_OLD = "routerconsole.disableOldThemes";
|
||||
public static final boolean DEFAULT_DISABLE_OLD = false;
|
||||
|
||||
private static final String _consoleNonce = Long.toString(RandomSource.getInstance().nextLong());
|
||||
|
||||
@ -44,13 +47,22 @@ public class CSSHelper extends HelperBase {
|
||||
|
||||
public String getTheme(String userAgent) {
|
||||
String url = BASE_THEME_PATH;
|
||||
if (userAgent != null && (userAgent.contains("MSIE") && !userAgent.contains("Trident/6"))) {
|
||||
if (userAgent != null && userAgent.contains("MSIE") && !userAgent.contains("Trident/6") &&
|
||||
!_context.getProperty(PROP_DISABLE_OLD, DEFAULT_DISABLE_OLD)) {
|
||||
url += FORCE + "/";
|
||||
} else {
|
||||
// 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);
|
||||
// remap deprecated themes
|
||||
if (theme.equals("midnight")) {
|
||||
if (_context.getProperty(PROP_DISABLE_OLD, DEFAULT_DISABLE_OLD))
|
||||
theme = "dark";
|
||||
} else if (theme.equals("classic")) {
|
||||
if (_context.getProperty(PROP_DISABLE_OLD, DEFAULT_DISABLE_OLD))
|
||||
theme = "light";
|
||||
}
|
||||
url += theme + "/";
|
||||
}
|
||||
return url;
|
||||
|
@ -11,12 +11,23 @@ import net.i2p.router.web.HelperBase;
|
||||
import net.i2p.router.web.Messages;
|
||||
import net.i2p.router.web.RouterConsoleRunner;
|
||||
|
||||
/**
|
||||
* Helper for /configui
|
||||
*/
|
||||
public class ConfigUIHelper extends HelperBase {
|
||||
|
||||
public String getSettings() {
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append("<div id=\"availablethemes\">");
|
||||
String current = _context.getProperty(CSSHelper.PROP_THEME_NAME, CSSHelper.DEFAULT_THEME);
|
||||
// remap deprecated themes
|
||||
if (current.equals("midnight")) {
|
||||
if (_context.getProperty(CSSHelper.PROP_DISABLE_OLD, CSSHelper.DEFAULT_DISABLE_OLD))
|
||||
current = "dark";
|
||||
} else if (current.equals("classic")) {
|
||||
if (_context.getProperty(CSSHelper.PROP_DISABLE_OLD, CSSHelper.DEFAULT_DISABLE_OLD))
|
||||
current = "light";
|
||||
}
|
||||
Set<String> themes = themeSet();
|
||||
for (String theme : themes) {
|
||||
buf.append("<label for=\"").append(theme).append("\"><div class=\"themechoice\">" +
|
||||
@ -71,10 +82,16 @@ public class ConfigUIHelper extends HelperBase {
|
||||
File[] files = dir.listFiles();
|
||||
if (files == null)
|
||||
return rv;
|
||||
boolean skipOld = _context.getProperty(CSSHelper.PROP_DISABLE_OLD, CSSHelper.DEFAULT_DISABLE_OLD);
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
if (!files[i].isDirectory())
|
||||
continue;
|
||||
String name = files[i].getName();
|
||||
if (files[i].isDirectory() && ! name.equals("images"))
|
||||
rv.add(name);
|
||||
if (name.equals("images"))
|
||||
continue;
|
||||
if (skipOld && (name.equals("midnight") || name.equals("classic")))
|
||||
continue;
|
||||
rv.add(name);
|
||||
}
|
||||
// user themes
|
||||
Set<String> props = _context.getPropertyNames();
|
||||
|
Reference in New Issue
Block a user