htmx

package
v1.1.3 Latest Latest
Warning

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

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

Documentation

Overview

Package htmx handles the routes and views for the AJAX responses using the htmx library.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIsDir = errors.New("the file is a directory")
	ErrName  = errors.New("the file name is invalid")
	ErrYT    = errors.New("youtube watch video id needs to be empty or 11 characters")
)
View Source
var (
	ErrDB     = errors.New("database connection is nil")
	ErrFormat = errors.New("invalid format")
	ErrKey    = errors.New("numeric record key is invalid")
)
View Source
var (
	ErrDir       = errors.New("cannot be a directory")
	ErrFile      = errors.New("cannot be a file")
	ErrSave      = errors.New("cannot save a file")
	ErrMultiHead = errors.New("multipart file header is nil")
	ErrUUID      = errors.New("invalid or an empty UUID")
)
View Source
var (
	ErrForm   = errors.New("form parameters could not be read")
	ErrInsert = errors.New("form submission could not be inserted into the database")
	ErrUpdate = errors.New("form submission could not update the database record")
)

Functions

func AdvancedSubmit

func AdvancedSubmit(c echo.Context, db *sql.DB, logger *zap.SugaredLogger, downloadDir string) error

AdvancedSubmit is a handler for the /uploader/advanced route.

func DBConnections added in v0.8.0

func DBConnections(c echo.Context, db *sql.DB) error

DBConnections is the handler for the database connections page.

func DataListMagazines

func DataListMagazines(c echo.Context, db *sql.DB, logger *zap.SugaredLogger, input string) error

DataListMagazines is a handler for the /datalist/magazines route.

func DataListReleasers

func DataListReleasers(c echo.Context, db *sql.DB, logger *zap.SugaredLogger, input string) error

DataListReleasers is a handler for the /datalist/releasers route.

func DeleteForever added in v0.8.0

func DeleteForever(c echo.Context, db *sql.DB, logger *zap.SugaredLogger, id string) error

DeleteForever is a handler for the /delete/forever route.

func DemozooLookup added in v0.10.0

func DemozooLookup(c echo.Context, db *sql.DB) error

DemozooLookup is the handler for the /demozoo/production route. This looks up the Demozoo production ID and returns a form button to submit the ID to the server for processing. If the Demozoo production ID is already in use, an error message is returned.

func DemozooSubmit

func DemozooSubmit(c echo.Context, db *sql.DB, logger *zap.SugaredLogger, downloadDir string) error

DemozooSubmit is the handler for the /demozoo/production put route. This will attempt to insert a new file record into the database using the Demozoo production ID. If the Demozoo production ID is already in use, an error message is returned.

func DemozooValid

func DemozooValid(c echo.Context, id int) (demozoo.Production, error)

DemozooValid looks up the Demozoo production ID and confirms that the production is suitable for Defacto2. If a production is not suitable, an message is returned.

A valid production requires at least one download link and must be a suitable type such as an intro, demo or cracktro for MS-DOS, Windows etc.

func Duplicate

func Duplicate(logger *zap.SugaredLogger, uid uuid.UUID, srcPath, dstDir string)

Duplicate copies the chosen file to the destination directory. The UUID needs be provided as a unique identifier for the filename. The source path is the temporary file that was uploaded. The destination directory is where the file will be copied to.

func GlobTo

func GlobTo(name string) string

GlobTo returns the path to the template file.

func HumanizeCount added in v0.10.0

func HumanizeCount(c echo.Context, db *sql.DB, logger *zap.SugaredLogger, name string) error

HumanizeCount handles the post submission for the Uploader classification, such as the platform, operating system, section or category tags. The return value is either the humanized and counted classification or an error.

func ImageSubmit

func ImageSubmit(c echo.Context, db *sql.DB, logger *zap.SugaredLogger, downloadDir string) error

ImageSubmit is a handler for the /uploader/image route.

func IntroSubmit

func IntroSubmit(c echo.Context, db *sql.DB, logger *zap.SugaredLogger, downloadDir string) error

IntroSubmit is a handler for the /uploader/intro route.

func LookupSHA384

func LookupSHA384(c echo.Context, db *sql.DB, logger *zap.SugaredLogger) error

LookupSHA384 is a handler for the /uploader/sha384 route.

func MagazineSubmit

func MagazineSubmit(c echo.Context, db *sql.DB, logger *zap.SugaredLogger, downloadDir string) error

MagazineSubmit is a handler for the /uploader/magazine route.

func Pings added in v0.8.0

func Pings(c echo.Context, proto string, port int) error

Pings is a handler for the /pings route.

func PouetLookup added in v0.10.0

func PouetLookup(c echo.Context, db *sql.DB) error

PouetLookup fetches the multiple download_links values from the Pouet 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 Pouet 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 PouetSubmit

func PouetSubmit(c echo.Context, db *sql.DB, logger *zap.SugaredLogger, downloadDir string) error

