diff --git a/crates/iz-web/src/layout.rs b/crates/iz-web/src/layout.rs
index 4aae81c..72b6d36 100644
--- a/crates/iz-web/src/layout.rs
+++ b/crates/iz-web/src/layout.rs
@@ -136,7 +136,9 @@ pub(crate) async fn avatar_script(cx: &Cx) -> Result {
/// The topbar's signed-in identity: the display name, opening on hover or
/// focus onto details (name, address, role) and sign-out. Shared by every
-/// signed-in page's topbar.
+/// signed-in page's topbar — which is why `avatar_script` rides along here:
+/// every page with avatars has this menu, and the script's guard makes the
+/// one emission enough no matter how many avatars the page carries.
pub async fn user_menu(cx: &Cx, me: &crate::detail::Me, lang: Lang) -> Result {
let role_key = match me.role {
iz_core::Role::Admin => Key::RoleAdminOption,
@@ -159,6 +161,7 @@ pub async fn user_menu(cx: &Cx, me: &crate::detail::Me, lang: Lang) -> Result {
+ (avatar_script(cx).await?)
}
}
diff --git a/crates/iz-web/src/people.rs b/crates/iz-web/src/people.rs
index 3bc3750..c0f0813 100644
--- a/crates/iz-web/src/people.rs
+++ b/crates/iz-web/src/people.rs
@@ -198,6 +198,5 @@ async fn people_page(cx: &Cx) -> Result {
(crate::layout::escape_script(cx).await?)
(crate::detail::escape_closes(cx).await?)
- (crate::layout::avatar_script(cx).await?)
}
}
diff --git a/crates/iz-web/src/settings.rs b/crates/iz-web/src/settings.rs
index a6ba29a..d633ac6 100644
--- a/crates/iz-web/src/settings.rs
+++ b/crates/iz-web/src/settings.rs
@@ -1647,6 +1647,5 @@ async fn settings_page(cx: &Cx) -> Result {
(crate::dropdown::dropdown_script(cx).await?)
(crate::layout::escape_script(cx).await?)
(crate::detail::escape_closes(cx).await?)
- (crate::layout::avatar_script(cx).await?)
}
}
diff --git a/crates/iz-web/tests/http.rs b/crates/iz-web/tests/http.rs
index 5e45d83..2de5916 100644
--- a/crates/iz-web/tests/http.rs
+++ b/crates/iz-web/tests/http.rs
@@ -3668,6 +3668,72 @@ async fn the_viewer_renders_in_page_for_a_renderable_file_and_ignores_a_foreign_
assert!(!String::from_utf8_lossy(&missing_page.bytes).contains("viewer-body"));
}
+/// The PDF reader is the one viewer with a presentation mode: its overlay
+/// carries the Present control and the delegated listener that answers it,
+/// while an image's overlay carries neither.
+#[tokio::test]
+async fn the_pdf_viewer_offers_presentation_mode_and_other_viewers_do_not() {
+ let app = App::open().await;
+ let admin_cookie = admin(&app).await;
+ let column = first_column(&app).await;
+ let task = a_task(&app, &admin_cookie, &column, "Present me").await;
+
+ let pdf = b"%PDF-1.4 nothing to see".to_vec();
+ app.post_multipart(
+ "/files",
+ Some(&admin_cookie),
+ &[("task_id", &task)],
+ Some(("deck.pdf", "application/pdf", &pdf)),
+ )
+ .await;
+ let snapshot = app
+ .post(
+ "/api/fetch_task",
+ Some(&admin_cookie),
+ &[("task_id", &task)],
+ )
+ .await;
+ let pdf_id = attachment_id_named(&snapshot.body, "deck.pdf");
+
+ let page = app
+ .get(&format!("/?task={task}&file={pdf_id}"), Some(&admin_cookie))
+ .await;
+ let html = String::from_utf8_lossy(&page.bytes);
+ assert!(
+ html.contains("viewer-present"),
+ "no Present control on a PDF: {html}"
+ );
+ assert!(
+ html.contains("requestFullscreen"),
+ "no presentation wiring on a PDF: {html}"
+ );
+
+ let png = [0x89u8, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 1, 2, 3, 4];
+ app.post_multipart(
+ "/files",
+ Some(&admin_cookie),
+ &[("task_id", &task)],
+ Some(("spec.png", "image/png", &png)),
+ )
+ .await;
+ let snapshot = app
+ .post(
+ "/api/fetch_task",
+ Some(&admin_cookie),
+ &[("task_id", &task)],
+ )
+ .await;
+ let png_id = attachment_id_named(&snapshot.body, "spec.png");
+ let page = app
+ .get(&format!("/?task={task}&file={png_id}"), Some(&admin_cookie))
+ .await;
+ let html = String::from_utf8_lossy(&page.bytes);
+ assert!(
+ !html.contains("viewer-present"),
+ "an image got the PDF's Present control: {html}"
+ );
+}
+
/// A file is opened from a section, so closing it lands back on that section:
/// the close links carry the tab the viewer was opened over, not the panel's
/// default.
@@ -5122,6 +5188,28 @@ async fn the_avatar_is_not_found_without_an_im_photo() {
.await;
assert_eq!(photo.status, StatusCode::NOT_FOUND);
}
+
+/// Every page with avatars carries the fallback script: the board's topbar
+/// and card faces are `
`s to 404s without it, and a bare failed `
`
+/// is the broken-image box, not the initials. Catches a page that renders
+/// `avatar()` without the behavior that hides the failure.
+#[tokio::test]
+async fn the_board_carries_the_avatar_fallback_script() {
+ let app = App::open().await;
+ let admin = admin(&app).await;
+
+ let page = app.get("/", Some(&admin)).await;
+ assert_eq!(page.status.as_u16(), 200);
+ let html = String::from_utf8(page.bytes).unwrap();
+ assert!(
+ html.contains("avatar-photo"),
+ "the topbar face is not on the board: {html}"
+ );
+ assert!(
+ html.contains("__izAvatar"),
+ "avatars without the fallback script show the broken-image box: {html}"
+ );
+}
/// Polls the store until a `Rule` send for `rule_id` addressed to `recipient`
/// exists beyond the `already` count — the engine runs off the request in a
/// spawned task, so the row is not there yet when the triggering call