Documentation ¶
Overview ¶
Package form provides functions for providing data for form and input elements.
Index ¶
- Constants
- func HumanizeCount(db *sql.DB, section, platform string) (template.HTML, error)
- func HumanizeCountStr(db *sql.DB, section, platform string) string
- func SanitizeFilename(name string) string
- func SanitizeGitHub(repo string) string
- func SanitizeSeparators(rawPath string) string
- func SanitizeURLPath(rawPath string) string
- func ValidDate(y, m, d string) (bool, bool, bool)
- func ValidVT(link string) bool
Constants ¶
const ReSanitizePath = "[^a-zA-Z0-9-._/]+" // Regular expression to sanitize the URL path.
Variables ¶
This section is empty.
Functions ¶
func HumanizeCount ¶ added in v0.10.0
HumanizeCount returns the human readable name of the platform and section tags combined and the number of existing artifacts. The number of existing artifacts is colored based on the count. If the count is 0, the text is red. If the count is 1, the text is blue. If the count is greater than 1, the text is unmodified.
func HumanizeCountStr ¶ added in v0.10.0
HumanizeCountStr returns the human readable name of the platform and section tags combined and the number of existing artifacts. Any errors are returned as a string.
func SanitizeFilename ¶
SanitizeFilename returns a sanitized version of the filename. The filename is trimmed of any leading or trailing whitespace, and any parent directory references are removed. Any Linux or Windows directory separators are replaced with a "-" hyphen.
func SanitizeGitHub ¶
SanitizeGitHub returns a sanitized version of the GitHub repository. The repo is trimmed of any invalid characters listed in the GitHub documentation.
func SanitizeSeparators ¶
SanitizeSeparators returns a sanitized version of the URL path. The path is trimmed of any URL scheme, host or query parameters, as well as any invalid path separators.
func SanitizeURLPath ¶
SanitizeURLPath returns a sanitized version of the URL path. Invalid characters are removed as are as incorrect path separators.
func ValidDate ¶
ValidDate returns three boolean values that indicate if the year, month, and day are valid. If any of the bool values are false, the date syntax is invalid and should not be used.
The year must be between 1980 and the current year. If the year is not in use, the month and day must not be in use. And if the month is not in use, the day must not in use.
A not in use value is either "0" or an empty string.
Types ¶
This section is empty.