webcore

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: BSD-3-Clause Imports: 22 Imported by: 0

README

webcore

Webcore is a framework designed for easily building content-focused sites

Documentation

Overview

Package webcore is a framework designed for easily building content-focused sites

Index

Constants

This section is empty.

Variables

View Source
var Examples = map[string]func(parent gi.Widget){}

Examples are the different core examples that exist as compiled Go code that can be run in webcore. The map is keyed by ID. Generated webcoregen.go files add to this by finding all code blocks with language Go (must be uppercase, as that indicates that is an "exported" example).

View Source
var NumExamples = map[string]int{}

NumExamples has the number of examples per page URL.

View Source
var PageType = gti.AddType(&gti.Type{Name: "cogentcore.org/core/webcore.Page", IDName: "page", Doc: "Page represents one site page", Embeds: []gti.Field{{Name: "Frame"}}, Fields: []gti.Field{{Name: "Source", Doc: "Source is the filesystem in which the content is located."}, {Name: "Context", Doc: "Context is the page's [coredom.Context]."}, {Name: "History", Doc: "The history of URLs that have been visited. The oldest page is first."}, {Name: "HistoryIndex", Doc: "HistoryIndex is the current place we are at in the History"}, {Name: "PagePath", Doc: "PagePath is the fs path of the current page in [Page.Source]"}, {Name: "URLToPagePath", Doc: "URLToPagePath is a map between user-facing page URLs and underlying\nFS page paths."}}, Instance: &Page{}})

PageType is the gti.Type for Page

Functions

func ExampleHandler added in v0.0.8

func ExampleHandler(ctx *coredom.Context) bool

ExampleHandler is the coredom handler for <webcore-example> HTML elements that handles examples.

Types

type Page

type Page struct {
	gi.Frame

	// Source is the filesystem in which the content is located.
	Source fs.FS

	// Context is the page's [coredom.Context].
	Context *coredom.Context `set:"-"`

	// The history of URLs that have been visited. The oldest page is first.
	History []string `set:"-"`

	// HistoryIndex is the current place we are at in the History
	HistoryIndex int `set:"-"`

	// PagePath is the fs path of the current page in [Page.Source]
	PagePath string `set:"-"`

	// URLToPagePath is a map between user-facing page URLs and underlying
	// FS page paths.
	URLToPagePath map[string]string `set:"-"`
}

Page represents one site page

func NewPage

func NewPage(par ki.Ki, name ...string) *Page

NewPage adds a new Page with the given name to the given parent: Page represents one site page

func (*Page) AppBar

func (pg *Page) AppBar(tb *gi.Toolbar)

AppBar is the default app bar for a Page

func (*Page) Config added in v0.0.8

func (pg *Page) Config()

func (*Page) KiType

func (t *Page) KiType() *gti.Type

KiType returns the *gti.Type of Page

func (*Page) New

func (t *Page) New() ki.Ki

New returns a new *Page value

func (*Page) OnInit

func (pg *Page) OnInit()

func (*Page) OpenURL

func (pg *Page) OpenURL(rawURL string, addToHistory bool)

OpenURL sets the content of the page from the given url. If the given URL has no scheme (eg: "/about"), then it sets the content of the page to the file specified by the URL. This is either the "index.md" file in the corresponding directory (eg: "/about/index.md") or the corresponding md file (eg: "/about.md"). If it has a scheme, (eg: "https://example.com"), then it opens it in the user's default browser.

func (*Page) SetSource

func (t *Page) SetSource(v fs.FS) *Page

SetSource sets the [Page.Source]: Source is the filesystem in which the content is located.

func (*Page) SetStackTop

func (t *Page) SetStackTop(v int) *Page

SetStackTop sets the [Page.StackTop]

func (*Page) SetTooltip

func (t *Page) SetTooltip(v string) *Page

SetTooltip sets the [Page.Tooltip]

Directories

Path Synopsis
examples
Package wpath handles webcore paths
Package wpath handles webcore paths

Jump to

Keyboard shortcuts

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