2020-11-16 15:26:03 +00:00
|
|
|
{% import "net/http" %}
|
2020-11-29 11:32:52 +00:00
|
|
|
{% import "path" %}
|
2021-02-20 16:14:33 +00:00
|
|
|
|
2021-02-20 15:48:51 +00:00
|
|
|
{% import "github.com/bouncepaw/mycorrhiza/hyphae" %}
|
2020-11-16 15:26:03 +00:00
|
|
|
{% import "github.com/bouncepaw/mycorrhiza/user" %}
|
2021-02-06 16:14:57 +00:00
|
|
|
{% import "github.com/bouncepaw/mycorrhiza/util" %}
|
2021-02-20 16:14:33 +00:00
|
|
|
{% import "github.com/bouncepaw/mycorrhiza/tree" %}
|
2020-08-31 17:52:26 +00:00
|
|
|
|
|
|
|
If `contents` == "", a helpful message is shown instead.
|
2021-02-20 16:14:33 +00:00
|
|
|
{% func HyphaHTML(rq *http.Request, h *hyphae.Hypha, contents string) %}
|
|
|
|
{% code
|
|
|
|
relatives, subhyphae, prevHyphaName, nextHyphaName := tree.Tree(h.Name)
|
|
|
|
%}
|
|
|
|
{%= NavHTML(rq, h.Name, "page") %}
|
2021-01-25 18:37:21 +00:00
|
|
|
<div class="layout">
|
2021-01-26 05:41:57 +00:00
|
|
|
<main class="main-width">
|
|
|
|
<article>
|
2021-02-20 16:14:33 +00:00
|
|
|
{%s= NaviTitleHTML(h) %}
|
2021-01-26 05:41:57 +00:00
|
|
|
{% if contents == "" %}
|
2021-02-20 15:48:51 +00:00
|
|
|
<p>This hypha has no text. Why not <a href="/edit/{%s h.Name %}">create it</a>?</p>
|
2021-01-26 05:41:57 +00:00
|
|
|
{% else %}
|
|
|
|
{%s= contents %}
|
|
|
|
{% endif %}
|
|
|
|
</article>
|
|
|
|
<section class="prevnext">
|
|
|
|
{% if prevHyphaName != "" %}
|
2021-02-06 16:14:57 +00:00
|
|
|
<a class="prevnext__el prevnext__prev" href="/hypha/{%s prevHyphaName %}" rel="prev">← {%s util.BeautifulName(path.Base(prevHyphaName)) %}</a>
|
2021-01-26 05:41:57 +00:00
|
|
|
{% endif %}
|
|
|
|
{% if nextHyphaName != "" %}
|
2021-02-06 16:14:57 +00:00
|
|
|
<a class="prevnext__el prevnext__next" href="/hypha/{%s nextHyphaName %}" rel="next">{%s util.BeautifulName(path.Base(nextHyphaName)) %} →</a>
|
2021-01-26 05:41:57 +00:00
|
|
|
{% endif %}
|
|
|
|
</section>
|
|
|
|
{% if u := user.FromRequest(rq); !user.AuthUsed || u.Group != "anon" %}
|
2021-02-20 15:48:51 +00:00
|
|
|
<form action="/upload-binary/{%s h.Name %}"
|
2021-01-26 05:41:57 +00:00
|
|
|
method="post" enctype="multipart/form-data"
|
|
|
|
class="upload-amnt">
|
2021-02-20 15:48:51 +00:00
|
|
|
{% if h.Exists && h.BinaryPath != "" %}
|
|
|
|
<a class="upload-amnt__unattach" href="/unattach-ask/{%s h.Name %}">Unattach current attachment?</a>
|
2021-01-26 05:41:57 +00:00
|
|
|
{% endif %}
|
|
|
|
<label for="upload-binary__input">Upload a new attachment</label>
|
|
|
|
<br>
|
|
|
|
<input type="file" id="upload-binary__input" name="binary"/>
|
|
|
|
<input type="submit"/>
|
|
|
|
</form>
|
|
|
|
{% endif %}
|
2021-02-20 16:14:33 +00:00
|
|
|
{%= SubhyphaeHTML(subhyphae) %}
|
|
|
|
</main>
|
|
|
|
{%= RelativeHyphaeHTML(relatives) %}
|
|
|
|
{%= BackLinksHTML(h) %}
|
|
|
|
</div>
|
|
|
|
{% 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) %}
|
|
|
|
<div class="layout">
|
|
|
|
<main class="main-width">
|
|
|
|
<article>
|
|
|
|
<p>Please note that viewing binary parts of hyphae is not supported in history for now.</p>
|
|
|
|
{%s= NaviTitleHTML(h) %}
|
|
|
|
{%s= contents %}
|
|
|
|
</article>
|
|
|
|
{%= SubhyphaeHTML(subhyphae) %}
|
|
|
|
</main>
|
|
|
|
{%= RelativeHyphaeHTML(relatives) %}
|
|
|
|
</div>
|
|
|
|
{% endfunc %}
|