experiment with nested thread sorting
This commit is contained in:
parent
23e2c9276a
commit
7feb254618
|
@ -175,7 +175,6 @@ input[type=file] {
|
||||||
.glow {
|
.glow {
|
||||||
box-shadow: 0px 0px 16px var(--hl);
|
box-shadow: 0px 0px 16px var(--hl);
|
||||||
}
|
}
|
||||||
|
|
||||||
.honk {
|
.honk {
|
||||||
margin: auto;
|
margin: auto;
|
||||||
background: var(--bg-dark);
|
background: var(--bg-dark);
|
||||||
|
@ -188,6 +187,35 @@ input[type=file] {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.level1 {
|
||||||
|
margin-left: 0.5em;
|
||||||
|
}
|
||||||
|
.level1::before {
|
||||||
|
position: absolute;
|
||||||
|
content: ">";
|
||||||
|
}
|
||||||
|
.level2 {
|
||||||
|
margin-left: 1.0em;
|
||||||
|
}
|
||||||
|
.level2::before {
|
||||||
|
position: absolute;
|
||||||
|
content: ">>";
|
||||||
|
}
|
||||||
|
.level3 {
|
||||||
|
margin-left: 1.5em;
|
||||||
|
}
|
||||||
|
.level3::before {
|
||||||
|
position: absolute;
|
||||||
|
content: ">>>";
|
||||||
|
}
|
||||||
|
.level4 {
|
||||||
|
margin-left: 2.0em;
|
||||||
|
}
|
||||||
|
.level4::before {
|
||||||
|
position: absolute;
|
||||||
|
content: ">>>>";
|
||||||
|
}
|
||||||
|
|
||||||
.chat {
|
.chat {
|
||||||
border-bottom: 0.5px solid var(--fg-subtle);
|
border-bottom: 0.5px solid var(--fg-subtle);
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
|
|
52
web.go
52
web.go
|
@ -779,7 +779,8 @@ func showconvoy(w http.ResponseWriter, r *http.Request) {
|
||||||
templinfo["TopHID"] = honks[0].ID
|
templinfo["TopHID"] = honks[0].ID
|
||||||
}
|
}
|
||||||
honks = osmosis(honks, u.UserID, false)
|
honks = osmosis(honks, u.UserID, false)
|
||||||
reversehonks(honks)
|
//reversehonks(honks)
|
||||||
|
honks = threadsort(honks)
|
||||||
templinfo["PageName"] = "convoy"
|
templinfo["PageName"] = "convoy"
|
||||||
templinfo["PageArg"] = c
|
templinfo["PageArg"] = c
|
||||||
templinfo["ServerMessage"] = "honks in convoy: " + c
|
templinfo["ServerMessage"] = "honks in convoy: " + c
|
||||||
|
@ -1017,6 +1018,50 @@ func trackback(xid string, r *http.Request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func threadsort(honks []*Honk) []*Honk {
|
||||||
|
kids := make(map[string][]*Honk)
|
||||||
|
for _, h := range honks {
|
||||||
|
kids[h.RID] = append(kids[h.RID], h)
|
||||||
|
}
|
||||||
|
done := make(map[*Honk]bool)
|
||||||
|
var thread []*Honk
|
||||||
|
var grabkids func(p *Honk)
|
||||||
|
level := 0
|
||||||
|
grabkids = func(p *Honk) {
|
||||||
|
if level > 4 {
|
||||||
|
p.Style += fmt.Sprintf(" level%d", 4)
|
||||||
|
} else {
|
||||||
|
p.Style += fmt.Sprintf(" level%d", level)
|
||||||
|
}
|
||||||
|
level++
|
||||||
|
childs := kids[p.XID]
|
||||||
|
sort.Slice(childs, func(i, j int) bool {
|
||||||
|
return childs[i].Date.Before(childs[j].Date)
|
||||||
|
})
|
||||||
|
for _, h := range childs {
|
||||||
|
done[h] = true
|
||||||
|
thread = append(thread, h)
|
||||||
|
grabkids(h)
|
||||||
|
}
|
||||||
|
level--
|
||||||
|
}
|
||||||
|
for _, h := range honks {
|
||||||
|
if h.RID == "" {
|
||||||
|
done[h] = true
|
||||||
|
thread = append(thread, h)
|
||||||
|
grabkids(h)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, h := range honks {
|
||||||
|
if !done[h] {
|
||||||
|
done[h] = true
|
||||||
|
thread = append(thread, h)
|
||||||
|
grabkids(h)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return thread
|
||||||
|
}
|
||||||
|
|
||||||
func honkology(honk *Honk) template.HTML {
|
func honkology(honk *Honk) template.HTML {
|
||||||
var user *WhatAbout
|
var user *WhatAbout
|
||||||
ok := somenumberedusers.Get(honk.UserID, &user)
|
ok := somenumberedusers.Get(honk.UserID, &user)
|
||||||
|
@ -1095,7 +1140,8 @@ func showonehonk(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
templinfo := getInfo(r)
|
templinfo := getInfo(r)
|
||||||
rawhonks := gethonksbyconvoy(honk.UserID, honk.Convoy, 0)
|
rawhonks := gethonksbyconvoy(honk.UserID, honk.Convoy, 0)
|
||||||
reversehonks(rawhonks)
|
//reversehonks(rawhonks)
|
||||||
|
rawhonks = threadsort(rawhonks)
|
||||||
var honks []*Honk
|
var honks []*Honk
|
||||||
for _, h := range rawhonks {
|
for _, h := range rawhonks {
|
||||||
if h.XID == xid {
|
if h.XID == xid {
|
||||||
|
@ -2327,6 +2373,8 @@ func webhydra(w http.ResponseWriter, r *http.Request) {
|
||||||
c := r.FormValue("c")
|
c := r.FormValue("c")
|
||||||
honks = gethonksbyconvoy(userid, c, wanted)
|
honks = gethonksbyconvoy(userid, c, wanted)
|
||||||
honks = osmosis(honks, userid, false)
|
honks = osmosis(honks, userid, false)
|
||||||
|
honks = threadsort(honks)
|
||||||
|
reversehonks(honks)
|
||||||
hydra.Srvmsg = templates.Sprintf("honks in convoy: %s", c)
|
hydra.Srvmsg = templates.Sprintf("honks in convoy: %s", c)
|
||||||
case "honker":
|
case "honker":
|
||||||
xid := r.FormValue("xid")
|
xid := r.FormValue("xid")
|
||||||
|
|
Loading…
Reference in New Issue