diff --git a/assets/assets.qtpl.go b/assets/assets.qtpl.go
index ce703dd..62aee1e 100644
--- a/assets/assets.qtpl.go
+++ b/assets/assets.qtpl.go
@@ -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; }
diff --git a/assets/default.css b/assets/default.css
index 84c6fb7..b96df8b 100644
--- a/assets/default.css
+++ b/assets/default.css
@@ -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; }
diff --git a/main.go b/main.go
index 138c589..1ce8cf2 100644
--- a/main.go
+++ b/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)
}
diff --git a/tree/tree.go b/tree/tree.go
index 4771aec..fe3a196 100644
--- a/tree/tree.go
+++ b/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(`
%s`, util.BeautifulName(path.Base(hyphaName)))
+ siblingsHTML += fmt.Sprintf(`%s`, 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(``, siblingsHTML), subhyphaeMatrix(children), prev, next
+ return fmt.Sprintf(``, 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(
- `%s`,
- class,
- s.name,
- util.BeautifulName(path.Base(s.name)),
- )
-}
-
-func (c *child) asHTML() string {
- if len(c.children) == 0 {
- return fmt.Sprintf(`%s`, 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(`%s`, c.name, util.BeautifulName(path.Base(c.name)))
- for _, child := range c.children {
- html += child.asHTML()
- }
- return html + `
`
-}
-
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
}
diff --git a/tree/view.qtpl b/tree/view.qtpl
new file mode 100644
index 0000000..353a912
--- /dev/null
+++ b/tree/view.qtpl
@@ -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
+ })
+%}
+
+
+ {%s util.BeautifulName(path.Base(c.name)) %}
+
+{% if len(c.children) > 0 %}
+
+ {% for _, child := range c.children %}
+ {%s= childHTML(&child) %}
+ {% endfor %}
+
+{% endif %}
+
+{% endfunc %}
+
+
+{% func siblingHTML(s *sibling) %}
+
+
+ {%s util.BeautifulName(path.Base(s.name)) %}
+
+ {% if s.directSubhyphaeCount > 0 %}
+
+ {%d s.directSubhyphaeCount %}
+
+ {% endif %}
+ {% if s.indirectSubhyphaeCount > 0 %}
+
+ ({%d s.indirectSubhyphaeCount %})
+
+ {% endif %}
+
+
+
+{% endfunc %}
diff --git a/tree/view.qtpl.go b/tree/view.qtpl.go
new file mode 100644
index 0000000..c078bb0
--- /dev/null
+++ b/tree/view.qtpl.go
@@ -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(`
+
+
+ `)
+//line tree/view.qtpl:24
+ qw422016.E().S(util.BeautifulName(path.Base(c.name)))
+//line tree/view.qtpl:24
+ qw422016.N().S(`
+
+`)
+//line tree/view.qtpl:26
+ if len(c.children) > 0 {
+//line tree/view.qtpl:26
+ qw422016.N().S(`
+
+ `)
+//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(`
+
+`)
+//line tree/view.qtpl:32
+ }
+//line tree/view.qtpl:32
+ qw422016.N().S(`
+
+`)
+//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(`
+
+
+ `)
+//line tree/view.qtpl:40
+ qw422016.E().S(util.BeautifulName(path.Base(s.name)))
+//line tree/view.qtpl:40
+ qw422016.N().S(`
+
+ `)
+//line tree/view.qtpl:42
+ if s.directSubhyphaeCount > 0 {
+//line tree/view.qtpl:42
+ qw422016.N().S(`
+
+ `)
+//line tree/view.qtpl:44
+ qw422016.N().D(s.directSubhyphaeCount)
+//line tree/view.qtpl:44
+ qw422016.N().S(`
+
+ `)
+//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(`
+
+ (`)
+//line tree/view.qtpl:49
+ qw422016.N().D(s.indirectSubhyphaeCount)
+//line tree/view.qtpl:49
+ qw422016.N().S(`)
+
+ `)
+//line tree/view.qtpl:51
+ }
+//line tree/view.qtpl:51
+ qw422016.N().S(`
+
+
+
+`)
+//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
+}