Skip to content

Commit

Permalink
Refine message template
Browse files Browse the repository at this point in the history
  • Loading branch information
waybackarchiver committed May 19, 2023
1 parent 6d84837 commit 4d0aa19
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 24 deletions.
4 changes: 2 additions & 2 deletions template/render/mastodon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import (
func TestRenderMastodon(t *testing.T) {
const toot = `‹ Example ›
source
Source
> https://example.com/
————
• Internet Archive
Expand Down
4 changes: 2 additions & 2 deletions template/render/nostr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ func TestRenderNostrForReply(t *testing.T) {
func TestRenderNostrForPublish(t *testing.T) {
expected := `‹ Example ›
source
Source
> https://example.com/
————
• Internet Archive
Expand Down
12 changes: 6 additions & 6 deletions template/render/relaychat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
25 changes: 15 additions & 10 deletions template/render/relaychat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 *****`

Expand Down
4 changes: 2 additions & 2 deletions template/render/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
4 changes: 2 additions & 2 deletions template/render/twitter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ func TestRenderTwitterForReply(t *testing.T) {
func TestRenderTwitterForPublish(t *testing.T) {
const tweet = `‹ Example ›
source
Source
> https://example.com/
————
• Internet Archive
Expand Down

0 comments on commit 4d0aa19

Please sign in to comment.