PouetSubmit is the handler for the /pouet/production PUT route. This will attempt to insert a new file record into the database using the Pouet production ID. If the Pouet production ID is already in use, an error message is returned.

func PouetValid

func PouetValid(c echo.Context, id int, useCache bool) (pouet.Response, error)

PouetValid fetches the first usable download link from the Pouet API. The production ID is validated and the production is checked to see if it is suitable for Defacto2. If the production is not suitable, an empty production is returned with a htmx message.

func Record16Colors

func Record16Colors(c echo.Context, db *sql.DB) error

Record16Colors handles the post submission for the file artifact 16 Colors link.

func RecordClassification

func RecordClassification(c echo.Context, db *sql.DB, logger *zap.SugaredLogger) error

RecordClassification handles the post submission for the file artifact classifications, such as the platform, operating system, section or category tags. The return value is either the humanized and counted classification or an error.

func RecordComment

func RecordComment(c echo.Context, db *sql.DB) error

RecordComment handles the post submission for the file artifact comment.

func RecordCommentReset

func RecordCommentReset(c echo.Context, db *sql.DB) error

RecordCommentReset handles the post submission for the file artifact comment reset.

func RecordCreatorAudio

func RecordCreatorAudio(c echo.Context, db *sql.DB) error

RecordCreatorAudio handles the post submission for the file artifact creator musician.

func RecordCreatorIll

func RecordCreatorIll(c echo.Context, db *sql.DB) error

RecordCreatorIll handles the post submission for the file artifact creator illustrator.

func RecordCreatorProg

func RecordCreatorProg(c echo.Context, db *sql.DB) error

RecordCreatorProg handles the post submission for the file artifact creator programmer.

func RecordCreatorReset

func RecordCreatorReset(c echo.Context, db *sql.DB) error

RecordCreatorReset handles the post submission for the file artifact creators reset.

func RecordCreatorText

func RecordCreatorText(c echo.Context, db *sql.DB) error

RecordCreatorText handles the post submission for the file artifact creator text.

func RecordDateIssued

func RecordDateIssued(c echo.Context, db *sql.DB) error

RecordDateIssued handles the post submission for the file artifact date of release.

func RecordDateIssuedReset

func RecordDateIssuedReset(c echo.Context, db *sql.DB, elmID string) error

RecordDateIssuedReset handles the post submission for the file artifact date of release reset.

func RecordDemozoo

func RecordDemozoo(c echo.Context, db *sql.DB) error

RecordDemozoo handles the post submission for the file artifact Demozoo production link.

func RecordEmulateBroken added in v0.10.0

func RecordEmulateBroken(c echo.Context, db *sql.DB) error

RecordEmulateBroken handles the patch submission for the broken emulation for a file artifact.

func RecordEmulateCPU added in v0.10.0

func RecordEmulateCPU(c echo.Context, db *sql.DB) error

RecordEmulateCPU handles the patch submission for the CPU emulation for a file artifact.

func RecordEmulateEMS added in v0.10.0

func RecordEmulateEMS(c echo.Context, db *sql.DB) error

func RecordEmulateMachine added in v0.10.0

func RecordEmulateMachine(c echo.Context, db *sql.DB) error

RecordEmulateMachine handles the patch submission for the machine and graphic emulation for a file artifact.

func RecordEmulateRunProgram added in v0.10.0

func RecordEmulateRunProgram(c echo.Context, db *sql.DB) error

RecordEmulateRunProgram handles the patch submission for the run program emulation.

func RecordEmulateSFX added in v0.10.0

func RecordEmulateSFX(c echo.Context, db *sql.DB) error

RecordEmulateSFX handles the patch submission for the audio emulation for a file artifact.

func RecordEmulateUMB added in v0.10.0

func RecordEmulateUMB(c echo.Context, db *sql.DB) error

func RecordEmulateXMS added in v0.10.0

func RecordEmulateXMS(c echo.Context, db *sql.DB) error

func RecordFilename

func RecordFilename(c echo.Context, db *sql.DB) error

RecordFilename handles the post submission for the file artifact filename.

func RecordFilenameReset

func RecordFilenameReset(c echo.Context, db *sql.DB) error

RecordFilenameReset handles the post submission for the file artifact filename reset.

func RecordGitHub

func RecordGitHub(c echo.Context, db *sql.DB) error

RecordGitHub handles the post submission for the file artifact GitHub repository link.

func RecordImageCopier added in v0.10.0

func RecordImageCopier(c echo.Context, debug *zap.SugaredLogger, dirs command.Dirs) error

func RecordImageCropper added in v0.10.0

func RecordImageCropper(c echo.Context, crop command.Crop, dirs command.Dirs) error

func RecordImagePixelator added in v0.10.0

func RecordImagePixelator(c echo.Context, dirs ...string) error

func RecordImagesDeleter added in v0.10.0

func RecordImagesDeleter(c echo.Context, dirs ...string) error
func RecordLinks(c echo.Context) error

