mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-10-30 19:56:16 +00:00
839f8bc2d6
assets.qtpl is no more! Now you can just add files to static/ folder, make sure the extension is registered in static.go (a shortcoming that'll be addressed in future Go versions), and you're done! It searches the local file system first, then falls back to the files embedded with the binary (in the static/ folder).
94 lines
2.9 KiB
Plaintext
94 lines
2.9 KiB
Plaintext
{% import "net/http" %}
|
|
|
|
{% import "github.com/bouncepaw/mycorrhiza/cfg" %}
|
|
{% import "github.com/bouncepaw/mycorrhiza/util" %}
|
|
{% import "github.com/bouncepaw/mycorrhiza/user" %}
|
|
{% import "github.com/bouncepaw/mycorrhiza/hyphae" %}
|
|
{% import "github.com/bouncepaw/mycorrhiza/history" %}
|
|
|
|
|
|
{% func PrimitiveDiffHTML(rq *http.Request, h *hyphae.Hypha, u *user.User, hash string) %}
|
|
{% code
|
|
text, err := history.PrimitiveDiffAtRevision(h.TextPath, hash)
|
|
if err != nil {
|
|
text = err.Error()
|
|
}
|
|
%}
|
|
{%= NavHTML(rq, h.Name, "history") %}
|
|
<div class="layout">
|
|
<main class="main-width">
|
|
<article>
|
|
<h1>Diff {%s util.BeautifulName(h.Name) %} at {%s hash %}</h1>
|
|
<pre class="codeblock"><code>{%s text %}</code></pre>
|
|
</article>
|
|
</main>
|
|
</div>
|
|
{% endfunc %}
|
|
|
|
{% func RecentChangesHTML(n int) %}
|
|
<div class="layout">
|
|
<main class="main-width recent-changes">
|
|
<h1>Recent Changes</h1>
|
|
|
|
<nav class="recent-changes__count">
|
|
See
|
|
{% for _, m := range []int{20, 0, 50, 0, 100} %}
|
|
{% switch m %}
|
|
{% case 0 %}
|
|
<span aria-hidden="true">|</span>
|
|
{% case n %}
|
|
<b>{%d n %}</b>
|
|
{% default %}
|
|
<a href="/recent-changes/{%d m %}">{%d m %}</a>
|
|
{% endswitch %}
|
|
{% endfor %}
|
|
recent changes
|
|
</nav>
|
|
|
|
<p><img class="icon" width="20" height="20" src="/static/icon/feed.svg">Subscribe via <a href="/recent-changes-rss">RSS</a>, <a href="/recent-changes-atom">Atom</a> or <a href="/recent-changes-json">JSON feed</a>.</p>
|
|
|
|
{% comment %}
|
|
Here I am, willing to add some accessibility using ARIA. Turns out,
|
|
role="feed" is not supported in any screen reader as of September
|
|
2020. At least web search says so. Even JAWS doesn't support it!
|
|
How come? I'll add the role anyway. -- bouncepaw
|
|
{% endcomment %}
|
|
|
|
{% code
|
|
changes := history.RecentChanges(n)
|
|
%}
|
|
<section class="recent-changes__list" role="feed">
|
|
{% if len(changes) == 0 %}
|
|
<p>Could not find any recent changes.</p>
|
|
{% else %}
|
|
{% for i, entry := range changes %}
|
|
<ul class="recent-changes__entry rc-entry" role="article"
|
|
aria-setsize="{%d n %}" aria-posinset="{%d i %}">
|
|
{%s= recentChangesEntry(entry) %}
|
|
</ul>
|
|
{% endfor %}
|
|
{% endif %}
|
|
</section>
|
|
</main>
|
|
</div>
|
|
{% endfunc %}
|
|
|
|
{% func recentChangesEntry(rev history.Revision) %}
|
|
<li class="rc-entry__time"><time>{%s rev.TimeString() %}</time></li>
|
|
<li class="rc-entry__hash">{%s rev.Hash %}</li>
|
|
<li class="rc-entry__links">{%s= rev.HyphaeLinksHTML() %}</li>
|
|
<li class="rc-entry__msg">{%s rev.Message %} {% if rev.Username != "anon" %}<span class="rc-entry__author">by <a href="/hypha/{%s cfg.UserHypha %}/{%s rev.Username %}" rel="author">{%s rev.Username %}</a></span>{% endif %}</li>
|
|
{% 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 util.BeautifulName(hyphaName) %}</h1>
|
|
{%s= list %}
|
|
</article>
|
|
</main>
|
|
</div>
|
|
{% endfunc %}
|