Name the author ahead of the feed on issue index lines
Every list of articles now reads "Author · Feed · Publication · N min": the signed-in issue page, the public issue page, the RSS feed and the EPUB's In This Issue page. `author_label` drops an author that is empty or only repeats the feed's title, as a dozen personal blogs do. Article pages keep their own byline. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VXYGBPoHZSDSfE5WcJ9bvj
This commit is contained in:
@@ -167,6 +167,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)
|
||||
@@ -929,6 +936,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![
|
||||
|
||||
Reference in New Issue
Block a user