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

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

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

{%s lc.Get("ui.media_tip") %} {%s lc.Get("ui.media_what_is") %}

{% default %}

{%s lc.Get("ui.media_empty") %} {%s lc.Get("ui.media_what_is") %}

{% 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.media_stat") %}

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

{% endif %} {% if strings.HasPrefix(mime, "image/") %}
{%s lc.Get("ui.media_include") %}
img { {%s h.CanonicalName() %} }
{% endif %} {% endswitch %} {% if u.CanProceed("upload-binary") %} {% endif %} {% switch h := h.(type) %} {% case *hyphae.MediaHypha %} {% if u.CanProceed("remove-media") %} {% endif %} {% endswitch %}
{% endfunc %} {% func Revision(meta viewutil.Meta, h hyphae.Hypha, contents, revHash string) %}

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

{%s= NaviTitle(meta, h.CanonicalName()) %} {%s= contents %}
{% for _, scriptPath := range cfg.ViewScripts %} {% endfor %} {% endfunc %}