Documentation
¶
Overview ¶
Package html contains code relating specifically to the web UI.
Index ¶
- func AddStaticHandler(logger logr.Logger, r *mux.Router) error
- func Error(w http.ResponseWriter, err string, code int)
- 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 MergeQuery(u string, q string) (templ.SafeURL, error)
- func PopFlashes(r *http.Request, w http.ResponseWriter) ([]flash, error)
- func Render(c templ.Component, w http.ResponseWriter, r *http.Request)
- func RenderSnippet(c templ.Component, w io.Writer, r *http.Request) error
- func RequestFromContext(ctx context.Context) *http.Request
- func ResponseFromContext(ctx context.Context) http.ResponseWriter
- 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 CacheBuster
- type DropDownUIWidth
- type DropdownUI
- type FlashStack
- type FlashType
Constants ¶
This section is empty.
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 MergeQuery ¶ added in v0.3.14
MergeQuery merges the query string into the given url, replacing any existing query parameters with the same name.
func PopFlashes ¶
func PopFlashes(r *http.Request, w http.ResponseWriter) ([]flash, error)
PopFlashes pops all flash messages off the stack
func Render ¶ added in v0.3.14
Render a template. Wraps the upstream templ handler to carry out additional actions every time a template is rendered.
func RenderSnippet ¶ added in v0.3.15
func RequestFromContext ¶ added in v0.3.14
func ResponseFromContext ¶ added in v0.3.14
func ResponseFromContext(ctx context.Context) http.ResponseWriter
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 CacheBuster ¶ added in v0.3.14
CacheBuster provides a cache-busting filesystem wrapper, mapping paths with a specific format containing a sha256 hash to paths without the hash in the wrapped filesystem. i.e. mapping
/css/main.1fc822f99a2cfb6b5f316f00107a7d2770d547b64f3e0ea69baec12001a95f9f.css -> /css/main.css
var (
AssetsFS *CacheBuster
)
func (*CacheBuster) Open ¶ added in v0.3.14
func (cb *CacheBuster) Open(fname string) (http.File, error)
Open strips the hash from the name before opening it in the wrapped filesystem.
func (*CacheBuster) Path ¶ added in v0.3.14
func (cb *CacheBuster) Path(fname string) (string, error)
Path inserts a hash of the named file into its filename, before the filename extension: <path>.<ext> -> <path>.<hash>.<ext>, where <hash> is the hex format of the SHA256 hash of the contents of the file.
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)
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
templ: version: v0.3.833
|
templ: version: v0.3.833 |
paths
Package paths are paths for use in templ templates.
|
Package paths are paths for use in templ templates. |
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. |