1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-13 05:50:27 +00:00
mycorrhiza/tree/view.qtpl
Timur Ismagilov a4c8741f7f Relative hyphae→sister hyphae, where it makes sense
CSS class has changed, please update your custom styles
2021-07-06 23:09:45 +05:00

56 lines
1.5 KiB
Plaintext

{% import "sort" %}
{% import "path" %}
{% import "github.com/bouncepaw/mycorrhiza/util" %}
{% func TreeHTML() %}
{% endfunc %}
Subhyphae links are recursive. It may end up looking like that if drawn with
pseudographics:
╔══════════════╗
║Foo ║ The presented hyphae are foo and foo/bar
║╔════════════╗║
║║Bar ║║
║╚════════════╝║
╚══════════════╝
{% func childHTML(c *child) %}
{% code
sort.Slice(c.children, func(i, j int) bool {
return c.children[i].name < c.children[j].name
})
%}
<li class="subhyphae__entry">
<a class="subhyphae__link" href="/hypha/{%s c.name %}">
{%s util.BeautifulName(path.Base(c.name)) %}
</a>
{% if len(c.children) > 0 %}
<ul>
{% for _, child := range c.children %}
{%s= childHTML(&child) %}
{% endfor %}
</ul>
{% endif %}
</li>
{% endfunc %}
{% func siblingHTML(s *sibling) %}
<li class="sister-hyphae__entry">
<a class="sister-hyphae__link" href="/hypha/{%s s.name %}">
{%s util.BeautifulName(path.Base(s.name)) %}
<span class="sister-hyphae__count">
{% if s.directSubhyphaeCount > 0 %}
<span class="sister-hyphae__direct-count">
{%d s.directSubhyphaeCount %}
</span>
{% endif %}
{% if s.indirectSubhyphaeCount > 0 %}
<span class="sister-hyphae__indirect-count">
({%d s.indirectSubhyphaeCount %})
</span>
{% endif %}
</span>
</a>
</li>
{% endfunc %}