diff --git a/views/nav.qtpl b/views/nav.qtpl index 1885dd2..1591ace 100644 --- a/views/nav.qtpl +++ b/views/nav.qtpl @@ -5,8 +5,13 @@ {% import "github.com/bouncepaw/mycorrhiza/util" %} {% import "github.com/bouncepaw/mycorrhiza/viewutil" %} -{% func hyphaInfoEntry(h hyphae.Hypha, u *user.User, action, displayText string) %} -{% if u.CanProceed(action) %} +{% func hyphaInfoEntry(h hyphae.Hypha, u *user.User, action string, hasToExist bool, displayText string) %} +{% code flag := true %} +{% switch h.(type) %} +{% case *hyphae.EmptyHypha %} + {% code flag = !hasToExist %} +{% endswitch %} +{% if u.CanProceed(action) && flag %} <li class="hypha-info__entry hypha-info__entry_{%s action %}"> <a class="hypha-info__link" href="/{%s action %}/{%s h.CanonicalName() %}">{%s displayText %}</a> </li> @@ -21,12 +26,12 @@ %} <nav class="hypha-info"> <ul class="hypha-info__list"> - {%= hyphaInfoEntry(h, u, "history", lc.Get("ui.history_link")) %} - {%= hyphaInfoEntry(h, u, "rename", lc.Get("ui.rename_link")) %} - {%= hyphaInfoEntry(h, u, "delete", lc.Get("ui.delete_link")) %} - {%= hyphaInfoEntry(h, u, "text", lc.Get("ui.text_link")) %} - {%= hyphaInfoEntry(h, u, "media", lc.Get("ui.media_link")) %} - {%= hyphaInfoEntry(h, u, "backlinks", lc.GetPlural("ui.backlinks_link", backs)) %} + {%= hyphaInfoEntry(h, u, "history", false, lc.Get("ui.history_link")) %} + {%= hyphaInfoEntry(h, u, "rename", true, lc.Get("ui.rename_link")) %} + {%= hyphaInfoEntry(h, u, "delete", true, lc.Get("ui.delete_link")) %} + {%= hyphaInfoEntry(h, u, "text", true, lc.Get("ui.text_link")) %} + {%= hyphaInfoEntry(h, u, "media", true, lc.Get("ui.media_link")) %} + {%= hyphaInfoEntry(h, u, "backlinks", false, lc.GetPlural("ui.backlinks_link", backs)) %} </ul> </nav> {% endfunc %} diff --git a/views/nav.qtpl.go b/views/nav.qtpl.go index 5c14894..04bc609 100644 --- a/views/nav.qtpl.go +++ b/views/nav.qtpl.go @@ -36,33 +36,28 @@ var ( ) //line views/nav.qtpl:8 -func streamhyphaInfoEntry(qw422016 *qt422016.Writer, h hyphae.Hypha, u *user.User, action, displayText string) { +func streamhyphaInfoEntry(qw422016 *qt422016.Writer, h hyphae.Hypha, u *user.User, action string, hasToExist bool, displayText string) { //line views/nav.qtpl:8 qw422016.N().S(` `) //line views/nav.qtpl:9 - if u.CanProceed(action) { + flag := true + //line views/nav.qtpl:9 + qw422016.N().S(` +`) +//line views/nav.qtpl:10 + switch h.(type) { +//line views/nav.qtpl:11 + case *hyphae.EmptyHypha: +//line views/nav.qtpl:11 + qw422016.N().S(` + `) +//line views/nav.qtpl:12 + flag = !hasToExist + +//line views/nav.qtpl:12 qw422016.N().S(` -<li class="hypha-info__entry hypha-info__entry_`) -//line views/nav.qtpl:10 - qw422016.E().S(action) -//line views/nav.qtpl:10 - qw422016.N().S(`"> - <a class="hypha-info__link" href="/`) -//line views/nav.qtpl:11 - qw422016.E().S(action) -//line views/nav.qtpl:11 - qw422016.N().S(`/`) -//line views/nav.qtpl:11 - qw422016.E().S(h.CanonicalName()) -//line views/nav.qtpl:11 - qw422016.N().S(`">`) -//line views/nav.qtpl:11 - qw422016.E().S(displayText) -//line views/nav.qtpl:11 - qw422016.N().S(`</a> -</li> `) //line views/nav.qtpl:13 } @@ -70,196 +65,225 @@ func streamhyphaInfoEntry(qw422016 *qt422016.Writer, h hyphae.Hypha, u *user.Use qw422016.N().S(` `) //line views/nav.qtpl:14 -} - + if u.CanProceed(action) && flag { //line views/nav.qtpl:14 -func writehyphaInfoEntry(qq422016 qtio422016.Writer, h hyphae.Hypha, u *user.User, action, displayText string) { -//line views/nav.qtpl:14 - qw422016 := qt422016.AcquireWriter(qq422016) -//line views/nav.qtpl:14 - streamhyphaInfoEntry(qw422016, h, u, action, displayText) -//line views/nav.qtpl:14 - qt422016.ReleaseWriter(qw422016) -//line views/nav.qtpl:14 -} - -//line views/nav.qtpl:14 -func hyphaInfoEntry(h hyphae.Hypha, u *user.User, action, displayText string) string { -//line views/nav.qtpl:14 - qb422016 := qt422016.AcquireByteBuffer() -//line views/nav.qtpl:14 - writehyphaInfoEntry(qb422016, h, u, action, displayText) -//line views/nav.qtpl:14 - qs422016 := string(qb422016.B) -//line views/nav.qtpl:14 - qt422016.ReleaseByteBuffer(qb422016) -//line views/nav.qtpl:14 - return qs422016 -//line views/nav.qtpl:14 -} - + qw422016.N().S(` +<li class="hypha-info__entry hypha-info__entry_`) +//line views/nav.qtpl:15 + qw422016.E().S(action) +//line views/nav.qtpl:15 + qw422016.N().S(`"> + <a class="hypha-info__link" href="/`) //line views/nav.qtpl:16 -func streamhyphaInfo(qw422016 *qt422016.Writer, meta viewutil.Meta, h hyphae.Hypha) { + qw422016.E().S(action) //line views/nav.qtpl:16 - qw422016.N().S(` + qw422016.N().S(`/`) +//line views/nav.qtpl:16 + qw422016.E().S(h.CanonicalName()) +//line views/nav.qtpl:16 + qw422016.N().S(`">`) +//line views/nav.qtpl:16 + qw422016.E().S(displayText) +//line views/nav.qtpl:16 + qw422016.N().S(`</a> +</li> `) //line views/nav.qtpl:18 + } +//line views/nav.qtpl:18 + qw422016.N().S(` +`) +//line views/nav.qtpl:19 +} + +//line views/nav.qtpl:19 +func writehyphaInfoEntry(qq422016 qtio422016.Writer, h hyphae.Hypha, u *user.User, action string, hasToExist bool, displayText string) { +//line views/nav.qtpl:19 + qw422016 := qt422016.AcquireWriter(qq422016) +//line views/nav.qtpl:19 + streamhyphaInfoEntry(qw422016, h, u, action, hasToExist, displayText) +//line views/nav.qtpl:19 + qt422016.ReleaseWriter(qw422016) +//line views/nav.qtpl:19 +} + +//line views/nav.qtpl:19 +func hyphaInfoEntry(h hyphae.Hypha, u *user.User, action string, hasToExist bool, displayText string) string { +//line views/nav.qtpl:19 + qb422016 := qt422016.AcquireByteBuffer() +//line views/nav.qtpl:19 + writehyphaInfoEntry(qb422016, h, u, action, hasToExist, displayText) +//line views/nav.qtpl:19 + qs422016 := string(qb422016.B) +//line views/nav.qtpl:19 + qt422016.ReleaseByteBuffer(qb422016) +//line views/nav.qtpl:19 + return qs422016 +//line views/nav.qtpl:19 +} + +//line views/nav.qtpl:21 +func streamhyphaInfo(qw422016 *qt422016.Writer, meta viewutil.Meta, h hyphae.Hypha) { +//line views/nav.qtpl:21 + qw422016.N().S(` +`) +//line views/nav.qtpl:23 u := meta.U lc := meta.Lc backs := backlinks.BacklinksCount(h) -//line views/nav.qtpl:21 +//line views/nav.qtpl:26 qw422016.N().S(` <nav class="hypha-info"> <ul class="hypha-info__list"> `) -//line views/nav.qtpl:24 - streamhyphaInfoEntry(qw422016, h, u, "history", lc.Get("ui.history_link")) -//line views/nav.qtpl:24 - qw422016.N().S(` - `) -//line views/nav.qtpl:25 - streamhyphaInfoEntry(qw422016, h, u, "rename", lc.Get("ui.rename_link")) -//line views/nav.qtpl:25 - qw422016.N().S(` - `) -//line views/nav.qtpl:26 - streamhyphaInfoEntry(qw422016, h, u, "delete", lc.Get("ui.delete_link")) -//line views/nav.qtpl:26 - qw422016.N().S(` - `) -//line views/nav.qtpl:27 - streamhyphaInfoEntry(qw422016, h, u, "text", lc.Get("ui.text_link")) -//line views/nav.qtpl:27 - qw422016.N().S(` - `) -//line views/nav.qtpl:28 - streamhyphaInfoEntry(qw422016, h, u, "media", lc.Get("ui.media_link")) -//line views/nav.qtpl:28 - qw422016.N().S(` - `) //line views/nav.qtpl:29 - streamhyphaInfoEntry(qw422016, h, u, "backlinks", lc.GetPlural("ui.backlinks_link", backs)) + streamhyphaInfoEntry(qw422016, h, u, "history", false, lc.Get("ui.history_link")) //line views/nav.qtpl:29 + qw422016.N().S(` + `) +//line views/nav.qtpl:30 + streamhyphaInfoEntry(qw422016, h, u, "rename", true, lc.Get("ui.rename_link")) +//line views/nav.qtpl:30 + qw422016.N().S(` + `) +//line views/nav.qtpl:31 + streamhyphaInfoEntry(qw422016, h, u, "delete", true, lc.Get("ui.delete_link")) +//line views/nav.qtpl:31 + qw422016.N().S(` + `) +//line views/nav.qtpl:32 + streamhyphaInfoEntry(qw422016, h, u, "text", true, lc.Get("ui.text_link")) +//line views/nav.qtpl:32 + qw422016.N().S(` + `) +//line views/nav.qtpl:33 + streamhyphaInfoEntry(qw422016, h, u, "media", true, lc.Get("ui.media_link")) +//line views/nav.qtpl:33 + qw422016.N().S(` + `) +//line views/nav.qtpl:34 + streamhyphaInfoEntry(qw422016, h, u, "backlinks", false, lc.GetPlural("ui.backlinks_link", backs)) +//line views/nav.qtpl:34 qw422016.N().S(` </ul> </nav> `) -//line views/nav.qtpl:32 +//line views/nav.qtpl:37 } -//line views/nav.qtpl:32 +//line views/nav.qtpl:37 func writehyphaInfo(qq422016 qtio422016.Writer, meta viewutil.Meta, h hyphae.Hypha) { -//line views/nav.qtpl:32 +//line views/nav.qtpl:37 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/nav.qtpl:32 +//line views/nav.qtpl:37 streamhyphaInfo(qw422016, meta, h) -//line views/nav.qtpl:32 +//line views/nav.qtpl:37 qt422016.ReleaseWriter(qw422016) -//line views/nav.qtpl:32 +//line views/nav.qtpl:37 } -//line views/nav.qtpl:32 +//line views/nav.qtpl:37 func hyphaInfo(meta viewutil.Meta, h hyphae.Hypha) string { -//line views/nav.qtpl:32 +//line views/nav.qtpl:37 qb422016 := qt422016.AcquireByteBuffer() -//line views/nav.qtpl:32 +//line views/nav.qtpl:37 writehyphaInfo(qb422016, meta, h) -//line views/nav.qtpl:32 +//line views/nav.qtpl:37 qs422016 := string(qb422016.B) -//line views/nav.qtpl:32 +//line views/nav.qtpl:37 qt422016.ReleaseByteBuffer(qb422016) -//line views/nav.qtpl:32 +//line views/nav.qtpl:37 return qs422016 -//line views/nav.qtpl:32 +//line views/nav.qtpl:37 } -//line views/nav.qtpl:34 +//line views/nav.qtpl:39 func streamcommonScripts(qw422016 *qt422016.Writer) { -//line views/nav.qtpl:34 +//line views/nav.qtpl:39 qw422016.N().S(` `) -//line views/nav.qtpl:35 +//line views/nav.qtpl:40 for _, scriptPath := range cfg.CommonScripts { -//line views/nav.qtpl:35 +//line views/nav.qtpl:40 qw422016.N().S(` <script src="`) -//line views/nav.qtpl:36 +//line views/nav.qtpl:41 qw422016.E().S(scriptPath) -//line views/nav.qtpl:36 +//line views/nav.qtpl:41 qw422016.N().S(`"></script> `) -//line views/nav.qtpl:37 +//line views/nav.qtpl:42 } -//line views/nav.qtpl:37 +//line views/nav.qtpl:42 qw422016.N().S(` `) -//line views/nav.qtpl:38 +//line views/nav.qtpl:43 } -//line views/nav.qtpl:38 +//line views/nav.qtpl:43 func writecommonScripts(qq422016 qtio422016.Writer) { -//line views/nav.qtpl:38 +//line views/nav.qtpl:43 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/nav.qtpl:38 +//line views/nav.qtpl:43 streamcommonScripts(qw422016) -//line views/nav.qtpl:38 +//line views/nav.qtpl:43 qt422016.ReleaseWriter(qw422016) -//line views/nav.qtpl:38 +//line views/nav.qtpl:43 } -//line views/nav.qtpl:38 +//line views/nav.qtpl:43 func commonScripts() string { -//line views/nav.qtpl:38 +//line views/nav.qtpl:43 qb422016 := qt422016.AcquireByteBuffer() -//line views/nav.qtpl:38 +//line views/nav.qtpl:43 writecommonScripts(qb422016) -//line views/nav.qtpl:38 +//line views/nav.qtpl:43 qs422016 := string(qb422016.B) -//line views/nav.qtpl:38 +//line views/nav.qtpl:43 qt422016.ReleaseByteBuffer(qb422016) -//line views/nav.qtpl:38 +//line views/nav.qtpl:43 return qs422016 -//line views/nav.qtpl:38 +//line views/nav.qtpl:43 } -//line views/nav.qtpl:40 +//line views/nav.qtpl:45 func streambeautifulLink(qw422016 *qt422016.Writer, hyphaName string) { -//line views/nav.qtpl:40 +//line views/nav.qtpl:45 qw422016.N().S(`<a href="/hypha/`) -//line views/nav.qtpl:40 +//line views/nav.qtpl:45 qw422016.N().S(hyphaName) -//line views/nav.qtpl:40 +//line views/nav.qtpl:45 qw422016.N().S(`">`) -//line views/nav.qtpl:40 +//line views/nav.qtpl:45 qw422016.E().S(util.BeautifulName(hyphaName)) -//line views/nav.qtpl:40 +//line views/nav.qtpl:45 qw422016.N().S(`</a>`) -//line views/nav.qtpl:40 +//line views/nav.qtpl:45 } -//line views/nav.qtpl:40 +//line views/nav.qtpl:45 func writebeautifulLink(qq422016 qtio422016.Writer, hyphaName string) { -//line views/nav.qtpl:40 +//line views/nav.qtpl:45 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/nav.qtpl:40 +//line views/nav.qtpl:45 streambeautifulLink(qw422016, hyphaName) -//line views/nav.qtpl:40 +//line views/nav.qtpl:45 qt422016.ReleaseWriter(qw422016) -//line views/nav.qtpl:40 +//line views/nav.qtpl:45 } -//line views/nav.qtpl:40 +//line views/nav.qtpl:45 func beautifulLink(hyphaName string) string { -//line views/nav.qtpl:40 +//line views/nav.qtpl:45 qb422016 := qt422016.AcquireByteBuffer() -//line views/nav.qtpl:40 +//line views/nav.qtpl:45 writebeautifulLink(qb422016, hyphaName) -//line views/nav.qtpl:40 +//line views/nav.qtpl:45 qs422016 := string(qb422016.B) -//line views/nav.qtpl:40 +//line views/nav.qtpl:45 qt422016.ReleaseByteBuffer(qb422016) -//line views/nav.qtpl:40 +//line views/nav.qtpl:45 return qs422016 -//line views/nav.qtpl:40 +//line views/nav.qtpl:45 }