// Copyright (C) 2025 wangyusong
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see
Feeds
`); err != nil { return "", errors.Wrap(err, "write feeds header") } for i, feed := range group.Feeds { if err := e.writeFeedContent(bodyBuf, feed); err != nil { return "", errors.Wrap(err, "write feed content") } // Add separator (except the last feed). if i < len(group.Feeds)-1 { if err := e.writeSeparator(bodyBuf); err != nil { return "", errors.Wrap(err, "write separator") } } } // Write disclaimer and HTML footer. if err := e.writeDisclaimer(bodyBuf); err != nil { return "", errors.Wrap(err, "write disclaimer") } if err := e.writeHTMLFooter(bodyBuf); err != nil { return "", errors.Wrap(err, "write HTML footer") } return bodyBuf.String(), nil } func (e *email) writeHTMLHeader(buf *buffer.Bytes) error { _, err := buf.WriteString(`Summary
`); err != nil { return errors.Wrap(err, "write summary header") } contentHTML, err := textconvert.MarkdownToHTML([]byte(summary)) if err != nil { return errors.Wrap(err, "markdown to HTML") } contentHTMLWithStyle := fmt.Sprintf(`Source: %s/%s
Published: %s | Scraped: %s
`, title, link, typ, source, pubTime, scrapeTime); err != nil { return errors.Wrap(err, "write feed header") } return nil } func (e *email) writeFeedBody(buf *buffer.Bytes, feed *route.Feed) error { if _, err := buf.WriteString(`Related:
`); err != nil { return errors.Wrapf(err, "write relateds header") } for _, f := range related { relTyp := f.Labels.Get(model.LabelType) relSource := f.Labels.Get(model.LabelSource) relTitle := f.Labels.Get(model.LabelTitle) relLink := f.Labels.Get(model.LabelLink) if _, err := fmt.Fprintf(buf, ` `, relLink, relTyp, relSource, relTitle); err != nil { return errors.Wrapf(err, "write relateds item") } } if _, err := buf.WriteString(`
免责声明 / Disclaimer
本邮件内容仅用于个人概括性学习和理解,版权归原作者所有。
This email content is for personal learning and understanding purposes only. All rights reserved to the original author.
严禁二次分发或传播!!!
NO redistribution or sharing!!!
如有侵权,请联系 / For copyright issues, please contact:
ysking7402@gmail.com