web

package
v1.5.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StaticFS, _ = fs.Sub(staticFiles, "static")

StaticFS provides access to embedded static files (htmx.min.js, etc.) with the "static/" prefix stripped so files are served at their base names.

Functions

This section is empty.

Types

type CompareInput

type CompareInput struct {
	// ASN1 is the first network's Autonomous System Number.
	ASN1 int
	// ASN2 is the second network's Autonomous System Number.
	ASN2 int
	// ViewMode is "shared" (default) or "full".
	ViewMode string
}

CompareInput holds the parameters for a network comparison.

type CompareService

type CompareService struct {
	// contains filtered or unexported fields
}

CompareService compares two networks' presences across IXPs, facilities, and campuses.

func NewCompareService

func NewCompareService(client *ent.Client) *CompareService

NewCompareService creates a CompareService backed by the given ent client.

func (*CompareService) Compare

Compare loads both networks' presences and computes set intersections to find shared IXPs, facilities, and campuses.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler serves web UI pages.

func NewHandler

func NewHandler(client *ent.Client, db *sql.DB) *Handler

NewHandler creates a web UI handler with integrated search and compare services.

func (*Handler) Register

func (h *Handler) Register(mux *http.ServeMux)

Register mounts web UI routes on the given mux. Static assets are served from embedded files at /static/. UI pages are served under the /ui/ prefix. A single wildcard pattern dispatches all /ui/ paths internally, following the pdbcompat handler pattern.

type PageContent

type PageContent struct {
	Title   string
	Content templ.Component
}

PageContent holds the title and body component for a page render. Defined per CS-5 to avoid >2 non-ctx arguments in renderPage.

type SearchHit

type SearchHit struct {
	// ID is the entity's database identifier.
	ID int
	// Name is the entity's display name.
	Name string
	// Subtitle provides context: ASN for networks, city/country for facilities/IXPs/campuses.
	Subtitle string
	// DetailURL is the path to the entity's detail page (e.g. "/ui/asn/13335").
	DetailURL string
}

SearchHit represents a single search result with display-ready fields.

type SearchService

type SearchService struct {
	// contains filtered or unexported fields
}

SearchService provides search across all 6 PeeringDB entity types.

func NewSearchService

func NewSearchService(client *ent.Client) *SearchService

NewSearchService creates a SearchService backed by the given ent client.

func (*SearchService) Search

func (s *SearchService) Search(ctx context.Context, query string) ([]TypeResult, error)

Search queries all 6 entity types in parallel for the given search term. Returns only types with matches, sorted in canonical type order. Queries under 2 characters (after trimming) return an empty slice.

type TypeResult

type TypeResult 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 []SearchHit
	// TotalCount is the exact number of matching records for count badge display.
	TotalCount int
}

TypeResult groups search hits for a single entity type with metadata for display.

Directories

Path Synopsis
templ: version: v0.3.1001
templ: version: v0.3.1001

Jump to

Keyboard shortcuts

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