{% 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.CanonicalName())}) %}

{% switch h.(type) %} {% case *hyphae.MediaHypha %}

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

{% default %}

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

{% endswitch %}
{% switch h := h.(type) %} {% case *hyphae.MediaHypha %} {% code mime := mimetype.FromExtension(path.Ext(h.MediaFilePath())) fileinfo, err := os.Stat(h.MediaFilePath()) %} {% 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 %} {% endswitch %} {% if u.CanProceed("upload-binary") %} {% endif %} {% switch h := h.(type) %} {% case *hyphae.MediaHypha %} {% if u.CanProceed("unattach-confirm") %} {% endif %} {% endswitch %}
{% 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.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.Hypha, contents, revHash string) %}

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

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