{% 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) %} {%= NavHTML(rq, h.Name, "attachment") %}

Attachment of {%s util.BeautifulName(h.Name) %}

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

This hypha has no attachment, you can upload it here.

{% else %}

You can manage the hypha's attachment on this page.

{% 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. {% func HyphaHTML(rq *http.Request, h *hyphae.Hypha, contents string) %} {% code relatives, subhyphae, prevHyphaName, nextHyphaName := tree.Tree(h.Name) u := user.FromRequest(rq) %} {%= NavHTML(rq, h.Name, "hypha") %}
{%s= NaviTitleHTML(h) %} {% if h.Exists %} {%s= contents %} {% else %} {%= nonExistentHyphaNotice(h, u) %} {% endif %}
{% if prevHyphaName != "" %} {% endif %} {% if nextHyphaName != "" %} {% endif %}
{%= SubhyphaeHTML(subhyphae) %}
{%= RelativeHyphaeHTML(relatives) %}
{%= viewScripts() %} {% endfunc %} {% func RevisionHTML(rq *http.Request, h *hyphae.Hypha, contents, revHash string) %} {% code relatives, subhyphae, _, _ := tree.Tree(h.Name) %} {%= NavHTML(rq, h.Name, "revision", revHash) %}

Please note that viewing binary parts of hyphae is not supported in history for now.

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