From 4d0aa199075a96c0733e352d8c68cfab407ce451 Mon Sep 17 00:00:00 2001 From: Wayback Archiver <66856220+waybackarchiver@users.noreply.github.com> Date: Fri, 19 May 2023 17:18:41 +0100 Subject: [PATCH] Refine message template --- template/render/mastodon_test.go | 4 ++-- template/render/nostr_test.go | 4 ++-- template/render/relaychat.go | 12 ++++++------ template/render/relaychat_test.go | 25 +++++++++++++++---------- template/render/render.go | 4 ++-- template/render/twitter_test.go | 4 ++-- 6 files changed, 29 insertions(+), 24 deletions(-) diff --git a/template/render/mastodon_test.go b/template/render/mastodon_test.go index adea9124..74709cc0 100644 --- a/template/render/mastodon_test.go +++ b/template/render/mastodon_test.go @@ -15,9 +15,9 @@ import ( func TestRenderMastodon(t *testing.T) { const toot = `‹ Example › -• source +• Source > https://example.com/ - + ———— • Internet Archive diff --git a/template/render/nostr_test.go b/template/render/nostr_test.go index e2c319e9..10af5aaf 100644 --- a/template/render/nostr_test.go +++ b/template/render/nostr_test.go @@ -15,9 +15,9 @@ func TestRenderNostrForReply(t *testing.T) { func TestRenderNostrForPublish(t *testing.T) { expected := `‹ Example › -• source +• Source > https://example.com/ - + ———— • Internet Archive diff --git a/template/render/relaychat.go b/template/render/relaychat.go index 1ac10cf2..5f4040d6 100644 --- a/template/render/relaychat.go +++ b/template/render/relaychat.go @@ -40,18 +40,18 @@ func (i *Relaychat) ForPublish() *Render { tmplBytes.WriteString(" ›") tmplBytes.WriteString("\n \n") } - // tmplBytes.WriteString("Source:") - // tmplBytes.WriteString("• ") - // tmplBytes.WriteString("\n \n") - tmplBytes.Write(i.join(i.main()).Bytes()) + // tmplBytes.WriteString("Source:\n") + tmplBytes.WriteString(original(i.Cols)) + tmplBytes.WriteString(" \n") + tmplBytes.Write(i.main().Bytes()) - return &Render{buf: *tmplBytes} + return &Render{buf: *i.join(tmplBytes)} } func (i *Relaychat) main() *bytes.Buffer { tmplBytes := new(bytes.Buffer) - const tmpl = "{{range $ := .}}{{ $.Arc | name }}:\n• {{ $.Dst }}\n{{end}}" + const tmpl = "{{range $ := .}}• {{ $.Arc | name }}:\n> {{ $.Dst }}\n{{end}}" tpl, err := template.New("relaychat").Funcs(funcMap()).Parse(tmpl) if err != nil { diff --git a/template/render/relaychat_test.go b/template/render/relaychat_test.go index d4f704b4..bd968c99 100644 --- a/template/render/relaychat_test.go +++ b/template/render/relaychat_test.go @@ -9,18 +9,23 @@ import ( ) func TestRenderForIRC(t *testing.T) { - expected := `‹ Example › + expected := `***** List of Archives ***** -***** List of Archives ***** +‹ Example › -Internet Archive: -• https://web.archive.org/web/20211000000001/https://example.com/ -archive.today: -• http://archive.today/abcdE -IPFS: -• https://ipfs.io/ipfs/QmTbDmpvQ3cPZG6TA5tnar4ZG6q9JMBYVmX2n3wypMQMtr -Telegraph: -• http://telegra.ph/title-01-01 +• Source +> https://example.com/ + +———— + +• Internet Archive: +> https://web.archive.org/web/20211000000001/https://example.com/ +• archive.today: +> http://archive.today/abcdE +• IPFS: +> https://ipfs.io/ipfs/QmTbDmpvQ3cPZG6TA5tnar4ZG6q9JMBYVmX2n3wypMQMtr +• Telegraph: +> http://telegra.ph/title-01-01 ***** End of Archives *****` diff --git a/template/render/render.go b/template/render/render.go index 59f59ffa..a45c9c85 100644 --- a/template/render/render.go +++ b/template/render/render.go @@ -234,11 +234,11 @@ func original(v interface{}) (o string) { }) var sb strings.Builder - sb.WriteString("• source\n") + sb.WriteString("• Source\n") for _, kv := range ss { sb.WriteString(`> `) sb.WriteString(kv.Key) - sb.WriteString("\n") + sb.WriteString("\n ") } sb.WriteString("\n————\n") diff --git a/template/render/twitter_test.go b/template/render/twitter_test.go index b68f9290..49c57075 100644 --- a/template/render/twitter_test.go +++ b/template/render/twitter_test.go @@ -29,9 +29,9 @@ func TestRenderTwitterForReply(t *testing.T) { func TestRenderTwitterForPublish(t *testing.T) { const tweet = `‹ Example › -• source +• Source > https://example.com/ - + ———— • Internet Archive