- Commit
- fac8f2af7c7d1fba3ffe9bd34343c6c0fa492ecd
- Parent
- 4a4d169c767bed7b13e1d8af19f76cf06a95dfd5
- Author
- Pablo <pablo-pie@riseup.net>
- Date
Improved the accessibility of the gallery
Custum build of stapix for tikz.pablopie.xyz
Improved the accessibility of the gallery
1 files changed, 13 insertions, 18 deletions
| Status | Name | Changes | Insertions | Deletions |
| Modified | src/main.rs | 2 files changed | 13 | 18 |
diff --git a/src/main.rs b/src/main.rs @@ -243,7 +243,7 @@ fn render_gallery( Ok(()) } -fn render_index(pics: &Vec<GalleryEntry>) -> io::Result<()> { +fn render_index(pics: &[GalleryEntry]) -> io::Result<()> { let mut path = PathBuf::from(TARGET_PATH); path.push("index.html"); @@ -273,24 +273,19 @@ fn render_index(pics: &Vec) -> io::Result<()> { const INTRO_MSG: &str = include_str!("html/intro.html"); writeln!(f, "{}", INTRO_MSG)?; - writeln!(f, "<div id=\"gallery\" role=\"feed\">")?; - - for pic in pics { - writeln!(f, "<article class=\"picture-container\">")?; - writeln!( - f, - "<a aria-label=\"{name}\" href=\"./{PAGES_PATH}/{name}.html\">", - name = Escaped(&pic.file_name) - )?; - writeln!( - f, - "<img alt=\"{alt}\" src=\"./{path}\">", - alt = Escaped(&pic.alt), - path = ThumbPath(pic), - )?; - writeln!(f, "</a>\n</article>")?; + // NOTE: see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/feed_role + let n_pics = pics.len(); + writeln!(f, "<div id=\"gallery\" role=\"feed\" aria-busy=\"false\">")?; + for (i, pic) in pics.iter().enumerate() { + writeln!(f, "<article class=\"picture-container\" aria-posinset=\"{i}\" aria-setsize=\"{n_pics}\" aria-label=\"{name}\" aria-description=\"visit the page for {name}\">", + name = Escaped(&pic.file_name))?; + writeln!(f, "<a href=\"./{PAGES_PATH}/{name}.html\">", + name = Escaped(&pic.file_name))?; + writeln!(f, "<img alt=\"{alt}\" src=\"./{path}\">", + alt = Escaped(&pic.alt), path = ThumbPath(pic))?; + writeln!(f, "</a>")?; + writeln!(f, "</article>")?; } - writeln!(f, "</div>")?; const OUTRO_MSG: &str = include_str!("html/outro.html");