Console: Move flag overrides to war
@@ -12,8 +12,8 @@
|
||||
* with headers set so the browser caches.
|
||||
*
|
||||
* As of 0.9.36:
|
||||
* All new and changed flags must go in the flags16x11/ dir,
|
||||
* which will be checked first by flags.jsp.
|
||||
* All new and changed flags must go in the ../resources/docs/icons/flags16x11/ dir,
|
||||
* which is copied into the war and will be checked first by flags.jsp.
|
||||
* The flags/ dir is the original set from famfamfam,
|
||||
* which may be symlinked in package installs.
|
||||
*
|
||||
@@ -23,44 +23,54 @@ if (c != null &&
|
||||
(c.length() == 2 || c.length() == 7) &&
|
||||
c.replaceAll("[a-z0-9_]", "").length() == 0) {
|
||||
String flagSet = "flags16x11";
|
||||
String s = request.getParameter("s");
|
||||
|
||||
String base = net.i2p.I2PAppContext.getGlobalContext().getBaseDir().getAbsolutePath() +
|
||||
java.io.File ffile;
|
||||
long lastmod;
|
||||
java.io.InputStream fin = flags_jsp.class.getResourceAsStream("/net/i2p/router/web/resources/docs/icons/" + flagSet + '/' + c + ".png");
|
||||
if (fin != null) {
|
||||
// found in the war
|
||||
java.io.File war = new java.io.File(net.i2p.I2PAppContext.getGlobalContext().getBaseDir(), "webapps/routerconsole.war");
|
||||
ffile = null;
|
||||
lastmod = war.lastModified();
|
||||
} else {
|
||||
// fallback to flags dir, which will be symlinked to /usr/share/flags/countries/16x11 for package builds
|
||||
String base = net.i2p.I2PAppContext.getGlobalContext().getBaseDir().getAbsolutePath() +
|
||||
java.io.File.separatorChar +
|
||||
"docs" + java.io.File.separatorChar + "icons";
|
||||
String file = flagSet + java.io.File.separatorChar + c + ".png";
|
||||
java.io.File ffile = new java.io.File(base, file);
|
||||
if (!ffile.exists()) {
|
||||
// fallback to flags dir, which will be symlinked to /usr/share/flags/countries/16x11 for package builds
|
||||
file = "flags" + java.io.File.separatorChar + c + ".png";
|
||||
String file = "flags" + java.io.File.separatorChar + c + ".png";
|
||||
ffile = new java.io.File(base, file);
|
||||
long length = ffile.length();
|
||||
if (length <= 0) {
|
||||
response.sendError(403, "Flag not found");
|
||||
return;
|
||||
}
|
||||
response.setHeader("Content-Length", Long.toString(length));
|
||||
lastmod = ffile.lastModified();
|
||||
}
|
||||
long lastmod = ffile.lastModified();
|
||||
if (lastmod > 0) {
|
||||
long iflast = request.getDateHeader("If-Modified-Since");
|
||||
// iflast is -1 if not present; round down file time
|
||||
if (iflast >= ((lastmod / 1000) * 1000)) {
|
||||
response.setStatus(304);
|
||||
if (fin != null)
|
||||
fin.close();
|
||||
return;
|
||||
}
|
||||
response.setDateHeader("Last-Modified", lastmod);
|
||||
// cache for a day
|
||||
response.setDateHeader("Expires", net.i2p.I2PAppContext.getGlobalContext().clock().now() + 86400000l);
|
||||
response.setHeader("Cache-Control", "public, max-age=604800");
|
||||
response.setHeader("X-Content-Type-Options", "nosniff");
|
||||
}
|
||||
long length = ffile.length();
|
||||
if (length > 0)
|
||||
response.setHeader("Content-Length", Long.toString(length));
|
||||
// cache for a day
|
||||
response.setDateHeader("Expires", net.i2p.I2PAppContext.getGlobalContext().clock().now() + 86400000l);
|
||||
response.setHeader("Cache-Control", "public, max-age=604800");
|
||||
response.setHeader("X-Content-Type-Options", "nosniff");
|
||||
response.setContentType("image/png");
|
||||
response.setHeader("Accept-Ranges", "none");
|
||||
java.io.FileInputStream fin = null;
|
||||
java.io.OutputStream cout = response.getOutputStream();
|
||||
try {
|
||||
// flags dir may be a symlink, which readFile will reject
|
||||
// We carefully vetted the "c" value above.
|
||||
//net.i2p.util.FileUtil.readFile(file, base, cout);
|
||||
fin = new java.io.FileInputStream(ffile);
|
||||
if (fin == null)
|
||||
fin = new java.io.FileInputStream(ffile);
|
||||
net.i2p.data.DataHelper.copy(fin, cout);
|
||||
} catch (java.io.IOException ioe) {
|
||||
// prevent 'Committed' IllegalStateException from Jetty
|
||||
|
Before Width: | Height: | Size: 275 B After Width: | Height: | Size: 275 B |
Before Width: | Height: | Size: 143 B After Width: | Height: | Size: 143 B |
Before Width: | Height: | Size: 143 B After Width: | Height: | Size: 143 B |
Before Width: | Height: | Size: 143 B After Width: | Height: | Size: 143 B |
Before Width: | Height: | Size: 545 B After Width: | Height: | Size: 545 B |
Before Width: | Height: | Size: 435 B After Width: | Height: | Size: 435 B |
Before Width: | Height: | Size: 347 B After Width: | Height: | Size: 347 B |
Before Width: | Height: | Size: 697 B After Width: | Height: | Size: 697 B |
Before Width: | Height: | Size: 469 B After Width: | Height: | Size: 469 B |
Before Width: | Height: | Size: 418 B After Width: | Height: | Size: 418 B |
Before Width: | Height: | Size: 413 B After Width: | Height: | Size: 413 B |
Before Width: | Height: | Size: 491 B After Width: | Height: | Size: 491 B |
Before Width: | Height: | Size: 228 B After Width: | Height: | Size: 228 B |
Before Width: | Height: | Size: 418 B After Width: | Height: | Size: 418 B |
Before Width: | Height: | Size: 333 B After Width: | Height: | Size: 333 B |
Before Width: | Height: | Size: 377 B After Width: | Height: | Size: 377 B |
22
build.xml
@@ -1498,7 +1498,7 @@
|
||||
<fileset dir="installer/resources/icons/flags/" includes="az.png cn.png de.png es.png fr.png hu.png id.png ir.png it.png jp.png nl.png pl.png pt.png ro.png ru.png se.png tr.png us.png" />
|
||||
</copy>
|
||||
<copy todir="pkg-temp/docs/icons/flags" >
|
||||
<!-- base flags/ dir only. flags16x11/ dir already copied by prepConsoleDocs target -->
|
||||
<!-- base flags/ dir only. flags16x11/ dir now in the war -->
|
||||
<fileset dir="installer/resources/icons/flags" />
|
||||
</copy>
|
||||
</target>
|
||||
@@ -1650,27 +1650,13 @@
|
||||
<delete dir="./pkg-mavencentral" />
|
||||
</target>
|
||||
|
||||
<!-- initialNews.xml files, GeoIP files, and flag icons -->
|
||||
<target name="prepConsoleDocs" depends="prepConsoleDocUpdates, prepgeoupdate" >
|
||||
<!-- initialNews.xml files and GeoIP files -->
|
||||
<target name="prepConsoleDocs" depends="prepgeoupdate" >
|
||||
<copy todir="pkg-temp/docs/initialNews/">
|
||||
<fileset dir="installer/resources/initialNews/" />
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<!-- flag icons -->
|
||||
<target name="prepConsoleDocUpdates">
|
||||
<copy todir="pkg-temp/docs/" >
|
||||
<!--
|
||||
As of 0.9.36:
|
||||
All new and changed flags must go in the flags16x11/ dir,
|
||||
which will be checked first by flags.jsp.
|
||||
The flags/ dir is the original set from famfamfam,
|
||||
which may be symlinked in package installs.
|
||||
-->
|
||||
<fileset dir="installer/resources/" includes="icons/flags16x11/*" />
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="consoleDocs" depends="deletepkg-temp, prepConsoleDocs">
|
||||
<zip destfile="docs.zip" basedir="pkg-temp" whenempty="fail" />
|
||||
</target>
|
||||
@@ -1790,7 +1776,7 @@
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="prepupdate" depends="build2, prepupdateSmall, prepConsoleDocUpdates, prepCertificates, prep-script-translation, truncatehistory">
|
||||
<target name="prepupdate" depends="build2, prepupdateSmall, prepCertificates, prep-script-translation, truncatehistory">
|
||||
<copy file="build/BOB.jar" todir="pkg-temp/lib/" />
|
||||
<copy file="build/sam.jar" todir="pkg-temp/lib/" />
|
||||
<copy file="build/i2psnark.jar" todir="pkg-temp/lib" />
|
||||
|