[fix](trx-frontend-http): vendor DSEG14 font locally to avoid CDN content blockers
Same issue as Leaflet — content blockers block the jsdelivr CDN request, causing the seven-segment font to fail loading and fall back to monospace. Also replace preload-to-stylesheet swap with media="print" onload swap for themes.css and leaflet.css to eliminate Safari preload warnings. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -8,9 +8,9 @@
|
|||||||
<link rel="shortcut icon" href="/favicon.ico?v=5" />
|
<link rel="shortcut icon" href="/favicon.ico?v=5" />
|
||||||
<link rel="apple-touch-icon" sizes="180x180" href="/favicon.png?v=5" />
|
<link rel="apple-touch-icon" sizes="180x180" href="/favicon.png?v=5" />
|
||||||
<link rel="stylesheet" href="/style.css" />
|
<link rel="stylesheet" href="/style.css" />
|
||||||
<link rel="preload" as="style" href="/themes.css" onload="this.onload=null;this.rel='stylesheet'" />
|
<link rel="stylesheet" href="/themes.css" media="print" onload="this.media='all'" />
|
||||||
<noscript><link rel="stylesheet" href="/themes.css" /></noscript>
|
<noscript><link rel="stylesheet" href="/themes.css" /></noscript>
|
||||||
<link rel="preload" as="style" href="/vendor/leaflet.css" onload="this.onload=null;this.rel='stylesheet'" />
|
<link rel="stylesheet" href="/vendor/leaflet.css" media="print" onload="this.media='all'" />
|
||||||
<noscript><link rel="stylesheet" href="/vendor/leaflet.css" /></noscript>
|
<noscript><link rel="stylesheet" href="/vendor/leaflet.css" /></noscript>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -77,7 +77,7 @@
|
|||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
font-display: swap;
|
font-display: swap;
|
||||||
src: url('https://cdn.jsdelivr.net/npm/@fontsource/dseg14-classic/files/dseg14-classic-latin-400-normal.woff2') format('woff2');
|
src: url('/vendor/dseg14-classic-latin-400-normal.woff2') format('woff2');
|
||||||
unicode-range: U+0030-0039, U+002E, U+002D, U+0020, U+002B;
|
unicode-range: U+0030-0039, U+002E, U+002D, U+0020, U+002B;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
Binary file not shown.
@@ -70,6 +70,9 @@ define_gz_cache!(
|
|||||||
define_gz_cache!(gz_vchan_js, status::VCHAN_JS, "vchan.js");
|
define_gz_cache!(gz_vchan_js, status::VCHAN_JS, "vchan.js");
|
||||||
define_gz_cache!(gz_bandplan_json, status::BANDPLAN_JSON, "bandplan.json");
|
define_gz_cache!(gz_bandplan_json, status::BANDPLAN_JSON, "bandplan.json");
|
||||||
|
|
||||||
|
// Vendored DSEG14 Classic font
|
||||||
|
// (binary woff2 — served directly, not through gz_cache)
|
||||||
|
|
||||||
// Vendored Leaflet 1.9.4
|
// Vendored Leaflet 1.9.4
|
||||||
define_gz_cache!(gz_leaflet_js, status::LEAFLET_JS, "leaflet.js");
|
define_gz_cache!(gz_leaflet_js, status::LEAFLET_JS, "leaflet.js");
|
||||||
define_gz_cache!(gz_leaflet_css, status::LEAFLET_CSS, "leaflet.css");
|
define_gz_cache!(gz_leaflet_css, status::LEAFLET_CSS, "leaflet.css");
|
||||||
@@ -378,6 +381,18 @@ pub(crate) async fn bandplan_json(req: HttpRequest) -> impl Responder {
|
|||||||
static_asset_response(&req, "application/json; charset=utf-8", c)
|
static_asset_response(&req, "application/json; charset=utf-8", c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Vendored DSEG14 Classic font
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[get("/vendor/dseg14-classic-latin-400-normal.woff2")]
|
||||||
|
pub(crate) async fn dseg14_classic_woff2() -> impl Responder {
|
||||||
|
HttpResponse::Ok()
|
||||||
|
.insert_header((header::CONTENT_TYPE, "font/woff2"))
|
||||||
|
.insert_header((header::CACHE_CONTROL, "public, max-age=604800, immutable"))
|
||||||
|
.body(status::DSEG14_CLASSIC_WOFF2)
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Vendored Leaflet 1.9.4
|
// Vendored Leaflet 1.9.4
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -667,6 +667,8 @@ pub fn configure(cfg: &mut web::ServiceConfig) {
|
|||||||
.service(assets::background_decode_js)
|
.service(assets::background_decode_js)
|
||||||
.service(assets::vchan_js)
|
.service(assets::vchan_js)
|
||||||
.service(assets::bandplan_json)
|
.service(assets::bandplan_json)
|
||||||
|
// Vendored DSEG14 Classic font
|
||||||
|
.service(assets::dseg14_classic_woff2)
|
||||||
// Vendored Leaflet 1.9.4
|
// Vendored Leaflet 1.9.4
|
||||||
.service(assets::leaflet_js)
|
.service(assets::leaflet_js)
|
||||||
.service(assets::leaflet_css)
|
.service(assets::leaflet_css)
|
||||||
|
|||||||
@@ -35,6 +35,10 @@ pub const BACKGROUND_DECODE_JS: &str = include_str!("../assets/web/plugins/backg
|
|||||||
pub const VCHAN_JS: &str = include_str!("../assets/web/plugins/vchan.js");
|
pub const VCHAN_JS: &str = include_str!("../assets/web/plugins/vchan.js");
|
||||||
pub const BANDPLAN_JSON: &str = include_str!("../assets/web/bandplan.json");
|
pub const BANDPLAN_JSON: &str = include_str!("../assets/web/bandplan.json");
|
||||||
|
|
||||||
|
// Vendored DSEG14 Classic font
|
||||||
|
pub const DSEG14_CLASSIC_WOFF2: &[u8] =
|
||||||
|
include_bytes!("../assets/web/vendor/dseg14-classic-latin-400-normal.woff2");
|
||||||
|
|
||||||
// Vendored Leaflet 1.9.4
|
// Vendored Leaflet 1.9.4
|
||||||
pub const LEAFLET_JS: &str = include_str!("../assets/web/vendor/leaflet.js");
|
pub const LEAFLET_JS: &str = include_str!("../assets/web/vendor/leaflet.js");
|
||||||
pub const LEAFLET_CSS: &str = include_str!("../assets/web/vendor/leaflet.css");
|
pub const LEAFLET_CSS: &str = include_str!("../assets/web/vendor/leaflet.css");
|
||||||
|
|||||||
Reference in New Issue
Block a user