filerecord

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Overview

Package filerecord provides functions for the file model which is an artifact record.

Index

Constants

View Source
const (
	YYYYMMDD = "2006-Jan-02"
)

Variables

This section is empty.

Functions

func AlertURL

func AlertURL(art *models.File) string

AlertURL returns the VirusTotal URL for the security alert for the file record. This will normally return an empty string unless the file has a security alert.

func AttrArtist

func AttrArtist(art *models.File) string

AttrArtist returns the attributed artist names for the file record.

func AttrMusic

func AttrMusic(art *models.File) string

AttrMusic returns the attributed musician names for the file record.

func AttrProg

func AttrProg(art *models.File) string

AttrProg returns the attributed programmer names for the file record.

func AttrWriter

func AttrWriter(art *models.File) string

AttrWriter returns the attributed text writer names for the file record.

func Basename

func Basename(art *models.File) string

Basename returns the name of the file given to the artifact file record.

func Checksum

func Checksum(art *models.File) string

Checksum returns the strong SHA386 hash checksum for the file record.

func Comment

func Comment(art *models.File) string

Comment returns the optional comment for the file record.

func Date

func Date(art *models.File) template.HTML

Date returns a formatted date string for the published date for the artifact.

func Dates

func Dates(art *models.File) (int16, int16, int16)

Dates returns the year, month and day for the published date for the artifact.

func Description

func Description(art *models.File) string

Description returns a human readable description for the artifact. This includes the title, the releaser and the year of release.

func DownloadID

func DownloadID(art *models.File) string

DownloadID returns the obfuscated ID for the file record. This is used to create a unique download link for the file based on its ID database key.

func EmbedReadme

func EmbedReadme(art *models.File) bool

EmbedReadme returns false if a text file artifact should not be displayed in the page as a readme or textfile. This includes artifacts that are set as documents such a HTML, PDF or BBS RIP images.

func ExtraZip

func ExtraZip(art *models.File, extraDir string) bool

ExtraZip returns true if the file record has repacked zip file offering in the extra directory. This repackage gets used by the DOS emulator and also offered as an secondary download when the original artifact file uses a defunct compression method or format.

The original artifact must always be preserved and offered as the primary download. But the extra zip file is a convenience for users who may not have the tools to decompress the original.

func FileEntry

func FileEntry(art *models.File) string

FileEntry returns the created and updated date and time for the file record using the "time ago" format.

For example, "Created 2 days ago" or "Updated 1 month ago".

func FirstHeader

func FirstHeader(art *models.File) string

FirstHeader returns the title of the file, unless the artifact is marked as a magazine issue, in which case it returns the issue number.

func Idenfication16C

func Idenfication16C(art *models.File) string

Idenfication16C returns the 16 color identification for the file record. This is usually a partial URL to the 16 color website.

func IdenficationDZ

func IdenficationDZ(art *models.File) string

IdenficationDZ returns the Demozoo production ID for the file record.

func IdenficationGitHub

func IdenficationGitHub(art *models.File) string

IdenficationGitHub returns the GitHub repository for the file record.

func IdenficationPouet

func IdenficationPouet(art *models.File) string

IdenficationPouet returns the Pouet production ID for the file record.

func IdenficationYT

func IdenficationYT(art *models.File) string

IdenficationYT returns the YouTube video watch ID for the file record.

func JsdosArchive

func JsdosArchive(art *models.File) bool

JsdosArchive returns true if the file record is a known MS-DOS archive file.

func JsdosBroken

func JsdosBroken(art *models.File) bool

JsdosBroken returns true if the MsDos artifact is known to be incompatible with the js-dos emulator.

func JsdosCPU

func JsdosCPU(art *models.File) string

JsdosCPU returns the js-dos CPU type for the file record.

func JsdosMachine

func JsdosMachine(art *models.File) string

JsdosMachine returns the js-dos machine type for the file record. This is usually the graphic card type but can also be a unique machine type such as "tandy" that is range of hardware.

func JsdosMemory

func JsdosMemory(art *models.File) (bool, bool, bool)

JsdosMemory returns true if js-dos should disable the XMS, EMS and UMB memory options.

func JsdosRun

func JsdosRun(art *models.File) string

JsdosRun returns the program name or sequence of commands to launch in the js-dos emulator.

func JsdosSound

func JsdosSound(art *models.File) string

JsdosSound returns the js-dos sound card or built-in audio for the file record.

func JsdosUsage

func JsdosUsage(filename, platform string) bool

