Documentation ¶
Overview ¶
Package simple provides functions for handling string or integer input data.
Index ¶
- Constants
- Variables
- func AssetSrc(abs, dir, unid, ext string) string
- func BytesHuman(i int64) string
- func DemozooGetLink(filename, filesize, demozoo, unid any) template.HTML
- func DownloadB(i any) template.HTML
- func ImageSample(unid, previewDir string) template.HTML
- func ImageSampleStat(unid, previewDir string) bool
- func ImageXY(name string) [2]string
- func LinkID(id any, elem string) (string, error)
- func LinkPreviewTip(name, platform string) string
- func LinkRelations(val string) template.HTML
- func LinkRelr(name string) (string, error)
- func LinkSites(val string) template.HTML
- func MIME(name string) string
- func MagicAsTitle(name string) string
- func MakeLink(name, class string, performant bool) (string, error)
- func MkContent(src string) string
- func ReleaserPair(a, b any) [2]string
- func Releasers(prime, second string, magazine bool) template.HTML
- func Screenshot(unid, desc, previewDir string) template.HTML
- func StatHumanize(name string) (string, string, string)
- func Thumb(unid, desc, thumbDir string, bottom bool) template.HTML
- func ThumbSample(unid, thumbDir string) template.HTML
- func Updated(t any, s string) string
Constants ¶
const (
YYYYMMDD = "2006-Jan-02"
)
Variables ¶
Functions ¶
func AssetSrc ¶
AssetSrc returns a URL to an artifact asset with an cache busting hash. The named dir is the directory where the asset is stored, the unid is the unique identifier of the asset, and the ext is the file extension of the expected asset.
func BytesHuman ¶
BytesHuman returns the file size for the file record.
func DemozooGetLink ¶
DemozooGetLink returns a HTML link to the Demozoo download links. The filename and filesize are used to determine if the file exists. The demozoo is the ID for the production on Demozoo. The unid is the unique identifier for the file record.
func DownloadB ¶
DownloadB returns a human readable string of the file size. The i value must be an integer or a null.Int64.
func ImageSample ¶
ImageSample returns a HTML image tag for the given unid. The previewDir is the directory where the preview images are stored.
func ImageSampleStat ¶
ImageSampleStat returns true if the image sample file exists and is not a 0 byte file. The previewDir is the directory where the preview images are stored.
func ImageXY ¶
ImageXY returns the named image filesize and dimensions. The dimensions are returned as a string in the format "width x height". If the file does not exist, an empty string array is returned.
func LinkID ¶
LinkID creates a URL to link to the record. The id is obfuscated to prevent direct linking. The elem is the element to link to, such as 'f' for file or 'd' for download.
func LinkPreviewTip ¶
LinkPreviewTip returns a tooltip to describe the preview link. The name is the filename of the file to preview and does not require path information. The platform is the platform or format of the file.
func LinkRelations ¶
LinkRelations returns a collection of HTML anchor links that point to artifacts.
The val string is a list of artifact descriptions and their URL ID separated by a semicolon ";". Multiple artifact entries are separated by a pipe "|".
For example, "NFO;9f1c2|Intro;a92116e".
func LinkRelr ¶
LinkRelr returns a link to the named group page.
Providing the name "a group" will return "/g/a-group".
func LinkSites ¶
LinkSites returns a collection of HTML anchor links that point to websites.
The val string is a list of website descriptions and their URL ID separated by a semicolon ";". Multiple website entries are separated by a pipe "|".
For example, "Site;example.com|Documentation;example.com/doc".
func MagicAsTitle ¶
MagicAsTitle returns the magic number description for the named file.
func MakeLink ¶
MakeLink returns a HTML anchor link to the named group page. When the performant flag is false, the link will apply additional typography to the group name. But this should not be used for large lists of links as it will significantly slow down the page rendering.
For example supplying the name "tport"
- with performant false will return a link displaying "tPORt"
- with performant true will return a link displaying "Tport"
func MkContent ¶
MkContent makes and/or returns a distinct directory path in the temp directory that is used to extract the contents of the content of the file download archive. To make the directory distinct it is prefixed with the basename of the src file.
The returned path should be removed after use.
func ReleaserPair ¶
ReleaserPair returns the primary and secondary releaser groups as two strings.
func Screenshot ¶
Screenshot returns a image elment with screenshots for the given unid. If a webp or avif image is available, and a legacy png or jpg image is available, a picture element is used to provide multiple sources for the image. Otherwise, a single img element is used.
The unid is the filename of the screenshot image without an extension. The desc is the description of the image used for the alt attribute in the img tag. The previewDir is the directory where the preview images are stored.
Supported formats are webp, png, jpg and avif.
func StatHumanize ¶
StatHumanize returns the last modified date, size in bytes and size formatted of the named file. If the file does not exist, the string "file not found" is returned.
An example of the returned values are:
"2024-Sep-03", "4,163", "4.2 kB"
func Thumb ¶
Thumb returns a HTML image tag or picture element for the given unid. The unid is the filename of the thumbnail image without an extension. The desc is the description of the image. The thumbDir is the directory where the thumbnail images are stored. The bottom flag is true if the image should be displayed at the bottom of the container element.
func ThumbSample ¶
ThumbSample returns a HTML image tag for the given unid. The unid is the filename of the thumbnail image without an extension. The thumbDir is the directory where the thumbnail images are stored.
Types ¶
This section is empty.