templates

package
v1.25.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2026 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

templ: version: v0.3.1020

templ: version: v0.3.1020

templ: version: v0.3.1020

templ: version: v0.3.1020

templ: version: v0.3.1020

templ: version: v0.3.1020

templ: version: v0.3.1020

templ: version: v0.3.1020

templ: version: v0.3.1020

templ: version: v0.3.1020

templ: version: v0.3.1020

templ: version: v0.3.1020

templ: version: v0.3.1020

templ: version: v0.3.1020

templ: version: v0.3.1020

templ: version: v0.3.1020

templ: version: v0.3.1020

templ: version: v0.3.1020

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AboutPage

func AboutPage(freshness DataFreshness, privacy PrivacySync, runtimeInfo RuntimeInfo) templ.Component

AboutPage renders the about page with project information, data freshness, and the Privacy & Sync section.

func Breadcrumb(typePlural string, entityName string) templ.Component

Breadcrumb renders navigation breadcrumbs: Home > TypePlural > EntityName. typePlural is the display name for the entity type (e.g., "Networks"). entityName is the specific entity being viewed.

func CampusDetailPage

func CampusDetailPage(data CampusDetail) templ.Component

CampusDetailPage renders the full campus detail page with header, stats, detail fields, and a collapsible lazy-loaded section for facilities.

func CampusFacilitiesList

func CampusFacilitiesList(rows []CampusFacilityRow, moreURL string) templ.Component

CampusFacilitiesList renders the list of campus facilities as a 3-column sortable table (Name, City, Country+flag) linking to the respective facility detail page.

func CampusFacilitiesRows added in v1.23.0

func CampusFacilitiesRows(rows []CampusFacilityRow, moreURL string) templ.Component

CampusFacilitiesRows renders one page of rows for CampusFacilitiesList, followed by a "Load more" row while another page remains. It is also the htmx response shape for the load-more request, so fetched pages accumulate in the same tbody.

func CarrierDetailPage

func CarrierDetailPage(data CarrierDetail) templ.Component

CarrierDetailPage renders the full carrier detail page with header, stats, detail fields, and a collapsible lazy-loaded section for facilities.

func CarrierFacilitiesList

func CarrierFacilitiesList(rows []CarrierFacilityRow, moreURL string) templ.Component

CarrierFacilitiesList renders the list of carrier facilities as a single-column name-only table linking to the respective facility detail page.

func CarrierFacilitiesRows added in v1.23.0

func CarrierFacilitiesRows(rows []CarrierFacilityRow, moreURL string) templ.Component

CarrierFacilitiesRows renders one page of rows for CarrierFacilitiesList, followed by a "Load more" row while another page remains. It is also the htmx response shape for the load-more request, so fetched pages accumulate in the same tbody.

func CollapsibleSection

func CollapsibleSection(title string, count int, bandwidth string, loadURL string) templ.Component

CollapsibleSection renders a collapsible details/summary element with htmx lazy loading on first expand. If count is 0, the section is not expandable and shows a static "None" message. A non-empty bandwidth (aggregate port speed) is appended to the count in the header.

func CompareFormPage

func CompareFormPage(asn1 string, asn2 string) templ.Component

CompareFormPage renders the comparison form with optional pre-filled ASN values. asn1 and asn2 are pre-filled when navigating from a network detail page.

func CompareResultsPage

func CompareResultsPage(data CompareData) templ.Component

CompareResultsPage renders the full comparison results between two networks.

func CopyableIP added in v1.7.0

func CopyableIP(label string, addr string) templ.Component

CopyableIP renders an IP address with click-to-copy and a hover clipboard icon. The click handling is a delegated listener in /static/ui.js: elements carrying data-copy are copied to the clipboard, and the .copied-msg inside the enclosing [data-copy-group] flashes as confirmation.

func CountryFlag added in v1.11.0

func CountryFlag(code string) templ.Component

CountryFlag renders a country flag icon with the country code text. Uses flag-icons CSS classes. If code is empty, renders nothing.

func DetailField

func DetailField(label string, value string) templ.Component

DetailField renders a label:value pair. Only renders if value is non-empty.

