1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-10-30 11:46:16 +00:00
mycorrhiza/views/readers.qtpl
2021-02-20 21:14:33 +05:00

82 lines
2.6 KiB
Plaintext

{% import "net/http" %}
{% import "path" %}
{% import "github.com/bouncepaw/mycorrhiza/hyphae" %}
{% import "github.com/bouncepaw/mycorrhiza/user" %}
{% import "github.com/bouncepaw/mycorrhiza/util" %}
{% import "github.com/bouncepaw/mycorrhiza/tree" %}
If `contents` == "", a helpful message is shown instead.
{% func HyphaHTML(rq *http.Request, h *hyphae.Hypha, contents string) %}
{% code
relatives, subhyphae, prevHyphaName, nextHyphaName := tree.Tree(h.Name)
%}
{%= NavHTML(rq, h.Name, "page") %}
<div class="layout">
<main class="main-width">
<article>
{%s= NaviTitleHTML(h) %}
{% if contents == "" %}
<p>This hypha has no text. Why not <a href="/edit/{%s h.Name %}">create it</a>?</p>
{% else %}
{%s= contents %}
{% endif %}
</article>
<section class="prevnext">
{% if prevHyphaName != "" %}
<a class="prevnext__el prevnext__prev" href="/hypha/{%s prevHyphaName %}" rel="prev">← {%s util.BeautifulName(path.Base(prevHyphaName)) %}</a>
{% endif %}
{% if nextHyphaName != "" %}
<a class="prevnext__el prevnext__next" href="/hypha/{%s nextHyphaName %}" rel="next">{%s util.BeautifulName(path.Base(nextHyphaName)) %} →</a>
{% endif %}
</section>
{% if u := user.FromRequest(rq); !user.AuthUsed || u.Group != "anon" %}
<form action="/upload-binary/{%s h.Name %}"
method="post" enctype="multipart/form-data"
class="upload-amnt">
{% if h.Exists && h.BinaryPath != "" %}
<a class="upload-amnt__unattach" href="/unattach-ask/{%s h.Name %}">Unattach current attachment?</a>
{% 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 %}
{%= 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 %}
{% func HistoryHTML(rq *http.Request, hyphaName, list string) %}
{%= NavHTML(rq, hyphaName, "history") %}
<div class="layout">
<main class="main-width">
<article class="history">
<h1>History of {%s hyphaName %}</h1>
{%s= list %}
</article>
</main>
</div>
{% endfunc %}