{% import "net/http" %} {% import "strings" %} {% import "path" %} {% import "os" %} {% import "github.com/bouncepaw/mycorrhiza/cfg" %} {% import "github.com/bouncepaw/mycorrhiza/hyphae" %} {% import "github.com/bouncepaw/mycorrhiza/l18n" %} {% import "github.com/bouncepaw/mycorrhiza/mimetype" %} {% import "github.com/bouncepaw/mycorrhiza/tree" %} {% import "github.com/bouncepaw/mycorrhiza/user" %} {% import "github.com/bouncepaw/mycorrhiza/util" %} {% func AttachmentMenuHTML(rq *http.Request, h *hyphae.Hypha, u *user.User) %} {% code lc := l18n.FromRequest(rq) %}

{%s= lc.Get("ui.attach_title", &l18n.Replacements{"name": beautifulLink(h.Name)}) %}

{% if h.BinaryPath == "" %}

{%s lc.Get("ui.attach_empty") %} {%s lc.Get("ui.attach_link") %}

{% else %}

{%s lc.Get("ui.attach_tip") %} {%s lc.Get("ui.attach_link") %}

{% endif %}
{% if h.BinaryPath != "" %} {% code mime := mimetype.FromExtension(path.Ext(h.BinaryPath)) fileinfo, err := os.Stat(h.BinaryPath) %} {% if err == nil %}
{%s lc.Get("ui.attach_stat") %}

{%s lc.Get("ui.attach_stat_mime") %} {%s mime %}

{% endif %} {% if strings.HasPrefix(mime, "image/") %}
{%s lc.Get("ui.attach_include") %}
img { {%s h.Name %} }
{% endif %} {% endif %} {% if u.CanProceed("upload-binary") %} {% endif %} {% if h.BinaryPath != "" && u.CanProceed("unattach-confirm") %} {% endif %}
{% endfunc %} If `contents` == "", a helpful message is shown instead. If you rename .prevnext, change the docs too. {% func HyphaHTML(rq *http.Request, lc *l18n.Localizer, h *hyphae.Hypha, contents string) %} {% code siblings, subhyphae, prevHyphaName, nextHyphaName := tree.Tree(h.Name) u := user.FromRequest(rq) %}
{% if u.CanProceed("edit") %}{% endif %} {%s= NaviTitleHTML(h) %} {% if h.Exists %} {%s= contents %} {% else %} {%= nonExistentHyphaNotice(h, u, lc) %} {% endif %}
{% if prevHyphaName != "" %} {% endif %} {% if nextHyphaName != "" %} {% endif %}
{%= SubhyphaeHTML(subhyphae, lc) %}
{%= hyphaInfo(rq, h) %}
{%= siblingHyphaeHTML(siblings, lc) %}
{%= viewScripts() %} {% endfunc %} {% func RevisionHTML(rq *http.Request, lc *l18n.Localizer, h *hyphae.Hypha, contents, revHash string) %} {% code siblings, subhyphae, _, _ := tree.Tree(h.Name) %}
{%= SubhyphaeHTML(subhyphae, lc) %}
{%= siblingHyphaeHTML(siblings, lc) %}
{%= viewScripts() %} {% endfunc %} {% func viewScripts() %} {% for _, scriptPath := range cfg.ViewScripts %} {% endfor %} {% endfunc %}