The logo beside the add-feed button, with the version on hover (#60)
The logo sat at the top of the feed list with "iPX" written beside it, and the page showed the version nowhere. It is now in the top bar just before the feed buttons, alone, and its tooltip names the app and its version. The version is filled in by the server as it sends the page, not by build.mjs: build.rs reruns only when web/ or package-lock.json changes, so a release that bumped only Cargo.toml would have kept the page naming the one before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
12
src/web.rs
12
src/web.rs
@@ -610,6 +610,9 @@ fn constant_time_eq(a: &str, b: &str) -> bool {
|
||||
// quotes, so ADMIN_LINK and HTML_TAG are spelled the way the minifier leaves them.
|
||||
const INDEX: &str = include_str!(concat!(env!("OUT_DIR"), "/index.html"));
|
||||
const ADMIN_LINK: &str = "<a id=admin ";
|
||||
// The logo's tooltip. Filled in here, not by build.mjs, because build.rs does not rerun when only
|
||||
// Cargo.toml's version changes, and the page would go on naming the last release.
|
||||
const VERSION_SLOT: &str = "iPX {version}";
|
||||
|
||||
/// The page, with the log button left out for anyone but an admin. Hiding it from the page's
|
||||
/// script instead showed it for a moment on every load, until /api/me answered.
|
||||
@@ -624,7 +627,7 @@ const HTML_TAG: &str = "<html lang=en>";
|
||||
/// are an admin. Not hidden for everyone else but left out: hiding it from the page's script
|
||||
/// showed it for a moment on every load, until /api/me answered (issue #29).
|
||||
fn page_for(admin: bool, theme: (Option<String>, Option<String>)) -> String {
|
||||
let mut page = with_theme(INDEX, theme);
|
||||
let mut page = with_theme(INDEX, theme).replacen(VERSION_SLOT, concat!("iPX ", env!("CARGO_PKG_VERSION")), 1);
|
||||
if !admin
|
||||
&& let Some(at) = page.find(ADMIN_LINK)
|
||||
&& let Some(len) = page[at..].find("</a>")
|
||||
@@ -1002,6 +1005,13 @@ mod tests {
|
||||
assert!(page.contains("id=prefs"), "and only the link: the settings button beside it stays");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_logo_names_the_version() {
|
||||
// If the minifier drifts from VERSION_SLOT, replacen matches nothing and says nothing.
|
||||
let page = page_for(false, (None, None));
|
||||
assert!(!page.contains(VERSION_SLOT) && page.contains(concat!("iPX ", env!("CARGO_PKG_VERSION"))));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_page_arrives_in_the_theme_the_account_chose() {
|
||||
let page = |t: &str, m: &str| page_for(true, (Some(t.into()), Some(m.into())));
|
||||
|
||||
Reference in New Issue
Block a user