func DetailHeader

func DetailHeader(typeBadge string, accentColor string, name string, subtitle string) templ.Component

DetailHeader renders the page header with type badge, entity name, and subtitle. The accentColor should match the search palette: emerald=net, sky=ix, violet=fac, amber=org, rose=campus, cyan=carrier.

func DetailLink(label string, url string) templ.Component

DetailLink renders a clickable URL field. Only renders if url is non-empty.

url is upstream-controlled free text (a PeeringDB website / looking-glass / route-server / policy URL), so it MUST go through templ.URL — which strips dangerous schemes like javascript: and data: — and NOT templ.SafeURL, which is an explicit "trust me" bypass of that sanitization and would let a malformed upstream record render an executable href.

func FacCarriersList

func FacCarriersList(rows []FacCarrierRow, moreURL string) templ.Component

FacCarriersList renders facility carriers as a single-column name-only table. Pre-sorted alphabetically server-side, no sort UI.

func FacCarriersRows added in v1.23.0

func FacCarriersRows(rows []FacCarrierRow, moreURL string) templ.Component

FacCarriersRows renders one page of rows for FacCarriersList, followed by a "Load more" row while another page remains. It is also the htmx response shape for the load-more request, so fetched pages accumulate in the same tbody.

func FacIXPsList

func FacIXPsList(rows []FacIXRow, moreURL string) templ.Component

FacIXPsList renders facility IXPs as a single-column name-only table. Pre-sorted alphabetically server-side, no sort UI.

func FacIXPsRows added in v1.23.0

func FacIXPsRows(rows []FacIXRow, moreURL string) templ.Component

FacIXPsRows renders one page of rows for FacIXPsList, followed by a "Load more" row while another page remains. It is also the htmx response shape for the load-more request, so fetched pages accumulate in the same tbody.

func FacNetworksList

func FacNetworksList(rows []FacNetworkRow, moreURL string) templ.Component

FacNetworksList renders facility networks as a 3-column sortable table with Name, ASN, and Country+flag columns.

func FacNetworksRows added in v1.23.0

func FacNetworksRows(rows []FacNetworkRow, moreURL string) templ.Component

FacNetworksRows renders one page of rows for FacNetworksList, followed by a "Load more" row while another page remains. It is also the htmx response shape for the load-more request, so fetched pages accumulate in the same tbody.

func FacilityDetailPage

func FacilityDetailPage(data FacilityDetail) templ.Component

FacilityDetailPage renders the full facility detail page with header, stats, detail fields, and collapsible lazy-loaded sections for related records.

func Footer() templ.Component

func FormatThousands added in v1.20.1

func FormatThousands(n int) string

FormatThousands renders n with comma thousands separators (e.g. 1234 -> "1,234").

func Home

func Home(query string, groups []SearchGroup) templ.Component

Home renders the homepage with search form and API quick links. query is pre-filled on direct navigation (bookmarked URLs). groups contains pre-computed search results for bookmarked URL support.

func IXDetailPage

func IXDetailPage(data IXDetail) templ.Component

IXDetailPage renders the full IXP detail page with header, stats, detail fields, and collapsible lazy-loaded sections for related records.

func IXFacilitiesList

func IXFacilitiesList(rows []IXFacilityRow, moreURL string) templ.Component

IXFacilitiesList renders IX facilities as a 3-column sortable table with Name, City, and Country+flag columns.

func IXFacilitiesRows added in v1.23.0

func IXFacilitiesRows(rows []IXFacilityRow, moreURL string) templ.Component

IXFacilitiesRows renders one page of rows for IXFacilitiesList, followed by a "Load more" row while another page remains. It is also the htmx response shape for the load-more request, so fetched pages accumulate in the same tbody.

func IXParticipantsList

func IXParticipantsList(rows []IXParticipantRow, moreURL string) templ.Component

IXParticipantsList renders IX participants as a 6-column sortable table with Name, ASN, Speed, IPv4, IPv6, and RS columns.

func IXParticipantsRows added in v1.23.0

func IXParticipantsRows(rows []IXParticipantRow, moreURL string) templ.Component

