hyperrenderer

package
v0.0.0-...-fc6bf95 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WebpageTypeAuthority = "authority"
	WebpageTypeHub       = "hub"
)

Variables

This section is empty.

Functions

func CityPathGenerator

func CityPathGenerator(webpage *Webpage) string

func CreatePathMap

func CreatePathMap(root HyperRenderer) map[string]HyperRenderer

func GetPaths

func GetPaths(node HyperRenderer) []string

func NoOpVisit

func NoOpVisit(hr HyperRenderer) bool

Types

type HyperRenderer

type HyperRenderer interface {
	GetID() string
	GetPath() string
	Render(wr io.Writer) error
	GetLinks() []HyperRenderer
}

func FindHyperRendererByID

func FindHyperRendererByID(root HyperRenderer, targetID string) HyperRenderer

func FindHyperRendererByPath

func FindHyperRendererByPath(root HyperRenderer, path string) HyperRenderer

type PathGeneratorfunc

type PathGeneratorfunc func(parent *Webpage) string

type VisitFunc

type VisitFunc func(HyperRenderer) bool

boolean value indicates whether the traversal should be terminated or not.

type VisitedMap

type VisitedMap map[HyperRenderer]struct{}

func Traverse

func Traverse(root HyperRenderer, f VisitFunc) VisitedMap

type Webpage

type Webpage struct {
	ID         uint64
	Path       string
	PathPrefix string
	Parent     *Webpage
	Links      []*Webpage
	Type       WebpageType

	PathGenerator PathGeneratorfunc
	AuthorityTmpl *template.Template
	HubTmpl       *template.Template
	CustomTmpl    *template.Template
}

func NewWebpage

func NewWebpage(
	webpageType WebpageType,
	opts ...WebpageOption,
) *Webpage

func (*Webpage) AddChild

func (wp *Webpage) AddChild(webpageType WebpageType, opts ...WebpageOption) *Webpage
func (wp *Webpage) AddLink(page *Webpage)

func (*Webpage) Clone

func (wp *Webpage) Clone(webpageType WebpageType) *Webpage

Clone creates a new Webpage instance based on the current one with a specified type, a unique ID, and no links.

func (*Webpage) CountLinksByType

func (wp *Webpage) CountLinksByType(t WebpageType) int

func (*Webpage) Draw

func (wp *Webpage) Draw(format graphviz.Format, w io.Writer) error

func (*Webpage) Faker

func (wp *Webpage) Faker() *gofakeit.Faker

func (*Webpage) GetID

func (wp *Webpage) GetID() string
func (wp *Webpage) GetLinks() []HyperRenderer

func (*Webpage) GetPath

func (wp *Webpage) GetPath() string

func (*Webpage) Render

func (wp *Webpage) Render(writer io.Writer) error

type WebpageOption

type WebpageOption func(*Webpage)

func WithAuthorityTemplate

func WithAuthorityTemplate(tmpl *template.Template) WebpageOption

func WithCustomTemplate

func WithCustomTemplate(tmpl *template.Template) WebpageOption

func WithHubTemplate

func WithHubTemplate(tmpl *template.Template) WebpageOption

func WithPathGenerator

func WithPathGenerator(f func(*Webpage) string) WebpageOption

func WithPathPrefix

func WithPathPrefix(prefix string) WebpageOption

type WebpageType

type WebpageType string

Jump to

Keyboard shortcuts

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