webapp

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KeySessID is the param name for session ID.
	KeySessID = "sid"
	// KeyIsHeaderOn is the param name for is the header on boolean.
	KeyIsHeaderOn = "hed"
	// KeyIsNavOn is the param name for the is the nav on boolean.
	KeyIsNavOn = "nav"
	// KeyLessonIndex is the param name for the lesson index.
	KeyLessonIndex = "lix"
	// KeyBlockIndex is the param name for the block index.
	KeyBlockIndex = "bix"
)

These must all be unique, and preferably short. They are used as URL query param and cookie field names.

Variables

This section is empty.

Functions

This section is empty.

Types

type NavPrinter struct {
	model.TxtPrinter
	// contains filtered or unexported fields
}

NavPrinter prints leftnav HTML to a Writer.

func NewTutorialNavPrinter

func NewTutorialNavPrinter(w io.Writer) *NavPrinter

NewTutorialNavPrinter returns a new printer for the given writer.

func (v *NavPrinter) VisitBlockTut(x *model.BlockTut)

VisitBlockTut does nothing. Not expanding blocks in the nav - too busy looking.

func (v *NavPrinter) VisitCourse(x *model.Course)

VisitCourse visits a course to print it.

func (v *NavPrinter) VisitLessonTut(x *model.LessonTut)

VisitLessonTut visits a lesson to print it.

func (v *NavPrinter) VisitTopCourse(x *model.TopCourse)

VisitTopCourse visits a course to print its children.

type SessionData

type SessionData struct {
	// The session ID.
	SessID TypeSessID
	// Is the header showing?
	IsHeaderOn bool
	// Is the nav showing?
	IsNavOn bool
	// The active lesson.
	LessonIndex int
	// The active block.
	BlockIndex int
}

SessionData holds session state data, presumably associated with a cookie.

func AssureSessionData

func AssureSessionData(s *sessions.Session) *SessionData

AssureSessionData tries to recover session data, saving defaults for missing data.

type TypeSessID

type TypeSessID string

TypeSessID represents a session ID.

type WebApp

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

WebApp presents a tutorial to a web browser.

func NewWebApp

func NewWebApp(
	sessionData *SessionData, host string,
	tut model.Tutorial, ds *base.DataSource, lp []int, cp [][]int) *WebApp

NewWebApp makes a new web app.

func (*WebApp) ColorBackground

func (wa *WebApp) ColorBackground() string

ColorBackground is just that.

func (*WebApp) ColorCodeBlockBackground

func (wa *WebApp) ColorCodeBlockBackground() string

ColorCodeBlockBackground is just that.

func (*WebApp) ColorCodeBlockText

func (wa *WebApp) ColorCodeBlockText() string

ColorCodeBlockText is just that.

func (*WebApp) ColorCodeHover

func (wa *WebApp) ColorCodeHover() string

ColorCodeHover is just that.

func (*WebApp) ColorControls

func (wa *WebApp) ColorControls() string

ColorControls is just that.

func (*WebApp) ColorHeader

func (wa *WebApp) ColorHeader() string

ColorHeader is just that.

func (*WebApp) ColorHelpBackground

func (wa *WebApp) ColorHelpBackground() string

ColorHelpBackground is just that.

func (*WebApp) ColorHover

func (wa *WebApp) ColorHover() string

ColorHover is just that.

func (*WebApp) ColorNavBackground

func (wa *WebApp) ColorNavBackground() string

ColorNavBackground is just that.

func (*WebApp) ColorNavSelected

func (wa *WebApp) ColorNavSelected() string

ColorNavSelected is just that.

func (*WebApp) ColorNavText

func (wa *WebApp) ColorNavText() string

ColorNavText is just that.

func (*WebApp) ColorTitle

func (wa *WebApp) ColorTitle() string

ColorTitle is just that.

func (*WebApp) CoursePaths

func (wa *WebApp) CoursePaths() [][]int

