app

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2024 License: GPL-3.0 Imports: 66 Imported by: 0

Documentation

Overview

Package app handles the routes and views for the Defacto2 website.

Index

Constants

View Source
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 TO is the center of the text.
	Welcome = `:                    ` +
		`·· WELCOME TO DEFACTO2 ··` +
		`                    ·`
)

Variables

View Source
var (
	ErrCategory = errors.New("unknown artifacts categories")
	ErrClaims   = errors.New("no sub id in the claims playload")
	ErrCode     = errors.New("the http status code is not valid")
	ErrCxt      = errors.New("the server could not create a context")
	ErrData     = errors.New("cache data is invalid or corrupt")
	ErrDB       = errors.New("database connection is nil")
	ErrExtract  = errors.New("unknown extractor value")
	ErrLinkID   = errors.New("the id value cannot be a negative number")
	ErrLinkType = errors.New("the id value is an invalid type")
	ErrMisMatch = errors.New("token mismatch")
	ErrSession  = errors.New("no sub id in session")
	ErrTarget   = errors.New("target not found")
	ErrTmpl     = errors.New("the server could not render the html template for this page")
	ErrUser     = errors.New("unknown user")
	ErrVal      = errors.New("value is empty")
	ErrZap      = errors.New("the zap logger cannot be nil")
)
View Source
var Caching = Cache{} //nolint:gochecknoglobals

Caching are values that are used throughout the app or layouts.

View Source
var ErrExist = errors.New("file already exists")

Functions

func Artifact404

func Artifact404(c echo.Context, id string) error

Artifact404 renders the error page for the artifact links.

func Artifacts

func Artifacts(c echo.Context, uri, page string) error

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 Artifacts404

func Artifacts404(c echo.Context, uri string) error

Artifacts404 renders the files error page for the Artifacts menu and categories. It provides different error messages to the standard error page.

func Artist

func Artist(c echo.Context) error

Artist is the handler for the Artist sceners page.

func Attribute

func Attribute(write, code, art, music, name string) string

Attribute returns a formatted string of the roles for the given scener name.

func BBS

func BBS(c echo.Context) error

BBS is the handler for the BBS page ordered by the most files.

func BBSAZ

func BBSAZ(c echo.Context) error

BBSAZ is the handler for the BBS page ordered alphabetically.

func BBSYear

func BBSYear(c echo.Context) error

BBSYear is the handler for the BBS page ordered by the year.

func BadRequestErr

func BadRequestErr(c echo.Context, uri string, err error) error

BadRequestErr is the handler for handling Bad Request Errors, caused by invalid user input or a malformed client requests.

func Brief

func Brief(platform, section any) string

Brief returns a human readable brief description of a release. Based on the platform, section, year and month.

func ByteFile

func ByteFile(cnt, bytes any) template.HTML

ByteFile returns a human readable string of the file count and bytes.

func ByteFileS

func ByteFileS(name string, count, bytes any) template.HTML

ByteFileS returns a human readable string of the byte count with a named description.

func Categories

func Categories(c echo.Context, logger *zap.SugaredLogger, stats bool) error

Categories is the handler for the artifact categories page.

func Checksum

func Checksum(c echo.Context, id string) error

Checksum is the handler for the Checksum file record page.

func Coder

func Coder(c echo.Context) error

Code is the handler for the Coder sceners page.

func DatabaseErr

func DatabaseErr(c echo.Context, uri string, err error) error

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 Day

func Day(d any) string

Day returns a string of the day number from the day d number between 1 and 31.

func Deletions

func Deletions(c echo.Context, page string) error
func DemozooGetLink(filename, filesize, demozoo, unid any) template.HTML

DemozooGetLink returns a HTML link to the Demozoo download links.

func Describe

func Describe(platform, section, year, month any) template.HTML

Describe returns a human readable description of a release. Based on the platform, section, year and month.

func Download

func Download(c echo.Context, logger *zap.SugaredLogger, path string) error

