diff --git a/poems/objects.py b/poems/objects.py index fff3593..3bde339 100644 --- a/poems/objects.py +++ b/poems/objects.py @@ -128,7 +128,7 @@ def __repr__(self): @property def translator(self) -> str: - return self.metadata["translator"] if "translator" in self.metadata else None + return self.metadata["translator"] if "translator" in self.metadata else "" @property def keywords(self) -> dict: @@ -144,7 +144,7 @@ def title_by_author(self): @property def pretty_date(self): if "date" not in self.metadata: - return None + return "" year, m, day = [self.metadata["date"].get(attr) for attr in ["year", "month", "day"]] x = "" if m: @@ -165,7 +165,7 @@ def spacetime(self): parts.append(self.metadata["location"]) if self.pretty_date: parts.append(self.pretty_date) - return ". ".join(parts) or None + return ". ".join(parts) or "" @property def test_email_subject(self): @@ -175,6 +175,16 @@ def test_email_subject(self): def daily_email_subject(self): return f"Poem of the Day: {self.title_by_author}" + @property + def html_description(self): + + if self.author.name: + description = f'{self.title} by {self.author.name} {self.author.dates.replace("--", "–")}' + else: + description = self.title + + return description + @property def html_body(self): body_text = self.body.replace("--", "—") # convert emdashes @@ -200,12 +210,14 @@ def html_body(self): return "\n".join(parsed_lines) - @property - def html_date(self): - return f'