package
0.0.0-20240624235250-9e89dfb7520d
Repository: https://github.com/tailscale/pkgsitelib.git
Documentation: pkg.go.dev

# README

// Copyright 2020 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file.

package frontend

import ( "bytes"

"github.com/google/safehtml"
"github.com/google/safehtml/uncheckedconversions"
"github.com/tailscale/pkgsitelib/pkg/sanitizer"

)

// Heading holds data about a heading and nested headings within a readme. // This data is used in the sidebar template to render the readme outline. type Heading struct { // Level is the original level of the heading. Level int // Text is the content from the readme contained within a heading. Text string // ID corresponds to the ID attribute for a heading element // and is also used in an href to the corresponding section // within the readme outline. All ids are prefixed with readme- // to avoid name collisions. ID string // Children are nested headings. Children []*Heading // parent is the heading this heading is nested within. Nil for top // level headings. parent *Heading }

// Readme holds the result of processing a REAME file. type Readme struct { HTML safehtml.HTML // rendered HTML Outline []*Heading // document headings Links []link // links from the "Links" section }

// sanitizeHTML sanitizes HTML from a bytes.Buffer so that it is safe. func sanitizeHTML(b *bytes.Buffer) safehtml.HTML { s := string(sanitizer.SanitizeBytes(b.Bytes())) return uncheckedconversions.HTMLFromStringKnownToSatisfyTypeContract(s) }

# Packages

Package client provides a client for interacting with the frontend.
No description provided by the author
Package page defines common fields shared by pages when rendering templages.
serrors contains error types used by the server.
No description provided by the author
Package urlinfo provides functions for extracting information out of url paths.
No description provided by the author

# Functions

NewServer creates a new Server for the given database and template directory.
ProcessReadme processes the README of unit u, if it has one.
Sections transforms a list of lines, which must be sorted, into a list of Sections.
TagRoute categorizes incoming requests to the frontend for use in monitoring.

# Variables

GenerateDepsDevURL controls whether a deps.dev URL is generated for the module.
ReadmeHeadingIDPrefix is the prefix for all heading ids in the readme.
RewriteImgSrc controls whether img src values in the README file are rewritten.
RewriteLinks controls whether links in the README file are rewritten.
ShowBreadcrumbDiscoverLink determines if hte initial "Discover Packages" link is included in the unit breadcrumb links.

# Structs

No description provided by the author
Directory is either a nested module or subdirectory of a unit, organized in a two level tree structure.
DirectoryInfo contains information about a package or nested module, relative to the path of a given unit.
File is a source file for a package.
Heading holds data about a heading and nested headings within a readme.
Homepage contains fields used in rendering the homepage template.
ImportedByDetails contains information for the collection of packages that import a given package.
ImportsDetails contains information for a package's imports.
License contains information used for a single license section.
LicenseMetadata contains license metadata that is used in the package header.
LicensePolicyPage is used to generate the static license policy page.
LicensesDetails contains license information for a package or module.
LocalModule holds information about a locally-hosted module.
MainDetails contains data needed to render the unit template.
Readme holds the result of processing a REAME file.
SearchPage contains all of the data that the search template needs to populate.
SearchResult contains data needed to display a single search result.
A Section represents a collection of lines with a common prefix.
Server can be installed to serve the go discovery frontend.
ServerConfig contains everything needed by a Server.
TabSettings defines tab-specific metadata.
UnitPage contains data needed to render the unit template.
VulnEntryPage holds the information for a page that displays a single vuln entry.
VulnListPage holds the information for a page that lists vuln entries.

# Interfaces

A Cacher is used to create request caches for http handlers.
FetchServerInterface is an interface for the parts of the server that support adding packages to a queue for fetching by a worker server.