html

package
v0.0.40 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2023 License: MPL-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package html contains code relating specifically to the web UI.

Index

Constants

View Source
const (
	FlashSuccessType flashType = "success"
	FlashWarningType flashType = "warning"
	FlashErrorType   flashType = "error"
)

Variables

This section is empty.

Functions

func AddStaticHandler added in v0.0.32

func AddStaticHandler(r *mux.Router, devMode bool)

AddStaticHandler adds a handler to router serving static assets (JS, CSS, etc) from within go binary. Dev mode sources files from local disk instead.

func AssertRedirect added in v0.0.33

func AssertRedirect(t *testing.T, w *httptest.ResponseRecorder, path string)

func CurrentOrganization added in v0.0.33

func CurrentOrganization(content any) *string

CurrentOrganization is a UI helper that is used to show the current organization on the web page.

func Error added in v0.0.27

func Error(w http.ResponseWriter, err string, code int)

func FlashError

func FlashError(w http.ResponseWriter, msg string)

FlashError helper writes a single flash error message

func FlashSuccess

func FlashSuccess(w http.ResponseWriter, msg string)

FlashSuccess helper writes a single flash success message

func FlashWarning added in v0.0.31

func FlashWarning(w http.ResponseWriter, msg string)

FlashWarning helper writes a single flash warning message

func MarkdownToHTML added in v0.0.32

func MarkdownToHTML(md []byte) template.HTML

func NewViewEngine added in v0.0.27

func NewViewEngine(devmode bool) (*viewEngine, error)

func PopFlashes added in v0.0.31

func PopFlashes(w http.ResponseWriter, r *http.Request) ([]flash, error)

PopFlashes pops all flash messages off the stack

func ReturnUserOriginalPage added in v0.0.33

func ReturnUserOriginalPage(w http.ResponseWriter, r *http.Request)

ReturnUserOriginalPage returns a user to the original page they tried to access before they were redirected to the login page.

func SendUserToLoginPage added in v0.0.33

func SendUserToLoginPage(w http.ResponseWriter, r *http.Request)

SendUserToLoginPage sends user to the login prompt page, saving the original page they tried to access so it can return them there after login.

func SetCookie added in v0.0.32

func SetCookie(w http.ResponseWriter, name, value string, expiry *time.Time)

SetCookie sets a cookie on the http response. A nil expiry sets no expiry, and a zero expiry sets it to be purged from the browser.

func UIRouter added in v0.0.32

func UIRouter(r *mux.Router) *mux.Router

UIRouter wraps the given router with a router suitable for web UI routes.

Types

type FlashStack added in v0.0.32

type FlashStack []flash

FlashStack is a stack of flash messages

func (*FlashStack) Push added in v0.0.32

func (s *FlashStack) Push(t flashType, msg string)

func (FlashStack) Write added in v0.0.32

func (s FlashStack) Write(w http.ResponseWriter)

Directories

Path Synopsis
Package paths provides rails-style path helpers for use with the web app.
Package paths provides rails-style path helpers for use with the web app.

Jump to

Keyboard shortcuts

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