Skip to content

Commit

Permalink
Merge pull request #78 from dandi/gh-74
Browse files Browse the repository at this point in the history
Use site title as text of root breadcrumb
  • Loading branch information
jwodder authored Feb 15, 2024
2 parents 919f4ac + add330f commit 9ccaacd
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,6 @@ Options
- `-p <PORT>`, `--port <PORT>` — Specify the port for the server to listen on
[default: 8080]

- `-T <TITLE>`, `--title <TITLE>` — Specify the site name to include in the
`<title>`s of HTML pages for collections
- `-T <TITLE>`, `--title <TITLE>` — Specify the site name to use in HTML/web
views of collections (used inside `<title>`'s and as the root breadcrumb
text) [default: dandidav]
6 changes: 3 additions & 3 deletions src/dav/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl CollectionContext {
let full_title = format!("{title} \u{2014} {title_path}");
CollectionContext {
title: full_title,
breadcrumbs: make_breadcrumbs(pathparts),
breadcrumbs: make_breadcrumbs(title, pathparts),
rows,
package_url: env!("CARGO_PKG_REPOSITORY"),
package_version: env!("CARGO_PKG_VERSION"),
Expand Down Expand Up @@ -185,11 +185,11 @@ fn maybe_timestamp<S: Serializer>(
}
}

fn make_breadcrumbs(pathparts: Vec<Component>) -> Vec<Link> {
fn make_breadcrumbs(title: &str, pathparts: Vec<Component>) -> Vec<Link> {
let mut links = Vec::with_capacity(pathparts.len().saturating_add(1));
let mut cumpath = String::from("/");
links.push(Link {
name: String::from("dandidav"),
name: title.to_owned(),
href: Href::from_path(&cumpath),
});
for p in pathparts {
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct Arguments {
#[arg(short, long, default_value_t = 8080)]
port: u16,

/// Site name to include in HTML page titles
/// Site name to use in HTML collection pages
#[arg(short = 'T', long, default_value = env!("CARGO_PKG_NAME"))]
title: String,
}
Expand Down
2 changes: 1 addition & 1 deletion src/testdata/render-collection/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</head>
<body>
<div class="breadcrumbs">
<a href="&#x2F;">dandidav</a> /
<a href="&#x2F;">Dandidav Test</a> /
<a href="&#x2F;foo&#x2F;">foo</a> /
<a href="&#x2F;foo&#x2F;bar&#x2F;">bar</a> /
<a href="&#x2F;foo&#x2F;bar&#x2F;baz&#x2F;">baz</a>
Expand Down
2 changes: 1 addition & 1 deletion src/testdata/render-collection/root.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</head>
<body>
<div class="breadcrumbs">
<a href="&#x2F;">dandidav</a>
<a href="&#x2F;">Dandidav Test</a>
</div>
<table class="collection">
<tr>
Expand Down

0 comments on commit 9ccaacd

Please sign in to comment.