Merge "Load fonts directly from Gerrit instead of 3rd party domains" into stable-3.2
diff --git a/BUILD b/BUILD
index 08741ba..6aa6df5 100644
--- a/BUILD
+++ b/BUILD
@@ -26,6 +26,17 @@
outs = ["gitiles-servlet-resources.jar"],
cmd = " && ".join([
"unzip -qd $$TMP $(location @gitiles-servlet//jar) \"com/google/gitiles/static/*\"",
+ "cd $$TMP/com/google/gitiles/static",
+ # To avoid loading 3rd party resources, we adapt gitiles' CSS to
+ # load fonts from Gerrit directly:
+ # 1. Strip out Google font CSS imports
+ "sed -e '\\%^@import .//fonts\\.googleapis\\.com/%d' -i base.css",
+ # 2. Add Gerrit's fonts CSS
+ "sed -e 's%^\\(.*Common styles and definitions.*\\)$$%" +
+ "\\1\\n\\n@import \"../../../styles/fonts.css\";%' -i base.css",
+ # 3. Use Gerrit's Roboto Mono for Source Code Pro
+ "sed -e 's/Source Code Pro/Roboto Mono/g' -i base.css",
+ # Switching from `static` to `+static` (see comment in plugin definiton)
"cd $$TMP/com/google/gitiles",
"mv static +static",
"zip -qr $$ROOT/$@ .",