{% 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/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) %}

Attachment of {%s= beautifulLink(h.Name) %}

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

This hypha has no attachment, you can upload it here. What are attachments?

{% else %}

You can manage the hypha's attachment on this page. What are attachments?

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

MIME type: {%s mime %}

{% endif %} {% if strings.HasPrefix(mime, "image/") %}
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, 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) %} {% endif %}
{% if prevHyphaName != "" %} {% endif %} {% if nextHyphaName != "" %} {% endif %}
{%= SubhyphaeHTML(subhyphae) %}
{%= hyphaInfo(rq, h) %}
{%= siblingHyphaeHTML(siblings) %}
{%= viewScripts() %} {% endfunc %} {% func RevisionHTML(rq *http.Request, h *hyphae.Hypha, contents, revHash string) %} {% code siblings, subhyphae, _, _ := tree.Tree(h.Name) %}
{%= SubhyphaeHTML(subhyphae) %}
{%= siblingHyphaeHTML(siblings) %}
{%= viewScripts() %} {% endfunc %} {% func viewScripts() %} {% for _, scriptPath := range cfg.ViewScripts %} {% endfor %} {% endfunc %}