Download is the handler for the Download file record page.

func DownloadB

func DownloadB(i any) template.HTML

DownloadB returns a human readable string of the file size.

func DownloadErr

func DownloadErr(c echo.Context, uri string, err error) error

DownloadErr is the handler for missing download files and database ID errors.

func FTP

func FTP(c echo.Context) error

FTP is the handler for the FTP page.

func FileMissingErr

func FileMissingErr(c echo.Context, uri string, err error) error

FileMissingErr is the handler for missing download files and database ID errors.

func ForApproval

func ForApproval(c echo.Context, page string) error

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

func ForbiddenErr(c echo.Context, uri string, err error) error

ForbiddenErr is the handler for handling Forbidden Errors, caused by clients requesting pages that they do not have permission to access.

func GetDemozooLink(c echo.Context, downloadDir string) error

GetDemozooLink 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 GlobTo

func GlobTo(name string) string

GlobTo returns the path to the template file.

func GoogleCallback

func GoogleCallback(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 History

func History(c echo.Context) error

History is the handler for the History page.

func Index

func Index(c echo.Context) error

Index is the handler for the Home page.

func Inline

func Inline(c echo.Context, logger *zap.SugaredLogger, path string) error

Inline is the handler for the Download file record page.

func InternalErr

func InternalErr(c echo.Context, uri string, err error) error

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 zap sugared logger. If the echo context is nil then a user hostile, fallback error in raw text is returned.

func Interview

func Interview(c echo.Context) error

Interview is the handler for the People Interviews page.

func LastUpdated

func LastUpdated(t any) string

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

func LinkDownload(id any, uri string) template.HTML

LinkDownload creates a URL to link to the file download of the record.

func LinkHref

func LinkHref(id any) (string, error)

LinkHref creates a URL path to link to the file page for the record.

func LinkInterview

func LinkInterview(href string) template.HTML

LinkInterview returns a SVG arrow icon to indicate an interview link hosted on an external website.

func LinkPage

func LinkPage(id any) template.HTML

LinkPage creates a URL anchor element to link to the file page for the record.

func LinkPreview

func LinkPreview(id any, name, platform string) template.HTML

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 their extension.

func LinkPreviewHref

func LinkPreviewHref(id any, name, platform string) string

LinkPreviewHref creates a URL path to link to the file record in tab, to use as a preview.

A list of supported file types: https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types

func LinkPreviewTip

func LinkPreviewTip(name, platform string) string

LinkPreviewTip returns a tooltip to describe the preview link.

func LinkPreviews

func LinkPreviews(youtube, demozoo, pouet, colors16, github, rels, sites string) []string

LinkPreviews returns a slice of HTML formatted links for the artifact editor.

func LinkRelFast

func LinkRelFast(a, b any) template.HTML

LinkRelFast returns the groups associated with a release and a link to each group. It is a faster version of LinkRelrs and should be used with the templates that have large lists of group names.

func LinkRelations

func LinkRelations(val string) template.HTML

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 LinkRelrs

func LinkRelrs(performant bool, a, b any) template.HTML

LinkRelrs 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 LinkRels

func LinkRels(a, b any) template.HTML

LinkRelrs returns the groups associated with a release and a link to each group.

func LinkRemote

func LinkRemote(href, name string) template.HTML

LinkRemote returns a HTML link with an embedded SVG icon to an external website.

func LinkSVG

func LinkSVG() template.HTML

LinkSVG returns an right-arrow SVG icon.

func LinkSamples

func LinkSamples(youtube, demozoo, pouet, colors16, github, rels, sites string) string

LinkSample returns a collection of HTML formatted links for the artifact editor.

func LinkScnr

func LinkScnr(name string) (string, error)

LinkScnr returns a link to the named scener page.

func LinkSites

func LinkSites(val string) template.HTML

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 LinkWiki

func LinkWiki(uri, name string) template.HTML

LinkWiki returns a HTML link with an embedded SVG icon to the Defacto2 wiki on GitHub.

func LogoText

func LogoText(s string) string

LogoText returns a string of text padded with spaces to center it in the logo.

func Magazine

func Magazine(c echo.Context) error

Magazine is the handler for the Magazine page.

func MagazineAZ

func MagazineAZ(c echo.Context) error

MagazineAZ is the handler for the Magazine page ordered chronologically.

func MimeMagic

func MimeMagic(s string) string

MimeMagic overrides some of the default linux file (magic) results. This is intended to be used to provide a more human readable description.

func Mod

func Mod(i any, max int) bool

Mod returns true if the given integer is a multiple of the given max integer.

func Mod3

func Mod3(i any) bool

Mod3 returns true if the given integer is a multiple of 3.

func Month

func Month(m any) string

Month returns a string of the month name from the month m number between 1 and 12.

func Musician

func Musician(c echo.Context) error

Musician is the handler for the Musiciansceners page.

func OptionsAnsiLove

func OptionsAnsiLove(zipContent string) template.HTML

OptionsAnsiLove returns a list of possible text or ANSI files in the archive content. In general, all file extensions are valid except for well known archives and executables. Due to the CP/M and DOS platform, 8.3 filename limitations, the file extension is not always reliable.

func OptionsPreview

func OptionsPreview(zipContent string) template.HTML

OptionsPreview returns a list of preview images or textfiles in the archive content.

func OptionsReadme

func OptionsReadme(zipContent string) template.HTML

OptionsReadme returns a list of readme and known textfiles in the archive content.

func Page404

func Page404(c echo.Context, uri, page string) error

Page404 renders the files page error page for the Artifacts menu and categories. It provides different error messages to the standard error page.

func PlatformEdit

func PlatformEdit(c echo.Context) error

PlatformEdit handles the post submission for the Platform selection field.

func PlatformTagInfo

func PlatformTagInfo(c echo.Context) error

PlatformTagInfo handles the POST submission for the platform and tag info.

func PostDesc

func PostDesc(c echo.Context, input string) error

PostDesc is the handler for the Search for file descriptions form post page.

func PostFilename

func PostFilename(c echo.Context) error

PostFilename is the handler for the Search for filenames form post page.

func PostIntro

func PostIntro(c echo.Context) error

PostIntro handles the POST request for the intro upload form.

func PostName

func PostName(c echo.Context, mode FileSearch) error

PostName is the handler for the Search for filenames form post page.

func PouetCache

func PouetCache(c echo.Context, data string) error

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 Prefix

func Prefix(s string) string

Prefix returns a string prefixed with a space.

func ProdPouet

func ProdPouet(c echo.Context, id string) error

ProdPouet is the handler for the Pouet prod JSON page.

func ProdZoo

func ProdZoo(c echo.Context, id string) error

ProdZoo is the handler for the Demozoo production JSON page.

func Reader

func Reader(c echo.Context) error

Interview is the handler for the People Interviews page.

func ReadmeDel

func ReadmeDel(c echo.Context, downloadDir string) error

ReadmeDel handles the post submission for the Delete readme asset button.

func ReadmePost

func ReadmePost(c echo.Context, logger *zap.SugaredLogger, downloadDir string) error

ReadmePost handles the post submission for the Readme in archive.

func ReadmeSuggest

func ReadmeSuggest(filename, group string, content ...string) string

ReadmeSuggest returns a suggested readme file name for the record. It prioritizes the filename and group name with a priority extension, such as ".nfo", ".txt", etc. If no priority extension is found, it will return the first textfile in the content list.

The filename should be the name of the file archive artifact. The group should be a name or common abbreviation of the group that released the artifact. The content should be a list of files contained in the artifact.

This is a port of the CFML function, variables.findTextfile found in File.cfc.

func ReadmeToggle

func ReadmeToggle(c echo.Context) error

ReadmeToggle handles the post submission for the Hide readme from view toggle.

func Readmes

func Readmes(content ...string) []string

Readmes returns a list of readme text files found in the file archive.

func RecordReleasers

func RecordReleasers(a, b any) [2]string

func RecordRels

func RecordRels(a, b any) string

RecordRels returns the groups associated with a release and joins them with a plus sign.

func RecordToggle

func RecordToggle(c echo.Context, state bool) error

RecordToggle handles the post submission for the File artifact is online and public toggle.

func Records

func Records(ctx context.Context, db *sql.DB, uri string, page, limit int) (models.FileSlice, error)

Records returns the records for the artifacts category URI. Note that the record statistics and counts get cached.

func RecordsSub

func RecordsSub(uri string) string

RecordsSub returns the records for the artifacts category URI.

func Releaser

func Releaser(c echo.Context) error

Releaser is the handler for the releaser page ordered by the most files.

func Releaser404

func Releaser404(c echo.Context, id string) error

Releaser404 renders the files error page for the Groups menu and invalid releasers.

func ReleaserAZ

func ReleaserAZ(c echo.Context) error

ReleaserAZ is the handler for the releaser page ordered alphabetically.

func ReleaserEdit

func ReleaserEdit(c echo.Context) error

ReleaserEdit handles the post submission for the Platform selection field.

func ReleaserYear

func ReleaserYear(c echo.Context) error

ReleaserYear is the handler for the releaser page ordered by year of the first release.

func Releasers

func Releasers(c echo.Context, uri string) error

Releasers is the handler for the list and preview of files credited to a releaser.

func SafeHTML

func SafeHTML(s string) template.HTML

SafeHTML returns a string as a template.HTML type. This is intended to be used to prevent HTML escaping.

func SafeJS

func SafeJS(s string) template.JS

SafeJS returns a string as a template.JS type. This is intended to be used to prevent JS escaping.

func Scener

func Scener(c echo.Context) error

Scener is the handler for the page to list all the sceners.

func Scener404

func Scener404(c echo.Context, id string) error

Scener404 renders the files error page for the People menu and invalid sceners.

func Sceners

func Sceners(c echo.Context, uri string) error

Sceners is the handler for the list and preview of files credited to a scener.

func SearchDesc

func SearchDesc(c echo.Context) error

SearchDesc is the handler for the Search for file descriptions page.

func SearchFile

func SearchFile(c echo.Context) error

SearchFile is the handler for the Search for files page.

func SearchReleaser

func SearchReleaser(c echo.Context) error

SearchReleaser is the handler for the Releaser Search page.

func SignOut

func SignOut(c echo.Context) error

SignOut is the handler for the Sign out of Defacto2 page.

func SignedOut

func SignedOut(c echo.Context) error

SignedOut is the handler to sign out and remove the current session.

func Signin

func Signin(c echo.Context, clientID, nonce string) error

Signin is the handler for the Sign in session page.

func SortContent

func SortContent(content ...string) []string

SortContent sorts the content list by the number of slashes in each string. It prioritizes strings with fewer slashes (i.e., closer to the root). If the number of slashes is the same, it sorts alphabetically.

func StatusErr

func StatusErr(c echo.Context, code int, uri string) error

StatusErr is the handler for the HTTP status pages such as the 404 - not found. If the zap 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 SubTitle

func SubTitle(section null.String, s any) template.HTML

SubTitle returns a secondary element with the record title.

func TagBrief

func TagBrief(tag string) string

TagBrief returns a small summary of the tag.

func TagEdit

func TagEdit(c echo.Context) error

TagEdit handles the post submission for the Tag selection field.

func TagInfo

func TagInfo(c echo.Context) error

TagInfo handles the POST submission for the platform and tag info.

func TagOption

func TagOption(selected, value any) template.HTML

TagOption returns a HTML option tag with the selected attribute if the selected matches the value.

func TagWithOS

func TagWithOS(os, tag string) string

TagWithOS returns a small summary of the tag with the operating system.

func Thanks

func Thanks(c echo.Context) error

Thanks is the handler for the Thanks page.

func TheScene

func TheScene(c echo.Context) error

TheScene is the handler for the The Scene page.

func TitleEdit

func TitleEdit(c echo.Context) error

TitleEdit handles the post submission for the Delete readme asset button.

func TrimSiteSuffix

func TrimSiteSuffix(s string) string

TrimSiteSuffix returns a string with the last 4 characters removed if they are " FTP" or " BBS".

func TrimSpace

func TrimSpace(a any) string

TrimSpace returns a string with all leading and trailing whitespace removed.

func Unwanted

func Unwanted(c echo.Context, page string) error

func Updated

func Updated(t any, s string) string

Updated 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 Valid

func Valid(path string) bool

Valid returns true if path is a valid URI for the list of files.

func VotePouet

func VotePouet(c echo.Context, logger *zap.SugaredLogger, id string) error

VotePouet is the handler for the Pouet production votes JSON page.

func Website

func Website(c echo.Context, open string) error

Website is the handler for the websites page. Open is the ID of the accordion section to open.

func WebsiteIcon

func WebsiteIcon(url string) template.HTML

websiteIcon returns a Bootstrap icon name for the given website url.

func Writer

func Writer(c echo.Context) error

Writer is the handler for the Writer page.

func YMDEdit

func YMDEdit(c echo.Context) error

YMDEdit handles the post submission for the Year, Month, Day selection fields.

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.

func List

func List() Accordion

List 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 (
	ArtifactEditor  Asset = iota // ArtifactEditor is the path to the minified Artifact Editor JS file.
	Bootstrap5                   // 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.
	DosboxJS                     // DosboxJS is the js-dos v6 default variant compiled with emscripten.
	DosboxWasm                   // DosboxWasm is the js-dos v6 WASM binary file.
	EditAssets                   // EditAssets is the path to the minified Editor assets JS file.
	EditArchive                  // EditArchive is the path to the minified Editor archive JS file.
	EditForApproval              // EditForApproval is the path to the minified Editor for-approval JS file.
	FA5Pro                       // FA5Pro is the path to the minified Font Awesome Pro v5 JS file.
	Htmx                         // Htmx is the path to the minified htmx AJAX JS file.
	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.
	Readme                       // Readme is the path to the minified Readme JS file.
	Uploader                     // Uploader is the path to the minified Uploader JS file.
)

type Cache

type Cache struct {
	RecordCount int // The total number of file records in the database.
}

Cache contains database values that are used throughout the app or layouts.

func (*Cache) Records

func (c *Cache) Records(i int)

Records caches the database record count.

type DemozooLink struct {
	UUID      string `json:"uuid"`       // UUID is the file production UUID.
	Filename  string `json:"filename"`   // Filename is the file name of the download.
	FileType  string `json:"file_type"`  // Type is the file type.
	FileHash  string `json:"file_hash"`  // Hash is the file integrity hash.
	Content   string `json:"content"`    // Content is the file archive content.
	Readme    string `json:"readme"`     // Readme is the file readme, text or NFO file.
	LinkURL   string `json:"link_url"`   // LinkURL is the download file link used to fetch the file.
	LinkClass string `json:"link_class"` // LinkClass is the download link class provided by Demozoo.
	Error     string `json:"error"`      // Error is the error message if the download or record update failed.
	Github    string `json:"github_repo"`
	YouTube   string `json:"youtube_video"`
	ID        int    `json:"id"`        // ID is the Demozoo production ID.
	FileSize  int    `json:"file_size"` // Size is the file size in bytes.
	Pouet     int    `json:"pouet_prod"`
	Success   bool   `json:"success"` // Success is the success status of the download and record update.
}

DemozooLink is the response from the task of GetDemozooFile.

func (*DemozooLink) ArchiveContent

func (got *DemozooLink) ArchiveContent(c echo.Context, path string) error

func (*DemozooLink) Download

func (got *DemozooLink) Download(c echo.Context, downloadDir string) error

func (*DemozooLink) Stat

func (got *DemozooLink) Stat(c echo.Context, downloadDir string) error

func (DemozooLink) Update

func (got DemozooLink) Update(c echo.Context) error

type Dirs

type Dirs struct {
	Download  string // path to the artifact download directory
	Preview   string // path to the preview and screenshot directory
	Thumbnail string // path to the file thumbnail directory
	URI       string // the URI of the file record
}

Dirs contains the directories used by the artifact pages.

func (Dirs) AnsiLovePost

func (dir Dirs) AnsiLovePost(c echo.Context, logger *zap.SugaredLogger) error

AnsiLovePost handles the post submission for the Preview from text in archive.

func (Dirs) Artifact

func (dir Dirs) Artifact(c echo.Context, logger *zap.SugaredLogger, readonly bool) error

Artifact is the handler for the of the file record.

func (Dirs) PreviewDel

func (dir Dirs) PreviewDel(c echo.Context) error

PreviewDel handles the post submission for the Delete complementary images button.

func (Dirs) PreviewPost

func (dir Dirs) PreviewPost(c echo.Context, logger *zap.SugaredLogger) error

PreviewPost handles the post submission for the Preview from image in archive.

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 (
	VGA8         Font = iota // VGA8 is the path to the IBM VGA 8px font file.
	VGA8Woff                 // VGA8Woff is the path to the IBM VGA 8px legacy WOFF format font file.
	VGA8TT                   // VGA8TT is the path to the IBM VGA 8px legacy TrueType format font file.
	A1200                    // 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.
	OpenSans                 // OpenSans is the path to the Open Sans font file.
	OpenSansWoff             // OpenSansWoff is the path to the Open Sans WOFF format font file.
	OpenSansTT               // OpenSansTT is the path to the Open Sans TrueType format font file.
)

type Fonts

type Fonts map[Font]string

Fonts are a map of the public facing font files.

func FontNames

func FontNames() Fonts

Names returns the absolute path of the public facing font files relative to the embed.FS root.

func FontRefs

func FontRefs() Fonts

FontRefs returns the relative path of the public facing font files. The strings are intended for href attributes in HTML link elements and the src attribute in HTML script elements.

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 is the value of the form input field to change.
	Platform string `query:"platform"` // Platform is the platform of the release.
	Tag      string `query:"tag"`      // Tag is the tag of the release.
	ID       int    `query:"id"`       // ID is the auto incrementing database id of the record.
	Year     int16  `query:"year"`     // Year is the year of the release.
	Month    int16  `query:"month"`    // Month is the month of the release.
	Day      int16  `query:"day"`      // Day is the day of the release.
	Online   bool   `query:"online"`   // Online is the record online and public toggle.
	Readme   bool   `query:"readme"`   // Readme hides the readme textfile 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 Interviews

type Interviews []Interviewee

Interviews is a collection of Interviewee.

type Links []struct {
	LinkTitle string // LinkTitle is the title of the Link.
	SubTitle  string // SublTitle 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 of the milestone and can be HTML.
	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 Collection

func Collection() Milestones

Collection of Milestones from the 1970s onwards.

func (Milestones) Len

func (m Milestones) Len() int

Len 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

type Paths map[Asset]string

Paths are a map of the public facing CSS, JS and WASM files.

func Hrefs

func Hrefs() Paths

Hrefs returns the relative path of the public facing CSS, JS and WASM files. The strings are intended for href attributes in HTML link elements and the src attribute in HTML script elements.

func Names

func Names() Paths

Names returns the absolute path of the public facing CSS, JS and WASM files relative to the embed.FS root.

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.
}

Picture is an image or screenshot for a milestone.

type SRI

type SRI struct {
	ArtifactEditor  string // Artifact Editor JS verification hash.
	Bootstrap5      string // Bootstrap CSS verification hash.
	Bootstrap5JS    string // Bootstrap JS verification hash.
	EditAssets      string // Editor Assets JS verification hash.
	EditArchive     string // Editor Archive JS verification hash.
	EditForApproval string // Editor For Approval JS verification hash.
	FA5Pro          string // Font Awesome Pro v5 verification hash.
	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.
	Readme          string // Readme JS verification hash.
	Uploader        string // Uploader JS verification hash.
	Htmx            string // htmx JS verification hash.
}

SRI are the Subresource Integrity hashes for the layout.

func (*SRI) Verify

func (s *SRI) Verify(fs embed.FS) error

Verify checks the integrity of the embedded CSS and JS files. These are required for Subresource Integrity (SRI) verification in modern browsers.

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 Sites

type Sites = []Site

Sites is a collection of websites.

type Stats

type Stats struct {
	IntroW    model.IntroWindows
	Record    model.Artifacts
	Ansi      model.Ansi
	AnsiBBS   model.AnsiBBS
	BBS       model.BBS
	BBSText   model.BBSText
	BBStro    model.BBStro
	Demoscene model.Demoscene
	MsDos     model.MsDos
	Intro     model.Intro
	IntroD    model.IntroMsDos
	Installer model.Installer
	Java      model.Java
	Linux     model.Linux
	Magazine  model.Magazine
	Macos     model.Macos
	Nfo       model.Nfo
	NfoTool   model.NfoTool
	Proof     model.Proof
	Script    model.Script
	Text      model.Text
	Windows   model.Windows
}

Stats are the database statistics for the artifacts categories.

func Statistics

func Statistics() Stats

Statistics returns the empty database statistics for the artifacts categories.

func (*Stats) Get

func (s *Stats) Get(ctx context.Context, db *sql.DB) error

Get and store the database statistics for the artifacts categories.

type Templ

type Templ struct {
	Brand       []byte        // Brand contains to the Defacto2 ASCII logo.
	Environment config.Config // Environment configurations from the host system environment.
	Public      embed.FS      // Public facing files.
	View        embed.FS      // Views are Go templates.
	RecordCount int           // RecordCount is the total number of records in the database.
	Subresource SRI           // SRI are the Subresource Integrity hashes for the layout.
	Version     string        // Version is the current version of the app.
}

Templ is the configuration and status of the web application templates.

func (Templ) ImageSample

func (web Templ) ImageSample(unid string) template.HTML

ImageSample returns a HTML image tag for the given unid.

func (Templ) Screenshot

func (web Templ) Screenshot(unid, desc string) template.HTML

Screenshot returns a picture elment with screenshots for the given unid. 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. Supported formats are webp, png, jpg and avif.

func (Templ) TemplateClosures

func (web Templ) TemplateClosures() template.FuncMap

TemplateClosures returns a map of closures that return converted type or modified strings.

func (Templ) TemplateElms

func (web Templ) TemplateElms() template.FuncMap

TemplateElms returns a map of functions that return HTML elements.

func (Templ) TemplateFuncMap

func (web Templ) TemplateFuncMap() template.FuncMap

TemplateFuncMap returns a map of all the template functions.

func (Templ) TemplateFuncs

func (web Templ) TemplateFuncs() template.FuncMap

TemplateFuncs 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().

func (*Templ) Templates

func (web *Templ) Templates() (map[string]*template.Template, error)

Templates returns a map of the templates used by the route.

func (Templ) Thumb

func (web Templ) Thumb(unid, desc string, bottom bool) template.HTML

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.

func (Templ) ThumbSample

func (web Templ) ThumbSample(unid string) template.HTML

ThumbSample returns a HTML image tag for the given unid.

type URI

type URI int

URI is a type for the files URI path.

func Match

func Match(path string) URI

Match path to a URI type or return -1 if not found.

func (URI) String

func (u URI) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL