~aw/fishbb

9d800f846f1640696315e05590d0b5a658ac7d24 — alex wennerberg a month ago 295fede
add basic replies
1 files changed, 10 insertions(+), 3 deletions(-)

M markdown.go
M markdown.go => markdown.go +10 -3
@@ 2,7 2,9 @@ package main

import (
	"bytes"
	"fmt"
	"html/template"
	"strings"

	"github.com/yuin/goldmark"
)


@@ 19,7 21,12 @@ func (p Post) Render() template.HTML {
// #post -> post

func (p Post) BuildReply() string {
	// naive solution: prefix everything with '> '
	// User [@username](/u/username) wrote in [#n](/post/n)...
	return p.Content
	var out bytes.Buffer
	// TODO link to post
	out.Write([]byte(fmt.Sprintf("[@%s](/u/%s) wrote:\n", p.Author.Username, p.Author.Username)))
	for _, line := range strings.Split(p.Content, "\n") {
		out.Write([]byte("> "))
		out.Write([]byte(line))
	}
	return out.String()
}