1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2025-01-05 17:40:26 +00:00

Fix missing subhyphae in the tree view

This commit is contained in:
Mikhail Chekan 2021-10-01 17:18:11 +08:00
parent 49e5ca8a6f
commit 8a30d84dfb
3 changed files with 28 additions and 6 deletions

View File

@ -104,7 +104,7 @@ func Tree(hyphaName string) (siblingsHTML, childrenHTML, prev, next string) {
wg.Done()
}()
go func() {
children = figureOutChildren(hyphaName, descendantsPool).children
children = figureOutChildren(hyphaName, descendantsPool, true).children
wg.Done()
}()
wg.Wait()
@ -128,10 +128,11 @@ func Tree(hyphaName string) (siblingsHTML, childrenHTML, prev, next string) {
type child struct {
name string
exists bool
children []child
}
func figureOutChildren(hyphaName string, subhyphaePool map[string]bool) child {
func figureOutChildren(hyphaName string, subhyphaePool map[string]bool, exists bool) child {
var (
nestLevel = strings.Count(hyphaName, "/")
adopted = make([]child, 0)
@ -140,10 +141,23 @@ func figureOutChildren(hyphaName string, subhyphaePool map[string]bool) child {
subnestLevel := strings.Count(subhyphaName, "/")
if subnestLevel-1 == nestLevel && path.Dir(subhyphaName) == hyphaName {
delete(subhyphaePool, subhyphaName)
adopted = append(adopted, figureOutChildren(subhyphaName, subhyphaePool))
adopted = append(adopted, figureOutChildren(subhyphaName, subhyphaePool, true))
}
}
return child{hyphaName, adopted}
for descName, _ := range subhyphaePool {
if strings.HasPrefix(descName, hyphaName) {
var (
rawSubPath = strings.TrimPrefix(descName, hyphaName)[1:]
slashIdx = strings.IndexRune(rawSubPath, '/')
)
if slashIdx > -1 {
var sibPath = descName[:slashIdx+len(hyphaName)+1]
adopted = append(adopted, figureOutChildren(sibPath, subhyphaePool, false))
} // `else` never happens?
}
}
return child{hyphaName, exists, adopted}
}
type sibling struct {

View File

@ -20,7 +20,7 @@ pseudographics:
})
%}
<li class="subhyphae__entry">
<a class="subhyphae__link" href="/hypha/{%s c.name %}">
<a class="subhyphae__link {% if !c.exists %}wikilink_new{% endif %}" href="/hypha/{%s c.name %}">
{%s util.BeautifulName(path.Base(c.name)) %}
</a>
{% if len(c.children) > 0 %}

View File

@ -82,7 +82,15 @@ func streamchildHTML(qw422016 *qt422016.Writer, c *child) {
//line tree/view.qtpl:21
qw422016.N().S(`
<li class="subhyphae__entry">
<a class="subhyphae__link" href="/hypha/`)
<a class="subhyphae__link `)
//line tree/view.qtpl:23
if !c.exists {
//line tree/view.qtpl:23
qw422016.N().S(`wikilink_new`)
//line tree/view.qtpl:23
}
//line tree/view.qtpl:23
qw422016.N().S(`" href="/hypha/`)
//line tree/view.qtpl:23
qw422016.E().S(c.name)
//line tree/view.qtpl:23