Documentation ¶
Index ¶
- Variables
- func BadgeClass(str string) template.HTML
- func CurrentUser(c CookieSetter) *pgmodels.User
- func DateISO(date time.Time) string
- func DateTimeISO(date time.Time) string
- func DateTimeUS(date time.Time) string
- func DateUS(date time.Time) string
- func DefaultString(value, _default string) string
- func DeleteCSRFCookie(c CookieSetter)
- func DeleteCookie(c CookieSetter, name string)
- func DeleteFlashCookie(c CookieSetter)
- func DeletePrefsCookie(c CookieSetter)
- func DeleteSessionCookie(c CookieSetter)
- func Dict(values ...interface{}) (map[string]interface{}, error)
- func EscapeAttr(s string) template.HTMLAttr
- func EscapeHTML(s string) template.HTML
- func FormatFloat(value float64, scale int) string
- func FormatInt(value int) string
- func FormatInt64(value int64) string
- func HumanSize(size int64) string
- func IconFor(str string) template.HTML
- func LinkifyUrls(text string) template.HTML
- func RoleName(role string) string
- func SetCSRFCookie(c CookieSetter) (string, error)
- func SetCookie(c CookieSetter, name, value string) error
- func SetFlashCookie(c CookieSetter, value string) error
- func SetPrefsCookie(c CookieSetter, value string) error
- func SetSessionCookie(c CookieSetter, user *pgmodels.User) error
- func SortIcon(currentUrl *url.URL, colName string) string
- func SortUrl(currentUrl *url.URL, colName string) string
- func StrEq(val1, val2 interface{}) bool
- func ToJSON(v interface{}) template.JS
- func Truncate(value string, length int) string
- func TruncateMiddle(str string, maxLen int) string
- func TruncateStart(str string, maxLen int) string
- func UnixToISO(ts int64) string
- func UserCan(user *pgmodels.User, permission constants.Permission, instID int64) bool
- func YesNo(value bool) string
- type ByLen
- type CookieSetter
- type CoverPhoto
Constants ¶
This section is empty.
Variables ¶
var BadgeClassMap = map[string]string{ constants.StatusCancelled: "is-cancelled", constants.StatusFailed: "is-failed", constants.StatusPending: "is-pending", constants.StatusStarted: "is-started", constants.StatusSuccess: "is-success", constants.StatusSuspended: "is-suspended", }
BadgeClassMap maps work item status and other constant values to css badge classes.
var IconMap = map[string]string{ constants.EventAccessAssignment: "admin_panel_settings", constants.EventCreate: "add_circle_outline", constants.EventDeletion: "delete_forever", constants.EventDigestCalculation: "description", constants.EventFixityCheck: "fingerprint", constants.EventIdentifierAssignment: "search", constants.EventIngestion: "file_upload", constants.EventReplication: "library_books", constants.ActionDelete: "delete_forever", constants.ActionIngest: "file_upload", constants.ActionRestoreFile: "file_download", constants.ActionRestoreObject: "file_download", constants.ActionGlacierRestore: "file_download", }
IconMap maps strings to Material icons.
var IconMissing = `help_outline`
IconMissing is the icon we show for items that are not in the IconMap. This appears as a question mark. If you see it on any web page, you should know to add an appropriate icon to the IconMap.
Functions ¶
func BadgeClass ¶
BadgeClass returns the css class for the specified string, where string is a work item status or other value defined in Constants.
func CurrentUser ¶
func CurrentUser(c CookieSetter) *pgmodels.User
func DateTimeISO ¶
DateTimeISO returns a date in format "2006-01-02T15:04:05Z"
func DateTimeUS ¶
DateUS returns a date in format "Jan 2, 2006 15:04:05"
func DefaultString ¶
DefaultString returns value if it's non-empty. Otherwise, it returns _default.
func DeleteCSRFCookie ¶
func DeleteCSRFCookie(c CookieSetter)
func DeleteCookie ¶
func DeleteCookie(c CookieSetter, name string)
func DeleteFlashCookie ¶
func DeleteFlashCookie(c CookieSetter)
func DeletePrefsCookie ¶
func DeletePrefsCookie(c CookieSetter)
func DeleteSessionCookie ¶
func DeleteSessionCookie(c CookieSetter)
func EscapeAttr ¶
EscapeAttr escapes an HTML attribute value. This helps avoid the ZgotmplZ problem.
func EscapeHTML ¶
EscapeHTML returns an escaped HTML string. This helps avoid the ZgotmplZ problem.
func FormatFloat ¶
FormatFloat formats a floating point number to have scale digits after the decimal point.
func FormatInt64 ¶
FormatInt64 formats a 64-bit integer value to include commas. 28635177 becomes 28,635,177
func HumanSize ¶
HumanSize returns a number of bytes in a human-readable format. Note that we use base 1024, not base 1000, because AWS uses 1024 to calculate the storage size of the objects we're reporting on.
func IconFor ¶
IconFor returns a FontAwesome icon for the specified string, as defined in helpers.IconMap. If the IconMap has no entry for the string, this returns helpers.IconMissing.
func LinkifyUrls ¶
LinkifyUrls converts urls in text to clickable links. That is, it replaces https://example.com with <a href="https://example.com">https://example.com</a>
URLs outside the current domain will open in a new tab (i.e. will have target="_blank").
This also replaces newlines with <br/> tags.
func SetCSRFCookie ¶
func SetCSRFCookie(c CookieSetter) (string, error)
func SetCookie ¶
func SetCookie(c CookieSetter, name, value string) error
func SetFlashCookie ¶
func SetFlashCookie(c CookieSetter, value string) error
func SetPrefsCookie ¶
func SetPrefsCookie(c CookieSetter, value string) error
func SetSessionCookie ¶
func SetSessionCookie(c CookieSetter, user *pgmodels.User) error
func SortIcon ¶
SortIcon returns the name of the sort icon to display at the top of a table column. This will be either "keyboard_arrow_up" or "keyboard_arrow_down"
func SortUrl ¶
SortUrl returns the url to sort results by the specified column. This is used in table column headers on index pages. Note that this returns a URL path and query string only. There's no hostname, port, or scheme.
func StrEq ¶
func StrEq(val1, val2 interface{}) bool
StrEq compares the string representation of two values and returns true if they are equal.
func Truncate ¶
Truncate truncates the value to the given length, appending an ellipses to the end. If value contains HTML tags, they will be stripped because truncating HTML can result in unclosed tags that will ruin the page layout.
func TruncateMiddle ¶
TruncateStart trims str to maxLen by removing them from the middle of the string. It adds dots to the middle of the string to indicate text was trimmed.
func TruncateStart ¶
TruncateStart trims str to maxLen by removing them from the start of the string. It adds leading dots to indicate some text was trimmed.
Types ¶
type CookieSetter ¶
type CookieSetter interface { SetCookie(name, value string, maxAge int, path, domain string, secure, httpOnly bool) SetSameSite(samesite http.SameSite) Get(key string) (value interface{}, exists bool) }
CookieSetter defines the methods used by gin.Context to set cookies. We define it as an interface so we don't have to mock the entire sprawling gin.Context when testing.
This also defines gin.Context's Get() method, which retrieves context values and SetSameSite, which is a security directive for cookie access.
type CoverPhoto ¶
func GetCover ¶
func GetCover() CoverPhoto