Special branch for the instance in kuketzblog@rooms.dismail.de which posts kuketzblogs mastodon posts.

This commit is contained in:
Martin Dosch 2018-12-14 14:18:46 +01:00
parent 638c24819f
commit 330d94cfd7

View file

@ -193,31 +193,23 @@ func getArticles(feedURL string, max int, noExcerpt bool) (string, error) {
// Remove redirects and tracking parameters from URL. // Remove redirects and tracking parameters from URL.
cleanURL, _ := removeTracking(article.Link) cleanURL, _ := removeTracking(article.Link)
// Don't process mastodon messages that are a reply
// Only send title and link if option noExcerpt is set, if strings.Contains(article.Content, "http://activitystrea.ms/schema/1.0/comment") == false {
// otherwise add the description.
if noExcerpt == true {
output = output + feed.Title + ": *" + article.Title + "*\n" +
cleanURL
} else {
// Strip HTML as we want to get plain text. // Strip HTML as we want to get plain text.
description, err := html2text.FromString(article.Description) mastodonContent := strings.Replace(article.Content, `</span><span class="ellipsis">`, "", -1)
mastodonContent = strings.Replace(mastodonContent, `</span><span class="invisible">`, "", -1)
mastodonContent = strings.Replace(mastodonContent, `</span>`, "", -1)
mastodonContent = strings.Replace(mastodonContent, `<span>`, "", -1)
mastodonContent, err = html2text.FromString(mastodonContent, html2text.Options{OmitLinks: true})
if err != nil { if err != nil {
return "", err return "", err
} }
// Only append article link if it is not yet contained in description (e.g. read more: URL). output = output + "Kuketz-Blog: " + mastodonContent + "\n\n" + cleanURL
if strings.Contains(description, article.Link) == true {
// Replace article link with URL cleaned from redirects and trackers.
description = strings.Replace(description, article.Link, cleanURL, -1)
output = output + feed.Title + ": *" + article.Title + "*\n\n" + description
} else {
output = output + feed.Title + ": *" + article.Title + "*\n\n" + description + "\n" + cleanURL
}
}
if i > 0 { if i > 0 {
output = output + "\n\n---\n\n" output = output + "\n\n---\n\n"
}
} }
} }