// SPDX-License-Identifier: AGPL-3.0-or-later
package web
// The fragments of the live updates (events.go). Each is a top-level element
// with an id: the page swaps the element that has the same id.
// FactValue is the value of a fact; its id, when it has one, is the target of
// the live updates ("last push").
templ FactValue(f Fact) {
if f.Time != "" {
} else {
{ f.Val }
}
}
// RepoGone replaces the card of a repository that is deleted or not visible
// any more; the page removes the element.
templ RepoGone(id string) {
}
// RefsBody is the rows of the refs table.
templ RefsBody(p RefsPage) {
for _, b := range p.Branches {
@refRow("branch", b)
}
for _, t := range p.Tags {
@refRow("tag", t)
}
}
// RefsKV is the facts of the rail of the refs page.
templ RefsKV(p RefsPage) {
default
{ p.Default }
branches
{ itoa(len(p.Branches)) }
tags
{ itoa(len(p.Tags)) }
if p.Latest != "" {
latest tag
{ p.Latest }
}
}
// LiveSlot is the place of a live banner, empty: a status region that stays
// in the page. The live updates (ermiteLive in ermite.js) replace its children,
// never the element, so that a screen reader announces the new banner (a
// region that is inserted with its content is not announced).
templ LiveSlot(id string) {
}
// liveBanner is the slot with its banner: a link that reloads or opens the
// page. Only the children of the element reach the page that has the slot.
templ liveBanner(id, text, href string) {
}
// CommitsBanner announces new commits on the branch the page lists. It links
// to the first page of the branch.
templ CommitsBanner(text, href string) {
@liveBanner("commits-head", text, href)
}
// MRNotice tells a merge request page that it is out of date, or the list that
// its content changed.
templ MRNotice(text, href string) {
@liveBanner("mr-notice", text, href)
}
// Live is the connection to the event stream, in the hint badge. It shows
// only once a connection stays lost for a few seconds (ermiteLive.lost): a
// page that never connected, that is live, or whose stream comes back right
// away (a proxy closing an idle stream) says nothing. The events of the stream are fragments that ermiteLive
// (ermite.js) swaps in the page. A page without a stream renders nothing.
//
// hx-sse retries a lost connection for ever, with a growing delay. A refusal
// that will not change (404: the repository is gone or hidden; 401) is handled
// by ermiteLive.error, which has the page fetch itself again.
templ Live(l Layout) {
if l.Live && l.LiveURL != "" {
}
}