1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-16 06:50:26 +00:00
mycorrhiza/views/stuff.qtpl
2022-03-30 00:11:34 +03:00

104 lines
3.1 KiB
Plaintext

{% import "fmt" %}
{% import "path/filepath" %}
{% import "github.com/bouncepaw/mycorrhiza/cfg" %}
{% import "github.com/bouncepaw/mycorrhiza/hyphae" %}
{% import "github.com/bouncepaw/mycorrhiza/util" %}
{% import "github.com/bouncepaw/mycorrhiza/l18n" %}
{% func TitleSearch(query string, generator func(string) <-chan string, lc *l18n.Localizer) %}
<div class="layout">
<main class="main-width title-search">
<h1>{%s lc.Get("ui.search_results_query", &l18n.Replacements{"query": query})%}</h1>
<p>{%s lc.Get("ui.search_results_desc")%}</p>
<ul class="title-search__results">
{% for hyphaName := range generator(query) %}
<li class="title-search__entry">
<a class="title-search__link wikilink" href="/hypha/{%s hyphaName %}">{%s util.BeautifulName(hyphaName) %}</a>
</li>
{% endfor %}
</main>
</div>
{% endfunc %}
{% func Backlinks(hyphaName string, generator func(string) <-chan string, lc *l18n.Localizer) %}
<div class="layout">
<main class="main-width backlinks">
<h1>{%s= lc.Get(
"ui.backlinks_heading",
&l18n.Replacements{
"hypha_link": fmt.Sprintf(
`<a href="/hypha/%s">%s</a>`,
hyphaName,
util.BeautifulName(hyphaName),
),
},
)%}</h1>
<p>{%s lc.Get("ui.backlinks_desc")%}</p>
<ul class="backlinks__list">
{% for hyphaName := range generator(hyphaName) %}
<li class="backlinks__entry">
<a class="backlinks__link wikilink" href="/hypha/{%s hyphaName %}">{%s util.BeautifulName(hyphaName) %}</a>
</li>
{% endfor %}
</ul>
</main>
</div>
{% endfunc %}
{% func Help(content, lang string, lc *l18n.Localizer) %}
<div class="layout">
<main class="main-width help">
<article>
{%s= content %}
</article>
</main>
{%s= helpTopics(lang, lc) %}
</div>
{% endfunc %}
{% func HelpEmptyError(lc *l18n.Localizer) %}
<h1>{%s lc.Get("help.empty_error_title") %}</h1>
<p>{%s lc.Get("help.empty_error_line_1") %}</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 %}
{% 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() %}
{% for _, scriptPath := range cfg.CommonScripts %}
<script src="{%s scriptPath %}"></script>
{% endfor %}
{% endfunc %}