IXParticipantsRows renders one page of rows for IXParticipantsList, followed by a "Load more" row while another page remains. It is also the htmx response shape for the load-more request, so fetched pages accumulate in the same tbody.

func IXPrefixesList

func IXPrefixesList(rows []IXPrefixRow, moreURL string) templ.Component

IXPrefixesList renders IX prefixes as a 3-column sortable table with Prefix, Protocol, and DFZ columns.

func IXPrefixesRows added in v1.23.0

func IXPrefixesRows(rows []IXPrefixRow, moreURL string) templ.Component

IXPrefixesRows renders one page of rows for IXPrefixesList, followed by a "Load more" row while another page remains. It is also the htmx response shape for the load-more request, so fetched pages accumulate in the same tbody.

func Layout

func Layout(opts LayoutOptions, contents templ.Component) templ.Component

func MapContainer added in v1.11.0

func MapContainer(id string, markers []MapMarker, zoom int) templ.Component

MapContainer renders a map container div carrying data attributes that /static/map-init.js reads to initialize a single-marker Leaflet map (CARTO tiles, theme-aware via window.__pdbMaps). Exactly one marker is expected. A future extension will handle multiple markers with fitBounds.

func MultiPinMapContainer added in v1.11.0

func MultiPinMapContainer(id string, markers []MapMarker, ariaLabel string, showLegend bool, legendLabels map[string]string) templ.Component

MultiPinMapContainer renders a taller map container whose data attributes /static/map-init.js reads to build a clustered circleMarker Leaflet map (fitBounds auto-zoom, optional legend). If no markers have valid coordinates, nothing is rendered. When some markers lack coordinates, an unmapped count message is shown below the map.

func Nav() templ.Component

func NetworkContactsList

func NetworkContactsList(rows []ContactRow, moreURL string) templ.Component

NetworkContactsList renders network contacts as a 4-column sortable table with Name, Role, Email, and Phone columns.

func NetworkContactsRows added in v1.23.0

func NetworkContactsRows(rows []ContactRow, moreURL string) templ.Component

NetworkContactsRows renders one page of rows for NetworkContactsList, followed by a "Load more" row while another page remains. It is also the htmx response shape for the load-more request, so fetched pages accumulate in the same tbody.

func NetworkDetailPage

func NetworkDetailPage(data NetworkDetail) templ.Component

NetworkDetailPage renders the full network detail page with header, stats, detail fields, and collapsible lazy-loaded sections for related records.

func NetworkFacilitiesList

func NetworkFacilitiesList(rows []NetworkFacRow, moreURL string) templ.Component

NetworkFacilitiesList renders network facility presences as a 3-column sortable table with Name, City, and Country+flag columns.

func NetworkFacilitiesRows added in v1.23.0

func NetworkFacilitiesRows(rows []NetworkFacRow, moreURL string) templ.Component

NetworkFacilitiesRows renders one page of rows for NetworkFacilitiesList, followed by a "Load more" row while another page remains. It is also the htmx response shape for the load-more request, so fetched pages accumulate in the same tbody.

func NetworkIXLansList

func NetworkIXLansList(rows []NetworkIXLanRow, moreURL string) templ.Component

NetworkIXLansList renders network IX presences as a 5-column sortable table with IX Name, Speed, IPv4, IPv6, and RS columns.

func NetworkIXLansRows added in v1.23.0

func NetworkIXLansRows(rows []NetworkIXLanRow, moreURL string) templ.Component

NetworkIXLansRows renders one page of rows for NetworkIXLansList, followed by a "Load more" row while another page remains. It is also the htmx response shape for the load-more request, so fetched pages accumulate in the same tbody.

func NotFoundPage

func NotFoundPage() templ.Component

NotFoundPage renders a styled 404 page with an embedded search box.

func OrgCampusesList

func OrgCampusesList(rows []OrgCampusRow, moreURL string) templ.Component

OrgCampusesList renders the list of org campuses as a single-column name-only table linking to the respective campus detail page.

func OrgCampusesRows added in v1.23.0

func OrgCampusesRows(rows []OrgCampusRow, moreURL string) templ.Component

