diff --git a/internal/matrix/post.go b/internal/matrix/post.go index 8639aa0..61a39aa 100644 --- a/internal/matrix/post.go +++ b/internal/matrix/post.go @@ -37,7 +37,9 @@ func formatPost(s *PostableStory) (plain, htmlBody string) { if s.Lede != "" { plainParts = append(plainParts, s.Lede) } - plainParts = append(plainParts, formatSourceTag(s.Source, s.Platforms, false)) + if tag := formatSourceTag(s.Source, s.Platforms, false); tag != "" { + plainParts = append(plainParts, tag) + } plain = strings.Join(plainParts, "\n") // HTML body @@ -55,25 +57,32 @@ func formatPost(s *PostableStory) (plain, htmlBody string) { if s.Lede != "" { htmlParts = append(htmlParts, html.EscapeString(s.Lede)) } - htmlParts = append(htmlParts, formatSourceTag(s.Source, s.Platforms, true)) + if tag := formatSourceTag(s.Source, s.Platforms, true); tag != "" { + htmlParts = append(htmlParts, tag) + } htmlBody = strings.Join(htmlParts, "
") return plain, htmlBody } -// formatSourceTag builds the source + platform tags line. +// formatSourceTag builds the source + platform tags line. An empty source is +// omitted rather than tagged: Pete's own reporting has no outlet to credit, and +// an empty tag would read as him signing his own name. func formatSourceTag(source string, platforms []string, isHTML bool) string { - if isHTML { - parts := []string{fmt.Sprintf("%s", html.EscapeString(strings.ToLower(source)))} - for _, p := range platforms { - parts = append(parts, fmt.Sprintf("%s", html.EscapeString(p))) - } - return strings.Join(parts, " \u00b7 ") + var parts []string + if source != "" { + parts = append(parts, strings.ToLower(source)) } - - parts := []string{fmt.Sprintf("`%s`", strings.ToLower(source))} - for _, p := range platforms { - parts = append(parts, fmt.Sprintf("`%s`", p)) + parts = append(parts, platforms...) + if len(parts) == 0 { + return "" + } + for i, p := range parts { + if isHTML { + parts[i] = fmt.Sprintf("%s", html.EscapeString(p)) + } else { + parts[i] = fmt.Sprintf("`%s`", p) + } } return strings.Join(parts, " \u00b7 ") } diff --git a/internal/web/adventure.go b/internal/web/adventure.go index e50ea93..fc8d892 100644 --- a/internal/web/adventure.go +++ b/internal/web/adventure.go @@ -151,12 +151,14 @@ func (s *Server) handleAdventureIngest(w http.ResponseWriter, r *http.Request) { if f.Tier == "priority" && s.advPost != nil && s.adv.Channel != "" { // No ImageURL: the emblem is an SVG (Matrix clients often block SVG // media), and the link's og:image carries the preview instead. + // No Source: the source tag exists to credit an outlet Pete is relaying + // (`ars technica`). On his own reporting it renders as him signing his + // own name under his own message. s.advPost(AdvPost{ GUID: f.GUID, Headline: headline, Lede: lede, ArticleURL: articleURL, - Source: advSource, Channel: s.adv.Channel, }) } diff --git a/internal/web/adventure_digest.go b/internal/web/adventure_digest.go index 8352b75..5667c98 100644 --- a/internal/web/adventure_digest.go +++ b/internal/web/adventure_digest.go @@ -94,7 +94,6 @@ func (s *Server) postDailyDigest(now time.Time) { Headline: headline, Lede: lede, ArticleURL: s.digestURL(date), - Source: advSource, Channel: s.adv.Channel, })