{% 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.MediaHypha, u *user.User) %} {% code lc := l18n.FromRequest(rq) %}

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

{% 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.CanonicalName() %} }
{% 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.Hypher, contents string) %} {% code siblings, subhyphae, prevHyphaName, nextHyphaName := tree.Tree(h.CanonicalName()) u := user.FromRequest(rq) %}
{% if u.CanProceed("edit") %} {% endif %} {% if cfg.UseAuth && util.IsProfileName(h.CanonicalName()) && u.Name == strings.TrimPrefix(h.CanonicalName(), cfg.UserHypha + "/") %} {% if u.Group == "admin" %} {% endif %} {% endif %} {%s= NaviTitleHTML(h) %} {% switch h.(type) %} {% case *hyphae.EmptyHypha %} {%= nonExistentHyphaNotice(h, u, lc) %} {% default %} {%s= contents %} {% endswitch %}
{% 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.Hypher, contents, revHash string) %} {% code siblings, subhyphae, _, _ := tree.Tree(h.CanonicalName()) %}

{%s lc.Get("ui.revision_warning") %} {%s lc.Get("ui.revision_link") %}

{%s= NaviTitleHTML(h) %} {%s= contents %}
{%= SubhyphaeHTML(subhyphae, lc) %}
{%= siblingHyphaeHTML(siblings, lc) %}
{%= viewScripts() %} {% endfunc %} {% func viewScripts() %} {% for _, scriptPath := range cfg.ViewScripts %} {% endfor %} {% endfunc %}