diff options
author | René 'Necoro' Neumann <necoro@necoro.eu> | 2020-05-07 23:32:34 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.eu> | 2020-05-07 23:32:34 +0200 |
commit | 0532548c8abf170aaf0abddab67561d2c499863a (patch) | |
tree | efdfecae6aca97724f9e06952b451428f053b307 /internal/feed | |
parent | 432e26e4177cf351953ac97474326a2f439beba5 (diff) | |
download | feed2imap-go-0532548c8abf170aaf0abddab67561d2c499863a.tar.gz feed2imap-go-0532548c8abf170aaf0abddab67561d2c499863a.tar.bz2 feed2imap-go-0532548c8abf170aaf0abddab67561d2c499863a.zip |
Improve html rendering
Diffstat (limited to '')
-rw-r--r-- | internal/feed/mail.go | 11 | ||||
-rw-r--r-- | internal/feed/template/feed.tpl.go | 74 |
2 files changed, 32 insertions, 53 deletions
diff --git a/internal/feed/mail.go b/internal/feed/mail.go index f77987e..ecd21ef 100644 --- a/internal/feed/mail.go +++ b/internal/feed/mail.go @@ -16,7 +16,6 @@ import ( "github.com/emersion/go-message" "github.com/emersion/go-message/mail" "github.com/gabriel-vasile/mimetype" - "golang.org/x/net/html" "github.com/Necoro/feed2imap-go/internal/feed/template" "github.com/Necoro/feed2imap-go/internal/http" @@ -241,13 +240,6 @@ func getBody(content, description string, bodyCfg config.Body) string { } } -func startsWithText(str string) bool { - reader := strings.NewReader(str) - tokenizer := html.NewTokenizerFragment(reader, "") - - return tokenizer.Next() == html.TextToken -} - func (item *item) buildBody() { feed := item.feed feedUrl, err := url.Parse(feed.Url) @@ -256,9 +248,6 @@ func (item *item) buildBody() { } body := getBody(item.Content, item.Description, feed.Body) - if body != "" && startsWithText(body) { - body = "<br />" + body - } if !feed.InclImages { item.Body = body diff --git a/internal/feed/template/feed.tpl.go b/internal/feed/template/feed.tpl.go index c3aede5..10f870b 100644 --- a/internal/feed/template/feed.tpl.go +++ b/internal/feed/template/feed.tpl.go @@ -7,63 +7,53 @@ const feedTpl = `{{- /*gotype:github.com/Necoro/feed2imap-go/internal/feed.feedi {{define "bottomLine"}} {{if .content}} <tr> - <td align="right"> - <span style="color: #ababab; ">{{.descr}}</span> + <td style="text-align: right; padding: 0"> + <span style="color: #ababab">{{.descr}}</span> </td> - <td> - <span style="color: #ababab; ">{{.content}}</span> + <td style="padding: 0"> + <span style="color: #ababab">{{.content}}</span> </td> </tr> {{end}} {{end}} -<table border="1" width="100%" cellpadding="0" cellspacing="0" style="border-spacing: 0; "> - <tr> - <td> - <table width="100%" bgcolor="#EDEDED" cellpadding="4" cellspacing="2"> - <tr> - <td align="right"><b>Feed</b></td> - <td width="100%"> +<table style="border: 2px black groove; background: #ededed; width: 100%; margin-bottom: 5px"> + <tr> + <td style="text-align: right; padding: 4px"><strong>Feed</strong></td> + <td style="width: 100%; padding: 4px"> {{with .Feed.Link}}<a href="{{.}}">{{end}} - <b>{{or .Feed.Title .Feed.Link "Unnammed feed"}}</b> - {{if .Feed.Link}}</a>{{end}} - </td> - </tr> - <tr> - <td align="right"><b>Item</b></td> - <td width="100%"> + <strong>{{or .Feed.Title .Feed.Link "Unnammed feed"}}</strong> + {{if .Feed.Link}}</a>{{end}} + </td> + </tr> + <tr> + <td style="text-align: right; padding: 4px"><strong>Item</strong></td> + <td style="width: 100%; padding: 4px"> {{with .Item.Link}}<a href="{{.}}">{{end}} - <b>{{or .Item.Title .Item.Link}}</b> - {{if .Item.Link}}</a>{{end}} - </td> - </tr> - </table> - </td> - </tr> + <strong>{{or .Item.Title .Item.Link}}</strong> + {{if .Item.Link}}</a>{{end}} + </td> + </tr> </table> {{with .Body}} {{html .}} {{end}} {{with .Item.Enclosures}} - <table border="1" width="100%" cellpadding="0" cellspacing="0" style="border-spacing: 0; "> - <tr> - <td> - <table width="100%" bgcolor="#EDEDED" cellpadding="2" cellspacing="2"> - <tr><td width="100%"><b>Files:</b></td></tr> - {{range .}} - <tr> + <table style="border: 2px black groove; background: #ededed; width: 100%; margin-top: 5px"> + <tr> + <td style="width: 100%"><strong>Files:</strong></td> + </tr> + {{range .}} + <tr> <td> - - <a href={{.URL}}>{{.URL | lastUrlPart}}</a> ({{with .Length}}{{. | byteCount}}, {{end}}{{.Type}}) + + <a href={{.URL}}>{{.URL | lastUrlPart}}</a> ({{with .Length}}{{. | byteCount}}, {{end}}{{.Type}}) </td> - </tr> - {{end}} - </table> - </td> - </tr> - </table> + </tr> + {{end}} + </table> {{end}} -<hr width="100%"/> -<table width="100%" cellpadding="0" cellspacing="0"> +<hr style="width: 100%"/> +<table style="width: 100%; border-spacing: 0"> {{template "bottomLine" (dict "descr" "Date:" "content" .Date)}} {{template "bottomLine" (dict "descr" "Author:" "content" .Creator)}} {{template "bottomLine" (dict "descr" "Filed under:" "content" (join ", " .Categories))}} |