mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-12-04 18:19:54 +00:00
Show subhyphae counters near the relative hyphae links
This commit is contained in:
parent
d65e976a43
commit
15a0b62e1c
@ -288,15 +288,11 @@ caption { caption-side: top; font-size: small; }
|
||||
.subhyphae__link { display: block; padding: .25rem; text-decoration: none; }
|
||||
.subhyphae__link:hover { background: #eee; }
|
||||
|
||||
.navitree { padding: 0; margin: 0; }
|
||||
.navitree__entry { }
|
||||
.navitree > .navitree__entry > a::before { display: inline-block; width: .5rem; color: #999; margin: 0 .25rem; }
|
||||
.navitree > .navitree__entry_infertile > a::before { content: " "} /* nbsp, careful */
|
||||
.navitree > .navitree__sibling_fertile > a::before { content: "▸"}
|
||||
.navitree__trunk { border-left: 1px #999 solid; }
|
||||
.navitree__link { text-decoration: none; display: block; padding: .25rem; }
|
||||
.navitree__entry_this > span { display: block; padding: .25rem; font-weight: bold; }
|
||||
.navitree__entry_this > span::before { content: " "; display: inline-block; width: 1rem; }
|
||||
.relative-hyphae__list { padding: 0; margin: 0; }
|
||||
.relative-hyphae__entry { clear: both; }
|
||||
.relative-hyphae__count { display: inline-block; float: right; }
|
||||
.relative-hyphae__entry_this { padding: .25rem .5rem; font-weight: bold; }
|
||||
.relative-hyphae__link { text-decoration: none; display: block; padding: .25rem .5rem; }
|
||||
|
||||
|
||||
/* Color stuff */
|
||||
@ -345,7 +341,7 @@ blockquote { border-left: 4px black solid; }
|
||||
.upload-amnt { border: #eee 1px solid; }
|
||||
td { border: #ddd 1px solid; }
|
||||
|
||||
.navitree__link:hover, .backlinks__link:hover { background-color: #eee; }
|
||||
.relative-hyphae__link:hover, .backlinks__link:hover { background-color: #eee; }
|
||||
|
||||
/* Dark theme! */
|
||||
@media (prefers-color-scheme: dark) {
|
||||
@ -355,7 +351,7 @@ main, article, .hypha-tabs__tab, header, .layout-card { background-color: #3434
|
||||
a, .wikilink_external { color: #f1fa8c; }
|
||||
a:visited, .wikilink_external:visited { color: #ffb86c; }
|
||||
.wikilink_new, .wikilink_new:visited { color: #dd4444; }
|
||||
.subhyphae__link:hover, .navitree__link:hover, .backlinks__link:hover { background-color: #444; }
|
||||
.subhyphae__link:hover, .relative-hyphae__link:hover, .backlinks__link:hover { background-color: #444; }
|
||||
|
||||
.header-links__link, .header-links__link:visited,
|
||||
.prevnext__el, .prevnext__el:visited { color: #ddd; }
|
||||
|
@ -177,15 +177,11 @@ caption { caption-side: top; font-size: small; }
|
||||
.subhyphae__link { display: block; padding: .25rem; text-decoration: none; }
|
||||
.subhyphae__link:hover { background: #eee; }
|
||||
|
||||
.navitree { padding: 0; margin: 0; }
|
||||
.navitree__entry { }
|
||||
.navitree > .navitree__entry > a::before { display: inline-block; width: .5rem; color: #999; margin: 0 .25rem; }
|
||||
.navitree > .navitree__entry_infertile > a::before { content: " "} /* nbsp, careful */
|
||||
.navitree > .navitree__sibling_fertile > a::before { content: "▸"}
|
||||
.navitree__trunk { border-left: 1px #999 solid; }
|
||||
.navitree__link { text-decoration: none; display: block; padding: .25rem; }
|
||||
.navitree__entry_this > span { display: block; padding: .25rem; font-weight: bold; }
|
||||
.navitree__entry_this > span::before { content: " "; display: inline-block; width: 1rem; }
|
||||
.relative-hyphae__list { padding: 0; margin: 0; }
|
||||
.relative-hyphae__entry { clear: both; }
|
||||
.relative-hyphae__count { display: inline-block; float: right; }
|
||||
.relative-hyphae__entry_this { padding: .25rem .5rem; font-weight: bold; }
|
||||
.relative-hyphae__link { text-decoration: none; display: block; padding: .25rem .5rem; }
|
||||
|
||||
|
||||
/* Color stuff */
|
||||
@ -234,7 +230,7 @@ blockquote { border-left: 4px black solid; }
|
||||
.upload-amnt { border: #eee 1px solid; }
|
||||
td { border: #ddd 1px solid; }
|
||||
|
||||
.navitree__link:hover, .backlinks__link:hover { background-color: #eee; }
|
||||
.relative-hyphae__link:hover, .backlinks__link:hover { background-color: #eee; }
|
||||
|
||||
/* Dark theme! */
|
||||
@media (prefers-color-scheme: dark) {
|
||||
@ -244,7 +240,7 @@ main, article, .hypha-tabs__tab, header, .layout-card { background-color: #3434
|
||||
a, .wikilink_external { color: #f1fa8c; }
|
||||
a:visited, .wikilink_external:visited { color: #ffb86c; }
|
||||
.wikilink_new, .wikilink_new:visited { color: #dd4444; }
|
||||
.subhyphae__link:hover, .navitree__link:hover, .backlinks__link:hover { background-color: #444; }
|
||||
.subhyphae__link:hover, .relative-hyphae__link:hover, .backlinks__link:hover { background-color: #444; }
|
||||
|
||||
.header-links__link, .header-links__link:visited,
|
||||
.prevnext__el, .prevnext__el:visited { color: #ddd; }
|
||||
|
3
main.go
3
main.go
@ -1,6 +1,7 @@
|
||||
//go:generate go get -u github.com/valyala/quicktemplate/qtc
|
||||
//go:generate qtc -dir=assets
|
||||
//go:generate qtc -dir=views
|
||||
//go:generate qtc -dir=tree
|
||||
package main
|
||||
|
||||
import (
|
||||
@ -177,7 +178,7 @@ Crawl-delay: 5`))
|
||||
|
||||
func main() {
|
||||
parseCliArgs()
|
||||
log.Println("Running MycorrhizaWiki β")
|
||||
log.Println("Running MycorrhizaWiki")
|
||||
if err := os.Chdir(WikiDir); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
37
tree/tree.go
37
tree/tree.go
@ -87,9 +87,9 @@ func Tree(hyphaName string) (siblingsHTML, childrenHTML, prev, next string) {
|
||||
for i, s := range siblings {
|
||||
if s.name == hyphaName {
|
||||
I = i
|
||||
siblingsHTML += fmt.Sprintf(`<li class="navitree__entry navitree__entry_this"><span>%s</span></li>`, util.BeautifulName(path.Base(hyphaName)))
|
||||
siblingsHTML += fmt.Sprintf(`<li class="relative-hyphae__entry relative-hyphae__entry_this"><span>%s</span></li>`, util.BeautifulName(path.Base(hyphaName)))
|
||||
} else {
|
||||
siblingsHTML += s.asHTML(hyphaName)
|
||||
siblingsHTML += siblingHTML(s)
|
||||
}
|
||||
}
|
||||
if I != 0 && len(siblings) > 1 {
|
||||
@ -98,7 +98,7 @@ func Tree(hyphaName string) (siblingsHTML, childrenHTML, prev, next string) {
|
||||
if I != len(siblings)-1 && len(siblings) > 1 {
|
||||
next = siblings[I+1].name
|
||||
}
|
||||
return fmt.Sprintf(`<ul class="navitree">%s</ul>`, siblingsHTML), subhyphaeMatrix(children), prev, next
|
||||
return fmt.Sprintf(`<ul class="relative-hyphae__list">%s</ul>`, siblingsHTML), subhyphaeMatrix(children), prev, next
|
||||
}
|
||||
|
||||
type child struct {
|
||||
@ -127,41 +127,12 @@ type sibling struct {
|
||||
indirectSubhyphaeCount int
|
||||
}
|
||||
|
||||
func (s *sibling) asHTML(hyphaName string) string {
|
||||
class := "navitree__entry navitree__sibling"
|
||||
if s.directSubhyphaeCount > 0 {
|
||||
class += " navitree__sibling_fertile navitree__entry_fertile"
|
||||
} else {
|
||||
class += " navitree__sibling_infertile navitree__entry_infertile"
|
||||
}
|
||||
return fmt.Sprintf(
|
||||
`<li class="%s"><a class="navitree__link" href="/hypha/%s">%s</a></li>`,
|
||||
class,
|
||||
s.name,
|
||||
util.BeautifulName(path.Base(s.name)),
|
||||
)
|
||||
}
|
||||
|
||||
func (c *child) asHTML() string {
|
||||
if len(c.children) == 0 {
|
||||
return fmt.Sprintf(`<li class="subhyphae__entry"><a class="subhyphae__link" href="/hypha/%s">%s</a></li>`, c.name, util.BeautifulName(path.Base(c.name)))
|
||||
}
|
||||
sort.Slice(c.children, func(i, j int) bool {
|
||||
return c.children[i].name < c.children[j].name
|
||||
})
|
||||
html := fmt.Sprintf(`<li class="subhyphae__entry"><a class="subhyphae__link" href="/hypha/%s">%s</a><ul>`, c.name, util.BeautifulName(path.Base(c.name)))
|
||||
for _, child := range c.children {
|
||||
html += child.asHTML()
|
||||
}
|
||||
return html + `</li></ul></li>`
|
||||
}
|
||||
|
||||
func subhyphaeMatrix(children []child) (html string) {
|
||||
sort.Slice(children, func(i, j int) bool {
|
||||
return children[i].name < children[j].name
|
||||
})
|
||||
for _, child := range children {
|
||||
html += child.asHTML()
|
||||
html += childHTML(&child)
|
||||
}
|
||||
return html
|
||||
}
|
||||
|
55
tree/view.qtpl
Normal file
55
tree/view.qtpl
Normal file
@ -0,0 +1,55 @@
|
||||
{% 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="relative-hyphae__entry">
|
||||
<a class="relative-hyphae__link" href="/hypha/{%s s.name %}">
|
||||
{%s util.BeautifulName(path.Base(s.name)) %}
|
||||
<span class="relative-hyphae__count">
|
||||
{% if s.directSubhyphaeCount > 0 %}
|
||||
<span class="relative-hyphae__direct-count">
|
||||
{%d s.directSubhyphaeCount %}
|
||||
</span>
|
||||
{% endif %}
|
||||
{% if s.indirectSubhyphaeCount > 0 %}
|
||||
<span class="relative-hyphae__indirect-count">
|
||||
({%d s.indirectSubhyphaeCount %})
|
||||
</span>
|
||||
{% endif %}
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
{% endfunc %}
|
235
tree/view.qtpl.go
Normal file
235
tree/view.qtpl.go
Normal file
@ -0,0 +1,235 @@
|
||||
// Code generated by qtc from "view.qtpl". DO NOT EDIT.
|
||||
// See https://github.com/valyala/quicktemplate for details.
|
||||
|
||||
//line tree/view.qtpl:1
|
||||
package tree
|
||||
|
||||
//line tree/view.qtpl:1
|
||||
import "sort"
|
||||
|
||||
//line tree/view.qtpl:2
|
||||
import "path"
|
||||
|
||||
//line tree/view.qtpl:3
|
||||
import "github.com/bouncepaw/mycorrhiza/util"
|
||||
|
||||
//line tree/view.qtpl:5
|
||||
import (
|
||||
qtio422016 "io"
|
||||
|
||||
qt422016 "github.com/valyala/quicktemplate"
|
||||
)
|
||||
|
||||
//line tree/view.qtpl:5
|
||||
var (
|
||||
_ = qtio422016.Copy
|
||||
_ = qt422016.AcquireByteBuffer
|
||||
)
|
||||
|
||||
//line tree/view.qtpl:5
|
||||
func StreamTreeHTML(qw422016 *qt422016.Writer) {
|
||||
//line tree/view.qtpl:5
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line tree/view.qtpl:6
|
||||
}
|
||||
|
||||
//line tree/view.qtpl:6
|
||||
func WriteTreeHTML(qq422016 qtio422016.Writer) {
|
||||
//line tree/view.qtpl:6
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line tree/view.qtpl:6
|
||||
StreamTreeHTML(qw422016)
|
||||
//line tree/view.qtpl:6
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line tree/view.qtpl:6
|
||||
}
|
||||
|
||||
//line tree/view.qtpl:6
|
||||
func TreeHTML() string {
|
||||
//line tree/view.qtpl:6
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line tree/view.qtpl:6
|
||||
WriteTreeHTML(qb422016)
|
||||
//line tree/view.qtpl:6
|
||||
qs422016 := string(qb422016.B)
|
||||
//line tree/view.qtpl:6
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line tree/view.qtpl:6
|
||||
return qs422016
|
||||
//line tree/view.qtpl:6
|
||||
}
|
||||
|
||||
// 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 ║║
|
||||
// ║╚════════════╝║
|
||||
// ╚══════════════╝
|
||||
|
||||
//line tree/view.qtpl:16
|
||||
func streamchildHTML(qw422016 *qt422016.Writer, c *child) {
|
||||
//line tree/view.qtpl:16
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line tree/view.qtpl:18
|
||||
sort.Slice(c.children, func(i, j int) bool {
|
||||
return c.children[i].name < c.children[j].name
|
||||
})
|
||||
|
||||
//line tree/view.qtpl:21
|
||||
qw422016.N().S(`
|
||||
<li class="subhyphae__entry">
|
||||
<a class="subhyphae__link" href="/hypha/`)
|
||||
//line tree/view.qtpl:23
|
||||
qw422016.E().S(c.name)
|
||||
//line tree/view.qtpl:23
|
||||
qw422016.N().S(`">
|
||||
`)
|
||||
//line tree/view.qtpl:24
|
||||
qw422016.E().S(util.BeautifulName(path.Base(c.name)))
|
||||
//line tree/view.qtpl:24
|
||||
qw422016.N().S(`
|
||||
</a>
|
||||
`)
|
||||
//line tree/view.qtpl:26
|
||||
if len(c.children) > 0 {
|
||||
//line tree/view.qtpl:26
|
||||
qw422016.N().S(`
|
||||
<ul>
|
||||
`)
|
||||
//line tree/view.qtpl:28
|
||||
for _, child := range c.children {
|
||||
//line tree/view.qtpl:28
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line tree/view.qtpl:29
|
||||
qw422016.N().S(childHTML(&child))
|
||||
//line tree/view.qtpl:29
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line tree/view.qtpl:30
|
||||
}
|
||||
//line tree/view.qtpl:30
|
||||
qw422016.N().S(`
|
||||
</ul>
|
||||
`)
|
||||
//line tree/view.qtpl:32
|
||||
}
|
||||
//line tree/view.qtpl:32
|
||||
qw422016.N().S(`
|
||||
</li>
|
||||
`)
|
||||
//line tree/view.qtpl:34
|
||||
}
|
||||
|
||||
//line tree/view.qtpl:34
|
||||
func writechildHTML(qq422016 qtio422016.Writer, c *child) {
|
||||
//line tree/view.qtpl:34
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line tree/view.qtpl:34
|
||||
streamchildHTML(qw422016, c)
|
||||
//line tree/view.qtpl:34
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line tree/view.qtpl:34
|
||||
}
|
||||
|
||||
//line tree/view.qtpl:34
|
||||
func childHTML(c *child) string {
|
||||
//line tree/view.qtpl:34
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line tree/view.qtpl:34
|
||||
writechildHTML(qb422016, c)
|
||||
//line tree/view.qtpl:34
|
||||
qs422016 := string(qb422016.B)
|
||||
//line tree/view.qtpl:34
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line tree/view.qtpl:34
|
||||
return qs422016
|
||||
//line tree/view.qtpl:34
|
||||
}
|
||||
|
||||
//line tree/view.qtpl:37
|
||||
func streamsiblingHTML(qw422016 *qt422016.Writer, s *sibling) {
|
||||
//line tree/view.qtpl:37
|
||||
qw422016.N().S(`
|
||||
<li class="relative-hyphae__entry">
|
||||
<a class="relative-hyphae__link" href="/hypha/`)
|
||||
//line tree/view.qtpl:39
|
||||
qw422016.E().S(s.name)
|
||||
//line tree/view.qtpl:39
|
||||
qw422016.N().S(`">
|
||||
`)
|
||||
//line tree/view.qtpl:40
|
||||
qw422016.E().S(util.BeautifulName(path.Base(s.name)))
|
||||
//line tree/view.qtpl:40
|
||||
qw422016.N().S(`
|
||||
<span class="relative-hyphae__count">
|
||||
`)
|
||||
//line tree/view.qtpl:42
|
||||
if s.directSubhyphaeCount > 0 {
|
||||
//line tree/view.qtpl:42
|
||||
qw422016.N().S(`
|
||||
<span class="relative-hyphae__direct-count">
|
||||
`)
|
||||
//line tree/view.qtpl:44
|
||||
qw422016.N().D(s.directSubhyphaeCount)
|
||||
//line tree/view.qtpl:44
|
||||
qw422016.N().S(`
|
||||
</span>
|
||||
`)
|
||||
//line tree/view.qtpl:46
|
||||
}
|
||||
//line tree/view.qtpl:46
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line tree/view.qtpl:47
|
||||
if s.indirectSubhyphaeCount > 0 {
|
||||
//line tree/view.qtpl:47
|
||||
qw422016.N().S(`
|
||||
<span class="relative-hyphae__indirect-count">
|
||||
(`)
|
||||
//line tree/view.qtpl:49
|
||||
qw422016.N().D(s.indirectSubhyphaeCount)
|
||||
//line tree/view.qtpl:49
|
||||
qw422016.N().S(`)
|
||||
</span>
|
||||
`)
|
||||
//line tree/view.qtpl:51
|
||||
}
|
||||
//line tree/view.qtpl:51
|
||||
qw422016.N().S(`
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
`)
|
||||
//line tree/view.qtpl:55
|
||||
}
|
||||
|
||||
//line tree/view.qtpl:55
|
||||
func writesiblingHTML(qq422016 qtio422016.Writer, s *sibling) {
|
||||
//line tree/view.qtpl:55
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line tree/view.qtpl:55
|
||||
streamsiblingHTML(qw422016, s)
|
||||
//line tree/view.qtpl:55
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line tree/view.qtpl:55
|
||||
}
|
||||
|
||||
//line tree/view.qtpl:55
|
||||
func siblingHTML(s *sibling) string {
|
||||
//line tree/view.qtpl:55
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line tree/view.qtpl:55
|
||||
writesiblingHTML(qb422016, s)
|
||||
//line tree/view.qtpl:55
|
||||
qs422016 := string(qb422016.B)
|
||||
//line tree/view.qtpl:55
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line tree/view.qtpl:55
|
||||
return qs422016
|
||||
//line tree/view.qtpl:55
|
||||
}
|
Loading…
Reference in New Issue
Block a user