Merge branch 'index-author'

This commit is contained in:
2026-09-09 18:12:38 +00:00
6 changed files with 46 additions and 5 deletions
+20
View File
@@ -174,6 +174,13 @@ impl Article {
.then_some(publication)
}
/// The trimmed author, unless empty or identical to the feed name.
pub fn author_label(&self) -> Option<String> {
let author = self.author.as_deref()?.trim();
(!author.is_empty() && !author.eq_ignore_ascii_case(self.feed_title.trim()))
.then(|| author.to_string())
}
/// Stable EPUB chapter id used by TOC and rating links (implementation notes §12).
pub fn chapter_id(&self) -> String {
format!("art-{}", self.best_entry_id)
@@ -944,6 +951,19 @@ mod tests {
assert_eq!(article.publication_label(), None);
}
#[test]
fn author_label_trims_and_omits_empty_or_matching_authors() {
let mut article = publication_article();
article.author = Some(" Jane Doe ".into());
assert_eq!(article.author_label().as_deref(), Some("Jane Doe"));
article.author = Some(" ".into());
assert_eq!(article.author_label(), None);
article.author = Some(" a FEED ".into());
assert_eq!(article.author_label(), None);
}
#[test]
fn composite_social_score_matches_spec_formula() {
let refs = vec![