mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-01-07 02:10:26 +00:00
Misc: Port /list to the new approach
This commit is contained in:
parent
f8fbc23202
commit
9eb92cfa6e
@ -30,25 +30,17 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func prepareViews() {
|
func prepareViews() {
|
||||||
var (
|
m := template.Must
|
||||||
m = template.Must
|
|
||||||
copyEnWith = func(f string) *template.Template {
|
|
||||||
return m(m(viewutil.BaseEn.Clone()).ParseFS(fs, f))
|
|
||||||
}
|
|
||||||
copyRuWith = func(f string) *template.Template {
|
|
||||||
return m(m(viewutil.BaseRu.Clone()).ParseFS(fs, f))
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
viewCardChain = viewutil.
|
viewCardChain = viewutil.
|
||||||
En(copyEnWith("view_card.html")).
|
En(viewutil.CopyEnWith(fs, "view_card.html")).
|
||||||
Ru(m(copyRuWith("view_card.html").Parse(ruTranslation)))
|
Ru(m(viewutil.CopyRuWith(fs, "view_card.html").Parse(ruTranslation)))
|
||||||
viewListChain = viewutil.
|
viewListChain = viewutil.
|
||||||
En(copyEnWith("view_list.html")).
|
En(viewutil.CopyEnWith(fs, "view_list.html")).
|
||||||
Ru(m(copyRuWith("view_list.html").Parse(ruTranslation)))
|
Ru(m(viewutil.CopyRuWith(fs, "view_list.html").Parse(ruTranslation)))
|
||||||
viewPageChain = viewutil.
|
viewPageChain = viewutil.
|
||||||
En(copyEnWith("view_page.html")).
|
En(viewutil.CopyEnWith(fs, "view_page.html")).
|
||||||
Ru(m(copyRuWith("view_page.html").Parse(ruTranslation)))
|
Ru(m(viewutil.CopyRuWith(fs, "view_page.html").Parse(ruTranslation)))
|
||||||
}
|
}
|
||||||
|
|
||||||
type cardData struct {
|
type cardData struct {
|
||||||
|
@ -28,17 +28,13 @@ func InitHandlers(rtr *mux.Router) {
|
|||||||
rtr.HandleFunc("/favicon.ico", func(w http.ResponseWriter, rq *http.Request) {
|
rtr.HandleFunc("/favicon.ico", func(w http.ResponseWriter, rq *http.Request) {
|
||||||
http.Redirect(w, rq, "/static/favicon.ico", http.StatusSeeOther)
|
http.Redirect(w, rq, "/static/favicon.ico", http.StatusSeeOther)
|
||||||
})
|
})
|
||||||
|
initViews()
|
||||||
}
|
}
|
||||||
|
|
||||||
// handlerList shows a list of all hyphae in the wiki in random order.
|
// handlerList shows a list of all hyphae in the wiki in random order.
|
||||||
func handlerList(w http.ResponseWriter, rq *http.Request) {
|
func handlerList(w http.ResponseWriter, rq *http.Request) {
|
||||||
var lc = l18n.FromRequest(rq)
|
|
||||||
util.PrepareRq(rq)
|
util.PrepareRq(rq)
|
||||||
util.HTTP200Page(w, views.Base(
|
viewList(viewutil.MetaFrom(w, rq))
|
||||||
viewutil.MetaFrom(w, rq),
|
|
||||||
lc.Get("ui.list_title"),
|
|
||||||
views.HyphaList(lc),
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// handlerReindex reindexes all hyphae by checking the wiki storage directory anew.
|
// handlerReindex reindexes all hyphae by checking the wiki storage directory anew.
|
21
misc/view_list.html
Normal file
21
misc/view_list.html
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{{define "list of hyphae"}}List of hyphae{{end}}
|
||||||
|
{{define "title"}}{{template "list of hyphae"}}{{end}}
|
||||||
|
{{define "body"}}
|
||||||
|
<div class="layout">
|
||||||
|
<main class="main-width">
|
||||||
|
<h1>{{template "list of hyphae"}}</h1>
|
||||||
|
<ol class="hypha-list">
|
||||||
|
{{range .Entries}}
|
||||||
|
<li class="hypha-list__entry">
|
||||||
|
<a class="hypha-list__link" href="/hypha/{{.Name}}">
|
||||||
|
{{beautifulName .Name}}
|
||||||
|
</a>
|
||||||
|
{{if .Ext}}
|
||||||
|
<span class="hypha-list__amnt-type">{{.Ext}}</span>
|
||||||
|
{{end}}
|
||||||
|
</li>
|
||||||
|
{{end}}
|
||||||
|
</ol>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
69
misc/views.go
Normal file
69
misc/views.go
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
package misc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"embed"
|
||||||
|
"github.com/bouncepaw/mycorrhiza/cfg"
|
||||||
|
"github.com/bouncepaw/mycorrhiza/hyphae"
|
||||||
|
"github.com/bouncepaw/mycorrhiza/viewutil"
|
||||||
|
"log"
|
||||||
|
"path/filepath"
|
||||||
|
"text/template"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
//go:embed *html
|
||||||
|
fs embed.FS
|
||||||
|
chainList viewutil.Chain
|
||||||
|
ruTranslation = `
|
||||||
|
{{define "list of hyphae"}}Список гиф{{end}}
|
||||||
|
`
|
||||||
|
)
|
||||||
|
|
||||||
|
func initViews() {
|
||||||
|
m := template.Must
|
||||||
|
chainList = viewutil.
|
||||||
|
En(viewutil.CopyEnWith(fs, "view_list.html")).
|
||||||
|
Ru(m(viewutil.CopyRuWith(fs, "view_list.html").Parse(ruTranslation)))
|
||||||
|
}
|
||||||
|
|
||||||
|
type listDatum struct {
|
||||||
|
Name string
|
||||||
|
Ext string
|
||||||
|
}
|
||||||
|
|
||||||
|
type listData struct {
|
||||||
|
viewutil.BaseData
|
||||||
|
Entries []listDatum
|
||||||
|
}
|
||||||
|
|
||||||
|
func viewList(meta viewutil.Meta) {
|
||||||
|
// TODO: make this better, there are too many loops and vars
|
||||||
|
var (
|
||||||
|
hyphaNames = make(chan string)
|
||||||
|
sortedHypha = hyphae.PathographicSort(hyphaNames)
|
||||||
|
data []listDatum
|
||||||
|
)
|
||||||
|
for hypha := range hyphae.YieldExistingHyphae() {
|
||||||
|
hyphaNames <- hypha.CanonicalName()
|
||||||
|
}
|
||||||
|
close(hyphaNames)
|
||||||
|
for hyphaName := range sortedHypha {
|
||||||
|
switch h := hyphae.ByName(hyphaName).(type) {
|
||||||
|
case *hyphae.TextualHypha:
|
||||||
|
data = append(data, listDatum{h.CanonicalName(), ""})
|
||||||
|
case *hyphae.MediaHypha:
|
||||||
|
data = append(data, listDatum{h.CanonicalName(), filepath.Ext(h.MediaFilePath())[1:]})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := chainList.Get(meta).ExecuteTemplate(meta.W, "page", listData{
|
||||||
|
BaseData: viewutil.BaseData{
|
||||||
|
Meta: meta,
|
||||||
|
HeaderLinks: cfg.HeaderLinks,
|
||||||
|
CommonScripts: cfg.CommonScripts,
|
||||||
|
},
|
||||||
|
Entries: data,
|
||||||
|
}); err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,6 @@
|
|||||||
{% import "fmt" %}
|
{% import "fmt" %}
|
||||||
{% import "path/filepath" %}
|
|
||||||
|
|
||||||
{% import "github.com/bouncepaw/mycorrhiza/cfg" %}
|
{% import "github.com/bouncepaw/mycorrhiza/cfg" %}
|
||||||
{% import "github.com/bouncepaw/mycorrhiza/hyphae" %}
|
|
||||||
{% import "github.com/bouncepaw/mycorrhiza/util" %}
|
{% import "github.com/bouncepaw/mycorrhiza/util" %}
|
||||||
{% import "github.com/bouncepaw/mycorrhiza/l18n" %}
|
{% import "github.com/bouncepaw/mycorrhiza/l18n" %}
|
||||||
|
|
||||||
@ -63,39 +61,6 @@
|
|||||||
<p>{%s lc.Get("help.empty_error_line_2a") %} <a class="wikilink wikilink_external wikilink_https" href="https://github.com/bouncepaw/mycorrhiza">{%s lc.Get("help.empty_error_link") %}</a> {%s lc.Get("help.empty_error_line_2b") %}</p>
|
<p>{%s lc.Get("help.empty_error_line_2a") %} <a class="wikilink wikilink_external wikilink_https" href="https://github.com/bouncepaw/mycorrhiza">{%s lc.Get("help.empty_error_link") %}</a> {%s lc.Get("help.empty_error_line_2b") %}</p>
|
||||||
{% endfunc %}
|
{% endfunc %}
|
||||||
|
|
||||||
{% func HyphaList(lc *l18n.Localizer) %}
|
|
||||||
<div class="layout">
|
|
||||||
<main class="main-width">
|
|
||||||
<h1>{%s lc.Get("ui.list_heading") %}</h1>
|
|
||||||
<p>{%s lc.GetPlural("ui.list_desc", hyphae.Count()) %}</p>
|
|
||||||
<ul class="hypha-list">
|
|
||||||
{% code
|
|
||||||
hyphaNames := make(chan string)
|
|
||||||
sortedHypha := hyphae.PathographicSort(hyphaNames)
|
|
||||||
for hypha := range hyphae.YieldExistingHyphae() {
|
|
||||||
hyphaNames <- hypha.CanonicalName()
|
|
||||||
}
|
|
||||||
close(hyphaNames)
|
|
||||||
%}
|
|
||||||
{% for hyphaName := range sortedHypha %}
|
|
||||||
{% code h := hyphae.ByName(hyphaName) %}
|
|
||||||
<li class="hypha-list__entry">
|
|
||||||
<a class="hypha-list__link" href="/hypha/{%s h.CanonicalName() %}">
|
|
||||||
{%s util.BeautifulName(h.CanonicalName()) %}
|
|
||||||
</a>
|
|
||||||
{% switch h := h.(type) %}
|
|
||||||
{% case *hyphae.MediaHypha %}
|
|
||||||
<span class="hypha-list__amnt-type">
|
|
||||||
{%s filepath.Ext(h.MediaFilePath())[1:] %}
|
|
||||||
</span>
|
|
||||||
{% endswitch %}
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
</main>
|
|
||||||
</div>
|
|
||||||
{% endfunc %}
|
|
||||||
|
|
||||||
{% func commonScripts() %}
|
{% func commonScripts() %}
|
||||||
{% for _, scriptPath := range cfg.CommonScripts %}
|
{% for _, scriptPath := range cfg.CommonScripts %}
|
||||||
<script src="{%s scriptPath %}"></script>
|
<script src="{%s scriptPath %}"></script>
|
||||||
|
@ -7,112 +7,106 @@ package views
|
|||||||
//line views/stuff.qtpl:1
|
//line views/stuff.qtpl:1
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
//line views/stuff.qtpl:2
|
//line views/stuff.qtpl:3
|
||||||
import "path/filepath"
|
|
||||||
|
|
||||||
//line views/stuff.qtpl:4
|
|
||||||
import "github.com/bouncepaw/mycorrhiza/cfg"
|
import "github.com/bouncepaw/mycorrhiza/cfg"
|
||||||
|
|
||||||
//line views/stuff.qtpl:5
|
//line views/stuff.qtpl:4
|
||||||
import "github.com/bouncepaw/mycorrhiza/hyphae"
|
|
||||||
|
|
||||||
//line views/stuff.qtpl:6
|
|
||||||
import "github.com/bouncepaw/mycorrhiza/util"
|
import "github.com/bouncepaw/mycorrhiza/util"
|
||||||
|
|
||||||
//line views/stuff.qtpl:7
|
//line views/stuff.qtpl:5
|
||||||
import "github.com/bouncepaw/mycorrhiza/l18n"
|
import "github.com/bouncepaw/mycorrhiza/l18n"
|
||||||
|
|
||||||
//line views/stuff.qtpl:9
|
//line views/stuff.qtpl:7
|
||||||
import (
|
import (
|
||||||
qtio422016 "io"
|
qtio422016 "io"
|
||||||
|
|
||||||
qt422016 "github.com/valyala/quicktemplate"
|
qt422016 "github.com/valyala/quicktemplate"
|
||||||
)
|
)
|
||||||
|
|
||||||
//line views/stuff.qtpl:9
|
//line views/stuff.qtpl:7
|
||||||
var (
|
var (
|
||||||
_ = qtio422016.Copy
|
_ = qtio422016.Copy
|
||||||
_ = qt422016.AcquireByteBuffer
|
_ = qt422016.AcquireByteBuffer
|
||||||
)
|
)
|
||||||
|
|
||||||
//line views/stuff.qtpl:9
|
//line views/stuff.qtpl:7
|
||||||
func StreamTitleSearch(qw422016 *qt422016.Writer, query string, generator func(string) <-chan string, lc *l18n.Localizer) {
|
func StreamTitleSearch(qw422016 *qt422016.Writer, query string, generator func(string) <-chan string, lc *l18n.Localizer) {
|
||||||
//line views/stuff.qtpl:9
|
//line views/stuff.qtpl:7
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
<div class="layout">
|
<div class="layout">
|
||||||
<main class="main-width title-search">
|
<main class="main-width title-search">
|
||||||
<h1>`)
|
<h1>`)
|
||||||
//line views/stuff.qtpl:12
|
//line views/stuff.qtpl:10
|
||||||
qw422016.E().S(lc.Get("ui.search_results_query", &l18n.Replacements{"query": query}))
|
qw422016.E().S(lc.Get("ui.search_results_query", &l18n.Replacements{"query": query}))
|
||||||
//line views/stuff.qtpl:12
|
//line views/stuff.qtpl:10
|
||||||
qw422016.N().S(`</h1>
|
qw422016.N().S(`</h1>
|
||||||
<p>`)
|
<p>`)
|
||||||
//line views/stuff.qtpl:13
|
//line views/stuff.qtpl:11
|
||||||
qw422016.E().S(lc.Get("ui.search_results_desc"))
|
qw422016.E().S(lc.Get("ui.search_results_desc"))
|
||||||
//line views/stuff.qtpl:13
|
//line views/stuff.qtpl:11
|
||||||
qw422016.N().S(`</p>
|
qw422016.N().S(`</p>
|
||||||
<ul class="title-search__results">
|
<ul class="title-search__results">
|
||||||
`)
|
`)
|
||||||
//line views/stuff.qtpl:15
|
//line views/stuff.qtpl:13
|
||||||
for hyphaName := range generator(query) {
|
for hyphaName := range generator(query) {
|
||||||
//line views/stuff.qtpl:15
|
//line views/stuff.qtpl:13
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
<li class="title-search__entry">
|
<li class="title-search__entry">
|
||||||
<a class="title-search__link wikilink" href="/hypha/`)
|
<a class="title-search__link wikilink" href="/hypha/`)
|
||||||
//line views/stuff.qtpl:17
|
//line views/stuff.qtpl:15
|
||||||
qw422016.E().S(hyphaName)
|
qw422016.E().S(hyphaName)
|
||||||
//line views/stuff.qtpl:17
|
//line views/stuff.qtpl:15
|
||||||
qw422016.N().S(`">`)
|
qw422016.N().S(`">`)
|
||||||
//line views/stuff.qtpl:17
|
//line views/stuff.qtpl:15
|
||||||
qw422016.E().S(util.BeautifulName(hyphaName))
|
qw422016.E().S(util.BeautifulName(hyphaName))
|
||||||
//line views/stuff.qtpl:17
|
//line views/stuff.qtpl:15
|
||||||
qw422016.N().S(`</a>
|
qw422016.N().S(`</a>
|
||||||
</li>
|
</li>
|
||||||
`)
|
`)
|
||||||
//line views/stuff.qtpl:19
|
//line views/stuff.qtpl:17
|
||||||
}
|
}
|
||||||
//line views/stuff.qtpl:19
|
//line views/stuff.qtpl:17
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
`)
|
`)
|
||||||
//line views/stuff.qtpl:22
|
//line views/stuff.qtpl:20
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/stuff.qtpl:22
|
//line views/stuff.qtpl:20
|
||||||
func WriteTitleSearch(qq422016 qtio422016.Writer, query string, generator func(string) <-chan string, lc *l18n.Localizer) {
|
func WriteTitleSearch(qq422016 qtio422016.Writer, query string, generator func(string) <-chan string, lc *l18n.Localizer) {
|
||||||
//line views/stuff.qtpl:22
|
//line views/stuff.qtpl:20
|
||||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||||
//line views/stuff.qtpl:22
|
//line views/stuff.qtpl:20
|
||||||
StreamTitleSearch(qw422016, query, generator, lc)
|
StreamTitleSearch(qw422016, query, generator, lc)
|
||||||
//line views/stuff.qtpl:22
|
//line views/stuff.qtpl:20
|
||||||
qt422016.ReleaseWriter(qw422016)
|
qt422016.ReleaseWriter(qw422016)
|
||||||
//line views/stuff.qtpl:22
|
//line views/stuff.qtpl:20
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/stuff.qtpl:22
|
//line views/stuff.qtpl:20
|
||||||
func TitleSearch(query string, generator func(string) <-chan string, lc *l18n.Localizer) string {
|
func TitleSearch(query string, generator func(string) <-chan string, lc *l18n.Localizer) string {
|
||||||
//line views/stuff.qtpl:22
|
//line views/stuff.qtpl:20
|
||||||
qb422016 := qt422016.AcquireByteBuffer()
|
qb422016 := qt422016.AcquireByteBuffer()
|
||||||
//line views/stuff.qtpl:22
|
//line views/stuff.qtpl:20
|
||||||
WriteTitleSearch(qb422016, query, generator, lc)
|
WriteTitleSearch(qb422016, query, generator, lc)
|
||||||
//line views/stuff.qtpl:22
|
//line views/stuff.qtpl:20
|
||||||
qs422016 := string(qb422016.B)
|
qs422016 := string(qb422016.B)
|
||||||
//line views/stuff.qtpl:22
|
//line views/stuff.qtpl:20
|
||||||
qt422016.ReleaseByteBuffer(qb422016)
|
qt422016.ReleaseByteBuffer(qb422016)
|
||||||
//line views/stuff.qtpl:22
|
//line views/stuff.qtpl:20
|
||||||
return qs422016
|
return qs422016
|
||||||
//line views/stuff.qtpl:22
|
//line views/stuff.qtpl:20
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/stuff.qtpl:24
|
//line views/stuff.qtpl:22
|
||||||
func StreamBacklinks(qw422016 *qt422016.Writer, hyphaName string, generator func(string) <-chan string, lc *l18n.Localizer) {
|
func StreamBacklinks(qw422016 *qt422016.Writer, hyphaName string, generator func(string) <-chan string, lc *l18n.Localizer) {
|
||||||
//line views/stuff.qtpl:24
|
//line views/stuff.qtpl:22
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
<div class="layout">
|
<div class="layout">
|
||||||
<main class="main-width backlinks">
|
<main class="main-width backlinks">
|
||||||
<h1>`)
|
<h1>`)
|
||||||
//line views/stuff.qtpl:27
|
//line views/stuff.qtpl:25
|
||||||
qw422016.N().S(lc.Get(
|
qw422016.N().S(lc.Get(
|
||||||
"ui.backlinks_heading",
|
"ui.backlinks_heading",
|
||||||
&l18n.Replacements{
|
&l18n.Replacements{
|
||||||
@ -123,329 +117,220 @@ func StreamBacklinks(qw422016 *qt422016.Writer, hyphaName string, generator func
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
//line views/stuff.qtpl:36
|
//line views/stuff.qtpl:34
|
||||||
qw422016.N().S(`</h1>
|
qw422016.N().S(`</h1>
|
||||||
<p>`)
|
<p>`)
|
||||||
//line views/stuff.qtpl:37
|
//line views/stuff.qtpl:35
|
||||||
qw422016.E().S(lc.Get("ui.backlinks_desc"))
|
qw422016.E().S(lc.Get("ui.backlinks_desc"))
|
||||||
//line views/stuff.qtpl:37
|
//line views/stuff.qtpl:35
|
||||||
qw422016.N().S(`</p>
|
qw422016.N().S(`</p>
|
||||||
<ul class="backlinks__list">
|
<ul class="backlinks__list">
|
||||||
`)
|
`)
|
||||||
//line views/stuff.qtpl:39
|
//line views/stuff.qtpl:37
|
||||||
for hyphaName := range generator(hyphaName) {
|
for hyphaName := range generator(hyphaName) {
|
||||||
//line views/stuff.qtpl:39
|
//line views/stuff.qtpl:37
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
<li class="backlinks__entry">
|
<li class="backlinks__entry">
|
||||||
<a class="backlinks__link wikilink" href="/hypha/`)
|
<a class="backlinks__link wikilink" href="/hypha/`)
|
||||||
//line views/stuff.qtpl:41
|
//line views/stuff.qtpl:39
|
||||||
qw422016.E().S(hyphaName)
|
qw422016.E().S(hyphaName)
|
||||||
//line views/stuff.qtpl:41
|
//line views/stuff.qtpl:39
|
||||||
qw422016.N().S(`">`)
|
qw422016.N().S(`">`)
|
||||||
//line views/stuff.qtpl:41
|
//line views/stuff.qtpl:39
|
||||||
qw422016.E().S(util.BeautifulName(hyphaName))
|
qw422016.E().S(util.BeautifulName(hyphaName))
|
||||||
//line views/stuff.qtpl:41
|
//line views/stuff.qtpl:39
|
||||||
qw422016.N().S(`</a>
|
qw422016.N().S(`</a>
|
||||||
</li>
|
</li>
|
||||||
`)
|
`)
|
||||||
//line views/stuff.qtpl:43
|
//line views/stuff.qtpl:41
|
||||||
}
|
}
|
||||||
//line views/stuff.qtpl:43
|
//line views/stuff.qtpl:41
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
</ul>
|
</ul>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
`)
|
`)
|
||||||
//line views/stuff.qtpl:47
|
//line views/stuff.qtpl:45
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/stuff.qtpl:47
|
//line views/stuff.qtpl:45
|
||||||
func WriteBacklinks(qq422016 qtio422016.Writer, hyphaName string, generator func(string) <-chan string, lc *l18n.Localizer) {
|
func WriteBacklinks(qq422016 qtio422016.Writer, hyphaName string, generator func(string) <-chan string, lc *l18n.Localizer) {
|
||||||
//line views/stuff.qtpl:47
|
//line views/stuff.qtpl:45
|
||||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||||
//line views/stuff.qtpl:47
|
//line views/stuff.qtpl:45
|
||||||
StreamBacklinks(qw422016, hyphaName, generator, lc)
|
StreamBacklinks(qw422016, hyphaName, generator, lc)
|
||||||
//line views/stuff.qtpl:47
|
//line views/stuff.qtpl:45
|
||||||
qt422016.ReleaseWriter(qw422016)
|
qt422016.ReleaseWriter(qw422016)
|
||||||
//line views/stuff.qtpl:47
|
//line views/stuff.qtpl:45
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/stuff.qtpl:47
|
//line views/stuff.qtpl:45
|
||||||
func Backlinks(hyphaName string, generator func(string) <-chan string, lc *l18n.Localizer) string {
|
func Backlinks(hyphaName string, generator func(string) <-chan string, lc *l18n.Localizer) string {
|
||||||
//line views/stuff.qtpl:47
|
//line views/stuff.qtpl:45
|
||||||
qb422016 := qt422016.AcquireByteBuffer()
|
qb422016 := qt422016.AcquireByteBuffer()
|
||||||
//line views/stuff.qtpl:47
|
//line views/stuff.qtpl:45
|
||||||
WriteBacklinks(qb422016, hyphaName, generator, lc)
|
WriteBacklinks(qb422016, hyphaName, generator, lc)
|
||||||
//line views/stuff.qtpl:47
|
//line views/stuff.qtpl:45
|
||||||
qs422016 := string(qb422016.B)
|
qs422016 := string(qb422016.B)
|
||||||
//line views/stuff.qtpl:47
|
//line views/stuff.qtpl:45
|
||||||
qt422016.ReleaseByteBuffer(qb422016)
|
qt422016.ReleaseByteBuffer(qb422016)
|
||||||
//line views/stuff.qtpl:47
|
//line views/stuff.qtpl:45
|
||||||
return qs422016
|
return qs422016
|
||||||
//line views/stuff.qtpl:47
|
//line views/stuff.qtpl:45
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/stuff.qtpl:49
|
//line views/stuff.qtpl:47
|
||||||
func StreamHelp(qw422016 *qt422016.Writer, content, lang string, lc *l18n.Localizer) {
|
func StreamHelp(qw422016 *qt422016.Writer, content, lang string, lc *l18n.Localizer) {
|
||||||
//line views/stuff.qtpl:49
|
//line views/stuff.qtpl:47
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
<div class="layout">
|
<div class="layout">
|
||||||
<main class="main-width help">
|
<main class="main-width help">
|
||||||
<article>
|
<article>
|
||||||
`)
|
`)
|
||||||
//line views/stuff.qtpl:53
|
//line views/stuff.qtpl:51
|
||||||
qw422016.N().S(content)
|
qw422016.N().S(content)
|
||||||
//line views/stuff.qtpl:53
|
//line views/stuff.qtpl:51
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
</article>
|
</article>
|
||||||
</main>
|
</main>
|
||||||
`)
|
`)
|
||||||
//line views/stuff.qtpl:56
|
//line views/stuff.qtpl:54
|
||||||
qw422016.N().S(helpTopics(lang, lc))
|
qw422016.N().S(helpTopics(lang, lc))
|
||||||
//line views/stuff.qtpl:56
|
//line views/stuff.qtpl:54
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
</div>
|
</div>
|
||||||
`)
|
`)
|
||||||
//line views/stuff.qtpl:58
|
//line views/stuff.qtpl:56
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/stuff.qtpl:58
|
//line views/stuff.qtpl:56
|
||||||
func WriteHelp(qq422016 qtio422016.Writer, content, lang string, lc *l18n.Localizer) {
|
func WriteHelp(qq422016 qtio422016.Writer, content, lang string, lc *l18n.Localizer) {
|
||||||
//line views/stuff.qtpl:58
|
//line views/stuff.qtpl:56
|
||||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||||
//line views/stuff.qtpl:58
|
//line views/stuff.qtpl:56
|
||||||
StreamHelp(qw422016, content, lang, lc)
|
StreamHelp(qw422016, content, lang, lc)
|
||||||
//line views/stuff.qtpl:58
|
//line views/stuff.qtpl:56
|
||||||
qt422016.ReleaseWriter(qw422016)
|
qt422016.ReleaseWriter(qw422016)
|
||||||
//line views/stuff.qtpl:58
|
//line views/stuff.qtpl:56
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/stuff.qtpl:58
|
//line views/stuff.qtpl:56
|
||||||
func Help(content, lang string, lc *l18n.Localizer) string {
|
func Help(content, lang string, lc *l18n.Localizer) string {
|
||||||
//line views/stuff.qtpl:58
|
//line views/stuff.qtpl:56
|
||||||
qb422016 := qt422016.AcquireByteBuffer()
|
qb422016 := qt422016.AcquireByteBuffer()
|
||||||
//line views/stuff.qtpl:58
|
//line views/stuff.qtpl:56
|
||||||
WriteHelp(qb422016, content, lang, lc)
|
WriteHelp(qb422016, content, lang, lc)
|
||||||
//line views/stuff.qtpl:58
|
//line views/stuff.qtpl:56
|
||||||
qs422016 := string(qb422016.B)
|
qs422016 := string(qb422016.B)
|
||||||
//line views/stuff.qtpl:58
|
//line views/stuff.qtpl:56
|
||||||
qt422016.ReleaseByteBuffer(qb422016)
|
qt422016.ReleaseByteBuffer(qb422016)
|
||||||
//line views/stuff.qtpl:58
|
//line views/stuff.qtpl:56
|
||||||
return qs422016
|
return qs422016
|
||||||
//line views/stuff.qtpl:58
|
//line views/stuff.qtpl:56
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/stuff.qtpl:60
|
//line views/stuff.qtpl:58
|
||||||
func StreamHelpEmptyError(qw422016 *qt422016.Writer, lc *l18n.Localizer) {
|
func StreamHelpEmptyError(qw422016 *qt422016.Writer, lc *l18n.Localizer) {
|
||||||
//line views/stuff.qtpl:60
|
//line views/stuff.qtpl:58
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
<h1>`)
|
<h1>`)
|
||||||
//line views/stuff.qtpl:61
|
//line views/stuff.qtpl:59
|
||||||
qw422016.E().S(lc.Get("help.empty_error_title"))
|
qw422016.E().S(lc.Get("help.empty_error_title"))
|
||||||
//line views/stuff.qtpl:61
|
//line views/stuff.qtpl:59
|
||||||
qw422016.N().S(`</h1>
|
qw422016.N().S(`</h1>
|
||||||
<p>`)
|
<p>`)
|
||||||
//line views/stuff.qtpl:62
|
//line views/stuff.qtpl:60
|
||||||
qw422016.E().S(lc.Get("help.empty_error_line_1"))
|
qw422016.E().S(lc.Get("help.empty_error_line_1"))
|
||||||
//line views/stuff.qtpl:62
|
//line views/stuff.qtpl:60
|
||||||
qw422016.N().S(`</p>
|
qw422016.N().S(`</p>
|
||||||
<p>`)
|
<p>`)
|
||||||
//line views/stuff.qtpl:63
|
//line views/stuff.qtpl:61
|
||||||
qw422016.E().S(lc.Get("help.empty_error_line_2a"))
|
qw422016.E().S(lc.Get("help.empty_error_line_2a"))
|
||||||
//line views/stuff.qtpl:63
|
//line views/stuff.qtpl:61
|
||||||
qw422016.N().S(` <a class="wikilink wikilink_external wikilink_https" href="https://github.com/bouncepaw/mycorrhiza">`)
|
qw422016.N().S(` <a class="wikilink wikilink_external wikilink_https" href="https://github.com/bouncepaw/mycorrhiza">`)
|
||||||
//line views/stuff.qtpl:63
|
//line views/stuff.qtpl:61
|
||||||
qw422016.E().S(lc.Get("help.empty_error_link"))
|
qw422016.E().S(lc.Get("help.empty_error_link"))
|
||||||
//line views/stuff.qtpl:63
|
//line views/stuff.qtpl:61
|
||||||
qw422016.N().S(`</a> `)
|
qw422016.N().S(`</a> `)
|
||||||
//line views/stuff.qtpl:63
|
//line views/stuff.qtpl:61
|
||||||
qw422016.E().S(lc.Get("help.empty_error_line_2b"))
|
qw422016.E().S(lc.Get("help.empty_error_line_2b"))
|
||||||
//line views/stuff.qtpl:63
|
//line views/stuff.qtpl:61
|
||||||
qw422016.N().S(`</p>
|
qw422016.N().S(`</p>
|
||||||
`)
|
`)
|
||||||
//line views/stuff.qtpl:64
|
//line views/stuff.qtpl:62
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/stuff.qtpl:64
|
//line views/stuff.qtpl:62
|
||||||
func WriteHelpEmptyError(qq422016 qtio422016.Writer, lc *l18n.Localizer) {
|
func WriteHelpEmptyError(qq422016 qtio422016.Writer, lc *l18n.Localizer) {
|
||||||
//line views/stuff.qtpl:64
|
//line views/stuff.qtpl:62
|
||||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||||
//line views/stuff.qtpl:64
|
//line views/stuff.qtpl:62
|
||||||
StreamHelpEmptyError(qw422016, lc)
|
StreamHelpEmptyError(qw422016, lc)
|
||||||
//line views/stuff.qtpl:64
|
//line views/stuff.qtpl:62
|
||||||
qt422016.ReleaseWriter(qw422016)
|
qt422016.ReleaseWriter(qw422016)
|
||||||
//line views/stuff.qtpl:64
|
//line views/stuff.qtpl:62
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/stuff.qtpl:64
|
//line views/stuff.qtpl:62
|
||||||
func HelpEmptyError(lc *l18n.Localizer) string {
|
func HelpEmptyError(lc *l18n.Localizer) string {
|
||||||
//line views/stuff.qtpl:64
|
//line views/stuff.qtpl:62
|
||||||
qb422016 := qt422016.AcquireByteBuffer()
|
qb422016 := qt422016.AcquireByteBuffer()
|
||||||
//line views/stuff.qtpl:64
|
//line views/stuff.qtpl:62
|
||||||
WriteHelpEmptyError(qb422016, lc)
|
WriteHelpEmptyError(qb422016, lc)
|
||||||
//line views/stuff.qtpl:64
|
//line views/stuff.qtpl:62
|
||||||
qs422016 := string(qb422016.B)
|
qs422016 := string(qb422016.B)
|
||||||
//line views/stuff.qtpl:64
|
//line views/stuff.qtpl:62
|
||||||
qt422016.ReleaseByteBuffer(qb422016)
|
qt422016.ReleaseByteBuffer(qb422016)
|
||||||
//line views/stuff.qtpl:64
|
//line views/stuff.qtpl:62
|
||||||
return qs422016
|
return qs422016
|
||||||
|
//line views/stuff.qtpl:62
|
||||||
|
}
|
||||||
|
|
||||||
//line views/stuff.qtpl:64
|
//line views/stuff.qtpl:64
|
||||||
}
|
|
||||||
|
|
||||||
//line views/stuff.qtpl:66
|
|
||||||
func StreamHyphaList(qw422016 *qt422016.Writer, lc *l18n.Localizer) {
|
|
||||||
//line views/stuff.qtpl:66
|
|
||||||
qw422016.N().S(`
|
|
||||||
<div class="layout">
|
|
||||||
<main class="main-width">
|
|
||||||
<h1>`)
|
|
||||||
//line views/stuff.qtpl:69
|
|
||||||
qw422016.E().S(lc.Get("ui.list_heading"))
|
|
||||||
//line views/stuff.qtpl:69
|
|
||||||
qw422016.N().S(`</h1>
|
|
||||||
<p>`)
|
|
||||||
//line views/stuff.qtpl:70
|
|
||||||
qw422016.E().S(lc.GetPlural("ui.list_desc", hyphae.Count()))
|
|
||||||
//line views/stuff.qtpl:70
|
|
||||||
qw422016.N().S(`</p>
|
|
||||||
<ul class="hypha-list">
|
|
||||||
`)
|
|
||||||
//line views/stuff.qtpl:73
|
|
||||||
hyphaNames := make(chan string)
|
|
||||||
sortedHypha := hyphae.PathographicSort(hyphaNames)
|
|
||||||
for hypha := range hyphae.YieldExistingHyphae() {
|
|
||||||
hyphaNames <- hypha.CanonicalName()
|
|
||||||
}
|
|
||||||
close(hyphaNames)
|
|
||||||
|
|
||||||
//line views/stuff.qtpl:79
|
|
||||||
qw422016.N().S(`
|
|
||||||
`)
|
|
||||||
//line views/stuff.qtpl:80
|
|
||||||
for hyphaName := range sortedHypha {
|
|
||||||
//line views/stuff.qtpl:80
|
|
||||||
qw422016.N().S(`
|
|
||||||
`)
|
|
||||||
//line views/stuff.qtpl:81
|
|
||||||
h := hyphae.ByName(hyphaName)
|
|
||||||
|
|
||||||
//line views/stuff.qtpl:81
|
|
||||||
qw422016.N().S(`
|
|
||||||
<li class="hypha-list__entry">
|
|
||||||
<a class="hypha-list__link" href="/hypha/`)
|
|
||||||
//line views/stuff.qtpl:83
|
|
||||||
qw422016.E().S(h.CanonicalName())
|
|
||||||
//line views/stuff.qtpl:83
|
|
||||||
qw422016.N().S(`">
|
|
||||||
`)
|
|
||||||
//line views/stuff.qtpl:84
|
|
||||||
qw422016.E().S(util.BeautifulName(h.CanonicalName()))
|
|
||||||
//line views/stuff.qtpl:84
|
|
||||||
qw422016.N().S(`
|
|
||||||
</a>
|
|
||||||
`)
|
|
||||||
//line views/stuff.qtpl:86
|
|
||||||
switch h := h.(type) {
|
|
||||||
//line views/stuff.qtpl:87
|
|
||||||
case *hyphae.MediaHypha:
|
|
||||||
//line views/stuff.qtpl:87
|
|
||||||
qw422016.N().S(`
|
|
||||||
<span class="hypha-list__amnt-type">
|
|
||||||
`)
|
|
||||||
//line views/stuff.qtpl:89
|
|
||||||
qw422016.E().S(filepath.Ext(h.MediaFilePath())[1:])
|
|
||||||
//line views/stuff.qtpl:89
|
|
||||||
qw422016.N().S(`
|
|
||||||
</span>
|
|
||||||
`)
|
|
||||||
//line views/stuff.qtpl:91
|
|
||||||
}
|
|
||||||
//line views/stuff.qtpl:91
|
|
||||||
qw422016.N().S(`
|
|
||||||
</li>
|
|
||||||
`)
|
|
||||||
//line views/stuff.qtpl:93
|
|
||||||
}
|
|
||||||
//line views/stuff.qtpl:93
|
|
||||||
qw422016.N().S(`
|
|
||||||
</ul>
|
|
||||||
</main>
|
|
||||||
</div>
|
|
||||||
`)
|
|
||||||
//line views/stuff.qtpl:97
|
|
||||||
}
|
|
||||||
|
|
||||||
//line views/stuff.qtpl:97
|
|
||||||
func WriteHyphaList(qq422016 qtio422016.Writer, lc *l18n.Localizer) {
|
|
||||||
//line views/stuff.qtpl:97
|
|
||||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
|
||||||
//line views/stuff.qtpl:97
|
|
||||||
StreamHyphaList(qw422016, lc)
|
|
||||||
//line views/stuff.qtpl:97
|
|
||||||
qt422016.ReleaseWriter(qw422016)
|
|
||||||
//line views/stuff.qtpl:97
|
|
||||||
}
|
|
||||||
|
|
||||||
//line views/stuff.qtpl:97
|
|
||||||
func HyphaList(lc *l18n.Localizer) string {
|
|
||||||
//line views/stuff.qtpl:97
|
|
||||||
qb422016 := qt422016.AcquireByteBuffer()
|
|
||||||
//line views/stuff.qtpl:97
|
|
||||||
WriteHyphaList(qb422016, lc)
|
|
||||||
//line views/stuff.qtpl:97
|
|
||||||
qs422016 := string(qb422016.B)
|
|
||||||
//line views/stuff.qtpl:97
|
|
||||||
qt422016.ReleaseByteBuffer(qb422016)
|
|
||||||
//line views/stuff.qtpl:97
|
|
||||||
return qs422016
|
|
||||||
//line views/stuff.qtpl:97
|
|
||||||
}
|
|
||||||
|
|
||||||
//line views/stuff.qtpl:99
|
|
||||||
func streamcommonScripts(qw422016 *qt422016.Writer) {
|
func streamcommonScripts(qw422016 *qt422016.Writer) {
|
||||||
//line views/stuff.qtpl:99
|
//line views/stuff.qtpl:64
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
`)
|
`)
|
||||||
//line views/stuff.qtpl:100
|
//line views/stuff.qtpl:65
|
||||||
for _, scriptPath := range cfg.CommonScripts {
|
for _, scriptPath := range cfg.CommonScripts {
|
||||||
//line views/stuff.qtpl:100
|
//line views/stuff.qtpl:65
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
<script src="`)
|
<script src="`)
|
||||||
//line views/stuff.qtpl:101
|
//line views/stuff.qtpl:66
|
||||||
qw422016.E().S(scriptPath)
|
qw422016.E().S(scriptPath)
|
||||||
//line views/stuff.qtpl:101
|
//line views/stuff.qtpl:66
|
||||||
qw422016.N().S(`"></script>
|
qw422016.N().S(`"></script>
|
||||||
`)
|
`)
|
||||||
//line views/stuff.qtpl:102
|
//line views/stuff.qtpl:67
|
||||||
}
|
}
|
||||||
//line views/stuff.qtpl:102
|
//line views/stuff.qtpl:67
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
`)
|
`)
|
||||||
//line views/stuff.qtpl:103
|
//line views/stuff.qtpl:68
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/stuff.qtpl:103
|
//line views/stuff.qtpl:68
|
||||||
func writecommonScripts(qq422016 qtio422016.Writer) {
|
func writecommonScripts(qq422016 qtio422016.Writer) {
|
||||||
//line views/stuff.qtpl:103
|
//line views/stuff.qtpl:68
|
||||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||||
//line views/stuff.qtpl:103
|
//line views/stuff.qtpl:68
|
||||||
streamcommonScripts(qw422016)
|
streamcommonScripts(qw422016)
|
||||||
//line views/stuff.qtpl:103
|
//line views/stuff.qtpl:68
|
||||||
qt422016.ReleaseWriter(qw422016)
|
qt422016.ReleaseWriter(qw422016)
|
||||||
//line views/stuff.qtpl:103
|
//line views/stuff.qtpl:68
|
||||||
}
|
}
|
||||||
|
|
||||||
//line views/stuff.qtpl:103
|
//line views/stuff.qtpl:68
|
||||||
func commonScripts() string {
|
func commonScripts() string {
|
||||||
//line views/stuff.qtpl:103
|
//line views/stuff.qtpl:68
|
||||||
qb422016 := qt422016.AcquireByteBuffer()
|
qb422016 := qt422016.AcquireByteBuffer()
|
||||||
//line views/stuff.qtpl:103
|
//line views/stuff.qtpl:68
|
||||||
writecommonScripts(qb422016)
|
writecommonScripts(qb422016)
|
||||||
//line views/stuff.qtpl:103
|
//line views/stuff.qtpl:68
|
||||||
qs422016 := string(qb422016.B)
|
qs422016 := string(qb422016.B)
|
||||||
//line views/stuff.qtpl:103
|
//line views/stuff.qtpl:68
|
||||||
qt422016.ReleaseByteBuffer(qb422016)
|
qt422016.ReleaseByteBuffer(qb422016)
|
||||||
//line views/stuff.qtpl:103
|
//line views/stuff.qtpl:68
|
||||||
return qs422016
|
return qs422016
|
||||||
//line views/stuff.qtpl:103
|
//line views/stuff.qtpl:68
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/bouncepaw/mycorrhiza/cfg"
|
"github.com/bouncepaw/mycorrhiza/cfg"
|
||||||
"github.com/bouncepaw/mycorrhiza/util"
|
"github.com/bouncepaw/mycorrhiza/util"
|
||||||
|
"io/fs"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template" // TODO: save the world
|
"text/template" // TODO: save the world
|
||||||
@ -13,7 +14,7 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
//go:embed *.html
|
//go:embed *.html
|
||||||
fs embed.FS
|
fsys embed.FS
|
||||||
BaseEn *template.Template
|
BaseEn *template.Template
|
||||||
BaseRu *template.Template
|
BaseRu *template.Template
|
||||||
m = template.Must
|
m = template.Must
|
||||||
@ -33,7 +34,7 @@ func Init() {
|
|||||||
BaseEn = m(m(template.New("").
|
BaseEn = m(m(template.New("").
|
||||||
Funcs(template.FuncMap{
|
Funcs(template.FuncMap{
|
||||||
"beautifulName": util.BeautifulName,
|
"beautifulName": util.BeautifulName,
|
||||||
}).ParseFS(fs, "base.html")).
|
}).ParseFS(fsys, "base.html")).
|
||||||
Parse(dataText))
|
Parse(dataText))
|
||||||
if !cfg.UseAuth {
|
if !cfg.UseAuth {
|
||||||
m(BaseEn.Parse(`{{define "auth"}}{{end}}`))
|
m(BaseEn.Parse(`{{define "auth"}}{{end}}`))
|
||||||
@ -85,3 +86,11 @@ func Base(meta Meta, title, body string, headElements ...string) string {
|
|||||||
}
|
}
|
||||||
return w.String()
|
return w.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CopyEnWith(fsys fs.FS, f string) *template.Template {
|
||||||
|
return m(m(BaseEn.Clone()).ParseFS(fsys, f))
|
||||||
|
}
|
||||||
|
|
||||||
|
func CopyRuWith(fsys fs.FS, f string) *template.Template {
|
||||||
|
return m(m(BaseRu.Clone()).ParseFS(fsys, f))
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user