components

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2025 License: UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SidebarLayout = "sidebar"
	FullLayout    = "full"
)

Layout

View Source
const RedirectViewType = "redirect-view"

Variables

This section is empty.

Functions

func RenderBreadcrumpComponent

func RenderBreadcrumpComponent(w io.Writer, data BreadcrumbData) error

Types

type ArticleData

type ArticleData struct {
	ComponentContent Component
	Classes          string
}
type BreadcrumbData struct {
	Parts    []BreadcrumbPart
	ArgParts []BreadcrumbPart
	Queries  []QueryParam
}
type BreadcrumbPart struct {
	Name string
	URL  string
}

type Component

type Component interface {
	Render(w io.Writer) error
}

func IndexLayout

func IndexLayout(data IndexData) Component

func NewReaderComponent

func NewReaderComponent(reader io.Reader) Component

func NewTemplateComponent

func NewTemplateComponent(name string, data any) Component

type DirData

type DirData struct {
	PkgPath     string
	Files       []string
	FileCounter int
	FilesLinks  FilesLinks
	Mode        ViewMode
}

type DirLinkType

type DirLinkType int
const (
	DirLinkTypeSource DirLinkType = iota
	DirLinkTypeFile
)

func (DirLinkType) LinkPrefix

func (d DirLinkType) LinkPrefix(pkgPath string) string

Get the prefixed link depending on link type - Package Source Code or Package File

type FilesLinks []FullFileLink

FilesLinks has to be an array of FileLink

func GetFullLinks(files []string, linkType DirLinkType, pkgPath string) FilesLinks

type FooterData

type FooterData struct {
	Analytics  bool
	AssetsPath string
	Sections   []FooterSection
}

func EnrichFooterData

func EnrichFooterData(data FooterData) FooterData
type FooterLink struct {
	Label string
	URL   string
}

type FooterSection

type FooterSection struct {
	Title string
	Links []FooterLink
}
type FullFileLink struct {
	Link string
	Name string
}

Files has to be an array with Link (prefixed) and Name (filename)

type HeadData

type HeadData struct {
	Title       string
	Description string
	Canonical   string
	Image       string
	URL         string
	ChromaPath  string
	AssetsPath  string
	Analytics   bool
	Remote      string
	ChainId     string
}

type HeaderData

type HeaderData struct {
	RealmPath  string
	RealmURL   weburl.GnoURL
	Breadcrumb BreadcrumbData
	Links      HeaderLinks
	ChainId    string
	Remote     string
	Mode       ViewMode
}

func EnrichHeaderData

func EnrichHeaderData(data HeaderData, mode ViewMode) HeaderData
type HeaderLink struct {
	Label    string
	URL      string
	Icon     string
	IsActive bool
}
func StaticHeaderDevLinks(u weburl.GnoURL, mode ViewMode) []HeaderLink
func StaticHeaderGeneralLinks() []HeaderLink
type HeaderLinks struct {
	General []HeaderLink
	Dev     []HeaderLink
}

type HelpData

type HelpData struct {
	// Selected function
	SelectedFunc string
	SelectedArgs map[string]string
	SelectedSend string

	RealmName string
	Functions []*doc.JSONFunc
	ChainId   string
	Remote    string
	PkgPath   string
	Doc       string
}

type HelpTocData

type HelpTocData struct {
	Icon  string
	Items []HelpTocItem
}

type HelpTocItem

type HelpTocItem struct {
	Link string
	Text string
}

type IndexData

type IndexData struct {
	HeadData
	HeaderData
	FooterData
	BodyView *View
	Mode     ViewMode
}

type QueryParam

type QueryParam struct {
	Key   string
	Value string
}

type RealmData

type RealmData struct {
	ComponentContent Component
	TocItems         *RealmTOCData
}

type RealmTOCData

type RealmTOCData struct {
	Items []*markdown.TocItem
}

type RedirectData

type RedirectData struct {
	To            string
	WithAnalytics bool
}

type SourceData

type SourceData struct {
	PkgPath      string
	Files        []string
	FileName     string
	FileSize     string
	FileLines    int
	FileCounter  int
	FileDownload string
	FileSource   Component
}

type SourceTocData

type SourceTocData struct {
	Icon         string
	ReadmeFile   SourceTocItem
	GnoFiles     []SourceTocItem
	GnoTestFiles []SourceTocItem
}

type SourceTocItem

type SourceTocItem struct {
	Link string
	Text string
}

type StatusData

type StatusData struct {
	Title      string
	Body       string
	ButtonURL  string
	ButtonText string
}

StatusData holds the dynamic fields for the "status" template

type TemplateComponent

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

func (*TemplateComponent) Render

func (c *TemplateComponent) Render(w io.Writer) error

type View

type View struct {
	Type ViewType
	Component
}

func DirectoryView

func DirectoryView(pkgPath string, files []string, fileCounter int, linkType DirLinkType, mode ViewMode) *View

func HelpView

func HelpView(data HelpData) *View

func NewTemplateView

func NewTemplateView(typ ViewType, name string, data any) *View

func RealmView

func RealmView(data RealmData) *View

func RedirectView

func RedirectView(data RedirectData) *View

func SourceView

func SourceView(data SourceData) *View

func StatusErrorComponent

func StatusErrorComponent(message string) *View

StatusErrorComponent returns a view for error scenarios

func StatusNoRenderComponent

func StatusNoRenderComponent(pkgPath string) *View

StatusNoRenderComponent returns a view for non-error notifications

func (*View) Render

func (v *View) Render(w io.Writer) error

func (*View) String

func (v *View) String() string

type ViewMode

type ViewMode int

ViewMode represents the current view mode of the application It affects the layout, navigation, and display of content

const (
	ViewModeExplorer ViewMode = iota // For exploring packages and paths
	ViewModeRealm                    // For realm content display
	ViewModePackage                  // For package content display
	ViewModeHome                     // For home page display
)

func (ViewMode) GetLayoutType

func (m ViewMode) GetLayoutType() string

GetLayoutType returns the appropriate layout type for the view mode

func (ViewMode) IsExplorer

func (m ViewMode) IsExplorer() bool

View mode predicates

func (ViewMode) IsHome

func (m ViewMode) IsHome() bool

func (ViewMode) IsPackage

func (m ViewMode) IsPackage() bool

func (ViewMode) IsRealm

func (m ViewMode) IsRealm() bool

func (ViewMode) ShouldShowDevTools

func (m ViewMode) ShouldShowDevTools() bool

ShouldShowDevTools returns whether dev tools should be shown for this mode

func (m ViewMode) ShouldShowGeneralLinks() bool

ShouldShowGeneralLinks returns whether general navigation links should be shown

type ViewType

type ViewType string
const DirectoryViewType ViewType = "dir-view"
const HelpViewType ViewType = "help-view"
const RealmViewType ViewType = "realm-view"
const SourceViewType ViewType = "source-view"
const StatusViewType ViewType = "status-view"

Jump to

Keyboard shortcuts

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