{% 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(query string, generator func(string) <-chan string, lc *l18n.Localizer) %}

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

{%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 helpTopicsHTML(lang string, lc *l18n.Localizer) %} {% 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 AboutHTML(lc *l18n.Localizer) %}

{%s lc.Get("ui.about_title", &l18n.Replacements{"name": cfg.WikiName}) %}

  • {%s= lc.Get("ui.about_version", &l18n.Replacements{"pre": "", "post": ""}) %} 1.5.0
  • {%- if cfg.UseAuth -%}
  • {%s lc.Get("ui.about_usercount") %} {%dul user.Count() %}
  • {%s lc.Get("ui.about_homepage") %} {%s cfg.HomeHypha %}
  • {%s lc.Get("ui.about_admins") %} {%- for i, username := range user.ListUsersWithGroup("admin") -%} {%- if i > 0 -%} {%- endif -%} {%s username %}{%- endfor -%}
  • {%- else -%}
  • {%s lc.Get("ui.about_noauth") %}
  • {%- endif -%}

{%s= lc.Get("ui.about_hyphae", &l18n.Replacements{"link": "/list"}) %}

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