OrgCampusesRows renders one page of rows for OrgCampusesList, followed by a "Load more" row while another page remains. It is also the htmx response shape for the load-more request, so fetched pages accumulate in the same tbody.

func OrgCarriersList

func OrgCarriersList(rows []OrgCarrierRow, moreURL string) templ.Component

OrgCarriersList renders the list of org carriers as a single-column name-only table linking to the respective carrier detail page.

func OrgCarriersRows added in v1.23.0

func OrgCarriersRows(rows []OrgCarrierRow, moreURL string) templ.Component

OrgCarriersRows renders one page of rows for OrgCarriersList, followed by a "Load more" row while another page remains. It is also the htmx response shape for the load-more request, so fetched pages accumulate in the same tbody.

func OrgDetailPage

func OrgDetailPage(data OrgDetail) templ.Component

OrgDetailPage renders the full organization detail page with header, stats, detail fields, and collapsible lazy-loaded sections for related records.

func OrgFacilitiesList

func OrgFacilitiesList(rows []OrgFacilityRow, moreURL string) templ.Component

OrgFacilitiesList renders the list of org facilities as a 3-column sortable table (Name, City, Country+flag) linking to the respective facility detail page.

func OrgFacilitiesRows added in v1.23.0

func OrgFacilitiesRows(rows []OrgFacilityRow, moreURL string) templ.Component

OrgFacilitiesRows renders one page of rows for OrgFacilitiesList, followed by a "Load more" row while another page remains. It is also the htmx response shape for the load-more request, so fetched pages accumulate in the same tbody.

func OrgIXPsList

func OrgIXPsList(rows []OrgIXRow, moreURL string) templ.Component

OrgIXPsList renders the list of org IXPs as a single-column name-only table linking to the respective IX detail page.

func OrgIXPsRows added in v1.23.0

func OrgIXPsRows(rows []OrgIXRow, moreURL string) templ.Component

OrgIXPsRows renders one page of rows for OrgIXPsList, followed by a "Load more" row while another page remains. It is also the htmx response shape for the load-more request, so fetched pages accumulate in the same tbody.

func OrgNetworksList

func OrgNetworksList(rows []OrgNetworkRow, moreURL string) templ.Component

OrgNetworksList renders the list of org networks as a 2-column sortable table (Name, ASN) linking to the respective network detail page by ASN.

func OrgNetworksRows added in v1.23.0

func OrgNetworksRows(rows []OrgNetworkRow, moreURL string) templ.Component

OrgNetworksRows renders one page of rows for OrgNetworksList, followed by a "Load more" row while another page remains. It is also the htmx response shape for the load-more request, so fetched pages accumulate in the same tbody.

func SearchForm

func SearchForm(query string, groups []SearchGroup) templ.Component

SearchForm renders the search input with htmx attributes and results container. query is pre-filled on direct navigation; groups are pre-rendered for bookmarked URLs.

func SearchResults

func SearchResults(groups []SearchGroup, query string) templ.Component

SearchResults renders grouped search results with per-type colored badges, count badges, and compact single-line result rows with inline metadata. query is echoed into the per-type "View all" link. Returns empty output when groups is nil or empty.

func SearchRow added in v1.20.0

func SearchRow(result SearchResult) templ.Component

SearchRow renders a single compact search hit row: name on the left, inline country/city/ASN metadata on the right. Shared by the grouped quick-search and the per-type "view all" page so the two never drift.

func SearchTypeMore added in v1.20.0

func SearchTypeMore(data SearchTypeView) templ.Component

SearchTypeMore is the htmx response to a "Load more" click: the next page of rows followed by a fresh "Load more" button (or nothing when exhausted). It replaces the previous button via hx-swap="outerHTML", so rows accumulate in the same divided container.

func SearchTypePage added in v1.20.0

func SearchTypePage(data SearchTypeView) templ.Component

SearchTypePage renders the per-type "view all" results page: a header with the exact match count, the first page of rows, and an htmx "Load more" button that appends subsequent pages.

func ServerErrorPage

func ServerErrorPage() templ.Component

