forked from jason/cpolis
		
	Make banner link and summary optional
This commit is contained in:
		@@ -30,12 +30,25 @@ func GenerateAtomFeed(c *Config, db *DB) (*string, error) {
 | 
			
		||||
		}
 | 
			
		||||
		entry := atom.NewEntry(articleTitle)
 | 
			
		||||
		entry.ID = atom.NewID(fmt.Sprint("urn:entry:", article.ID))
 | 
			
		||||
		entry.Content = atom.NewContent(atom.OutOfLine, "text/hmtl", article.ContentLink)
 | 
			
		||||
		entry.Published = atom.NewDate(article.Created)
 | 
			
		||||
 | 
			
		||||
		linkID := entry.AddLink(atom.NewLink(article.BannerLink))
 | 
			
		||||
		entry.Links[linkID].Rel = "enclosure"
 | 
			
		||||
		entry.Links[linkID].Type = "image/webp"
 | 
			
		||||
		if article.AutoGenerated {
 | 
			
		||||
			entry.Content = atom.NewContent(atom.InlineText, "text", "")
 | 
			
		||||
		} else {
 | 
			
		||||
			entry.Content = atom.NewContent(atom.OutOfLine, "text/hmtl", article.ContentLink)
 | 
			
		||||
 | 
			
		||||
			articleSummary, err := ConvertToPlain(article.Summary)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				return nil, fmt.Errorf("error converting description to plain text for Atom feed: %v", err)
 | 
			
		||||
			}
 | 
			
		||||
			entry.Summary = atom.NewText("text", articleSummary)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if len(article.BannerLink) > 0 {
 | 
			
		||||
			linkID := entry.AddLink(atom.NewLink(article.BannerLink))
 | 
			
		||||
			entry.Links[linkID].Rel = "enclosure"
 | 
			
		||||
			entry.Links[linkID].Type = "image/webp"
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		user, err := db.GetUser(c, article.AuthorID)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
@@ -43,15 +56,6 @@ func GenerateAtomFeed(c *Config, db *DB) (*string, error) {
 | 
			
		||||
		}
 | 
			
		||||
		entry.AddAuthor(atom.NewPerson(user.FirstName + " " + user.LastName))
 | 
			
		||||
 | 
			
		||||
		articleSummary, err := ConvertToPlain(article.Summary)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, fmt.Errorf("error converting description to plain text for Atom feed: %v", err)
 | 
			
		||||
		}
 | 
			
		||||
		if article.AutoGenerated {
 | 
			
		||||
			articleSummary = "auto generated"
 | 
			
		||||
		}
 | 
			
		||||
		entry.Summary = atom.NewText("text", articleSummary)
 | 
			
		||||
 | 
			
		||||
		tags, err := db.GetArticleTags(article.ID)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, fmt.Errorf("error getting tags for articles for Atom feed: %v", err)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user