RecordLinks handles the post submission for a form submission to provide the HTML formatted links for the "Links" section of the artifact editor.

func RecordLinksReset added in v0.8.0

func RecordLinksReset(c echo.Context, db *sql.DB) error

RecordLinksReset handles the post submission for the file artifact links reset.

func RecordPouet

func RecordPouet(c echo.Context, db *sql.DB) error

RecordPouet handles the post submission for the file artifact Pouet production link.

func RecordReadmeCopier added in v0.10.0

func RecordReadmeCopier(c echo.Context, extraDir string) error

func RecordReadmeDeleter added in v0.10.0

func RecordReadmeDeleter(c echo.Context, extraDir string) error

func RecordReadmeImager added in v0.10.0

func RecordReadmeImager(c echo.Context, logger *zap.SugaredLogger, dirs command.Dirs) error

func RecordRelations

func RecordRelations(c echo.Context, db *sql.DB) error

RecordRelations handles the post submission for the file artifact releaser relationships.

func RecordReleasers

func RecordReleasers(c echo.Context, db *sql.DB) error

RecordReleasers handles the post submission for the file artifact releasers. It will only update the releaser1 and the releaser2 values if they have changed. The return value is either "Updated" or "Update" depending on if the values have changed.

func RecordReleasersReset

func RecordReleasersReset(c echo.Context, db *sql.DB) error

RecordReleasersReset handles the post submission for the file artifact releasers reset. It will always reset and save the releaser1 and the releaser2 values. The return value is always "Resetted" unless an error occurs.

func RecordSites

func RecordSites(c echo.Context, db *sql.DB) error

RecordSites handles the post submission for the file artifact website links.

func RecordThumb added in v0.10.0

func RecordThumb(c echo.Context, thumb command.Thumb, dirs command.Dirs) error

func RecordThumbAlignment added in v0.10.0

func RecordThumbAlignment(c echo.Context, align command.Align, dirs command.Dirs) error

func RecordTitle

func RecordTitle(c echo.Context, db *sql.DB) error

RecordTitle handles the post submission for the file artifact title.

func RecordTitleReset

func RecordTitleReset(c echo.Context, db *sql.DB) error

RecordTitleReset handles the post submission for the file artifact title reset.

func RecordToggle

func RecordToggle(c echo.Context, db *sql.DB, state bool) error

RecordToggle handles the post submission for the file artifact record toggle. The return value is either "online" or "offline" depending on the state.

func RecordToggleByID added in v0.8.0

func RecordToggleByID(c echo.Context, db *sql.DB, key string, state bool) error

RecordToggle handles the post submission for the file artifact record toggle. The key string is converted into an integer and used as the artifact id. The return value is either "online" or "offline" depending on the state.

func RecordVirusTotal

func RecordVirusTotal(c echo.Context, db *sql.DB) error

RecordVirusTotal handles the post submission for the file artifact VirusTotal report link.

func RecordYouTube

func RecordYouTube(c echo.Context, db *sql.DB) error

RecordYouTube handles the post submission for the file artifact YouTube watch video link.

func SearchByID added in v0.8.0

func SearchByID(c echo.Context, db *sql.DB, logger *zap.SugaredLogger) error

SearchByID is a handler for the /editor/search/id route.

func SearchReleaser

func SearchReleaser(c echo.Context, db *sql.DB, logger *zap.SugaredLogger) error

SearchReleaser is a handler for the /search/releaser route.

func Suggestion

func Suggestion(name, initialism string, count any) string

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

func TemplateFuncMap

func TemplateFuncMap() template.FuncMap

TemplateFuncMap are a collection of mapped functions that can be used in a template.

func Templates

func Templates(fs embed.FS) map[string]*template.Template

Templates returns a map of the templates.

func TextSubmit

func TextSubmit(c echo.Context, db *sql.DB, logger *zap.SugaredLogger, downloadDir string) error

TextSubmit is a handler for the /uploader/text route.

func TrainerSubmit

func TrainerSubmit(c echo.Context, db *sql.DB, logger *zap.SugaredLogger, downloadDir string) error

TrainerSubmit is a handler for the /uploader/trainer route.

func UploadPreview added in v0.10.0

func UploadPreview(c echo.Context, previewDir, thumbnailDir string) error

func UploadReplacement added in v0.10.0

func UploadReplacement(c echo.Context, db *sql.DB, downloadDir string) error

UploadReplacement is the file transfer handler that uploads, validates a new file upload and updates the existing artifact record with the new file information. The logger is optional and if nil then the function will not log any debug information.

Types

type Submission added in v0.10.0

type Submission int
const (
	Demozoo Submission = iota
	Pouet
)

func (Submission) String added in v0.10.0

func (prod Submission) String() string

func (Submission) Submit added in v0.10.0

func (prod Submission) Submit(
	c echo.Context, db *sql.DB, logger *zap.SugaredLogger, downloadDir string,
) error

Jump to

Keyboard shortcuts

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