{% 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/categories" %} {% 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" %} {% import "github.com/bouncepaw/mycorrhiza/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 %} If `contents` == "", a helpful message is shown instead. If you rename .prevnext, change the docs too. {% func Hypha(meta viewutil.Meta, h hyphae.Hypha, contents string) %} {% code subhyphae, prevHyphaName, nextHyphaName := tree.Tree(h.CanonicalName()) lc := meta.Lc %}
{% if meta.U.CanProceed("edit") %} {% endif %} {% if cfg.UseAuth && util.IsProfileName(h.CanonicalName()) && meta.U.Name == strings.TrimPrefix(h.CanonicalName(), cfg.UserHypha + "/") %} {% if meta.U.Group == "admin" %} {% endif %} {% endif %} {%s= NaviTitle(meta, h.CanonicalName()) %} {% switch h.(type) %} {% case *hyphae.EmptyHypha %} {%s= EmptyHypha(meta, h.CanonicalName()) %} {% default %} {%s= contents %} {% endswitch %}
{% if prevHyphaName != "" %} {% endif %} {% if nextHyphaName != "" %} {% endif %}
{% if strings.TrimSpace(subhyphae) != "" %}

{%s lc.Get("ui.subhyphae") %}

{% endif %}
{%= hyphaInfo(meta, h) %}
{%s= categories.CategoryCard(meta, h.CanonicalName()) %} {%= viewScripts() %} {% 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 %}
{%= viewScripts() %} {% endfunc %} {% func viewScripts() %} {% for _, scriptPath := range cfg.ViewScripts %} {% endfor %} {% endfunc %}