experiment with collapsing posts

master
Ted Unangst 5 years ago
parent a576dcc9ec
commit babda8d0a7

@ -31,7 +31,7 @@ import (
"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 @@ func reverbolate(honks []*Honk) {
}
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 {
@ -95,6 +94,13 @@ func reverbolate(honks []*Honk) {
}
}
func unsee(userid int64, precis string, noise string) string {
if precis != "" {
return "more..."
}
return ""
}
func osmosis(honks []*Honk, userid int64) []*Honk {
zords := getzords(userid)
j := 0

@ -72,6 +72,7 @@ type Honk struct {
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 @@ func showrss(w http.ResponseWriter, r *http.Request) {
} else {
honks = getpublichonks()
}
reverbolate(honks)
reverbolate(-1, honks)
home := fmt.Sprintf("https://%s/", serverName)
base := home
@ -620,14 +623,16 @@ func showhonk(w http.ResponseWriter, r *http.Request) {
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 @@ func savehonk(w http.ResponseWriter, r *http.Request) {
}
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

@ -37,7 +37,10 @@ in reply to: <a href="{{ .RID }}" rel=noreferrer>{{ .RID }}</a>
<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 @@ in reply to: <a href="{{ .RID }}" rel=noreferrer>{{ .RID }}</a>
{{ end }}
{{ end }}
{{ end }}
</div>
</details>
{{ end }}
{{ if $bonkcsrf }}
<p>
<details>
<details class="actions">
<summary>Actions
</summary>
<div>

@ -168,15 +168,18 @@ input[type=file] {
.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 {

Loading…
Cancel
Save