support plugin themes

This commit is contained in:
zzz
2010-02-26 16:58:01 +00:00
parent 7b70210c9a
commit b4911a2b2f
3 changed files with 75 additions and 11 deletions

View File

@ -20,7 +20,29 @@ if (uri.endsWith(".css")) {
response.setContentType("image/x-icon");
}
response.setHeader("Cache-Control", "max-age=86400"); // cache for a day
String base = net.i2p.I2PAppContext.getGlobalContext().getBaseDir().getAbsolutePath() +
/*
* User or plugin themes
* If the request is for /themes/console/foo/bar/baz,
* and the property routerconsole.theme.foo=/path/to/foo,
* get the file from /path/to/foo/bar/baz
*/
String themePath = null;
final String PFX = "/themes/console/";
if (uri.startsWith(PFX) && uri.length() > PFX.length() + 1) {
String theme = uri.substring(PFX.length());
int slash = theme.indexOf('/');
if (slash > 0) {
theme = theme.substring(0, slash);
themePath = net.i2p.I2PAppContext.getGlobalContext().getProperty("routerconsole.theme." + theme);
if (themePath != null)
uri = uri.substring(PFX.length() + theme.length()); // /bar/baz
}
}
String base;
if (themePath != null)
base = themePath;
else
base = net.i2p.I2PAppContext.getGlobalContext().getBaseDir().getAbsolutePath() +
java.io.File.separatorChar + "docs";
net.i2p.util.FileUtil.readFile(uri, base, response.getOutputStream());
%>