CoursePaths emits a javascript 2D array holding lesson paths. The length equals the number of lessons. Each entry should contain an array of course indices that should be active when the lesson is active.

func (wa *WebApp) DataSourceLink() template.URL

DataSourceLink lets the user find the original data.

func (*WebApp) DataSourceName

func (wa *WebApp) DataSourceName() string

DataSourceName is the source of the data.

func (*WebApp) DocTitle

func (wa *WebApp) DocTitle() string

DocTitle is the name of the document or web page.

func (*WebApp) Host

func (wa *WebApp) Host() string

Host is the webapp's host.

func (*WebApp) InitialBlock

func (wa *WebApp) InitialBlock() int

InitialBlock is where the user should start.

func (*WebApp) InitialHeaderOn

func (wa *WebApp) InitialHeaderOn() bool

InitialHeaderOn is should the header be on?

func (*WebApp) InitialLesson

func (wa *WebApp) InitialLesson() int

InitialLesson is where the user should start.

func (*WebApp) InitialNavOn

func (wa *WebApp) InitialNavOn() bool

InitialNavOn is should the nav be on?

func (*WebApp) KeyBlockIndex

func (wa *WebApp) KeyBlockIndex() string

KeyBlockIndex delivers the corresponding const to a template.

func (*WebApp) KeyIsHeaderOn

func (wa *WebApp) KeyIsHeaderOn() string

KeyIsHeaderOn delivers the corresponding const to a template.

func (*WebApp) KeyIsNavOn

func (wa *WebApp) KeyIsNavOn() string

KeyIsNavOn delivers the corresponding const to a template.

func (*WebApp) KeyLessonIndex

func (wa *WebApp) KeyLessonIndex() string

KeyLessonIndex delivers the corresponding const to a template.

func (*WebApp) KeySessID

func (wa *WebApp) KeySessID() string

KeySessID delivers the corresponding const to a template.

func (*WebApp) LayBodyMediumWidth

func (wa *WebApp) LayBodyMediumWidth() int

LayBodyMediumWidth is the min body width of medium mode. Small mode (presumably phones) is anything thinner.

func (*WebApp) LayBodyWideWidth

func (wa *WebApp) LayBodyWideWidth() int

LayBodyWideWidth is the min body width of "wide" mode.

func (*WebApp) LayFooterHeight

func (wa *WebApp) LayFooterHeight() int

LayFooterHeight is just that.

func (*WebApp) LayHeaderHeight

func (wa *WebApp) LayHeaderHeight() int

LayHeaderHeight is just that.

func (*WebApp) LayMinHeaderWidth

func (wa *WebApp) LayMinHeaderWidth() int

LayMinHeaderWidth is just that.

func (*WebApp) LayMinimizedHeaderHeight

func (wa *WebApp) LayMinimizedHeaderHeight() int

LayMinimizedHeaderHeight is just that.

func (*WebApp) LayNavBoxWidth

func (wa *WebApp) LayNavBoxWidth() int

LayNavBoxWidth is just that.

func (*WebApp) LayNavLeftPad

func (wa *WebApp) LayNavLeftPad() int

LayNavLeftPad is just that.

func (*WebApp) LayNavTopBotPad

func (wa *WebApp) LayNavTopBotPad() int

LayNavTopBotPad is just that.

func (*WebApp) LessonCount

func (wa *WebApp) LessonCount() int

LessonCount is just that.

func (*WebApp) Lessons

func (wa *WebApp) Lessons() []*program.LessonPgm

Lessons is the list of lessons known to the webapp.

func (*WebApp) Render

func (wa *WebApp) Render(w io.Writer) error

Render writes a web page to the given writer.

func (*WebApp) SessID

func (wa *WebApp) SessID() TypeSessID

SessID is the id of the session returned

func (*WebApp) TransitionSpeedMs

func (wa *WebApp) TransitionSpeedMs() int

TransitionSpeedMs is speed of css transitions in milliseconds.

Jump to

Keyboard shortcuts

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