Skip to content

Commit 1db0868

Browse files
committed
Update tabler icons to version 3.35 and refactor icon extraction logic for improved performance
1 parent 52e11df commit 1db0868

2 files changed

Lines changed: 18 additions & 21 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- When SQLPage is deployed behind a reverse proxy, compressing responses between sqlpage and the proxy is wasteful.
1010
- In the table component, allow simple objects in custom_actions instead of requiring arrays of objects.
1111
- Fatser icon loading. Previously, even a page containing a single icon required downloading and parsing a ~2MB file. This resulted in a delay where pages initially appeared with a blank space before icons appeared. Icons are now inlined inside pages and appear instantaneously.
12+
- Updated tabler icons to 3.35
1213

1314
## v0.39.0 (2025-10-28)
1415
- Ability to execute sql for URL paths with another extension. If you create sitemap.xml.sql, it will be executed for example.com/sitemap.xml

build.rs

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async fn main() {
2424
spawn(download_deps(c.clone(), "sqlpage.css")),
2525
spawn(download_tabler_icons(
2626
c.clone(),
27-
"https://cdn.jsdelivr.net/npm/@tabler/icons-sprite@3.34.0/dist/tabler-sprite.svg",
27+
"https://cdn.jsdelivr.net/npm/@tabler/icons-sprite@3.35.0/dist/tabler-sprite.svg",
2828
)),
2929
spawn(download_deps(c.clone(), "apexcharts.js")),
3030
spawn(download_deps(c.clone(), "tomselect.js")),
@@ -189,31 +189,30 @@ async fn download_tabler_icons(client: Rc<awc::Client>, sprite_url: &str) {
189189

190190
fn generate_icons_rs(icon_map_path: &Path, cached_sprite_path: &Path) {
191191
let sprite_content = std::fs::read_to_string(cached_sprite_path).unwrap();
192-
let icons = extract_icons_from_sprite(&sprite_content);
193192
let mut file = File::create(icon_map_path).unwrap();
194193

195-
writeln!(file, "#[allow(clippy::all)]").unwrap();
196-
writeln!(file, "use std::collections::HashMap;").unwrap();
197-
writeln!(file, "use std::sync::LazyLock;").unwrap();
198-
writeln!(file).unwrap();
199194
writeln!(
200195
file,
201-
"pub static ICON_MAP: LazyLock<HashMap<String, &'static str>> = LazyLock::new(|| {{"
196+
"#[allow(clippy::all)]
197+
use std::collections::HashMap;
198+
use std::sync::LazyLock;
199+
"
202200
)
203201
.unwrap();
204-
writeln!(file, " let mut m = HashMap::new();").unwrap();
205-
206-
for (name, content) in icons {
207-
writeln!(file, " m.insert({:?}.to_string(), r#\"{}\"#);", name, content).unwrap();
208-
}
202+
writeln!(
203+
file,
204+
"pub static ICON_MAP: LazyLock<HashMap<&'static str, &'static str>> = LazyLock::new(|| {{"
205+
)
206+
.unwrap();
207+
writeln!(file, "let mut m = HashMap::new();").unwrap();
209208

210-
writeln!(file, " m").unwrap();
211-
writeln!(file, "}});").unwrap();
209+
extract_icons_from_sprite(&sprite_content, |name, content| {
210+
writeln!(file, "m.insert({name:?}, r#\"{content}\"#);").unwrap();
211+
});
212+
writeln!(file, "m}});").unwrap();
212213
}
213214

214-
fn extract_icons_from_sprite(sprite_content: &str) -> Vec<(String, String)> {
215-
let mut icons = Vec::new();
216-
215+
fn extract_icons_from_sprite(sprite_content: &str, mut callback: impl FnMut(&str, &str)) {
217216
let mut pos = 0;
218217
while let Some(symbol_start) = sprite_content[pos..].find("<symbol") {
219218
let symbol_start = pos + symbol_start;
@@ -233,14 +232,11 @@ fn extract_icons_from_sprite(sprite_content: &str) -> Vec<(String, String)> {
233232
let content_end = symbol_tag.rfind("</symbol>").unwrap();
234233
let inner_content = symbol_tag[content_start..content_end].trim();
235234

236-
icons.push((icon_name.to_string(), inner_content.to_string()));
235+
callback(icon_name, inner_content);
237236
}
238237
}
239-
240238
pos = symbol_end;
241239
}
242-
243-
icons
244240
}
245241

246242
/// On debian-based linux distributions, odbc drivers are installed in /usr/lib/<target>-linux-gnu/odbc

0 commit comments

Comments
 (0)