package systemviews import ( "fmt" "strings" "github.com/bnema/dumber/internal/domain/entity" ) templ HistoryView(data historyRenderData) { @Alert("success", data.Notice) @Alert("error", data.Error) @Section("sv-history-controls", "Manage history") { @HistoryControls(data) } @Section("sv-history-domains", "Top domains") { @HistoryDomains(data) } @Section("sv-history-timeline", "Recent visits") { @HistoryTimeline(data) } } templ HistoryControls(data historyRenderData) { if showHistoryFilters(data) {
if data.Query != "" { Query: { data.Query } } if data.DomainFilter != "" { Domain: { data.DomainFilter } }
}
{ historyShowingLabel(data) }
Clean up for _, item := range historyCleanupItems() { }
} templ HistoryDomains(data historyRenderData) { if data.Loading { @LoadingPanel("Loading top domains…") } else if len(data.Domains) == 0 { @EmptyState("No domain statistics yet") } else {
for _, domain := range data.Domains { if domain != nil && domain.Domain != "" { {{ domainKey := historyDomainActionKey(domain) }} {{ displayDomain := historyDomainDisplayLabel(domain) }} { fmt.Sprintf("%dp · %dv", domain.PageCount, domain.TotalVisits) } } }
} } templ HistoryTimeline(data historyRenderData) { if data.Loading { @LoadingPanel("Loading recent visits…") } else {
{{ groups := groupHistoryEntries(data.Entries) }} if len(groups) == 0 { @EmptyState(historyTimelineEmptyMessage(data)) } else { @HistoryTimelineGroups(data.Entries, "") } @HistoryLoadMore(data)
} } templ HistoryTimelineAppend(data historyRenderData) { @HistoryTimelineAppendGroups(data.Entries, data.AppendSkipFirstDate) @HistoryLoadMore(data) } templ HistoryTimelineGroups(entries []*entity.HistoryEntry, skipFirstDate string) { {{ groups := groupHistoryEntries(entries) }} for _, group := range groups { @HistoryTimelineGroup(group, true) } } templ HistoryTimelineAppendGroups(entries []*entity.HistoryEntry, mergeFirstDate string) { {{ groups := groupHistoryEntries(entries) }} for index, group := range groups { if index == 0 && group.Date == mergeFirstDate {
for _, entry := range group.Entries { if entry != nil { @HistoryItem(entry) } }
} else { @HistoryTimelineGroup(group, true) } } } templ HistoryTimelineGroup(group historyTimelineGroup, showHeading bool) {
if showHeading {

{ group.Label }

}
} templ HistoryLoadMore(data historyRenderData) {
if showHistoryLoadMore(data) { } else if strings.TrimSpace(data.Query) == "" && countHistoryEntries(data.Entries) > 0 {

End of history

}
} templ HistoryItem(entry *entity.HistoryEntry) {
  • {{ faviconURL := historyItemFaviconURL(entry) }}
    { historyItemLabel(entry) }

    { historyItemURL(entry) }

    { historyItemMeta(entry) }

    @ButtonIconLabel(iconExternal, "Open")
  • }