{% import "fmt" %} {% import "path/filepath" %} {% import "sort" %} {% import "github.com/bouncepaw/mycorrhiza/cfg" %} {% import "github.com/bouncepaw/mycorrhiza/hyphae" %} {% import "github.com/bouncepaw/mycorrhiza/user" %} {% import "github.com/bouncepaw/mycorrhiza/util" %} {% import "github.com/bouncepaw/mycorrhiza/l18n" %} {% func BaseHTML(title, body string, lc *l18n.Localizer, u *user.User, headElements ...string) %} {%s title %} {% for _, el := range headElements %}{%s= el %}{% endfor %}
{%s= body %} {%= CommonScripts() %} {% endfunc %} {% func TitleSearchHTML(query string, generator func(string) <-chan string, lc *l18n.Localizer) %}

{%s lc.Get("ui.search_results_query", &l18n.Replacements{"query": query})%}

{%s lc.Get("ui.search_results_desc")%}

{% endfunc %} It outputs a poorly formatted JSON, but it works and is valid. {% func TitleSearchJSON(query string, generator func(string) <-chan string) %} {% code // Lol counter := 0 %} { "source_query": "{%s query %}", "results": [ {% for hyphaName := range generator(query) %} {% if counter > 0 %}, {% endif %}{ "canonical_name": "{%s hyphaName %}", "beautiful_name": "{%s util.BeautifulName(hyphaName) %}", "url": "{%s cfg.URL + "/hypha/" + hyphaName %}" }{% code counter++ %} {% endfor %} ] } {% endfunc %} {% func BacklinksHTML(hyphaName string, generator func(string) <-chan string, lc *l18n.Localizer) %}

{%s= lc.Get( "ui.backlinks_heading", &l18n.Replacements{ "hypha_link": fmt.Sprintf( `%s`, hyphaName, util.BeautifulName(hyphaName), ), }, )%}

{%s lc.Get("ui.backlinks_desc")%}

{% endfunc %} {% func HelpHTML(content, lang string, lc *l18n.Localizer) %}
{%s= content %}
{%s= helpTopicsHTML(lang, lc) %}
{% endfunc %} {% func HelpEmptyErrorHTML(lc *l18n.Localizer) %}

{%s lc.Get("help.empty_error_title") %}

{%s lc.Get("help.empty_error_line_1") %}

{%s lc.Get("help.empty_error_line_2a") %} {%s lc.Get("help.empty_error_link") %} {%s lc.Get("help.empty_error_line_2b") %}

{% endfunc %} {% func helpTopicBadgeHTML(lang, topic string) %} ? {% endfunc %} {% func UserListHTML(lc *l18n.Localizer) %}

{%s lc.Get("ui.users_heading") %}

{% code var ( admins = make([]string, 0) moderators = make([]string, 0) editors = make([]string, 0) ) for u := range user.YieldUsers() { switch u.Group { case "admin": admins = append(admins, u.Name) case "moderator": moderators = append(moderators, u.Name) case "editor", "trusted": editors = append(editors, u.Name) } } sort.Strings(admins) sort.Strings(moderators) sort.Strings(editors) %}

{%s lc.Get("ui.users_admins") %}

    {% for _, name := range admins %}
  1. {%s name %}
  2. {% endfor %}

{%s lc.Get("ui.users_moderators") %}

    {% for _, name := range moderators %}
  1. {%s name %}
  2. {% endfor %}

{%s lc.Get("ui.users_editors") %}

    {% for _, name := range editors %}
  1. {%s name %}
  2. {% endfor %}
{% endfunc %} {% func HyphaListHTML(lc *l18n.Localizer) %}

{%s lc.Get("ui.list_heading") %}

{%s lc.GetPlural("ui.list_desc", hyphae.Count()) %}

{% endfunc %} {% func CommonScripts() %} {% for _, scriptPath := range cfg.CommonScripts %} {% endfor %} {% endfunc %}