ServerErrorPage renders a styled 500 page with a link back to the homepage.

func StatBadge

func StatBadge(label string, count int) templ.Component

StatBadge renders a small stat indicator for the header area.

func SyncingPage

func SyncingPage() templ.Component

SyncingPage renders a standalone page shown by readiness middleware before the first sync completes. It is self-contained with its own DOCTYPE, head, and styling because it renders outside the normal handler flow at the middleware level.

Types

type AboutPageData added in v1.14.0

type AboutPageData struct {
	Freshness DataFreshness
	Privacy   PrivacySync
	Runtime   RuntimeInfo
}

AboutPageData bundles the payloads consumed by the terminal About renderer. The dispatch table (internal/web/termrender/dispatch.go) registers a single concrete type per page; this struct is that type for /ui/about.

type CampusDetail

type CampusDetail = catalog.CampusDetail

type CampusFacilityRow

type CampusFacilityRow = catalog.CampusFacilityRow

type CarrierDetail

type CarrierDetail = catalog.CarrierDetail

type CarrierFacilityRow

type CarrierFacilityRow = catalog.CarrierFacilityRow

type CompareCampus

type CompareCampus = catalog.CompareCampus

type CompareCampusFacility

type CompareCampusFacility = catalog.CompareCampusFacility

type CompareData

type CompareData = catalog.CompareData

type CompareFacPresence

type CompareFacPresence = catalog.CompareFacPresence

type CompareFacility

type CompareFacility = catalog.CompareFacility

type CompareIXP

type CompareIXP = catalog.CompareIXP

type CompareIXPresence

type CompareIXPresence = catalog.CompareIXPresence

type CompareNetwork

type CompareNetwork = catalog.CompareNetwork

type ContactRow

type ContactRow = catalog.ContactRow

type DataFreshness

type DataFreshness struct {
	Available  bool
	LastSyncAt time.Time
	Age        time.Duration
}

DataFreshness holds sync status information for the About page display.

type FacCarrierRow

type FacCarrierRow = catalog.FacCarrierRow

type FacIXRow

type FacIXRow = catalog.FacIXRow

type FacNetworkRow

type FacNetworkRow = catalog.FacNetworkRow

type FacilityDetail

type FacilityDetail = catalog.FacilityDetail

type IXDetail

type IXDetail = catalog.IXDetail

type IXFacilityRow

type IXFacilityRow = catalog.IXFacilityRow

type IXParticipantRow

type IXParticipantRow = catalog.IXParticipantRow

type IXPrefixRow

type IXPrefixRow = catalog.IXPrefixRow

type LayoutOptions added in v1.23.0

type LayoutOptions struct {
	Title       string
	Description string
	Canonical   string
	NeedsMap    bool
}

LayoutOptions carries per-page head configuration for Layout. NeedsMap gates the Leaflet/markercluster includes: only the pages that render a MapContainer pay the ~200 KB of map assets. Description and Canonical are optional SEO fields: when set they emit the meta description / canonical link and their OpenGraph twins.

type MapMarker added in v1.11.0

type MapMarker struct {
	// Lat is the marker's latitude.
	Lat float64
	// Lng is the marker's longitude.
	Lng float64
	// Name is the display name in the popup.
	Name string
	// Location is the city/country text in the popup.
	Location string
	// NetCount is the network count shown in the popup.
	NetCount int
	// IXCount is the IX count shown in the popup.
	IXCount int
	// DetailURL is the link to the entity detail page.
	DetailURL string
	// Color is the circleMarker fillColor hex (e.g. "#10b981"). Empty for single-pin maps.
	Color string
	// Stroke is the circleMarker stroke hex (e.g. "#059669"). Empty for single-pin maps.
	Stroke string
	// Extra is an additional popup line (e.g. network names for compare maps). Empty if not needed.
	Extra string
}

MapMarker holds data for a single map pin.

type NetworkDetail

type NetworkDetail = catalog.NetworkDetail

type NetworkFacRow

type NetworkFacRow = catalog.NetworkFacRow

type NetworkIXLanRow

type NetworkIXLanRow = catalog.NetworkIXLanRow

