{% import "fmt" %} {% import "net/http" %} {% import "time" %} {% import "github.com/bouncepaw/mycorrhiza/cfg" %} {% import "github.com/bouncepaw/mycorrhiza/l18n" %} {% import "github.com/bouncepaw/mycorrhiza/user" %} {% import "github.com/bouncepaw/mycorrhiza/hyphae" %} {% import "github.com/bouncepaw/mycorrhiza/history" %} {% func PrimitiveDiff(rq *http.Request, h hyphae.ExistingHypha, u *user.User, hash string) %} {% code lc := l18n.FromRequest(rq) text, err := history.PrimitiveDiffAtRevision(h.TextFilePath(), hash) if err != nil { text = err.Error() } %}

{%s= lc.Get("ui.diff_title", &l18n.Replacements{"name": beautifulLink(h.CanonicalName()), "rev": hash}) %}

{%s text %}
{% endfunc %} {% func RecentChanges(n int, lc *l18n.Localizer) %}

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

{%s= lc.Get("ui.recent_subscribe", &l18n.Replacements{"rss": "RSS", "atom": "Atom", "json": fmt.Sprintf("%s", lc.Get("ui.recent_subscribe_json"))}) %}

{% 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) var year, day int var month time.Month %}
{% if len(changes) == 0 %}

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

{% else %} {% for i, entry := range changes %} {% code y, m, d := entry.Time.UTC().Date() %} {% if d != day || m != month || y != year %}

{%s fmt.Sprintf("%04d-%02d-%02d", y, m, d) %}

{% code year, month, day = y, m, d %} {% endif %}
{%s= recentChanges(entry) %}
{% endfor %} {% endif %}
{% endfunc %} {% func recentChanges(rev history.Revision) %}
{%s rev.Hash %} {% if rev.Username != "anon" %} {% endif %}
{%s= rev.HyphaeLinksHTML() %} {%s rev.Message %}
{% endfunc %} {% func History(rq *http.Request, hyphaName, list string, lc *l18n.Localizer) %}

{%s= fmt.Sprintf(lc.Get("ui.history_title"), beautifulLink(hyphaName)) %}

{%s= list %}
{% endfunc %}