Added Html Background
							parent
							
								
									e822d510ba
								
							
						
					
					
						commit
						d8081ec1c8
					
				|  | @ -0,0 +1,38 @@ | ||||||
|  | package main | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"bytes" | ||||||
|  | 	"text/template" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | func GenerateEpisodeDescription(imageURL, title, content string) string { | ||||||
|  | 	// Template con sezione CDATA
 | ||||||
|  | 	const descTemplate = `<![CDATA[ | ||||||
|  | 	{{if .ImageURL}}<img src="{{.ImageURL}}" width="300" style="float:right; margin:0 0 10px 10px;">{{end}} | ||||||
|  | 	<h3 style="margin-top:0;">{{.Title}}</h3> | ||||||
|  | 	<div style="clear:both;"></div> | ||||||
|  | 	{{.Content}} | ||||||
|  | 	]]>` | ||||||
|  | 
 | ||||||
|  | 	// Dati per il template
 | ||||||
|  | 	data := struct { | ||||||
|  | 		ImageURL string | ||||||
|  | 		Title    string | ||||||
|  | 		Content  string | ||||||
|  | 	}{ | ||||||
|  | 		ImageURL: imageURL, | ||||||
|  | 		Title:    title, | ||||||
|  | 		Content:  content, | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	// Esecuzione del template
 | ||||||
|  | 	var buf bytes.Buffer | ||||||
|  | 	tmpl := template.Must(template.New("desc").Parse(descTemplate)) | ||||||
|  | 
 | ||||||
|  | 	if err := tmpl.Execute(&buf, data); err != nil { | ||||||
|  | 		// Fallback con CDATA
 | ||||||
|  | 		return "<![CDATA[<h3>" + title + "</h3>" + content + "]]>" | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return buf.String() | ||||||
|  | } | ||||||
|  | @ -50,9 +50,11 @@ func generateRSS() error { | ||||||
| 			timepub = time.Now() | 			timepub = time.Now() | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | 		htmlDesc := GenerateEpisodeDescription(epBaseImg, ep.Title, ep.Description) | ||||||
|  | 
 | ||||||
| 		item := podcast.Item{ | 		item := podcast.Item{ | ||||||
| 			Title:       ep.Title, | 			Title:       ep.Title, | ||||||
| 			Description: ep.Description, | 			Description: htmlDesc, | ||||||
| 			PubDate:     &timepub, | 			PubDate:     &timepub, | ||||||
| 			Enclosure: &podcast.Enclosure{ | 			Enclosure: &podcast.Enclosure{ | ||||||
| 				URL:    epBaseUrl, | 				URL:    epBaseUrl, | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue