1 file changed, +13, -3
a883a5dJoin the README and LICENSE buttons and mark the current one
src/html.rs
+13, -3
+13, -3
@@ -105,6 +105,7 @@ struct RepoNav<'a> {
105105 git_ref: &'a str,
106106 tab: Tab,
107107 depth: usize,
108+ path: &'a str,
108109 }
109110
110111 fn crumb(text: &str, href: Option<String>) -> String {
@@ -185,7 +186,12 @@ fn file_links(nav: &RepoNav, repo_root: &str) -> Vec<String> {
185186 .filter_map(|(label, names)| {
186187 let entry = repo_file(root, names)?;
187188 let href = percent_encode(&format!("blob/{}/{}.html", nav.git_ref, entry.name));
188 - Some(format!("<a href=\"{repo_root}{href}\">{label}</a>"))
189+ let class = if entry.name == nav.path {
190+ " class=\"btn-active\""
191+ } else {
192+ ""
193+ };
194+ Some(format!("<a{class} href=\"{repo_root}{href}\">{label}</a>"))
189195 })
190196 .collect()
191197 }
@@ -276,7 +282,7 @@ fn wrap_page(title: &str, nav: Option<&RepoNav>, body: &str) -> String {
276282 let files = file_links(nav, &repo_root);
277283 if !files.is_empty() {
278284 page.push_str(&format!(
279 - "<nav class=\"navs flex gap-2\">\n{}\n</nav>\n",
285+ "<nav class=\"navs buttons flex\">\n{}\n</nav>\n",
280286 files.join("\n")
281287 ));
282288 }
@@ -343,6 +349,7 @@ pub fn gen_summary(repo: &RepoInfo) -> String {
343349 git_ref: &repo.head_dir,
344350 tab: Tab::Summary,
345351 depth: 0,
352+ path: "",
346353 };
347354 let last_change = repo
348355 .commit_list
@@ -422,6 +429,7 @@ fn gen_refs(repo: &RepoInfo, tab: Tab, refs: &[RefInfo]) -> String {
422429 git_ref: &repo.head_dir,
423430 tab,
424431 depth: 0,
432+ path: "",
425433 };
426434
427435 let mut body = String::from("<div class=\"box mt-0 p-0\">\n");
@@ -449,6 +457,7 @@ pub fn gen_tree(repo: &RepoInfo, git_ref: &RefInfo, folder: &Folder) -> String {
449457 git_ref: &git_ref.dir,
450458 tab: Tab::Tree,
451459 depth,
460+ path: "",
452461 };
453462 let repo_root = "../".repeat(depth);
454463 let blob_dir = format!("{repo_root}blob/{tree_path}/");
@@ -472,14 +481,15 @@ pub fn gen_blob(
472481 source: bool,
473482 ) -> String {
474483 let depth = 1 + join_path(&git_ref.dir, &folder.path).split('/').count();
484+ let path = join_path(&folder.path, &entry.name);
475485 let nav = RepoNav {
476486 repo,
477487 git_ref: &git_ref.dir,
478488 tab: Tab::Tree,
479489 depth,
490+ path: &path,
480491 };
481492 let repo_root = "../".repeat(depth);
482 - let path = join_path(&folder.path, &entry.name);
483493 let mut details = String::from("<div class=\"ml-auto flex items-center gap\">\n");
484494 if has_source_page(entry) {
485495 let root = if source { "blob" } else { "source" };