experiment with collapsing posts
This commit is contained in:
parent
a576dcc9ec
commit
babda8d0a7
24
fun.go
24
fun.go
|
@ -31,7 +31,7 @@ import (
|
||||||
"humungus.tedunangst.com/r/webs/htfilter"
|
"humungus.tedunangst.com/r/webs/htfilter"
|
||||||
)
|
)
|
||||||
|
|
||||||
func reverbolate(honks []*Honk) {
|
func reverbolate(userid int64, honks []*Honk) {
|
||||||
filt := htfilter.New()
|
filt := htfilter.New()
|
||||||
for _, h := range honks {
|
for _, h := range honks {
|
||||||
h.What += "ed"
|
h.What += "ed"
|
||||||
|
@ -61,17 +61,16 @@ func reverbolate(honks []*Honk) {
|
||||||
}
|
}
|
||||||
zap := make(map[*Donk]bool)
|
zap := make(map[*Donk]bool)
|
||||||
h.Noise = unpucker(h.Noise)
|
h.Noise = unpucker(h.Noise)
|
||||||
precis := h.Precis
|
h.Open = "open"
|
||||||
if strings.HasPrefix(h.Noise, "<p>"+precis) {
|
if userid != -1 {
|
||||||
precis = ""
|
if badword := unsee(userid, h.Precis, h.Noise); badword != "" {
|
||||||
|
if h.Precis == "" {
|
||||||
|
h.Precis = badword
|
||||||
}
|
}
|
||||||
if precis != "" {
|
h.Open = ""
|
||||||
if strings.IndexByte(precis, ':') == -1 {
|
|
||||||
precis = "summary: " + precis
|
|
||||||
}
|
}
|
||||||
precis = "<p>" + precis + "<p>"
|
|
||||||
}
|
}
|
||||||
h.HTML, _ = filt.String(precis + h.Noise)
|
h.HTML, _ = filt.String(h.Noise)
|
||||||
emuxifier := func(e string) string {
|
emuxifier := func(e string) string {
|
||||||
for _, d := range h.Donks {
|
for _, d := range h.Donks {
|
||||||
if d.Name == e {
|
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 {
|
func osmosis(honks []*Honk, userid int64) []*Honk {
|
||||||
zords := getzords(userid)
|
zords := getzords(userid)
|
||||||
j := 0
|
j := 0
|
||||||
|
|
19
honk.go
19
honk.go
|
@ -72,6 +72,7 @@ type Honk struct {
|
||||||
Whofore int64
|
Whofore int64
|
||||||
HTML template.HTML
|
HTML template.HTML
|
||||||
Style string
|
Style string
|
||||||
|
Open string
|
||||||
Donks []*Donk
|
Donks []*Donk
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,19 +139,21 @@ func homepage(w http.ResponseWriter, r *http.Request) {
|
||||||
templinfo := getInfo(r)
|
templinfo := getInfo(r)
|
||||||
u := login.GetUserInfo(r)
|
u := login.GetUserInfo(r)
|
||||||
var honks []*Honk
|
var honks []*Honk
|
||||||
|
var userid int64 = -1
|
||||||
if r.URL.Path == "/front" || u == nil {
|
if r.URL.Path == "/front" || u == nil {
|
||||||
honks = getpublichonks()
|
honks = getpublichonks()
|
||||||
} else {
|
} else {
|
||||||
|
userid = u.UserID
|
||||||
if r.URL.Path == "/atme" {
|
if r.URL.Path == "/atme" {
|
||||||
honks = gethonksforme(u.UserID)
|
honks = gethonksforme(userid)
|
||||||
} else {
|
} else {
|
||||||
honks = gethonksforuser(u.UserID)
|
honks = gethonksforuser(userid)
|
||||||
honks = osmosis(honks, u.UserID)
|
honks = osmosis(honks, userid)
|
||||||
}
|
}
|
||||||
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
|
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
|
||||||
}
|
}
|
||||||
|
|
||||||
reverbolate(honks)
|
reverbolate(userid, honks)
|
||||||
|
|
||||||
templinfo["Honks"] = honks
|
templinfo["Honks"] = honks
|
||||||
templinfo["ShowRSS"] = true
|
templinfo["ShowRSS"] = true
|
||||||
|
@ -202,7 +205,7 @@ func showrss(w http.ResponseWriter, r *http.Request) {
|
||||||
} else {
|
} else {
|
||||||
honks = getpublichonks()
|
honks = getpublichonks()
|
||||||
}
|
}
|
||||||
reverbolate(honks)
|
reverbolate(-1, honks)
|
||||||
|
|
||||||
home := fmt.Sprintf("https://%s/", serverName)
|
home := fmt.Sprintf("https://%s/", serverName)
|
||||||
base := home
|
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,
|
func honkpage(w http.ResponseWriter, r *http.Request, u *login.UserInfo, user *WhatAbout,
|
||||||
honks []*Honk, infomsg string) {
|
honks []*Honk, infomsg string) {
|
||||||
reverbolate(honks)
|
|
||||||
templinfo := getInfo(r)
|
templinfo := getInfo(r)
|
||||||
|
var userid int64 = -1
|
||||||
if u != nil {
|
if u != nil {
|
||||||
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
|
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
|
||||||
|
userid = u.UserID
|
||||||
}
|
}
|
||||||
if u == nil {
|
if u == nil {
|
||||||
w.Header().Set("Cache-Control", "max-age=60")
|
w.Header().Set("Cache-Control", "max-age=60")
|
||||||
}
|
}
|
||||||
|
reverbolate(userid, honks)
|
||||||
if user != nil {
|
if user != nil {
|
||||||
filt := htfilter.New()
|
filt := htfilter.New()
|
||||||
templinfo["Name"] = user.Name
|
templinfo["Name"] = user.Name
|
||||||
|
@ -1071,7 +1076,7 @@ func savehonk(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
if r.FormValue("preview") == "preview" {
|
if r.FormValue("preview") == "preview" {
|
||||||
honks := []*Honk{&honk}
|
honks := []*Honk{&honk}
|
||||||
reverbolate(honks)
|
reverbolate(userinfo.UserID, honks)
|
||||||
templinfo := getInfo(r)
|
templinfo := getInfo(r)
|
||||||
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
|
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
|
||||||
templinfo["Honks"] = honks
|
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>
|
<span style="margin-left: 1em;" class="clip">convoy: {{ .Convoy }}</span>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</header>
|
</header>
|
||||||
<div class="noise">
|
<p>
|
||||||
|
<details class="noise" {{ .Open }} >
|
||||||
|
<summary>{{ .Precis }}</summary>
|
||||||
|
<p>{{ .Precis }}
|
||||||
<p>{{ .HTML }}
|
<p>{{ .HTML }}
|
||||||
{{ range .Donks }}
|
{{ range .Donks }}
|
||||||
{{ if .Local }}
|
{{ if .Local }}
|
||||||
|
@ -58,11 +61,11 @@ in reply to: <a href="{{ .RID }}" rel=noreferrer>{{ .RID }}</a>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</details>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ if $bonkcsrf }}
|
{{ if $bonkcsrf }}
|
||||||
<p>
|
<p>
|
||||||
<details>
|
<details class="actions">
|
||||||
<summary>Actions
|
<summary>Actions
|
||||||
</summary>
|
</summary>
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -168,15 +168,18 @@ input[type=file] {
|
||||||
.limited .noise a {
|
.limited .noise a {
|
||||||
color: #a79;
|
color: #a79;
|
||||||
}
|
}
|
||||||
|
details.noise[open] summary {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
.inlineform {
|
.inlineform {
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
.inlineform select {
|
.inlineform select {
|
||||||
}
|
}
|
||||||
.honk details summary {
|
.honk details.actions summary {
|
||||||
color: #aab;
|
color: #aab;
|
||||||
}
|
}
|
||||||
.limited details summary {
|
.limited details.actions summary {
|
||||||
color: #a79;
|
color: #a79;
|
||||||
}
|
}
|
||||||
h1, h2 {
|
h1, h2 {
|
||||||
|
|
Loading…
Reference in New Issue