type OrgCampusRow

type OrgCampusRow = catalog.OrgCampusRow

type OrgCarrierRow

type OrgCarrierRow = catalog.OrgCarrierRow

type OrgDetail

type OrgDetail = catalog.OrgDetail

type OrgFacilityRow

type OrgFacilityRow = catalog.OrgFacilityRow

type OrgIXRow

type OrgIXRow = catalog.OrgIXRow

type OrgNetworkRow

type OrgNetworkRow = catalog.OrgNetworkRow

type PrivacySync added in v1.14.0

type PrivacySync struct {
	// AuthMode is the human-readable label: "Authenticated with PeeringDB
	// API key" or "Anonymous (no key)".
	AuthMode string

	// PublicTier is the lowercase env-var value: "public" or "users".
	// Matches PDBPLUS_PUBLIC_TIER so operators can map the UI back to the
	// deploy config without translating.
	PublicTier string

	// PublicTierExplanation is the one-line plain-language gloss of what
	// PublicTier means for an anonymous caller's data view. Rendered below
	// the PublicTier value on both surfaces.
	PublicTierExplanation string

	// OverrideActive is true when PublicTier == "users". When true, the
	// HTML renders an amber "Override active" badge and the terminal
	// prepends a "! " indicator to the Public Tier line.
	OverrideActive bool
}

PrivacySync carries the Privacy & Sync section payload for both the HTML (about.templ) and terminal (termrender/about.go) About page renderings. Populated by web.Handler.handleAbout from the handler's captured startup values; the renderers do not read env vars or config at request time.

OverrideActive is true iff PDBPLUS_PUBLIC_TIER=users was in effect at process start — the "never silent escalation" flag.

type RuntimeInfo added in v1.25.0

type RuntimeInfo struct {
	Version string
	Region  string
}

RuntimeInfo carries optional public process metadata for the About page. Region is empty outside platforms that supply a deployment-region value.

type SearchGroup

type SearchGroup struct {
	// TypeName is the human-readable plural name (e.g. "Networks", "IXPs").
	TypeName string
	// TypeSlug is the short identifier used in URLs (e.g. "net", "ix").
	TypeSlug string
	// AccentColor is the Tailwind color name for visual grouping (e.g. "emerald", "sky").
	AccentColor string
	// Results holds up to 10 matching entities.
	Results []SearchResult
	// HasMore indicates whether additional matches exist beyond the displayed results.
	HasMore bool
	// Total is the exact number of matches across all pages. Equals len(Results)
	// when HasMore is false; drives the "View all N" link when HasMore is true.
	Total int
}

SearchGroup represents a group of search results for one entity type. These types mirror web.TypeResult and web.SearchHit, defined in the templates package to avoid circular imports (web imports templates, so templates cannot import web).

type SearchResult

type SearchResult struct {
	// Name is the entity's display name.
	Name string
	// Country is the ISO 3166-1 alpha-2 code; empty if not available.
	Country string
	// City is the city name; empty if not available.
	City string
	// ASN is the AS number; 0 if not applicable (non-network entity).
	ASN int
	// DetailURL is the path to the entity's detail page (e.g. "/ui/asn/13335").
	DetailURL string
}

SearchResult represents a single search hit for template rendering.

type SearchTypeView added in v1.20.0

type SearchTypeView struct {
	// TypeName is the human-readable plural name (e.g. "Networks").
	TypeName string
	// TypeSlug is the short identifier used in URLs (e.g. "net").
	TypeSlug string
	// AccentColor is the Tailwind color name for visual grouping.
	AccentColor string
	// Query is the search term, echoed in the header and pagination links.
	Query string
	// Total is the exact number of matches across all pages.
	Total int
	// Hits holds this page's matching entities.
	Hits []SearchResult
	// HasMore indicates whether matches exist beyond this page.
	HasMore bool
	// NextOffset is the offset for the next "Load more" request.
	NextOffset int
}

SearchTypeView holds the data for one page of the per-type "view all" results page (and its "Load more" fragment). It mirrors web.SearchTypeResult but lives in the templates package to avoid a web -> templates import cycle.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL