slurdge / goeland

An alternative to rss2email written in golang with many filters
MIT License
169 stars 11 forks source link

Patch to add URL variable to template #185

Closed clipcarl closed 7 months ago

clipcarl commented 7 months ago

The attached huge and complicated patch adds a URL variable for use in the email template to allow for adding a clickable link to to the original article like so:

<a href="{{.URL}}">{{.EntryTitle}}</a>

Patch:

diff -urN goeland-0.16.0.dist/cmd/run.go goeland-0.16.0.cet/cmd/run.go
--- goeland-0.16.0.dist/cmd/run.go  2023-10-27 07:34:30.000000000 -0700
+++ goeland-0.16.0.cet/cmd/run.go   2023-12-16 01:56:03.808909272 -0800
@@ -160,6 +160,7 @@
        EntryFooter   string
        ContentID     string
        CSS           string
+       URL           string
    }{
        EntryTitle:    html.EscapeString(entry.Title),
        EntryContent:  entry.Content,
@@ -169,6 +170,7 @@
        EntryFooter:   footer,
        ContentID:     "cid:" + logoAttachmentName,
        CSS:           defaultCSS,
+       URL:           entry.URL,
    }
    if destination == "htmlfile" {
        data.ContentID = "data:image/png;base64," + base64.StdEncoding.EncodeToString(logoBytes)

goeland-add_url_var.patch.txt

slurdge commented 7 months ago

Hello, it seems exactly like this one : https://github.com/slurdge/goeland/pull/178/commits

I'm still confused on what is the expected output compared to use the "IncludeLink" filter. Could you show me an example ?

clipcarl commented 7 months ago

Hello, it seems exactly like this one : https://github.com/slurdge/goeland/pull/178/commits

So it does! I guess someone else beat me to it. I'll close this one then.

slurdge commented 7 months ago

Wait ! I still don't understand the goal :-) So I won't merge it until I grasp the best way to achieve what is needed. Please comment either here or on the pull request. Ideally show me a screenshot and/or html of what you want to achieve.

slurdge commented 7 months ago

Also, is this the same as https://github.com/slurdge/goeland/discussions/104 ?

clipcarl commented 7 months ago

The goal is to allow for adding a clickable link to to the original article in the email generated by goeland. It is the same as #178 and #104 .

The documentation suggests that IncludeLink only works when generating digests. I wish to add the link when not using digests.

slurdge commented 7 months ago

Ah ! So you mean, take a source, have one email per entry, and each entry has the link back to the website ? Basically, let's say 10x the emails, and each <h1> has a link right ? If so I think I can make inclueLink work all the time.

clipcarl commented 7 months ago

So you mean, take a source, have one email per entry, and each entry has the link back to the website ?

Yes. One generated email for each RSS article and the generated email has a link to the full article.

... each <h1> has a link right ? If so I think I can make inclueLink work all the time.

I customize the style of the link and its placement in the email's template so if IncludeLink automatically adds something like <h1> that wouldn't work for me. Also I'm not sure if IncludeLink would allow for customizing the location of the link in the email which I also do.

My preference would be to have #178 even if you do change IncludeLink.

Thanks!

slurdge commented 7 months ago

if IncludeLink automatically adds something like <h1> that wouldn't work for me.

Yeah that would do exactly that.

My preference would be to have https://github.com/slurdge/goeland/pull/178 even if you do change IncludeLink.

I understand. I'll merge the PR but not the bit that changes the default template.

Also, if you have nice email templates, feel free to share them, I'm always hoping to add more.

slurdge commented 7 months ago

Done in v0.18.0

clipcarl commented 7 months ago

Thank you!