mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-12-12 05:20:26 +00:00
103 lines
3.6 KiB
Plaintext
103 lines
3.6 KiB
Plaintext
{% import "path/filepath" %}
|
|
{% import "strings" %}
|
|
|
|
{% import "github.com/bouncepaw/mycorrhiza/cfg" %}
|
|
{% import "github.com/bouncepaw/mycorrhiza/hyphae" %}
|
|
{% import "github.com/bouncepaw/mycorrhiza/user" %}
|
|
{% import "github.com/bouncepaw/mycorrhiza/util" %}
|
|
|
|
{% func nonExistentHyphaNotice(h *hyphae.Hypha, u *user.User) %}
|
|
<section class="non-existent-hypha">
|
|
<h2 class="non-existent-hypha__title">This hypha does not exist</h2>
|
|
{% if cfg.UseAuth && u.Group == "anon" %}
|
|
<p>You are not authorized to create new hyphae. Here is what you can do:</p>
|
|
<ul>
|
|
<li><a href="/login">Log in to your account, if you have one</a></li>
|
|
{% if cfg.AllowRegistration %}<li><a href="/register">Register a new account</a></li>{% endif %}
|
|
</ul>
|
|
{% else %}
|
|
|
|
<div class="non-existent-hypha__ways">
|
|
<section class="non-existent-hypha__way">
|
|
<h3 class="non-existent-hypha__subtitle">📝 Write a text</h3>
|
|
<p>Write a note, a diary, an article, a story or anything textual using <a href="https://mycorrhiza.wiki/hypha/mycomarkup" class="shy-link">Mycomarkup</a>. Full history of edits to the document will be saved.</p>
|
|
<p>Make sure to follow this wiki's writing conventions if there are any.</p>
|
|
<a class="btn btn_accent stick-to-bottom" href="/edit/{%s h.Name %}">Create</a>
|
|
</section>
|
|
|
|
<section class="non-existent-hypha__way">
|
|
<h3 class="non-existent-hypha__subtitle">🖼 Upload a media</h3>
|
|
<p>Upload a picture, a video or an audio. Most common formats can be accessed from the browser, others can be only downloaded afterwards. You can write a description for the media later.</p>
|
|
<form action="/upload-binary/{%s h.Name %}"
|
|
method="post" enctype="multipart/form-data"
|
|
class="upload-binary">
|
|
<label for="upload-binary__input"></label>
|
|
<input type="file" id="upload-binary__input" name="binary">
|
|
|
|
<input type="submit" class="btn stick-to-bottom" value="Upload">
|
|
</form>
|
|
</section>
|
|
</div>
|
|
{% endif %}
|
|
</section>
|
|
{% endfunc %}
|
|
|
|
{% func NaviTitleHTML(h *hyphae.Hypha) %}
|
|
{% code
|
|
var (
|
|
prevAcc = "/hypha/"
|
|
parts = strings.Split(h.Name, "/")
|
|
)
|
|
%}
|
|
<h1 class="navi-title">
|
|
{% stripspace %}
|
|
<a href="/hypha/{%s cfg.HomeHypha %}">
|
|
{%-s= cfg.NaviTitleIcon -%}
|
|
<span aria-hidden="true" class="navi-title__colon">:</span>
|
|
</a>
|
|
|
|
{% for i, part := range parts %}
|
|
{% if i > 0 %}
|
|
<span aria-hidden="true" class="navi-title__separator">/</span>
|
|
{% endif %}
|
|
|
|
<a href="{%s prevAcc + part %}" rel="{% if i == len(parts) - 1 %}bookmark{% else %}up{% endif %}">
|
|
{%s= util.BeautifulName(part) %}
|
|
</a>
|
|
{% code prevAcc += part + "/" %}
|
|
{% endfor %}
|
|
{% endstripspace %}
|
|
</h1>
|
|
{% endfunc %}
|
|
|
|
{% func AttachmentHTML(h *hyphae.Hypha) %}
|
|
{% switch filepath.Ext(h.BinaryPath) %}
|
|
|
|
{% case ".jpg", ".gif", ".png", ".webp", ".svg", ".ico" %}
|
|
<div class="binary-container binary-container_with-img">
|
|
<a href="/binary/{%s= h.Name %}"><img src="/binary/{%s= h.Name %}"/></a>
|
|
</div>
|
|
|
|
{% case ".ogg", ".webm", ".mp4" %}
|
|
<div class="binary-container binary-container_with-video">
|
|
<video controls>
|
|
<source src="/binary/{%s= h.Name %}"/>
|
|
<p>Your browser does not support video. <a href="/binary/{%s= h.Name %}">Download video</a></p>
|
|
</video>
|
|
</div>
|
|
|
|
{% case ".mp3" %}
|
|
<div class="binary-container binary-container_with-audio">
|
|
<audio controls>
|
|
<source src="/binary/{%s= h.Name %}"/>
|
|
<p>Your browser does not support audio. <a href="/binary/{%s= h.Name %}">Download audio</a></p>
|
|
</audio>
|
|
</div>
|
|
|
|
{% default %}
|
|
<div class="binary-container binary-container_with-nothing">
|
|
<p><a href="/binary/{%s= h.Name %}">Download media</a></p>
|
|
</div>
|
|
{% endswitch %}
|
|
{% endfunc %}
|