experiment with collapsing posts
Ted Unangst tedu@tedunangst.com
Wed, 10 Jul 2019 14:36:14 -0400
4 files changed,
39 insertions(+),
22 deletions(-)
M
fun.go
→
fun.go
@@ -31,7 +31,7 @@
"humungus.tedunangst.com/r/webs/htfilter" ) -func reverbolate(honks []*Honk) { +func reverbolate(userid int64, honks []*Honk) { filt := htfilter.New() for _, h := range honks { h.What += "ed"@@ -61,17 +61,16 @@ _, h.Oondle = honkerhandle(h.Oonker)
} zap := make(map[*Donk]bool) h.Noise = unpucker(h.Noise) - precis := h.Precis - if strings.HasPrefix(h.Noise, "<p>"+precis) { - precis = "" - } - if precis != "" { - if strings.IndexByte(precis, ':') == -1 { - precis = "summary: " + precis + h.Open = "open" + if userid != -1 { + if badword := unsee(userid, h.Precis, h.Noise); badword != "" { + if h.Precis == "" { + h.Precis = badword + } + h.Open = "" } - precis = "<p>" + precis + "<p>" } - h.HTML, _ = filt.String(precis + h.Noise) + h.HTML, _ = filt.String(h.Noise) emuxifier := func(e string) string { for _, d := range h.Donks { if d.Name == e {@@ -93,6 +92,13 @@ }
} h.Donks = h.Donks[:j] } +} + +func unsee(userid int64, precis string, noise string) string { + if precis != "" { + return "more..." + } + return "" } func osmosis(honks []*Honk, userid int64) []*Honk {
M
honk.go
→
honk.go
@@ -72,6 +72,7 @@ Public bool
Whofore int64 HTML template.HTML Style string + Open string Donks []*Donk }@@ -138,19 +139,21 @@ func homepage(w http.ResponseWriter, r *http.Request) {
templinfo := getInfo(r) u := login.GetUserInfo(r) var honks []*Honk + var userid int64 = -1 if r.URL.Path == "/front" || u == nil { honks = getpublichonks() } else { + userid = u.UserID if r.URL.Path == "/atme" { - honks = gethonksforme(u.UserID) + honks = gethonksforme(userid) } else { - honks = gethonksforuser(u.UserID) - honks = osmosis(honks, u.UserID) + honks = gethonksforuser(userid) + honks = osmosis(honks, userid) } templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r) } - reverbolate(honks) + reverbolate(userid, honks) templinfo["Honks"] = honks templinfo["ShowRSS"] = true@@ -202,7 +205,7 @@ honks = gethonksbyuser(name, false)
} else { honks = getpublichonks() } - reverbolate(honks) + reverbolate(-1, honks) home := fmt.Sprintf("https://%s/", serverName) base := home@@ -620,14 +623,16 @@ }
func honkpage(w http.ResponseWriter, r *http.Request, u *login.UserInfo, user *WhatAbout, honks []*Honk, infomsg string) { - reverbolate(honks) templinfo := getInfo(r) + var userid int64 = -1 if u != nil { templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r) + userid = u.UserID } if u == nil { w.Header().Set("Cache-Control", "max-age=60") } + reverbolate(userid, honks) if user != nil { filt := htfilter.New() templinfo["Name"] = user.Name@@ -1071,7 +1076,7 @@ whofore = 3
} if r.FormValue("preview") == "preview" { honks := []*Honk{&honk} - reverbolate(honks) + reverbolate(userinfo.UserID, honks) templinfo := getInfo(r) templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r) templinfo["Honks"] = honks
M
views/honk.html
→
views/honk.html
@@ -37,7 +37,10 @@ {{ else }}
<span style="margin-left: 1em;" class="clip">convoy: {{ .Convoy }}</span> {{ end }} </header> -<div class="noise"> +<p> +<details class="noise" {{ .Open }} > +<summary>{{ .Precis }}</summary> +<p>{{ .Precis }} <p>{{ .HTML }} {{ range .Donks }} {{ if .Local }}@@ -58,11 +61,11 @@ {{ end }}
{{ end }} {{ end }} {{ end }} -</div> +</details> {{ end }} {{ if $bonkcsrf }} <p> -<details> +<details class="actions"> <summary>Actions </summary> <div>
M
views/style.css
→
views/style.css
@@ -168,15 +168,18 @@ }
.limited .noise a { color: #a79; } +details.noise[open] summary { + display: none; +} .inlineform { display: inline; } .inlineform select { } -.honk details summary { +.honk details.actions summary { color: #aab; } -.limited details summary { +.limited details.actions summary { color: #a79; } h1, h2 {