Skip to content

Commit

Permalink
CLDR-17270 st: don't use late cache busting for bundle.js
Browse files Browse the repository at this point in the history
- spotless
  • Loading branch information
srl295 committed Feb 2, 2024
1 parent ceef05b commit 261ff29
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyTool.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package org.unicode.cldr.web;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletConfig;
Expand All @@ -19,9 +20,6 @@
import org.unicode.cldr.util.CLDRURLS;
import org.unicode.cldr.util.CldrUtility;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class SurveyTool extends HttpServlet {
static final Logger logger = SurveyLog.forClass(SurveyTool.class);

Expand Down Expand Up @@ -250,7 +248,7 @@ public static void includeMonitoring(Writer out) throws IOException {
}
}

static private final Gson gson = new GsonBuilder().setPrettyPrinting().create();
private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();

private final class STManifest {
public String jsfiles[];
Expand All @@ -271,19 +269,23 @@ public static void includeJavaScript(HttpServletRequest request, Writer out)
// use WebPack-built manifest.json to include all chunks.
// ideally this would all come from a static .html file built by WebPack.
// TODO https://unicode-org.atlassian.net/browse/CLDR-17353
try (final InputStream is = request.getServletContext().getResourceAsStream("dist/manifest.json");
final Reader r = new InputStreamReader(is, StandardCharsets.UTF_8);) {
for(final String f : gson.fromJson(r, STManifest.class).jsfiles) {
out.write("<script src=\"" + request.getContextPath() + "/dist/" + f.toString() + "\"></script>\n");
}
try (final InputStream is =
request.getServletContext().getResourceAsStream("dist/manifest.json");
final Reader r = new InputStreamReader(is, StandardCharsets.UTF_8); ) {
for (final String f : gson.fromJson(r, STManifest.class).jsfiles) {
out.write(
"<script src=\""
+ request.getContextPath()
+ "/dist/"
+ f.toString()
+ "\"></script>\n");
}
}

includeJqueryJavaScript(request, out);
includeCldrJavaScript(request, out);
}



private static void includeJqueryJavaScript(HttpServletRequest request, Writer out)
throws IOException {
// Per https://en.wikipedia.org/wiki/JQuery#Release_history --
Expand Down

0 comments on commit 261ff29

Please sign in to comment.