Documentation ¶
Overview ¶
Package html contains code relating specifically to the web UI.
Index ¶
- Constants
- func AddStaticHandler(logger logr.Logger, r *mux.Router, devMode bool) error
- func Error(w http.ResponseWriter, err string, code int, devMode bool)
- func FlashError(w http.ResponseWriter, msg string)
- func FlashSuccess(w http.ResponseWriter, msg string)
- func FlashWarning(w http.ResponseWriter, msg string)
- func MarkdownToHTML(md []byte) template.HTML
- func NewRenderer(devMode bool) (*renderer, error)
- func PopFlashes(r *http.Request) ([]flash, error)
- func ReturnUserOriginalPage(w http.ResponseWriter, r *http.Request)
- func SendUserToLoginPage(w http.ResponseWriter, r *http.Request)
- func SetCookie(w http.ResponseWriter, name, value string, expiry *time.Time)
- func UIRouter(r *mux.Router) *mux.Router
- type DropDownUIWidth
- type DropdownUI
- type FlashStack
- type Renderer
- type SitePage
Constants ¶
const ( FlashSuccessType flashType = "success" FlashWarningType flashType = "warning" FlashErrorType flashType = "error" )
const ( // number of items in a paginated result to show on a single page PageSize int = 100 )
Variables ¶
This section is empty.
Functions ¶
func AddStaticHandler ¶
AddStaticHandler adds a handler to router serving static assets (JS, CSS, etc) from within go binary. Enabling developer mode sources files from local disk instead and starts a live reload server, which reloads the browser whenever static files change.
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 ¶
func FlashWarning(w http.ResponseWriter, msg string)
FlashWarning helper writes a single flash warning message
func MarkdownToHTML ¶
func NewRenderer ¶
NewRenderer constructs a renderer. If developer mode is enabled then templates are loaded from disk every time a template is rendered.
func PopFlashes ¶
PopFlashes pops all flash messages off the stack
func ReturnUserOriginalPage ¶
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 ¶
func SendUserToLoginPage(w http.ResponseWriter, r *http.Request)
SendUserToLoginPage sends user to the login prompt page, saving the original path they tried to access so it can return them there after login.
Types ¶
type DropDownUIWidth ¶ added in v0.1.9
type DropDownUIWidth string
const ( NarrowDropDown DropDownUIWidth = "narrow" WideDropDown DropDownUIWidth = "wide" )
type DropdownUI ¶ added in v0.1.0
type DropdownUI struct { // Name to send along with value in the POST form Name string // Existing values to NOT show in the dropdown Existing []string // Available values to show in the dropdown Available []string // Action is the form action URL Action string // Placeholder to show in the input element. Placeholder string // Width: "narrow" or "wide" Width DropDownUIWidth }
DropdownUI populates a search/dropdown UI component.
type FlashStack ¶
type FlashStack []flash
FlashStack is a stack of flash messages
func (*FlashStack) Push ¶
func (s *FlashStack) Push(t flashType, msg string)
func (FlashStack) Write ¶
func (s FlashStack) Write(w http.ResponseWriter)
type Renderer ¶
type Renderer interface {
// contains filtered or unexported methods
}
Renderer renders pages and templates
type SitePage ¶
type SitePage struct { Title string // page title Version string // otf version string in footer CurrentOrganization string // contains filtered or unexported fields }
SitePage contains data shared by all pages when rendering templates.