Documentation
¶
Overview ¶
Package htmx handles the routes and views for the AJAX responses using the htmx library.
Index ¶
- Constants
- Variables
- func Alternatives(s string) []string
- func Areacodes(c *echo.Context) error
- func Close(sl *slog.Logger, msg string, file multipart.File)
- func CommitNotOn(c *echo.Context, tx *sql.Tx, name string, ...) error
- func CommitOn(c *echo.Context, tx *sql.Tx, name string, ...) error
- func CommitSanitize(c *echo.Context, tx *sql.Tx, name string, sanitize func(string) string, ...) error
- func CommitStr(c *echo.Context, tx *sql.Tx, name string, ...) error
- func CommitStrKey(c *echo.Context, tx *sql.Tx, name string, ...) error
- func DBConnections(c *echo.Context, db *sql.DB) error
- func DataListMagazines(sl *slog.Logger, c *echo.Context, db *sql.DB, input string) error
- func DataListReleasers(sl *slog.Logger, c *echo.Context, db *sql.DB, input string) error
- func DeleteForever(sl *slog.Logger, c *echo.Context, tx *sql.Tx, recordKey string) error
- func FSAlign(sl *slog.Logger, c *echo.Context, align command.Align, dirs command.Dirs) error
- func FSCopyDIZ(c *echo.Context, dirs command.Dirs) error
- func FSCopyHelp(c *echo.Context, dirs command.Dirs) error
- func FSCopyReadme(sl *slog.Logger, c *echo.Context, dirs command.Dirs) error
- func FSCrop(sl *slog.Logger, c *echo.Context, crop command.Crop, dirs command.Dirs) error
- func FSPixelate(sl *slog.Logger, c *echo.Context, directory ...dir.Directory) error
- func FSRemoveDIZ(c *echo.Context, extra dir.Directory) error
- func FSRemoveHelp(c *echo.Context, extra dir.Directory) error
- func FSRemoveImages(c *echo.Context, directories ...dir.Directory) error
- func FSRemoveReadme(c *echo.Context, extra dir.Directory) error
- func FSThumb(sl *slog.Logger, c *echo.Context, thumb command.Generate, dirs command.Dirs) error
- func FSUseBinText(sl *slog.Logger, c *echo.Context, dirs command.Dirs) error
- func FSUseImage(sl *slog.Logger, c *echo.Context, dirs command.Dirs) error
- func FSUseReadme(sl *slog.Logger, c *echo.Context, amigaFont bool, dirs command.Dirs) error
- func GlobTo(name string) string
- func HTMLLinkTo(c *echo.Context, err error) error
- func Key(c *echo.Context) (int64, error)
- func KeyParam(c *echo.Context) (int64, error)
- func PageReload(c *echo.Context) *echo.Context
- func Paths(c *echo.Context) (unid, filename string, err error)
- func Pings(c *echo.Context, proto string, port int) error
- func SaveTemp(sl *slog.Logger, c *echo.Context, key string, fileHeader *multipart.FileHeader) (string, error)
- func SearchByID(sl *slog.Logger, c *echo.Context, db *sql.DB) error
- func SearchReleaser(sl *slog.Logger, c *echo.Context, db *sql.DB, ft *fulltext.Tidbits) error
- func SearchResult(index any) template.HTML
- func StatusOK(c *echo.Context, name string) error
- func Suggestion(name, initialism string, count any) string
- func TemplateFuncMap() template.FuncMap
- func Templates(fsys fs.FS) map[string]*template.Template
- func Tx16Colors(c *echo.Context, tx *sql.Tx) error
- func TxComment(c *echo.Context, tx *sql.Tx) error
- func TxCommentUndo(c *echo.Context, tx *sql.Tx) error
- func TxCreditAudio(c *echo.Context, tx *sql.Tx) error
- func TxCreditIll(c *echo.Context, tx *sql.Tx) error
- func TxCreditProg(c *echo.Context, tx *sql.Tx) error
- func TxCreditText(c *echo.Context, tx *sql.Tx) error
- func TxCreditUndo(c *echo.Context, tx *sql.Tx) error
- func TxDemozoo(c *echo.Context, tx *sql.Tx) error
- func TxEmulateBroken(c *echo.Context, tx *sql.Tx) error
- func TxEmulateCPU(c *echo.Context, tx *sql.Tx) error
- func TxEmulateEMS(c *echo.Context, tx *sql.Tx) error
- func TxEmulateMachine(c *echo.Context, tx *sql.Tx) error
- func TxEmulateRunProg(c *echo.Context, tx *sql.Tx) error
- func TxEmulateSFX(c *echo.Context, tx *sql.Tx) error
- func TxEmulateUMB(c *echo.Context, tx *sql.Tx) error
- func TxEmulateXMS(c *echo.Context, tx *sql.Tx) error
- func TxFilename(c *echo.Context, tx *sql.Tx) error
- func TxFilenameUndo(c *echo.Context, tx *sql.Tx) error
- func TxGitHub(c *echo.Context, tx *sql.Tx) error
- func TxLastMod(c *echo.Context, tx *sql.Tx) error
- func TxLinksUndo(c *echo.Context, tx *sql.Tx) error
- func TxPouet(c *echo.Context, tx *sql.Tx) error
- func TxPublic(c *echo.Context, tx *sql.Tx, state bool) error
- func TxPublicByKey(c *echo.Context, tx *sql.Tx, key string, state bool) error
- func TxReadmeOff(c *echo.Context, tx *sql.Tx) error
- func TxRelations(c *echo.Context, tx *sql.Tx) error
- func TxReleasers(c *echo.Context, tx *sql.Tx) error
- func TxReleasersUndo(c *echo.Context, tx *sql.Tx) error
- func TxTags(sl *slog.Logger, c *echo.Context, tx *sql.Tx) error
- func TxTitle(c *echo.Context, tx *sql.Tx) error
- func TxTitleUndo(c *echo.Context, tx *sql.Tx) error
- func TxVirusTotal(c *echo.Context, tx *sql.Tx) error
- func TxWebsites(c *echo.Context, tx *sql.Tx) error
- func TxYMD(c *echo.Context, tx *sql.Tx) error
- func TxYMDUndo(c *echo.Context, tx *sql.Tx) error
- func TxYouTube(c *echo.Context, tx *sql.Tx) error
- func UPAdvanced(sl *slog.Logger, c *echo.Context, tx *sql.Tx, download dir.Directory) error
- func UPCount(sl *slog.Logger, c *echo.Context, db *sql.DB, name string) error
- func UPImage(sl *slog.Logger, c *echo.Context, tx *sql.Tx, download dir.Directory) error
- func UPIntro(sl *slog.Logger, c *echo.Context, tx *sql.Tx, download dir.Directory) error
- func UPMagazine(sl *slog.Logger, c *echo.Context, tx *sql.Tx, download dir.Directory) error
- func UPSHA384(sl *slog.Logger, c *echo.Context, db *sql.DB) error
- func UPText(sl *slog.Logger, c *echo.Context, tx *sql.Tx, download dir.Directory) error
- func UPTrainer(sl *slog.Logger, c *echo.Context, tx *sql.Tx, download dir.Directory) error
- func UUID(c *echo.Context) (string, error)
- func Validate(path string) error
- func ValidateDemozoo(c *echo.Context, prodID int, useCache bool) (demozoo.Production, error)
- func ValidatePouet(c *echo.Context, prodID int, useCache bool) (pouet.Response, error)
- type Copy
- type Ext
- type Insert
- type Prod
- func (prod Prod) ButtonOK(c *echo.Context, prodID int, info ...string) error
- func (prod Prod) ID(c *echo.Context) (int, error)
- func (prod Prod) Lookup(c *echo.Context, db *sql.DB, useCache bool) error
- func (prod Prod) String() string
- func (prod Prod) Submit(sl *slog.Logger, c *echo.Context, db *sql.DB, tx *sql.Tx, ...) error
- func (prod Prod) ValidFn(c *echo.Context, prodID int, useCache bool, fn func(string) (string, error)) (bool, error)
- type Record
- type Submit
- type Transfer
- type YMD
Constants ¶
const EditorKey = "artifact-editor-key"
Variables ¶
var ( ErrIsDir = errors.New("htmx: the file is a directory") ErrPath = errors.New("htmx: the file path is invalid") ErrYMD = errors.New("htmx: invalid ymd format") ErrYouTube = errors.New("htmx: youtube watch video id needs to be empty or 11 characters") ErrFormRead = errors.New("htmx form: parameters could not be read") ErrFormInsert = errors.New("htmx form: submission could not be inserted into the database") ErrFormUpdate = errors.New("htmx form: submission could not update a database record") )
Functions ¶
func Alternatives ¶ added in v1.7.12
Alternatives returns a slice of possible matching alternative names, spellings, acronyms and initialisms for the s string.
func CommitNotOn ¶ added in v1.14.0
func CommitSanitize ¶ added in v1.14.0
func CommitStrKey ¶ added in v1.14.0
func DBConnections ¶ added in v0.8.0
DBConnections is the handler for the database connections page.
func DataListMagazines ¶
DataListMagazines is a handler for the /datalist/magazines route.
func DataListReleasers ¶
DataListReleasers is a handler for the /datalist/releasers route.
func DeleteForever ¶ added in v0.8.0
DeleteForever is a handler for the /delete/forever route. The recordKey is the numeric ID used by the record database table.
func FSCopyDIZ ¶ added in v1.14.0
FSCopyDIZ handles the htmx request to use the file_id.diz artifact as a preview.
func FSCopyHelp ¶ added in v1.14.0
FSCopyHelp handles the htmx request to use the helper textfile as a preview.
func FSCopyReadme ¶ added in v1.14.0
func FSPixelate ¶ added in v1.14.0
FSPixelate handles the htmx request to pixelate both the preview and thumbnails, if they are not suitable for a general audience. This also has an added benefit of reducing the file sizes of both images and reducing page load.
func FSRemoveDIZ ¶ added in v1.14.0
FSRemoveDIZ handles the request to remove the uuid named file_id.diz text file from the provided extra directory.
func FSRemoveHelp ¶ added in v1.14.0
FSRemoveHelp handles the request to remove the uuid named helper (.hlp) text file from the provided extra directory.
func FSRemoveImages ¶ added in v1.14.0
FSRemoveImages handles the request to remove the uuid named image files from the directories provided.
func FSRemoveReadme ¶ added in v1.14.0
FSRemoveReadme handles the request to remove the uuid named readme text file from the provided extra directory.
func FSUseBinText ¶ added in v1.14.0
FSUseBinText handles the htmx request to use the text file artifact as a preview.
func FSUseImage ¶ added in v1.14.0
FSUseImage handles the htmx request to use an image file artifact as a preview.
func FSUseReadme ¶ added in v1.14.0
FSUseReadme handles the htmx request to use the text file artifact as a preview.
func GlobTo ¶
GlobTo returns the path to the named template file. If name is empty, the path to the view/htmx directory is returned.
func HTMLLinkTo ¶ added in v1.14.0
HTMLLinkTo handles the post submission for a form submission to provide the HTML formatted links for the "Links" section of the artifact editor.
func KeyParam ¶ added in v1.14.0
KeyParam returns the "id" value from the URL parameters or returns 0 and an error if it is invalid.
func PageReload ¶ added in v1.14.0
PageReload is a helper function to set the HTTP HTMX header for the browser to refresh the page.
func Paths ¶ added in v1.14.0
Paths returns two values provided by the URL parameters:
The UUID unique identifier for the file assets storage. The original filename of the artifact, however this maybe modified to be friendly with URL queries.
An error is returned if the unid or filename values are invalid.
func Pings ¶ added in v0.8.0
Pings is a handler for the /pings route.
The proto string should either be "http" or "https".
func SaveTemp ¶ added in v1.14.0
func SaveTemp(sl *slog.Logger, c *echo.Context, key string, fileHeader *multipart.FileHeader) (string, error)
SaveTemp is a generic file writer that saves the chosen file upload to a temporary file. Note the multipart file header needs to be closed outside of this func.
func SearchByID ¶ added in v0.8.0
SearchByID is a handler for the /editor/search/id route.
func SearchReleaser ¶
SearchReleaser is a handler for the /search/releaser route.
func SearchResult ¶ added in v1.8.14
func Suggestion ¶
Suggestion returns a human readable string of the byte count with a named description.
func TemplateFuncMap ¶
TemplateFuncMap are a collection of mapped functions that can be used in a template.
func Tx16Colors ¶ added in v1.14.0
Tx16Colors handles the post submission for the file artifact 16 Colors link.
func TxComment ¶ added in v1.14.0
TxComment handles the post submission for the file artifact comment.
func TxCommentUndo ¶ added in v1.14.0
TxCommentUndo handles the post submission for the file artifact comment reset.
func TxCreditAudio ¶ added in v1.14.0
TxCreditAudio handles the post submission for the file artifact creator musician.
func TxCreditIll ¶ added in v1.14.0
TxCreditIll handles the post submission for the file artifact creator illustrator.
func TxCreditProg ¶ added in v1.14.0
TxCreditProg handles the post submission for the file artifact creator programmer.
func TxCreditText ¶ added in v1.14.0
TxCreditText handles the post submission for the file artifact creator text.
func TxCreditUndo ¶ added in v1.14.0
TxCreditUndo handles the post submission for the file artifact creators reset.
func TxDemozoo ¶ added in v1.14.0
TxDemozoo handles the post submission for the file artifact Demozoo production link.
func TxEmulateBroken ¶ added in v1.14.0
TxEmulateBroken handles the patch submission for the broken emulation for a file artifact.
func TxEmulateCPU ¶ added in v1.14.0
TxEmulateCPU handles the patch submission for the CPU emulation for a file artifact.
func TxEmulateMachine ¶ added in v1.14.0
TxEmulateMachine handles the patch submission for the machine and graphic emulation for a file artifact.
func TxEmulateRunProg ¶ added in v1.14.0
TxEmulateRunProg handles the patch submission for the run program emulation.
func TxEmulateSFX ¶ added in v1.14.0
TxEmulateSFX handles the patch submission for the audio emulation for a file artifact.
func TxFilename ¶ added in v1.14.0
TxFilename handles the post submission for the file artifact filename.
func TxFilenameUndo ¶ added in v1.14.0
TxFilenameUndo handles the post submission for the file artifact filename reset.
func TxGitHub ¶ added in v1.14.0
TxGitHub handles the post submission for the file artifact GitHub repository link.
func TxLastMod ¶ added in v1.14.0
TxLastMod is the post submission to set the date of release to be the last modification date of the file download or file archive.
func TxLinksUndo ¶ added in v1.14.0
TxLinksUndo handles the post submission for the file artifact links reset.
func TxPouet ¶ added in v1.14.0
TxPouet handles the post submission for the file artifact Pouet production link.
func TxPublic ¶ added in v1.14.0
TxPublic handles the post submission for the file artifact record toggle. The return value is either "online" or "offline" depending on the state.
func TxPublicByKey ¶ added in v1.14.0
TxPublicByKey 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 TxReadmeOff ¶ added in v1.14.0
TxReadmeOff handles the htmx request to disable the in page display of both the text files readme and file_id.diz for the file artifact.
func TxRelations ¶ added in v1.14.0
TxRelations handles the post submission for the file artifact releaser relationships.
func TxReleasers ¶ added in v1.14.0
TxReleasers 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 TxReleasersUndo ¶ added in v1.14.0
TxReleasersUndo 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 TxTags ¶ added in v1.14.0
TxTags 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 TxTitleUndo ¶ added in v1.14.0
TxTitleUndo handles the post submission for the file artifact title reset.
func TxVirusTotal ¶ added in v1.14.0
TxVirusTotal handles the post submission for the file artifact VirusTotal report link.
func TxWebsites ¶ added in v1.14.0
TxWebsites handles the post submission for the file artifact website links.
func TxYouTube ¶ added in v1.14.0
TxYouTube handles the post submission for the file artifact YouTube watch video link.
func UPAdvanced ¶ added in v1.14.0
UPAdvanced is a handler for the /uploader/advanced route.
func UPCount ¶ added in v1.14.0
UPCount 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 UPMagazine ¶ added in v1.14.0
UPMagazine is a handler for the /uploader/magazine route.
func UPSHA384 ¶ added in v1.14.0
UPSHA384 is a handler for the /uploader/sha384 route. It checks the SHA-384 hash against the database to see if the file already exists, and returns the URI if it does. Otherwise, if it does not exist, it returns an empty string.
func UUID ¶ added in v1.7.0
UUID returns the uuid from the URL parameters and returns an error if it is invalid.
func Validate ¶ added in v1.7.0
Validate checks that the path is not absolute and does not allow for any path traversal. It returns an error if the path is invalid.
func ValidateDemozoo ¶ added in v1.14.0
ValidateDemozoo 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 ValidatePouet ¶ added in v1.14.0
ValidatePouet 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.
Types ¶
type Insert ¶ added in v1.14.0
type Insert struct {
FileHeader *multipart.FileHeader
Readme string
Key string
Content []string
Checksum [48]byte
Magic magicnumber.Signature
}
type Prod ¶ added in v1.14.0
type Prod int
func (Prod) ID ¶ added in v1.14.0
ID validates the production ID and ensures that it is a valid numeric value.
func (Prod) Submit ¶ added in v1.14.0
func (prod Prod) Submit( sl *slog.Logger, c *echo.Context, db *sql.DB, tx *sql.Tx, download dir.Directory, ) error
Submit handles the PUT production routes for Demozoo and Pouet. This will attempt to insert a new file record into the database using the production ID. If the ID is already in use, an error message is returned.
Note both a sql.Tx and sql.DB are required as there are two separate commit stages.
type Submit ¶ added in v1.14.0
type Submit struct {
Download dir.Directory
Extra dir.Directory
Preview dir.Directory
Thumbnail dir.Directory
}
func (Submit) Replacement ¶ added in v1.14.0
Replacement is the file transfer handler that uploads, validates a new file upload and updates the existing artifact record with the new file information.
type Transfer ¶ added in v1.14.0
Transfer is a generic file transfer handler that uploads and validates a chosen file upload. The provided key is the name of the form input field.
func (Transfer) CopyTemp ¶ added in v1.14.0
CopyTemp copies the uploaded file to the downloads directory store. The fname UUID needs be provided as a unique identifier filename. The tempDest is the saved, temporary file that was uploaded.