Documentation
¶
Overview ¶
Package app handles the routes and views for the Defacto2 website.
Index ¶
- Constants
- Variables
- func APIInfo(sl *slog.Logger, c *echo.Context) error
- func Apps(sl *slog.Logger, c *echo.Context) error
- func Areacodes(sl *slog.Logger, c *echo.Context) error
- func ArtifactErr(sl *slog.Logger, c *echo.Context, id string) error
- func Artifacts(sl *slog.Logger, c *echo.Context, db *sql.DB, uri, page string) error
- func ArtifactsErr(sl *slog.Logger, c *echo.Context, uri string) error
- func Artist(sl *slog.Logger, c *echo.Context, db *sql.DB) error
- func Attribute(write, code, art, music, name string) string
- func BBS(sl *slog.Logger, c *echo.Context, db *sql.DB) error
- func BBSAZ(sl *slog.Logger, c *echo.Context, db *sql.DB) error
- func BBSYear(sl *slog.Logger, c *echo.Context, db *sql.DB) error
- func BadRequestErr(sl *slog.Logger, c *echo.Context, uri string, err error) error
- func Brief(platform, section any) string
- func BrokenTexts(sl *slog.Logger, c *echo.Context) error
- func ByteBytes(bytes any) template.HTML
- func ByteFile(count, bytes any) template.HTML
- func ByteFileS(name string, count, bytes any) template.HTML
- func Categories(sl *slog.Logger, c *echo.Context, db *sql.DB, stats bool) error
- func Checksum(sl *slog.Logger, c *echo.Context, db *sql.DB, id string) error
- func Coder(sl *slog.Logger, c *echo.Context, db *sql.DB) error
- func Compression(sl *slog.Logger, c *echo.Context) error
- func Configurations(sl *slog.Logger, c *echo.Context, db *sql.DB, conf config.Config) error
- func DatabaseErr(sl *slog.Logger, c *echo.Context, uri string, err error) error
- func Day(d any) string
- func Deletions(sl *slog.Logger, c *echo.Context, db *sql.DB, page string) error
- func Dependencies(sl *slog.Logger, c *echo.Context) error
- func Describe(platform, section, year, month any) template.HTML
- func Download(sl *slog.Logger, c *echo.Context, db *sql.DB, path dir.Directory) error
- func DownloadErr(sl *slog.Logger, c *echo.Context, uri string, err error) error
- func DownloadJsDos(sl *slog.Logger, c *echo.Context, db *sql.DB, extra, downl dir.Directory) error
- func EditFn(sl *slog.Logger, c *echo.Context, db *sql.DB, ...) error
- func EmptyTester(c *echo.Context) map[string]any
- func FTP(sl *slog.Logger, c *echo.Context, db *sql.DB) error
- func FileMissingErr(sl *slog.Logger, c *echo.Context, uri string, err error) error
- func FixNumericSuffix(sl *slog.Logger, c *echo.Context, db *sql.DB) error
- func Fixers(sl *slog.Logger, c *echo.Context, db *sql.DB) error
- func Fixes(sl *slog.Logger, c *echo.Context) error
- func ForApproval(sl *slog.Logger, c *echo.Context, db *sql.DB, page string) error
- func ForbiddenErr(sl *slog.Logger, c *echo.Context, uri string, err error) error
- func GetDemozoo(ctx context.Context, sl *slog.Logger, c *echo.Context, tx *sql.Tx, prodID int, ...) error
- func GetDemozooParam(sl *slog.Logger, c *echo.Context, tx *sql.Tx, download dir.Directory) error
- func GetPouet(ctx context.Context, sl *slog.Logger, tx *sql.Tx, prodID int, unid string, ...) error
- func GlobTo(name string) string
- func GoogleCallback(sl *slog.Logger, c *echo.Context, clientID string, maxAge int, ...) error
- func HasSuffix(s, suffix string) bool
- func History(sl *slog.Logger, c *echo.Context) error
- func Index(sl *slog.Logger, c *echo.Context) error
- func Inline(sl *slog.Logger, c *echo.Context, db *sql.DB, path dir.Directory) error
- func InternalErr(sl *slog.Logger, c *echo.Context, uri string, err error) error
- func Interview(sl *slog.Logger, c *echo.Context) error
- func LastUpdated(t any) string
- func LinkDownload(id any, securityAlert string) template.HTML
- func LinkHref(id any) (string, error)
- func LinkInterview(href string) template.HTML
- func LinkPage(id, kboard any) template.HTML
- func LinkPreview(id any, name, platform string) template.HTML
- func LinkPreviews(youtube, demozoo, pouet, colors16, github, rels, sites string) []string
- func LinkReleasers(performant, magazine bool, a, b any) template.HTML
- func LinkRelrs(magazine bool, a, b any) template.HTML
- func LinkRels(a, b any) template.HTML
- func LinkRelsPerf(a, b any) template.HTML
- func LinkRemote(href, name string) template.HTML
- func LinkRemoteTip(href, name, tooltip string) template.HTML
- func LinkRunApp(id any) template.HTML
- func LinkScnr(name string) (string, error)
- func LinkScnrs(names string) template.HTML
- func LinkWiki(uri, name string) template.HTML
- func LinkWikiTip(uri, name, tooltip string) template.HTML
- func LockIn80Columns(year int16, src ...byte) bool
- func LogoText(s string) string
- func Magazine(sl *slog.Logger, c *echo.Context, db *sql.DB) error
- func MagazineAZ(sl *slog.Logger, c *echo.Context, db *sql.DB) error
- func MarkAll(highlight, s string) string
- func Mask(s string) string
- func Month(m any) string
- func MusicModule(magic any) bool
- func Musician(sl *slog.Logger, c *echo.Context, db *sql.DB) error
- func New(sl *slog.Logger, c *echo.Context) error
- func PageErr(sl *slog.Logger, c *echo.Context, uri, page string) error
- func PlatformEdit(sl *slog.Logger, c *echo.Context, db *sql.DB) error
- func PlatformTagInfo(c *echo.Context) error
- func PostDesc(sl *slog.Logger, c *echo.Context, db *sql.DB, input string) error
- func PostFilename(sl *slog.Logger, c *echo.Context, db *sql.DB) error
- func PostName(sl *slog.Logger, c *echo.Context, db *sql.DB, mode FileSearch) error
- func PouetCache(c *echo.Context, data string) error
- func Prefix(s string) string
- func ProdPouet(c *echo.Context, id string) error
- func ProdZoo(c *echo.Context, id string) error
- func RecordRels(a, b any) string
- func Releaser(sl *slog.Logger, c *echo.Context, db *sql.DB, uri string, public fs.FS) error
- func ReleaserErr(sl *slog.Logger, c *echo.Context, invalidID string) error
- func Releasers(sl *slog.Logger, c *echo.Context, db *sql.DB) error
- func ReleasersAZ(sl *slog.Logger, c *echo.Context, db *sql.DB) error
- func ReleasersYear(sl *slog.Logger, c *echo.Context, db *sql.DB) error
- func RemovePCBoard(b []byte) []byte
- func Routes(sl *slog.Logger, c *echo.Context, r echo.Routes) error
- func SafeBBS(a any) template.HTML
- func SafeDocument(a any) template.HTML
- func SafeHTML(s string) template.HTML
- func SafeJS(s string) template.JS
- func Safety(platform, section any) bool
- func Scener(sl *slog.Logger, c *echo.Context, db *sql.DB) error
- func ScenerErr(sl *slog.Logger, c *echo.Context, id string) error
- func Sceners(sl *slog.Logger, c *echo.Context, db *sql.DB, uri string) error
- func SearchDesc(sl *slog.Logger, c *echo.Context) error
- func SearchFile(sl *slog.Logger, c *echo.Context) error
- func SearchID(sl *slog.Logger, c *echo.Context) error
- func SearchReleaser(sl *slog.Logger, c *echo.Context) error
- func SignOut(sl *slog.Logger, c *echo.Context) error
- func SignedOut(sl *slog.Logger, c *echo.Context) error
- func Signin(sl *slog.Logger, c *echo.Context, clientID string, nonce []byte) error
- func SortContent(content string) []string
- func StatusErr(sl *slog.Logger, c *echo.Context, code int, uri string) error
- func StripSup(s string) map[string]template.HTML
- func SubTitle(section null.String, title any, large bool) template.HTML
- func TagBrief(tag string) string
- func TagEdit(sl *slog.Logger, c *echo.Context, db *sql.DB) error
- func TagInfo(c *echo.Context) error
- func TagOption(sel, value any) template.HTML
- func TagWithOS(os, tag string) string
- func Terms(sl *slog.Logger, c *echo.Context) error
- func Thanks(sl *slog.Logger, c *echo.Context) error
- func TheScene(sl *slog.Logger, c *echo.Context) error
- func Titles(sl *slog.Logger, c *echo.Context) error
- func TrimSiteSuffix(s string) string
- func TrimSpace(a any) string
- func URLEncode(a any) string
- func Unwanted(sl *slog.Logger, c *echo.Context, db *sql.DB, page string) error
- func VotePouet(sl *slog.Logger, c *echo.Context, id string) error
- func Website(sl *slog.Logger, c *echo.Context, open string) error
- func WebsiteIcon(url string) template.HTML
- func Writer(sl *slog.Logger, c *echo.Context, db *sql.DB) error
- func YMDEdit(c *echo.Context, tx *sql.Tx) error
- type Accordion
- type Asset
- type Cache
- type Dirs
- type FileSearch
- type Font
- type FontPaths
- type Form
- type Group
- type Groups
- type Integer
- type Interviewee
- type Interviews
- type Links
- type Milestone
- type Milestones
- type Page
- type Pagination
- type Paths
- type Picture
- type SRI
- type Site
- type Sites
- type WebApp
- func (wa *WebApp) FuncClosure() template.FuncMap
- func (wa *WebApp) FuncDB(ctx context.Context, db *sql.DB) template.FuncMap
- func (wa *WebApp) FuncElem() template.FuncMap
- func (wa *WebApp) FuncMap(ctx context.Context, db *sql.DB) template.FuncMap
- func (wa *WebApp) FuncStatic() template.FuncMap
- func (wa *WebApp) Funcs() template.FuncMap
- func (wa *WebApp) Layout(name filename) []string
- func (wa *WebApp) Pages() Page
- func (wa *WebApp) Templates(ctx context.Context, db *sql.DB) (map[string]*template.Template, error)
Constants ¶
const ( PcEpoch = model.EpochYear // pc epoch is the default year for PC/MS-DOS files without a timestamp CgaEpoch = 1988 // cga epoch is the final year to use the IBM PC CGA font for viewing textfiles )
const Assets = int(_maxAsset)
Assets is the total number of public facing asset files.
const ErrTmpl = "cannot render the html template for this page"
const Fonts = int(_maxFont)
Fonts is the total number of public facing font files.
const ( // Welcome is the default logo monospace text, // each side contains 20 whitespace characters. // The welcome to defacto2 text is 19 characters long. // The letter O of the word "TO" is the center of the text. Welcome = `: ` + `·· WELCOME TO DEFACTO2 ··` + ` ·` )
Variables ¶
var ( ErrArtifact = errors.New("app: artifact response is nil") ErrClaims = errors.New("app: no sub id in the claims payload") ErrCorrupt = errors.New("app: cache data is invalid or corrupt") ErrDownload = errors.New("app: cannot stat the downloaded file") ErrMisMatch = errors.New("app: token mismatch") ErrNegative = errors.New("app: value cannot be a negative number") ErrSession = errors.New("app: no sub id in session") ErrStatus = errors.New("app: http status code is not valid") ErrType = errors.New("app: wrong type of value") ErrUser = errors.New("app: unknown user") ErrValue = errors.New("app: value is empty") ErrMissingObfuscatedID = errors.New("app: missing obfuscated ID") ErrInvalidObfuscatedID = errors.New("app: invalid obfuscated ID") ErrFileNotFound = errors.New("app: file not found") ErrInvalidFilenamePattern = errors.New("app: filename does not match numeric suffix pattern") )
var Caching = Cache{RecordCount: 0} //nolint:gochecknoglobals
Caching are values that are used throughout the app or layouts.
Functions ¶
func Areacodes ¶ added in v1.6.0
Areacodes is the handler for the BBS and telephone area codes page.
func ArtifactErr ¶ added in v1.14.0
ArtifactErr renders the error page for the artifact links.
func Artifacts ¶
Artifacts is the handler for the list and preview of the files page. The uri is the category or collection of files to display. The page is the page number of the results to display.
func ArtifactsErr ¶ added in v1.14.0
ArtifactsErr renders the files error page for the Artifacts menu and categories. It provides different error messages to the standard error page.
func Attribute ¶
Attribute returns a formatted string of the roles for the given scener name. For example if the name is "ben", write is "ben" and code is "bianca,ben" then the following would return:
"Writer and programmer attributions"
func BadRequestErr ¶
BadRequestErr is the handler for handling Bad Request Errors, caused by invalid user input or a malformed client requests.
func Brief ¶
Brief returns a human readable brief description of the combined platform and section. For example providing "windows" and "intro" would return:
"a Windows intro"
func BrokenTexts ¶ added in v1.8.0
BrokenTexts is the handler for the Broken texts page.
func ByteBytes ¶ added in v1.12.0
ByteBytes returns both the bytes and a human readable string of the bytes.
func ByteFileS ¶
ByteFileS returns a human readable string of the byte count with a named description.
func Categories ¶
Categories is the handler for the artifact categories page.
func Compression ¶ added in v1.8.19
Compression is the handler for information on historic compression tools page.
func Configurations ¶ added in v0.8.0
Configurations is the handler for the Configuration page.
func DatabaseErr ¶
DatabaseErr is the handler for database connection issues. A HTTP 503 Service Unavailable error is returned, to reflect the database connection issue but where the server is still running and usable for the client.
func Dependencies ¶ added in v1.14.1
Dependencies is the handler for the dependencies page.
func Describe ¶
Describe returns a human readable description of a release. Based on the platform, section, year and month.
For example providing "windows", "intro", 1990 and 1 would return:
"a Windows intro published in Jan, 1990."
func DownloadErr ¶
DownloadErr is the handler for missing download files and database ID errors.
func DownloadJsDos ¶ added in v0.9.0
func DownloadJsDos(sl *slog.Logger, c *echo.Context, db *sql.DB, extra, downl dir.Directory, ) error
DownloadJsDos is the handler for the js-dos emulator to download zip files that are then mounted as a C: hard drive in the emulation. js-dos only supports common zip compression methods, so this func first attempts to offer a re-archived zip file found in the extra directory, and only if that fails does it offer the original download file.
func EmptyTester ¶ added in v0.14.0
EmptyTester is a map of defaults for the app template tests.
func FileMissingErr ¶
FileMissingErr is the handler for missing download files and database ID errors.
func FixNumericSuffix ¶ added in v1.10.4
FixNumericSuffix handles the fixing of numeric suffixes in filenames.
func ForApproval ¶
ForApproval is the handler for the list and preview of the files page. The uri is the category or collection of files to display. The page is the page number of the results to display.
func ForbiddenErr ¶
ForbiddenErr is the handler for handling Forbidden Errors, caused by clients requesting pages that they do not have permission to access.
func GetDemozoo ¶ added in v0.10.0
func GetDemozoo( ctx context.Context, sl *slog.Logger, c *echo.Context, tx *sql.Tx, prodID int, unid string, download dir.Directory, ) error
GetDemozoo fetches the download link from Demozoo and saves it to the download directory. It then runs Update to modify the database record with various metadata from the file and Demozoo record API data.
This function is a wrapper for the remote.DemozooLink.Download method.
func GetDemozooParam ¶ added in v0.10.0
GetDemozooParam fetches the multiple download_links values from the Demozoo production API and attempts to download and save one of the linked files. If multiple links are found, the first link is used as they should all point to the same asset.
Both the Demozoo production ID param and the Defacto2 UUID query param values are required as params to fetch the production data and to save the file to the correct filename.
func GetPouet ¶ added in v0.10.0
func GetPouet( ctx context.Context, sl *slog.Logger, tx *sql.Tx, prodID int, unid string, download dir.Directory, ) error
GetPouet fetches the download link from Pouet and saves it to the download directory. It then runs Update to modify the database record with various metadata from the file and Pouet record API data.
This function is a wrapper for the remote.PouetLink.Download method.
func GoogleCallback ¶
func GoogleCallback(sl *slog.Logger, c *echo.Context, clientID string, maxAge int, accounts ...[48]byte, ) error
GoogleCallback is the handler for the Google OAuth2 callback page to verify the Google ID token.
func InternalErr ¶
InternalErr is the handler for handling Internal Server Errors, caused by programming bugs or crashes. The uri string is the part of the URL that caused the error. The optional error value is logged using the logger. If the echo context is nil then a user hostile, fallback error in raw text is returned.
func LastUpdated ¶
LastUpdated returns a string of the time since the given time t. The time is formatted as "Last updated 1 hour ago". If the time is not valid, an empty string is returned.
func LinkDownload ¶
LinkDownload creates a URL to link to the file download of the record. The id needs to be a valid integer. If the security alert is not empty, then a strike-through warning is returned. For example providing 1 and an empty security alert would return:
<a class="card-link" href="/d/9b1c6">Download</a>
func LinkHref ¶
LinkHref creates a URL path to link to the file page for the record. The id needs to be a valid integer.
func LinkInterview ¶
LinkInterview returns a SVG arrow icon to indicate an interview link hosted on an external website. If the href is not a valid URL then an empty string is returned.
func LinkPage ¶
LinkPage creates a URL anchor element to link to the file page for the record. The id needs to be a valid integer. The keyboard shortcut is "kboard" and is used to link to the file page with the keyboard focus. It can be left empty to not include the keyboard shortcut.
func LinkPreview ¶
LinkPreview creates a URL to link to the file record in-tab to use as a preview. The preview link will only show with compatible file types based on the platform and filename extension. The id needs to be a valid integer, the name is the filename and the platform is the platform of the release. Any invalid values will return an empty string.
For example providing 1, "readme.txt" and "text" would return:
<a class="card-link" href="/v/9b1c6">Preview</a>
But providing 1, "file.zip" and "text" would return an empty string.
func LinkPreviews ¶
LinkPreviews returns a slice of HTML formatted links for the artifact editor.
func LinkReleasers ¶ added in v0.10.0
LinkReleasers returns the groups associated with a release and a link to each group. The performant flag will use the group name instead of the much slower group slug formatter.
func LinkRelsPerf ¶ added in v1.5.13
LinkRelsPerf returns the groups associated with a release and a link to each group. It is a faster version of LinkRels and can be used with the templates that have large lists of group names.
func LinkRemote ¶
LinkRemote returns a HTML link with an embedded SVG icon to an external website. There are no checks for the href or name values other than they are not empty.
func LinkRemoteTip ¶ added in v1.7.0
LinkRemoteTip returns a HTML link with an embedded SVG icon to an external website. If the href or name values are empty then an error message is returned. If the tooltip is empty then LinkRemote is returned.
func LinkRunApp ¶ added in v0.10.0
LinkRunApp creates a URL anchor element to link to the artifact page to launch the js-dos emulator. The id needs to be a valid integer. For example providing 1 would return:
<a class="card-link" href="/f/9b1c6#runapp">Run app</a>
func LinkScnr ¶
LinkScnr returns a link to the named scener page. If the name is empty then an empty string is returned with no error. An example of providing "some scener" would return:
"/p/some-scener", nil
func LinkScnrs ¶ added in v1.2.0
LinkScnrs returns a list of links to the named scener pages. Multiple names can be provided as a comma separated string. If the name is empty then an empty string is returned with no error.
func LinkWiki ¶
LinkWiki returns a HTML link with an embedded SVG icon to the Defacto2 wiki on GitHub. The uri must be a valid URI path to a wiki page and the name must not be empty.
func LinkWikiTip ¶ added in v1.7.0
LinkWikiTip returns a HTML link with an embedded SVG icon to the Defacto2 wiki on GitHub. The uri must be a valid URI path to a wiki page and the name must not be empty. If the tooltip is empty then LinkWiki is returned.
func LockIn80Columns ¶ added in v1.12.1
LockIn80Columns returns true if the readme viewer should probably lock the width of text to a maximum of 80 columns, the traditional screen width on Microsoft DOS. However, with the popularization of Microsoft Windows and the use of notepad.exe, many newer texts break with this lock. But there are reasons to use it, as BBS era texts sometimes lack newlines.
In the future this could be expanded to count the number of newlines vs the size of the byte sec.
This func does the following checks:
- confirms the text isn't PCBoard
- confirms the text isn't newer than 1992
func LogoText ¶
LogoText returns a string of text padded with spaces to center it in the logo. If the string is empty then the default logo text is returned. The text is converted to uppercase and truncated if it is longer than the limit. An example of providing "abc" would return:
" : ·· ABC ·· ·"
func MagazineAZ ¶
MagazineAZ is the handler for the Magazine page ordered chronologically.
func MarkAll ¶ added in v1.11.0
MarkAll surrounds all occurrences of highlight in the string with <mark> elements.
func Month ¶
Month returns a short string of the month. If the month number is not a valid then an empty string is returned. For example providing 1 would return:
"Jan"
func MusicModule ¶ added in v1.10.4
MusicModule returns true if the magic string indicates a music file. Only tracker music is valid, MIDI, MP3, return false.
func PageErr ¶ added in v1.14.0
PageErr renders the files page error page for the Artifacts menu and categories. It provides different error messages to the standard error page.
func PlatformEdit ¶
PlatformEdit handles the post submission for the Platform selection field.
func PlatformTagInfo ¶
PlatformTagInfo handles the POST submission for the platform and tag info.
func PostFilename ¶
PostFilename is the handler for the Search for filenames form post page.
func PouetCache ¶
PouetCache parses the cached data for the Pouet production votes. If the cache is valid it is returned as JSON response. If the cache is invalid or corrupt an error will be returned and a API request should be made to Pouet.
func RecordRels ¶
RecordRels returns the groups associated with a release and joins them using a plus sign. For example providing "Group 1" and "Group 2" would return:
"Group 1 + Group 2"
func ReleaserErr ¶ added in v1.14.0
ReleaserErr renders the files error page for the Groups menu and invalid releasers.
func ReleasersAZ ¶ added in v1.14.0
ReleasersAZ is the handler for the releaser page ordered alphabetically.
func ReleasersYear ¶ added in v1.14.0
ReleasersYear is the handler for the releaser page ordered by year of the first release.
func RemovePCBoard ¶ added in v1.6.3
RemovePCBoard removes any PCBoard sequences from the byte slice.
func SafeBBS ¶ added in v1.6.3
SafeBBS returns a string as a template.HTML type to prevent HTML escaping in the template. If PCBoard or Renegard color codes are discovered, these will be converted into italic elements containing custom color classes.
Note: See [internal.filerecord.ForceSimpleText] for manual override options based on the SHA3 filehash value.
If any value is not a valid string then an empty string is returned.
func SafeDocument ¶ added in v1.11.2
SafeDocument returns a string as a template.HTML type to prevent HTML escaping in the template. To avoid false positives, this does not handle PCBoard or Renegard color codes.
If any value is not a valid string then an empty string is returned.
func SafeHTML ¶
SafeHTML returns a string as a template.HTML type to prevent HTML escaping in the template.
func SafeJS ¶
SafeJS returns a string as a template.JS type to prevent JavaScript escaping in the template.
func Safety ¶ added in v1.11.2
Safety returns true if SafeDocument should be used instead of SafeBBS.
func ScenerErr ¶ added in v1.14.0
ScenerErr renders the files error page for the People menu and invalid sceners.
func SearchDesc ¶
SearchDesc is the handler for the Search for file descriptions page.
func SearchFile ¶
SearchFile is the handler for the Search for files page.
func SearchReleaser ¶
SearchReleaser is the handler for the Releaser Search page.
func SortContent ¶
func StatusErr ¶
StatusErr is the handler for the HTTP status pages such as the 404 - not found. If the logger is nil then the error page is returned but no error is logged. If the echo context is nil then a user hostile, fallback error in raw text is returned.
func StripSup ¶ added in v1.10.0
StripSup removes <sup>...</sup> tags from a string and returns the cleaned string. The sup tags are returned separately if present, otherwise empty string.
Usage in templates: {{ $result := stripSup .Title }} returns a map with "text" and "sup" keys.
func SubTitle ¶
SubTitle returns a secondary element with the record title. If the section is "magazine" and the title is a number then it is prefixed with "Issue". For example providing "magazine" and 1 would return:
`<h3 class="card-subtitle mb-2 text-body-secondary fs-6">Issue 1</h3>`
Otherwise providing "text" and "Some Cool Stuff" would return:
`<h3 class="card-subtitle mb-2 text-body-secondary fs-6">Some Cool Stuff</h3>`
func TagBrief ¶
TagBrief returns a small summary of the tag. For example providing "interview" would return:
"Conversations with the personalities of The Scene"
func TagOption ¶
TagOption returns a HTML option tag with a "selected" attribute if the s matches the value. For example providing "interview" and "interview" would return:
`<option value="interview" selected>`
func TagWithOS ¶
TagWithOS returns a small summary of the tag with the operating system. If either the os or tags are unknown then a message is returned. For example providing "dos" and "magazine" would return:
"a Dos magazine"
func TrimSiteSuffix ¶
TrimSiteSuffix returns a string with the last 4 characters removed if they are " FTP" or " BBS". For example providing "My super FTP" would return:
"My super"
func TrimSpace ¶
TrimSpace returns a string with all leading and trailing whitespace removed. If the value is a null.String then the value is checked for validity.
func URLEncode ¶ added in v0.10.0
URLEncode returns a URL encoded string from the given string. This can be used to pass filenames as URL parameters.
func Website ¶
Website is the handler for the websites page. Open is the ID of the accordion section to open.
func WebsiteIcon ¶
WebsiteIcon returns a Bootstrap icon name for the given website url. For example if the url contains "archive.org" then the Bootstrap icon "bank2" svg icon is returned.
Types ¶
type Accordion ¶
type Accordion = []struct {
Name string // Name of the category.
Title string // Title tab for the category.
ID string // ID of the category.
Sites Sites // Sites are the websites shown in the category.
Open bool // Whether the category is displayed or closed.
}
Accordion is a collection of websites grouped by a category.
type Asset ¶
type Asset int
Asset is a relative path to a public facing CSS, JS or WASM file.
const ( Bootstrap5 Asset = iota // Bootstrap is the path to the minified Bootstrap 5.3 CSS file. Bootstrap5JS // BootstrapJS is the path to the minified Bootstrap 5.3 JS file. BootstrapIcons // BootstrapIcons is the path to the custom Bootstrap Icons SVG sprites file. ContentBinary // ContentBinary is the path to the minified ansi JS file. ContentText // ContentText is the path to the minified readme JS file. DosboxJS // DosboxJS is the js-dos v6 default variant compiled with emscripten. DosboxWasm // DosboxWasm is the js-dos v6 WASM binary file. ChiptunePlayer // ChiptunePlayer is the path to the minified chiptune player JS file. EditArtifact // EditArtifact is the path to the minified Artifact Editor JS file. EditAssets // EditAssets is the path to the minified Editor assets JS file. EditForApproval // EditForApproval is the path to the minified Editor for-approval JS file. Htmx // Htmx is the path to the minified htmx AJAX JS file. HtmxRespTargets // HtmxRespTargets is the path to the minified response targets extension file. IndexJS // IndexJS is the path to the minified JS file used by the index template. Jsdos6JS // Jsdos6JS is the path to the minified js-dos v6 JS file. Layout // Layout is the path to the minified layout CSS file. LayoutJS // LayoutJS is the path to the minified layout JS file. Pouet // Pouet is the path to the minified Pouet JS file. Uploader // Uploader is the path to the minified Uploader JS file. )
type Cache ¶
type Cache struct {
RecordCount int64 // The total number of file records in the database.
}
Cache contains database values that are used throughout the app or layouts, but do not change frequently enough to warrant a database query on every page load.
type Dirs ¶
type Dirs struct {
Download dir.Directory // path to the artifact download directory
Preview dir.Directory // path to the preview and screenshot directory
Thumbnail dir.Directory // path to the file thumbnail directory
Extra dir.Directory // path to the extra files directory
URI string // the URI of the File record
ID int64 // the database key of the File record
UUID string // the database uuid key of the File record
Platform string // the platform of the File record
Section string // the section of the File record
Magic string // the magic btyes of the File record
Maximum struct {
Items int // maximum archive items to display
Readme int64 // maximum size of text files to display
}
ReadOnly bool // disable editing features
}
Dirs contains the directories used by the artifact pages.
type FileSearch ¶
type FileSearch int
FileSearch is the type of search to perform.
const ( Filenames FileSearch = iota // Filenames is the search for filenames. Descriptions // Descriptions is the search for file descriptions and titles. )
type Font ¶
type Font int
Font is a relative path to a public facing font file.
const ( A1200 Font = iota // A1200 is the path to the Topaz Plus font file. A1200Woff // A1200Woff is the path to the Topaz Plus legacy WOFF format font file. A1200Tt // A1200Tt is the path to the Topaz Plus legacy TrueType format font file. MicroKnight MicroKnightTt CascadiaMono // CascadiaMono is the path to the Cascadia Mono font file. CascadiaMonoWoff // CascadiaMonoWoff is the path to the Cascadia Mono WOFF format font file. CascadiaMonoTt // CascadiaMonoTt is the path to the Cascadia Mono TrueType format font file. IBMVGA8x16Tt IBMVGA8x16 IBMEGA8x8Tt IBMEGA8x8 IBMCGATt IBMCGA IBMMDATt IBMMDA )
type FontPaths ¶ added in v1.14.0
FontPaths are a map of the public facing font files.
type Form ¶
type Form struct {
Target string `query:"target"` // Target is the name of the file to extract from the zip archive.
Value string `query:"value"` // Value of the form input field to change.
Platform string `query:"platform"` // Platform of the release.
Tag string `query:"tag"` // Tag of the release.
ID int `query:"id"` // ID is the auto incrementing database id of the record.
Year int16 `query:"year"` // Year of the release.
Month int16 `query:"month"` // Month of the release.
Day int16 `query:"day"` // Day of the release.
Online bool `query:"online"` // Online is the record online and public toggle.
Readme bool `query:"readme"` // Readme hides the readme text file from the artifact page.
}
Form is the form data for the editor.
type Group ¶
type Group struct {
Name string // Name is the name of the group.
Link string // Link is a local URL to the group.
Interviews Interviews // Interviews is a list of interviews with members of the group.
}
Group is a collection of interviews with members of a group.
type Groups ¶
type Groups []Group
Groups is a collection of group interviews.
func Interviewees ¶
func Interviewees() Groups
Interviewees returns a list of interviewees and their interviews. These are categorized by the group they were in at the time of the interview.
type Interviewee ¶
type Interviewee struct {
Scener string // Scener is the name of the person interviewed.
Content string // Content is a short description of the interview.
Link string // Link is the URL to the interview.
Year int // Year is the year the interview was conducted.
Month int // Month is the month the interview was conducted.
}
Interviewee is a person who was interviewed with a link to the interview.
type Links ¶
type Links []struct {
LinkTitle string // LinkTitle is the title of the Link.
SubTitle string // SubTitle is the title of the Link in a smaller font and in brackets.
Link string // Link is the URL to an article about the milestone or the product.
Forward string // Forward is an optional name of a group that is prefixed before the link to indicate a merger.
}
Links is a collection of Links.
type Milestone ¶
type Milestone struct {
Picture Picture // Picture is an image or screenshot for a milestone.
Prefix string // Prefix replacement for the month, such as 'Early', 'Mid' or 'Late'.
Title string // Title of the milestone should be the accomplishment.
Lead string // Lead paragraph, is optional and should usually be the product.
Content string // Content is the main body text (plain text).
ContentHTML string // ContentHTML is the HTML formatted version.
Link string // Link is the URL to an article about the milestone or the product.
LinkTitle string // LinkTitle is the title of the Link.
List Links // Links is a collection of links that are displayed as a HTML list.
Year int // Year of the milestone.
Month int // Month of the milestone.
Day int // Day of the milestone.
Highlight bool // Highlight is a flag to outline the milestone.
}
Milestone is an accomplishment for a year and optional month.
type Milestones ¶
type Milestones []Milestone
Milestones is a collection of Milestone.
func (Milestones) Count ¶ added in v1.14.0
func (m Milestones) Count() int
Count is the number of Milestones.
type Pagination ¶
type Pagination struct {
BaseURL string // BaseURL is the base URL for the pagination links.
CurrPage int // CurrPage is the current page number.
SumPages int // SumPages is the total number of pages.
PrevPage int // PrevPage is the previous page number.
NextPage int // NextPage is the next page number.
TwoBelow int // TwoBelow is the page number two below the current page.
TwoAfter int // TwoAfter is the page number two after the current page.
RangeStep int // RangeStep is the number of pages to skip in the pagination range.
}
type Paths ¶
Paths are a map of the public facing CSS, JS and WASM files.
type Picture ¶
type Picture struct {
Title string // Title of the picture.
Alt string // Alt is the alternative text for the picture.
Attribution string // Attribution is the name of the author of the picture.
License string // License is the license of the picture.
LicenseLink string // LicenseLink is the URL to the license of the picture.
Webp string // Webp is the filename of the WebP screenshot.
Png string // Png is the filename of the PNG screenshot.
Jpg string // Jpg is the filename of the JPG photo.
Avif string // Avif is the filename of the AVIF photo.
Webm string // Webm is the filename of the WebM multimedia container, such as a video.
}
Picture is an image or screenshot for a milestone.
type SRI ¶
type SRI struct {
Bootstrap5 string // Bootstrap CSS verification hash.
Bootstrap5JS string // Bootstrap JS verification hash.
BootstrapIcons string // Bootstrap Icons SVG verification hash.
CanvasAnsi string // ANSI JS verification hash.
CanvasReadme string // Readme JS verification hash.
ChiptunePlayer string // Chiptune Player JS verification hash.
EditArtifact string // Artifact Editor JS verification hash.
EditAssets string // Editor Assets JS verification hash.
EditForApproval string // Editor For Approval JS verification hash.
IndexJS string
Jsdos6JS string // js-dos v6 verification hash.
DosboxJS string // DOSBox Emscripten verification hash.
Layout string // Layout CSS verification hash.
LayoutJS string // Layout JS verification hash.
Pouet string // Pouet JS verification hash.
Uploader string // Uploader JS verification hash.
Htmx string // htmx JS verification hash.
HtmxRespTargets string // htmx response targets extension JS verification hash.
}
SRI are the Sub-Resource Integrity hashes for the layout.
type Site ¶
type Site struct {
Title string // Title of the website.
URL string // URL of the website, including the HTTP or HTTPS protocol.
Info string // A short description of the website.
}
Site is a website.
type WebApp ¶ added in v1.14.0
type WebApp struct {
Public fs.FS // Public facing files.
View fs.FS // Views are Go templates.
Subresource SRI // SRI are the Subresource Integrity hashes for the layout.
Version string // Version is the current version of the app.
Brand []byte // Brand contains to the Defacto2 ASCII logo.
Environment config.Config // Environment configurations from the host system environment.
RecordCount int64 // RecordCount is the total number of records in the database.
}
WebApp is the configuration and status of the web application templates.
func (*WebApp) FuncClosure ¶ added in v1.14.0
FuncClosure returns a map of closures that return converted type or modified strings.
func (*WebApp) FuncElem ¶ added in v1.14.0
FuncElem returns a map of functions that return HTML elements.
func (*WebApp) FuncStatic ¶ added in v1.14.0
func (*WebApp) Funcs ¶ added in v1.14.0
Funcs are a collection of mapped functions that can be used in a template.
The "fmtURI" function is not performant for large lists, instead use "fmtRangeURI" in TemplateStrings().