html

package
v2.26.7 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContinueExecution causes the execution of a panel to continue.
	ContinueExecution = true
	// AbortExecution causes the execution of a panel to be aborted.
	AbortExecution = false
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ContentProvider

type ContentProvider interface {
	// GetTitle returns the title of the panel.
	GetTitle() string
	// GetCaption returns the caption which is displayed on the panel.
	GetCaption() string

	// GetContentJavaScript delivers additional JavaScript code.
	GetContentJavaScript() string
	// GetContentStyleSheet delivers additional stylesheet code.
	GetContentStyleSheet() string
	// GetContentBody delivers the actual body content.
	GetContentBody() string
}

ContentProvider defines various methods for HTML content providers.

type ExecutionResult

type ExecutionResult = bool

ExecutionResult is the type returned by the PreExecute function of PanelProvider.

type Panel

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

Panel provides basic HTML panel functionality.

func NewPanel

func NewPanel(name string, provider PanelProvider, conf *config.Configuration, log *zerolog.Logger) (*Panel, error)

NewPanel creates a new panel.

func (*Panel) AddTemplate

func (panel *Panel) AddTemplate(name TemplateID, provider ContentProvider) error

AddTemplate adds and compiles a new template.

func (*Panel) Execute

func (panel *Panel) Execute(w http.ResponseWriter, r *http.Request, session *Session, dataProvider PanelDataProvider) error

Execute generates the HTTP output of the panel and writes it to the response writer.

type PanelDataProvider

type PanelDataProvider = func(*Session) interface{}

PanelDataProvider is the function signature for panel data providers.

type PanelProvider

type PanelProvider interface {
	// GetActiveTemplate returns the name of the active template.
	GetActiveTemplate(*Session, string) string

	// PreExecute is called before the actual template is being executed.
	PreExecute(*Session, string, http.ResponseWriter, *http.Request) (ExecutionResult, error)
}

PanelProvider handles general panel tasks.

type Session

type Session struct {
	ID            string
	MigrationID   string
	RemoteAddress string
	CreationTime  time.Time
	Timeout       time.Duration

	Data map[string]interface{}
	// contains filtered or unexported fields
}

Session stores all data associated with an HTML session.

func NewSession

func NewSession(name string, timeout time.Duration, r *http.Request) *Session

NewSession creates a new session, giving it a random ID.

func (*Session) HalftimePassed

func (sess *Session) HalftimePassed() bool

HalftimePassed checks whether the session has passed the first half of its lifetime.

func (*Session) HasExpired

func (sess *Session) HasExpired() bool

HasExpired checks whether the session has reached is timeout.

func (*Session) IsUserLoggedIn added in v2.3.0

func (sess *Session) IsUserLoggedIn() bool

IsUserLoggedIn tells whether a user is currently logged in.

func (*Session) LoggedInUser

func (sess *Session) LoggedInUser() *SessionUser

LoggedInUser retrieves the currently logged in user or nil if none is logged in.

func (*Session) LoginUser added in v2.3.0

func (sess *Session) LoginUser(acc *data.Account, site *data.Site)

LoginUser logs in the provided user.

func (*Session) LogoutUser added in v2.3.0

func (sess *Session) LogoutUser()

LogoutUser logs out the currently logged in user.

func (*Session) Save

func (sess *Session) Save(cookiePath string, w http.ResponseWriter)

Save stores the session ID in a cookie using a response writer.

func (*Session) VerifyRequest

func (sess *Session) VerifyRequest(r *http.Request, verifyRemoteAddress bool) error

VerifyRequest checks whether the provided request matches the stored session.

type SessionManager

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

SessionManager manages HTML sessions.

func NewSessionManager

func NewSessionManager(name string, conf *config.Configuration, log *zerolog.Logger) (*SessionManager, error)

NewSessionManager creates a new session manager.

func (*SessionManager) HandleRequest

func (mngr *SessionManager) HandleRequest(w http.ResponseWriter, r *http.Request) (*Session, error)

HandleRequest performs all session-related tasks during an HTML request. Always returns a valid session object.

func (*SessionManager) PurgeSessions

func (mngr *SessionManager) PurgeSessions()

PurgeSessions removes any expired sessions.

type SessionUser added in v2.3.0

type SessionUser struct {
	Account *data.Account
	Site    *data.Site
}

SessionUser holds information about the logged in user

type TemplateID

type TemplateID = string

TemplateID is the type for template identifiers.

Jump to

Keyboard shortcuts

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