JsdosUsage returns true if the js-dos emulator should be used with the filename.

func JsdosUse

func JsdosUse(art *models.File) bool

jsdosUse returns true if the file record is a known, MS-DOS executable. The supported file types are .zip archives and .exe, .com. binaries. Script files such as .bat and .cmd are not supported.

func JsdosUtilities

func JsdosUtilities(art *models.File) bool

JsdosUtilities returns true the js-dos emulator should also load the utilities archive as an internal hard disk drive.

func LastModification

func LastModification(art *models.File) string

LastModification returns the last modified date and time for the file record.

func LastModificationAgo

func LastModificationAgo(art *models.File) string

LastModificationAgo returns the last modified date in a human readable format.

func LastModificationDate

func LastModificationDate(art *models.File) string

LastModificationDate returns the last modified date for the file record.

func LastModifications

func LastModifications(art *models.File) (int, int, int)

LastModifications returns the year, month and day for the last modified date for the file record.

func LegacyString

func LegacyString(s string) string

LegacyString returns a string that is converted to UTF-8 if it is not already. Intended for filenames in archives that may have been encoded using a legacy charset, such as ISO-8859-1 (Commodore Amiga) or Windows-1252 (Windows 9x) and using non-ASCII characters.

func LinkPreview

func LinkPreview(art *models.File) string

LinkPreview returns a URL path to link to the file record in tab, to use as a preview. A preview link is only available for certain file types such as images, text, documents, and renders the whole item in its own browser tab without any HTML or CSS from the website.

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(art *models.File) string

LinkPreviewTip returns a tooltip for the link preview.

func LinkSVG

func LinkSVG() template.HTML

LinkSVG returns an right-arrow SVG icon.

func ListContent

func ListContent(art *models.File, src string) template.HTML

ListContent returns a list of the files contained in the archive file.

func Magic

func Magic(art *models.File) string

Magic returns the magic number or guessed file type for the file record.

func Readme

func Readme(r *models.File) string

Readme returns a guessed or suggested readme file name to use for the record.

func ReadmeNone

func ReadmeNone(art *models.File) bool

ReadmeNone returns true if the file record should not display the text file content in the artifact page.

func RecordIsNew

func RecordIsNew(art *models.File) bool

RecordIsNew returns true if the file record is a new upload.

func RecordOffline

func RecordOffline(art *models.File) bool

RecordOffline returns true if the file record is marked as offline. This means the artifact has been soft deleted and is no longer available for download.

func RecordOnline

func RecordOnline(art *models.File) bool

RecordOnline returns true if the artifact file record is available for download.

func RecordProblems

func RecordProblems(art *models.File) string

RecordProblems returns a list of validation problems for the file record.

func Relations

func Relations(art *models.File) template.HTML

Relations returns the list of relationships for the file record.

func RelationsStr

func RelationsStr(art *models.File) string

RelationsStr returns the list of relationships for the file record as a string.

func ReleaserPair

func ReleaserPair(art *models.File) (string, string)

ReleaserPair returns the pair of releaser names for the file record. The first name is the releaser "for" and the second name is the releaser "by".

func TagCategory

func TagCategory(art *models.File) string

TagCategory returns the "Tag as category" for the file record, which is used to group similar artifacts together.

func TagProgram

func TagProgram(art *models.File) string

TagProgram returns the "Programs or apps" for the file record, which is the platform or operating system the artifact is intended for.

func Title

func Title(art *models.File) string

Title returns the brief title of the file record or a issue number for a magazine.

func UnID

func UnID(art *models.File) string

UnID returns the universal unique ID for the file record commonly known as a UUID.

func Websites

func Websites(art *models.File) template.HTML

Websites returns the list of links for the file record.

func WebsitesStr

func WebsitesStr(art *models.File) string

WebsitesStr returns the list of links for the file record as a string.

func ZipContent

func ZipContent(art *models.File) string

ZipContent returns the archive content of the file download, or an empty string if not an archive file.

Types

type ListEntry

type ListEntry struct {
	RelativeName            string
	Signature               string
	Filesize                string
	ImageConfig             string
	MusicConfig             string
	UniqueID                string
	Executable              magicnumber.Windows
	Images, Programs, Texts bool
}

ListEntry is a struct for the directory item that is used to generate the HTML.

func (ListEntry) HTML

func (m ListEntry) HTML(bytes int64, platform, section string) string

HTML returns the HTML for an file item in the "Download content" section of the File editor.

Jump to

Keyboard shortcuts

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