Added Html Background

main
Uriel Fanelli 2025-05-04 19:55:48 +02:00
parent e822d510ba
commit d8081ec1c8
2 changed files with 41 additions and 1 deletions

38
page.go Normal file
View File

@ -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()
}

View File

@ -50,9 +50,11 @@ func generateRSS() error {
timepub = time.Now()
}
htmlDesc := GenerateEpisodeDescription(epBaseImg, ep.Title, ep.Description)
item := podcast.Item{
Title: ep.Title,
Description: ep.Description,
Description: htmlDesc,
PubDate: &timepub,
Enclosure: &podcast.Enclosure{
URL: epBaseUrl,