1 file changed, +14, -21
9cfca65Make the whole text of symlink and submodule rows the link
author
mogi <git@paramogi.world> on 20-11-2026 00:46 UTC
committer
mogi <git@paramogi.world> on 20-11-2026 00:46 UTC
parentad21f82
src/html.rs
+14, -21
+14, -21
        @@ -1445,31 +1445,24 @@ fn write_listing(
14451445     for entry in &folder.entries {
14461446         let name = &entry.name;
14471447         let link =
1448    -            |href: String| format!("<a href=\"{}\">{}</a>", escape_str(&href), escape_str(name));
1449    -        let leads = || {
1450    -            path_href(git_ref, repo_root, &join_path(&folder.path, name))
1451    -                .map_or_else(|| escape_str(name), link)
1452    -        };
    1448+            |href: String, text: String| format!("<a href=\"{}\">{text}</a>", escape_str(&href));
    1449+        let leads =
    1450+            |text: String| match path_href(git_ref, repo_root, &join_path(&folder.path, name)) {
    1451+                Some(href) => link(href, text),
    1452+                None => format!("<span>{text}</span>"),
    1453+            };
14531454         let (icon, name) = if entry.is_dir {
1454    -            (
1455    -                FOLDER_ICON,
1456    -                link(percent_encode(&format!("{tree_dir}{name}/index.html"))),
1457    -            )
    1455+            let href = percent_encode(&format!("{tree_dir}{name}/index.html"));
    1456+            (FOLDER_ICON, link(href, escape_str(name)))
14581457         } else if let Some(target) = &entry.link {
1459    -            (
1460    -                SYMLINK_ICON,
1461    -                format!("<span>{} &rarr; {}</span>", leads(), escape_str(target)),
1462    -            )
    1458+            let text = format!("{} &rarr; {}", escape_str(name), escape_str(target));
    1459+            (SYMLINK_ICON, leads(text))
14631460         } else if let Some(commit) = &entry.commit {
1464    -            (
1465    -                SUBMODULE_ICON,
1466    -                format!("<span>{} @ {}</span>", leads(), &commit[..7]),
1467    -            )
    1461+            let text = format!("{} @ {}", escape_str(name), &commit[..7]);
    1462+            (SUBMODULE_ICON, leads(text))
14681463         } else {
1469    -            (
1470    -                FILE_ICON,
1471    -                link(percent_encode(&format!("{blob_dir}{name}.html"))),
1472    -            )
    1464+            let href = percent_encode(&format!("{blob_dir}{name}.html"));
    1465+            (FILE_ICON, link(href, escape_str(name)))
14731466         };
14741467         body.push_str(&format!(
14751468             "\