~aw/fishbb

b155a4833a6fe8fc6de5a662df7b480dfa030960 — alex wennerberg a month ago e8cee8b
idk
6 files changed, 11 insertions(+), 20 deletions(-)

M TODO
R markdown.go => gemtext.go
M go.mod
M go.sum
M post.go
M views/header.html
M TODO => TODO +1 -2
@@ 4,9 4,9 @@ RESEARCH:
- look into email: IMAP uname/pw?

FEATURES:
consider htmx

minor/bugs:
notifications are just a search of mentions
rate limit registration
better error handling on login
better ux for account creation


@@ 15,7 15,6 @@ links on home and thread list should go to the post ( BETTER LINK  TO POST )
Login/Reigster:
finish up replies
finish up oauth integration
Notifications (Including integration with PWA / browser API)
post preview on edit?
Search
- auto-hyperlink @mention maybe?

R markdown.go => gemtext.go +5 -10
@@ 6,24 6,19 @@ import (
	"html/template"
	"strings"

	"github.com/yuin/goldmark"
	"git.sr.ht/~aw/gmi2html"
)

var md = goldmark.New()

func (p Post) Render() template.HTML {
	var out bytes.Buffer
	md.Convert([]byte(p.Content), &out)
	return template.HTML(out.String())
	r := gmi2html.NewReader(strings.NewReader(p.Content))
	r.NestedBlocks = true
	return template.HTML(r.HTMLString())
}

// @user -> username
// #post -> post

func (p Post) BuildReply() string {
	var out bytes.Buffer
	// TODO link to post
	out.Write([]byte(fmt.Sprintf("[@%s](/u/%s) wrote:\n", p.Author.Username, p.Author.Username)))
	out.Write([]byte(fmt.Sprintf("@%s wrote:\n", p.Author.Username)))
	for _, line := range strings.Split(p.Content, "\n") {
		out.Write([]byte("> "))
		out.Write([]byte(line))

M go.mod => go.mod +1 -1
@@ 8,13 8,13 @@ require (
)

require (
	git.sr.ht/~aw/gmi2html v0.1.3
	github.com/BurntSushi/toml v1.4.0
	github.com/alexedwards/argon2id v1.0.0
	github.com/go-chi/chi/v5 v5.1.0
	github.com/go-chi/httplog/v2 v2.0.11
	github.com/go-chi/httprate v0.9.0
	github.com/k3a/html2text v1.2.1
	github.com/yuin/goldmark v1.4.13
	golang.org/x/oauth2 v0.21.0
)


M go.sum => go.sum +2 -1
@@ 1,5 1,7 @@
cloud.google.com/go/compute/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2QxYC4trgAKZc=
cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k=
git.sr.ht/~aw/gmi2html v0.1.3 h1:Gj2vcmI/HqSs+9t05s0y/9n8o7swXSnJH4H+AQSu1Sc=
git.sr.ht/~aw/gmi2html v0.1.3/go.mod h1:WXvBJ0UXRsTcMcm/jmE1yJXz4bxUZDdFqv8HDcIueE0=
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/alexedwards/argon2id v1.0.0 h1:wJzDx66hqWX7siL/SRUmgz3F8YMrd/nfX/xHHcQQP0w=


@@ 26,7 28,6 @@ github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykE
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=

M post.go => post.go +1 -5
@@ 27,9 27,7 @@ type PostSummary struct {
	Content     string
}

// generate a preview for a post
// TODO more sophisticated
const previewLength = 10
const previewLength = 150

// unused atm
func (p Post) Preview() string {


@@ 62,8 60,6 @@ func getPostSlug(postid int) (string, error) {
	if err != nil {
		return "", err
	}
	// TODO fix bug here
	fmt.Println(count, config.PageSize, postid, threadid)
	postPage := ((count) / config.PageSize) + 1
	var url string
	// TODO url builder

M views/header.html => views/header.html +1 -1
@@ 26,7 26,7 @@
      {{ else }}
	  Hello, <a href="/me">{{.User.Username}}</a>.
	  {{ if .User.Role.ModLevel }}<a href="/control">control</a>{{ end }}
	  <a href="/notifications">✉️</a>
	  <a href="/search?q=@{{.User.Username}}">✉️</a>
	  <form style="display:inline" action="/logout" method="POST"><button class="link-button">Logout</button>
	<input type="hidden" name="CSRF" value="{{.CSRFToken}}">
	  </form>